summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 0fcb7dbbdb..1388dd5c09 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -783,7 +783,7 @@ static void clone_tables(H264Context *dst, H264Context *src, int i){
dst->list_counts = src->list_counts;
dst->s.obmc_scratchpad = NULL;
- ff_h264_pred_init(&dst->hpc, src->s.codec_id);
+ ff_h264_pred_init(&dst->hpc, src->s.codec_id, src->sps.bit_depth_luma);
}
/**
@@ -811,8 +811,8 @@ static av_cold void common_init(H264Context *h){
s->height = s->avctx->height;
s->codec_id= s->avctx->codec->id;
- ff_h264dsp_init(&h->h264dsp);
- ff_h264_pred_init(&h->hpc, s->codec_id);
+ ff_h264dsp_init(&h->h264dsp, 8);
+ ff_h264_pred_init(&h->hpc, s->codec_id, 8);
h->dequant_coeff_pps= -1;
s->unrestricted_mv=1;
@@ -895,7 +895,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
ff_h264_decode_init_vlc();
h->pixel_shift = 0;
- h->sps.bit_depth_luma = 8;
+ h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
h->thread_context[0] = h;
h->outputed_poc = INT_MIN;
@@ -2998,6 +2998,20 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
if(avctx->has_b_frames < 2)
avctx->has_b_frames= !s->low_delay;
+
+ if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
+ if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
+ avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+ h->pixel_shift = h->sps.bit_depth_luma > 8;
+
+ ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
+ ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
+ dsputil_init(&s->dsp, s->avctx);
+ } else {
+ av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
+ return -1;
+ }
+ }
break;
case NAL_PPS:
init_get_bits(&s->gb, ptr, bit_length);