[Libav-user] Newbie: H264 codec context parameters

Chu Xuan Khoi khoicx at tsdv.com.vn
Thu Dec 29 04:35:47 CET 2011


Dear all,
It is the first time I write H264 decoder by using libavcodec. I have some
trouble when create the codec context: I created a new codec context and
assigned the parameters:
codecDecode = avcodec_find_decoder(CODEC_ID_H264);
if (!codecDecode) {
  fprintf(stderr, "codec not found\n");
  exit(1);
}
ctxDecode= avcodec_alloc_context();
avcodec_get_context_defaults(ctxDecode);
ctxDecode->flags2 |= CODEC_FLAG2_FAST;
ctxDecode->pix_fmt = PIX_FMT_YUV420P;
ctxDecode->width = clip_width;
ctxDecode->height = clip_height;
ctxDecode->dsp_mask = (FF_MM_MMX | FF_MM_MMXEXT | FF_MM_SSE);

if (avcodec_open(ctxDecode, codecDecode) < 0) {
  fprintf(stderr, "could not open codec\n");
  exit(1);
}
It cannot decode the packets.
I have tried to change the file mpeg2 video with CODEC_ID_MPEG2VIDEO. The code
runs.
What is my problem? Do any more parameters need to be assigned in decode
context?
Thanks,



More information about the Libav-user mailing list