Commit d0d39b6c authored by cehoyos's avatar cehoyos

Factorize ff_h264_decode_extradata().

Patch by Howard Chu, hyc highlandsun com


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@23340 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3af1792a
...@@ -844,41 +844,11 @@ static av_cold void common_init(H264Context *h){ ...@@ -844,41 +844,11 @@ static av_cold void common_init(H264Context *h){
memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t)); memset(h->pps.scaling_matrix8, 16, 2*64*sizeof(uint8_t));
} }
av_cold int ff_h264_decode_init(AVCodecContext *avctx){ int ff_h264_decode_extradata(H264Context *h)
H264Context *h= avctx->priv_data; {
MpegEncContext * const s = &h->s; AVCodecContext *avctx = h->s.avctx;
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 && *(char *)avctx->extradata == 1){ if(*(char *)avctx->extradata == 1){
int i, cnt, nalsize; int i, cnt, nalsize;
unsigned char *p = avctx->extradata; unsigned char *p = avctx->extradata;
...@@ -916,9 +886,50 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ ...@@ -916,9 +886,50 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
h->nal_length_size = ((*(((char*)(avctx->extradata))+4))&0x03)+1; h->nal_length_size = ((*(((char*)(avctx->extradata))+4))&0x03)+1;
} else { } else {
h->is_avc = 0; 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 -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){ 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->avctx->has_b_frames = h->sps.num_reorder_frames;
s->low_delay = 0; s->low_delay = 0;
......
...@@ -679,6 +679,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode); ...@@ -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_write_back_intra_pred_mode(H264Context *h);
void ff_h264_hl_decode_mb(H264Context *h); void ff_h264_hl_decode_mb(H264Context *h);
int ff_h264_frame_start(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_init(AVCodecContext *avctx);
av_cold int ff_h264_decode_end(AVCodecContext *avctx); av_cold int ff_h264_decode_end(AVCodecContext *avctx);
av_cold void ff_h264_decode_init_vlc(void); av_cold void ff_h264_decode_init_vlc(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment