summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorHoward Chu <hyc@highlandsun.com>2010-05-26 19:00:59 +0000
committerCarl Eugen Hoyos <cehoyos@rainbow.studorg.tuwien.ac.at>2010-05-26 19:00:59 +0000
commit05e953193d6181deb6922b3d596b580d059c49c5 (patch)
treed120573493070193e7effe2e51572c7727d8fd6a /libavcodec
parent35f7c39a5d2f417720fd8ed1e365114d7abffb5d (diff)
Factorize ff_h264_decode_extradata().
Patch by Howard Chu, hyc highlandsun com Originally committed as revision 23340 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c81
-rw-r--r--libavcodec/h264.h1
2 files changed, 47 insertions, 35 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index e4654f0435..31050631c3 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -844,41 +844,11 @@ static av_cold void common_init(H264Context *h){
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(AVCodecContext *avctx){
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;
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index c6563af35e..2f1dc95ba8 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -679,6 +679,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode);
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);