diff options
author | Oskar Arvidsson <oskar@irock.se> | 2011-03-29 17:48:59 +0200 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-05-10 07:24:36 -0400 |
commit | 19a0729b4cfacfd90b8ee84ab0c093ff7e397e65 (patch) | |
tree | 63279dbdeba8d3fd96b5c971a224341ec32f7100 /libavcodec/h264.c | |
parent | fcc0224e4fbd44ae268903185b0cf83560b13555 (diff) | |
download | ffmpeg-19a0729b4cfacfd90b8ee84ab0c093ff7e397e65.tar.gz |
Adds 8-, 9- and 10-bit versions of some of the functions used by the h264 decoder.
This patch lets e.g. dsputil_init chose dsp functions with respect to
the bit depth to decode. The naming scheme of bit depth dependent
functions is <base name>_<bit depth>[_<prefix>] (i.e. the old
clear_blocks_c is now named clear_blocks_8_c).
Note: Some of the functions for high bit depth is not dependent on the
bit depth, but only on the pixel size. This leaves some room for
optimizing binary size.
Preparatory patch for high bit depth h264 decoding support.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 22 |
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); |