[FFmpeg-trac] #3449(avcodec:new): av_parser_parse2 fails on H264 elementary stream
FFmpeg
trac at avcodec.org
Mon Mar 10 15:54:45 CET 2014
#3449: av_parser_parse2 fails on H264 elementary stream
-------------------------------------+-------------------------------------
Reporter: lordAtticus | Owner:
Type: defect | Status: new
Priority: important | Component: avcodec
Version: git-master | Resolution:
Keywords: h264 | Blocked By:
regression | Reproduced by developer: 0
Blocking: |
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by lordAtticus):
It's more about parsing here, rather then actual decoding. The stream I
added contains 4 nalus(h264 packet), a PPS, SPS a SEI and an I frame. This
makes it valid video and can be played back even in vlc. Parser is meant
to be used when we have in same buffer multiple frames. The parser
identifies the boundaries between multiple nalus so we can split the
buffer and feed it step by step to decoder. So the generic approach in
streaming video is to first parse the incoming buffer to identify
individual nalus, then feed them individually to the decoder, something
like this:
// parse buffer until complete
while(inLength) {
parsedLength = av_parser_parse2(videoInParserContext,
videoInCodecContext,
&outData, &outLength,
inData, inLength,
0, 0, 0);
inData += parsedLength;
inLength -= parsedLength;
if(outLength) {
av_init_packet(&videoInPacket);
videoInPacket.data = outData;
videoInPacket.size = outLength;
avcodec_decode_video2(videoInCodecContext, videoInFrame,
&gotData, &videoInPacket);
if (gotData) {
// display videoInFrame
}
}
The problem since 2.x releases is that the parser sets outData to NULL,
outSize to 0 and parsedLength to inLength, forcing code to exit the loop
and discard data.
Running a debug build I traced the root of the problem to line 67 to 70 in
h264_parser.c, if we are to restore the state "7" with code from ffmpeg
v1.2.x the problem is gone. However, reverting to old code may not be the
solution, since I reckon the asm was introduced to improve performance...
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3449#comment:4>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list