[Ffmpeg-cvslog] r8197 - in trunk/libavcodec: avcodec.h h264.c

Luca Barbato lu_zero
Sat Mar 3 18:40:46 CET 2007


michael wrote:
> Author: michael
> Date: Sat Mar  3 00:35:26 2007
> New Revision: 8197
> 
> Modified:
>    trunk/libavcodec/avcodec.h
>    trunk/libavcodec/h264.c
> 
> Log:
> support feeding individual NAL units to the decoder instead of just complete frames


rtsp in mplayer, vlc should be the same.

I could provide a test server to check.

decode_frame (avctx=0x106b6390, data=0x106b62b0, data_size=0x7fae4198,
    buf=0x106af790 "\006\005???E????H?\226,? ?#??x264 - core 54 -
H.264/MPEG-4 AVC codec - Copyleft 2005 -
http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0
analyse=0x1:0 me=dia subme=7 brdo=0 mixed_ref=0 m"...,
    buf_size=463) at h264.c:8366
8366            s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
(gdb) bt
#0  decode_frame (avctx=0x106b6390, data=0x106b62b0, data_size=0x7fae4198,
    buf=0x106af790 "\006\005???E????H?\226,? ?#??x264 - core 54 -
H.264/MPEG-4 AVC codec - Copyleft 2005 -
http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0
analyse=0x1:0 me=dia subme=7 brdo=0 mixed_ref=0 m"...,
    buf_size=463) at h264.c:8366
#1  0x101f3270 in avcodec_decode_video (avctx=0x106b6390,
picture=0x106b62b0,
    got_picture_ptr=0x7fae4198,
    buf=0x106af790 "\006\005???E????H?\226,? ?#??x264 - core 54 -
H.264/MPEG-4 AVC codec - Copyleft 2005 -
http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0
analyse=0x1:0 me=dia subme=7 brdo=0 mixed_ref=0 m"...,
    buf_size=463) at utils.c:880
#2  0x100cbec4 in decode (sh=0x106af5a0, data=0x106af790, len=463,
    flags=275473072) at vd_ffmpeg.c:781



> 
> 
> Modified: trunk/libavcodec/avcodec.h
> ==============================================================================
> --- trunk/libavcodec/avcodec.h	(original)
> +++ trunk/libavcodec/avcodec.h	Sat Mar  3 00:35:26 2007
> @@ -37,8 +37,8 @@ extern "C" {
>  #define AV_STRINGIFY(s)         AV_TOSTRING(s)
>  #define AV_TOSTRING(s) #s
>  
> -#define LIBAVCODEC_VERSION_INT  ((51<<16)+(35<<8)+0)
> -#define LIBAVCODEC_VERSION      51.35.0
> +#define LIBAVCODEC_VERSION_INT  ((51<<16)+(36<<8)+0)
> +#define LIBAVCODEC_VERSION      51.36.0
>  #define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
>  
>  #define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
> @@ -384,6 +384,7 @@ typedef struct RcOverride{
>  #define CODEC_FLAG2_MEMC_ONLY     0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
>  #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format
>  #define CODEC_FLAG2_SKIP_RD       0x00004000 ///< RD optimal MB level residual skiping
> +#define CODEC_FLAG2_CHUNKS        0x00008000 ///< input bitstream might be truncated at a packet boundaries instead of only at frame boundaries
>  
>  /* Unsupported options :
>   *              Syntax Arithmetic coding (SAC)
> 
> Modified: trunk/libavcodec/h264.c
> ==============================================================================
> --- trunk/libavcodec/h264.c	(original)
> +++ trunk/libavcodec/h264.c	Sat Mar  3 00:35:26 2007
> @@ -4516,6 +4516,11 @@ static int decode_slice_header(H264Conte
>  
>      first_mb_in_slice= get_ue_golomb(&s->gb);
>  
> +    if((s->flags2 & CODEC_FLAG2_CHUNKS) && first_mb_in_slice == 0){
> +        h->slice_num = 0;
> +        s->current_picture_ptr= NULL;
> +    }
> +
>      slice_type= get_ue_golomb(&s->gb);
>      if(slice_type > 9){
>          av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
> @@ -8095,8 +8100,11 @@ static int decode_nal_units(H264Context 
>          av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
>      }
>  #endif
> -    h->slice_num = 0;
> -    s->current_picture_ptr= NULL;
> +    if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
> +        h->slice_num = 0;
> +        s->current_picture_ptr= NULL;
> +    }
> +
>      for(;;){
>          int consumed;
>          int dst_length;
> @@ -8232,24 +8240,6 @@ static int decode_nal_units(H264Context 
>          }
>      }
>  
> -    if(!s->current_picture_ptr) return buf_index; //no frame
> -
> -    s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
> -    s->current_picture_ptr->pict_type= s->pict_type;
> -
> -    h->prev_frame_num_offset= h->frame_num_offset;
> -    h->prev_frame_num= h->frame_num;
> -    if(s->current_picture_ptr->reference){
> -        h->prev_poc_msb= h->poc_msb;
> -        h->prev_poc_lsb= h->poc_lsb;
> -    }
> -    if(s->current_picture_ptr->reference)
> -        execute_ref_pic_marking(h, h->mmco, h->mmco_index);
> -
> -    ff_er_frame_end(s);
> -
> -    MPV_frame_end(s);
> -
>      return buf_index;
>  }
>  
> @@ -8365,23 +8355,36 @@ static int decode_frame(AVCodecContext *
>      if(buf_index < 0)
>          return -1;
>  
> -    //FIXME do something with unavailable reference frames
> +    if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){
> +        Picture *out = s->current_picture_ptr;
> +        Picture *cur = s->current_picture_ptr;
> +        Picture *prev = h->delayed_output_pic;
> +        int i, pics, cross_idr, out_of_order, out_idx;
>  
> -//    if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_index, buf_size);
> -    if(!s->current_picture_ptr){
> -        av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
> -        return -1;
> -    }
> +        s->mb_y= 0;
> +
> +        s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
> +        s->current_picture_ptr->pict_type= s->pict_type;
> +
> +        h->prev_frame_num_offset= h->frame_num_offset;
> +        h->prev_frame_num= h->frame_num;
> +        if(s->current_picture_ptr->reference){
> +            h->prev_poc_msb= h->poc_msb;
> +            h->prev_poc_lsb= h->poc_lsb;
> +        }
> +        if(s->current_picture_ptr->reference)
> +            execute_ref_pic_marking(h, h->mmco, h->mmco_index);
> +
> +        ff_er_frame_end(s);
> +
> +        MPV_frame_end(s);
> +
> +    //FIXME do something with unavailable reference frames
>  
> -    {
> -        Picture *out = s->current_picture_ptr;
>  #if 0 //decode order
>          *data_size = sizeof(AVFrame);
>  #else
>          /* Sort B-frames into display order */
> -        Picture *cur = s->current_picture_ptr;
> -        Picture *prev = h->delayed_output_pic;
> -        int i, pics, cross_idr, out_of_order, out_idx;
>  
>          if(h->sps.bitstream_restriction_flag
>             && s->avctx->has_b_frames < h->sps.num_reorder_frames){
> _______________________________________________
> ffmpeg-cvslog mailing list
> ffmpeg-cvslog at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-cvslog


-- 

Luca Barbato

Gentoo/linux Gentoo/PPC
http://dev.gentoo.org/~lu_zero





More information about the ffmpeg-cvslog mailing list