[Libav-user] H.264 nal decode

Alex Cohn alexcohn at netvision.net.il
Tue Apr 10 09:03:50 CEST 2012


On Tue, Apr 10, 2012 at 09:19, srikanta mondal <srkntmondal at gmail.com> wrote:
[...]
>        x264_param_t param;
[...]
>        x264_param_default(&param);
[...]
>        //For streaming:
>        param.b_repeat_headers =1;
>        param.b_annexb = 1;                //1
[...]
>              i_frame_size = x264_encoder_encode( encoder, &headers, &i_nal, &pic_in, &pic_out );
>              decoding(heders[0].p_payload, i_frame_size);
[...]
> void decoding(uint8_t *data, int size)
> {
>     AVPacket *pkt;
>     pkt = new AVPacket();
>     int gotpicture;
>
>     av_init_packet(pkt);
>     avcodec_get_frame_defaults(picture);
>
>     pkt->data = data;
>     pkt->size = size;
>     int outSize = avcodec_decode_video2(m_pContext, picture, &gotpicture,
> pkt);
> }
>
> I get the error of segmentation fault by gdb debugger.
>
> Thanks and regards
> Srikanta Mondal

You asked for annexb format of payload. To avcodec_decode_video2() you
must pass the stripped data. Try to simply replace the call
 decoding(heders[0].p_payload, i_frame_size)
with
  decoding(heders[0].p_payload+4, i_frame_size-4);

BR,
Alex


More information about the Libav-user mailing list