[FFmpeg-user] Decoding XDCAM 4:2:2 using libavcodec-5.5 : error 0xbebbb1b7 (AVERROR_INVALIDDATA)

francesco at bltitalia.com francesco at bltitalia.com
Tue Apr 1 16:35:49 CEST 2014


I post this message on libav list too, but no one response.
Hi to all 
I have written a code for decoding IMX-D10 at 30, 40 and 50 M and works
fine.  Attempting to decode XDCAM 4:2:2 at 1920x1080 it seems that only
first frame (I-Frame) is decoded.  After this I receive the error
0xbebbbb1b7 from avcodec_decode_video2 routine.  Here is the code:

 pCodec = NULL;   pFrame = NULL;  pCodecCtx = NULL;
  av_init_packet(&packet);

  pCodec=avcodec_find_decoder(CODEC_ID_MPEG2VIDEO);
  if( pCodec==NULL)
  {   str1.printf("Error at frame %ld: Unable to find CODEC_ID_MPEG2VIDEO
exited",frmcnt,err);smsmemo->Memo1->Lines->Add(str1);
     errDS10 = -3; goto end_convDS10;
   }
  pCodecCtx = avcodec_alloc_context3(pCodec);
  // Allocate video frame
  pFrame=avcodec_alloc_frame();
 // Open codec
  if(avcodec_open2(pCodecCtx, pCodec,NULL)<0) { 
smsmemo->Memo1->Lines->Add("Unable to open codec!"); errDS10 = -5; goto
end_convDS10;}

  packet.size = bfsz; // This is the size passed to the routine
  packet.data = fbuf; // This is the buffer passed to the routine

  frameFinished = 1;    err = 0;
  do
  {
  // Decode video frame
   err = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,&packet);
   if(err<0)
   {  str1.printf("Error (%lx) at frame %ld returned from
avcodec_decode_video2, exited",err,frmcnt); smsmemo->Memo1->Lines->Add(str1);
     errDS10 = -7; goto end_convDS10;
   }
   Application->ProcessMessages();

  }
  while ((!frameFinished)&&(packet.size>0))  ;

The first frame is decoded correctly; is an I-Frame and these are the first
bytes of header:

00 00 01 B3 78 04 38 33 7A 12 22 02 10 20 20 26
20 26 2C 2C 2C 2C 2C 2C 34 30 34 36 36 36 34 34
34 34 36 36 36 3A 3A 3A 44 44 44 3A 3A 3A 36 36
3A 3A 40 40 44 44 4A 4C 4A 46 46 44 46 4C 4C 50
50 50 60 60 5C 5C 70 70 74 8A 8A A7 10 11 11 12
12 12 13 13 13 13 14 14 14 14 14 15 15 15 15 15
15 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17
18 18 18 19 18 18 18 19 1A 1A 1A 1A 19 1B 1B 1B
1B 1B 1C 1C 1C 1C 1E 1E 1E 1F 1F 21 00 00 01 B5
18 24 00 01 01 00 00 00 01 B5 21 01 01 01 1E 02
21 C0 00 00 01 B8 00 08 00 40 00 00 01 00 00 8B
22 10 00 00 00 01 B5 ...

as you can see from first pachet header (00 00 00 01 00) is an I-Frame (byte
5 is 0x8B that is 10001011 and insulating bits 3,4 and 5 we have 1 =>
I-Frame). Second packet is an B frame, here is header:

00 00 01 00 00 1A D7 83 B8 00 00 01 B5 84 45 4B
9C 00 00 00 01 B5 38 40 80 80 98 80 98 B0 B0 B0
B0 B0 B0 D0 C0 D0 D8 D8 D8 D0 D0 D0 D0 D8 D8 D8
E8 E8 E9 11 11 10 E8 E8 E8 D8 D8 E8 E9 01 01 11
11 29 31 29 19 19 11 19 31

we have 0x1a that is 00011010 and now bits 3,4and 5 are 011 that identify a
B-Frame.  I receive error till next I frame.  There is something I'm missing
or it's a bug (or limit ) of this version of libavcodec ?
Regards



More information about the ffmpeg-user mailing list