This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8168 H.264 decoder hangs after a while with packet loss

After a while decoding a video stream with significant packet loss in it (here random 10%, but also happens for other values), the decoder hangs and stops returning any buffers.  The decoder returns a lot of errors while running (as expected, given the nature of the stream).  Here is the last bit of log from the video M3 core (filtered to remove the spammy Start/StopInstance messages):

N:Video P:1 #:30089 T:000000132bd39355 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30090 T:000000132bdc60b3 S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30112 T:000000132fcfe28f S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30113 T:000000132fd85d3b S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30131 T:0000001332d372b7 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30132 T:0000001332eaf105 S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30163 T:00000013390ee915 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30165 T:00000013391ad443 S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30170 T:0000001339b33305 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30171 T:0000001339bb8151 S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x80000000
N:Video P:1 #:30209 T:00000013400f7b07 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30211 T:00000013401bf721 S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30231 T:0000001343416c8b S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30232 T:0000001343507f3d S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2935::omxHandle 0x9dc82500::Error->Decoder returned error 0x2000a00
N:Video P:1 #:30248 T:00000013465883a9 S:OMX_TI_VIDDEC_Process::Line 2582::omxHandle 0x9dc82500::Error->Decoder returned error 0x8008000
N:Video P:1 #:30249 T:000000134658fc91 S:Module<OMX.TI.DUCATI.VIDDEC> Entering<OMX_BASE_CB_ReturnEventNotify> @line<100>
N:Video P:1 #:30250 T:0000001346596745 S:Module<OMX.TI.DUCATI.VIDDEC> @<OMX_BASE_CB_ReturnEventNotify> @line<158> msg<Notify client for error>
N:Video P:1 #:30251 T:000000134659d6fd S: hComponent: 0x9dc82500; EventHandler: 0x9e36b2b1
N:Video P:1 #:30252 T:0000001346618775 S:Module<OMX.TI.DUCATI.VIDDEC> Leaving<OMX_BASE_CB_ReturnEventNotify> @line<224> with error<0:ErrorNone>


The final error code, 0x8008000, is IH264VDEC_ERR_HDVICP2_IMPROPER_STATE | XDM_FATALERROR.  None of the other error returns from the decoder have this value, nor do any of them have either of those error bits set.  From the last few thousand lines:

$ cat log | grep "Decoder returned" | sed 's/.* //' | sort | uniq -c
    128 0x2000a00
      8 0x401
    180 0x80000000
    748 0x80001080
      1 0x8008000
     22 0x82000a00
    172 0x82001a80


This 0x8008000 error is consistently the last thing in the log, and is also returned to userspace as an error callback (OMX_ErrorStreamCorrupt).  After this point, the decoder accepts further input buffers but doesn't appear to do anything with them, so they quickly run out on the application side.  No output buffers are returned either.

So:
- Have I made some error in using the decoder to cause it to enter this error state?
- If not, how can I recover from this error to continue decoding the stream?


Other details which may or may not be relevant:
- It only seems to happen when running all of our application code - extracting H.264 from a failing RTP stream and running it through the decoder on its own does not fail.
- There is also an MJPEG decoder and an H.264 encoder running on the video M3 at the same time as the decoder when this fails.
- The H.264 input stream is 1280x720, 30fps, 1.4Mb/s (though 10% of RTP packets are dropped and slice reassembly will have dropped more, possibly reducing those numbers significantly).
- It is baseline profile, and consistently has two slices per frame.
- The whole system runs correctly for some time (from a few minutes to maybe an hour or so) before the above failure happens.
- The decoder binary is built from EZSDK 5.04, h264dec 01.00.00.08.
- The hardware is a DM8168 revision 2.0 on our own board.


Thanks,

- Mark

  • Hi Mark,

                 You have mentioned that H.264 decoder is returning IH264VDEC_ERR_HDVICP2_IMPROPER_STATE | XDM_FATALERROR and after that it stops giving output. This behavior is observed only in Multi-Codec scenario running with MJPEG decoder and H.264 Encoder.

    At the start and end of H.264 Decoder we will check whether iConts and VDMA are in RESET state or not and if they are not in RESET state, decoder returns IH264VDEC_ERR_HDVICP2_IMPROPER_STATE error. In Multi-Codec scenario, if the Codec/module which ran just before H.264 Decoder didn't kept iConts or VDMA in Reset state, then Decoder returns the above mentioned errors.

    So lets first narrow down the issue, by running the below combinations of Codecs in the application:

    1) Running H.264 Encoder and H.264 Decoder only

    2) Running MJPEG Decoder and H.264 Decoder only

    Could you please try these experiments so that we will be able to know which Codec/module is actually causing the issue.

    Thanks & Regards,

    Suresh

  • Hi Suresh,

    I have now run more combinations of codecs.  The two combinations you suggest do both fail, and it also failed in a case where no other codecs were running at all.  In that case, it errored out after about 40 minutes of a stream with 10% packet loss with no other codecs running at the same time (I did not see this error on a previous attempt, so I may not have run it for long enough at that time).  Note also that the decoder consistently runs for many hours (with other codecs running as well) if the packet loss is not present.

    Could the codec which leaves the HDVICP in the incorrect state be the immediately prior run of the same H.264 decoder?  Alternatively, is there any other situation in which the decoder can return the IH264VDEC_ERR_HDVICP2_IMPROPER_STATE error?

    Thanks,

    - Mark

  • Hi Mark,

                  In H.264 Decoder we will check whether HDVICP is in reset state or not at the start and at the end of Decoder process call. If decoder leaves HDVICP in improper state, at the end of that process call we will have a HDVICP reset state check which fails, and the decoder returns IH264VDEC_ERR_HDVICP2_IMPROPER_STATE error.

    Could you do one more experiment to confirm whether the error occurred because of Error Concealment algorithm or because of actual Decoder. In create time parameter, initialize the variable errConcealmentMode as 0(Disable error concealment) and check whether you are getting this error or not.

    Could you tell me which version of H.264 decoder you are using?

    Thanks & Regards,

    Suresh

  • Hi Suresh,

    With errConcealmentMode set to 0, the decoder still failed - it stopped with the IH264VDEC_ERR_HDVICP2_IMPROPER_STATE error after some time decoding.  The change did have an noticable effect - the errors in the decoded video look quite different (and errConcealmentMode was set to 1 previously).

    The H.264 decoder version is 01.00.00.08.

    Thanks,

    - Mark

  • Hi Mark,

                Are you observing these errors with some specific error sequence? If you observe this issue with a particular sequence, Could you share the stream with us?

    Thanks & Regards,

    Suresh

  • Hi Suresh,

    I have been able to track this problem down further.

    When everything in an intra frame except the Sequence Parameter Set is lost and the SPS on its own is passed into the decoder, the decoder sometimes returns the IH264VDEC_ERR_HDVICP2_IMPROPER_STATE error code and stops decoding.  This does not happen consistently, and I haven't been able to work out what other factors are relevant to the problem.

    Modifying our code around the decoder to avoid passing an SPS into the decoder without intra frame data (by dropping frames if they contain no coded slice NAL units) appears to fix the problem, and it is able to decode in the previously-failing case.

    This is only going to happen in RTP-like cases, and even then is pretty unlikely without large slices (losing a large set of single NAL unit intra packets is much harder than losing components of an FU-A such that the slice isn't reconstructable), so I can't really provide a stream for it.  However, it should be relatively straightforward to create the case programmatically by dropping parts of a frame.

    Thanks,

    - Mark