Hi everybody,
A few months ago, I used AVCodec to decode MPEG-2 streaming video frames
and it worked perfectly for what I needed at that time. I'm now using
AVCodec to decode a stream encoded with x264. I'm successful at decoding
it except that I have artifacts that are recurrently appearing on my
decoded frames.
Here are the errors that I receive while decoding :
[h264 @ 0x115bc00]negative number of zero coeffs at 69 41
[h264 @ 0x115bc00]error while decoding MB 69 41
[h264 @ 0x115bc00]concealing 916 DC, 916 AC, 916 MV errors
[h264 @ 0x115bc00]Missing reference picture
[h264 @ 0x115bc00]decode_slice_header error
[h264 @ 0x115bc00]concealing 4134 DC, 4134 AC, 4134 MV errors
[h264 @ 0x115bc00]number of reference frames exceeds max (probably
corrupt input), discarding one
I also managed to display the first bytes of the incoming stream before
decoding. While, most of the time, the encoded frames start with 0x0,
0x0, 0x0, 0x1, 0x41 or 0x0, 0x0, 0x0, 0x1, 0x67, the artifacts seem to
appear when I have no normal starting bytes for the frame, e.g. 0x5f,
0xffffffec, 0x49, 0x25. Might it be the decoded laking too much bytes to
decode, which leaves an incomplete encoded frame in my buffer? Also,
every frames sent by my server starts with normal starting bytes, i.e.
0x0 0x0 0x0 0x1, so I guess the problem is not with x264... Is AVCodec
supporting all x264 encoder's features ?
Here's a sample of the code I am using to initialize and to decode.
[...]
// Initialization :
avcodec_register_all();
codec = avcodec_find_decoder(CODEC_ID_H264);
if(!codec){
// means that we didn't find the codec...
cerr << "Error: Can't get specified codec." << endl;
return false;
}
codecContext = avcodec_alloc_context();
codecContext->hurry_up = 1;
codecContext->error_recognition = FF_ER_COMPLIANT;
codecContext->error_concealment= FF_EC_GUESS_MVS;
codecContext->skip_top = 0;
codecContext->skip_bottom= 0;
codecContext->skip_loop_filter = AVDISCARD_DEFAULT;
codecContext->skip_idct = AVDISCARD_DEFAULT;
codecContext->skip_frame = AVDISCARD_DEFAULT;
codecContext->stream_codec_tag= '462h';
codecContext->pix_fmt = PIX_FMT_YUV420P;
if(avcodec_open(codecContext, codec) < 0){
cerr << "Error: Can't open codec." << endl;
return false;
}
pFrame = avcodec_alloc_frame();
if(codec->capabilities & CODEC_CAP_TRUNCATED)
codecContext->flags |= CODEC_FLAG_TRUNCATED;
return true;
[...]
// Decoding ...
int frameFinished = 0;
int usedBytes = 0;
int leftBytes = bufferSize;
while(leftBytes > 0){
usedBytes = avcodec_decode_video(codecContext, pFrame,
&frameFinished, (uint8_t*)buffer, bufferSize);
leftBytes -= usedBytes;
if(usedBytes < 0){
cerr << "Error: error while decoding frame." << endl;
}
if(frameFinished){
if(codecContext->width != width || codecContext->height !=
height){
// Redefining the width and height of the decoder...
[...]
}
return usedBytes;
}
// updates statistics here... number of frames received,
time taken, etc.
[...]
}
}
return usedBytes;
[...]
Any inputs, thoughts, or redirection would be very appreciated... I'm
using version 52.28 on Windows 32 bits (compiled through MinGW).
Thanks,
Jerome
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user