[FFmpeg-cvslog] r23340 - in trunk/libavcodec: h264.c h264.h

cehoyos subversion
Wed May 26 21:00:59 CEST 2010


Author: cehoyos
Date: Wed May 26 21:00:59 2010
New Revision: 23340

Log:
Factorize ff_h264_decode_extradata().

Patch by Howard Chu, hyc highlandsun com

Modified:
   trunk/libavcodec/h264.c
   trunk/libavcodec/h264.h

Modified: trunk/libavcodec/h264.c
==============================================================================
--- trunk/libavcodec/h264.c	Wed May 26 20:54:59 2010	(r23339)
+++ trunk/libavcodec/h264.c	Wed May 26 21:00:59 2010	(r23340)
@@ -844,41 +844,11 @@ static av_cold void common_init(H264Cont
     memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
 }
 
-av_cold int ff_h264_decode_init(AVCodecContext *avctx){
-    H264Context *h= avctx->priv_data;
-    MpegEncContext * const s = &h->s;
-
-    MPV_decode_defaults(s);
-
-    s->avctx = avctx;
-    common_init(h);
-
-    s->out_format = FMT_H264;
-    s->workaround_bugs= avctx->workaround_bugs;
-
-    // set defaults
-//    s->decode_mb= ff_h263_decode_mb;
-    s->quarter_sample = 1;
-    if(!avctx->has_b_frames)
-    s->low_delay= 1;
-
-    avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
-
-    ff_h264_decode_init_vlc();
-
-    h->thread_context[0] = h;
-    h->outputed_poc = INT_MIN;
-    h->prev_poc_msb= 1<<16;
-    h->x264_build = -1;
-    ff_h264_reset_sei(h);
-    if(avctx->codec_id == CODEC_ID_H264){
-        if(avctx->ticks_per_frame == 1){
-            s->avctx->time_base.den *=2;
-        }
-        avctx->ticks_per_frame = 2;
-    }
+int ff_h264_decode_extradata(H264Context *h)
+{
+    AVCodecContext *avctx = h->s.avctx;
 
-    if(avctx->extradata_size > 0 && avctx->extradata && *(char *)avctx->extradata == 1){
+    if(*(char *)avctx->extradata == 1){
         int i, cnt, nalsize;
         unsigned char *p = avctx->extradata;
 
@@ -916,9 +886,50 @@ av_cold int ff_h264_decode_init(AVCodecC
         h->nal_length_size = ((*(((char*)(avctx->extradata))+4))&0x03)+1;
     } else {
         h->is_avc = 0;
-        if(decode_nal_units(h, s->avctx->extradata, s->avctx->extradata_size) < 0)
+        if(decode_nal_units(h, avctx->extradata, avctx->extradata_size) < 0)
             return -1;
     }
+    return 0;
+}
+
+av_cold int ff_h264_decode_init(AVCodecContext *avctx){
+    H264Context *h= avctx->priv_data;
+    MpegEncContext * const s = &h->s;
+
+    MPV_decode_defaults(s);
+
+    s->avctx = avctx;
+    common_init(h);
+
+    s->out_format = FMT_H264;
+    s->workaround_bugs= avctx->workaround_bugs;
+
+    // set defaults
+//    s->decode_mb= ff_h263_decode_mb;
+    s->quarter_sample = 1;
+    if(!avctx->has_b_frames)
+    s->low_delay= 1;
+
+    avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
+
+    ff_h264_decode_init_vlc();
+
+    h->thread_context[0] = h;
+    h->outputed_poc = INT_MIN;
+    h->prev_poc_msb= 1<<16;
+    h->x264_build = -1;
+    ff_h264_reset_sei(h);
+    if(avctx->codec_id == CODEC_ID_H264){
+        if(avctx->ticks_per_frame == 1){
+            s->avctx->time_base.den *=2;
+        }
+        avctx->ticks_per_frame = 2;
+    }
+
+    if(avctx->extradata_size > 0 && avctx->extradata &&
+        ff_h264_decode_extradata(h))
+        return -1;
+
     if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames < h->sps.num_reorder_frames){
         s->avctx->has_b_frames = h->sps.num_reorder_frames;
         s->low_delay = 0;

Modified: trunk/libavcodec/h264.h
==============================================================================
--- trunk/libavcodec/h264.h	Wed May 26 20:54:59 2010	(r23339)
+++ trunk/libavcodec/h264.h	Wed May 26 21:00:59 2010	(r23340)
@@ -679,6 +679,7 @@ int ff_h264_check_intra_pred_mode(H264Co
 void ff_h264_write_back_intra_pred_mode(H264Context *h);
 void ff_h264_hl_decode_mb(H264Context *h);
 int ff_h264_frame_start(H264Context *h);
+int ff_h264_decode_extradata(H264Context *h);
 av_cold int ff_h264_decode_init(AVCodecContext *avctx);
 av_cold int ff_h264_decode_end(AVCodecContext *avctx);
 av_cold void ff_h264_decode_init_vlc(void);



More information about the ffmpeg-cvslog mailing list