|
|
@ -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){ |
|
|
|
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; |
|
|
|