diff options
author | Anton Khirnov <anton@khirnov.net> | 2015-03-06 16:03:51 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-04-05 12:01:34 +0200 |
commit | 84f226a3bcd8b39801a4c9051c033ab7d61aaf76 (patch) | |
tree | bfa2bbf15aabe59b0196c7ac318628d04faef8d4 | |
parent | aa1a1b2496cf3ca817e78e27bd0262a50adb91a1 (diff) | |
download | ffmpeg-84f226a3bcd8b39801a4c9051c033ab7d61aaf76.tar.gz |
h264: use the correct SPS during PPS parsing
There is in general no reason for the currently active SPS to be the one
referenced by the PPS being parsed.
-rw-r--r-- | libavcodec/h264_ps.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index ad284da5f9..d1708076b8 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -545,19 +545,15 @@ static void build_qp_table(PPS *pps, int t, int index, const int depth) int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length) { + const SPS *sps; unsigned int pps_id = get_ue_golomb(&h->gb); PPS *pps; - const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); + int qp_bd_offset; int bits_left; if (pps_id >= MAX_PPS_COUNT) { av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id); return AVERROR_INVALIDDATA; - } else if (h->sps.bit_depth_luma > 10) { - av_log(h->avctx, AV_LOG_ERROR, - "Unimplemented luma bit depth=%d (max=10)\n", - h->sps.bit_depth_luma); - return AVERROR_PATCHWELCOME; } pps = av_mallocz(sizeof(PPS)); @@ -569,6 +565,14 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length) av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id); goto fail; } + sps = h->sps_buffers[pps->sps_id]; + + if (sps->bit_depth_luma > 10) { + av_log(h->avctx, AV_LOG_ERROR, + "Unimplemented luma bit depth=%d (max=10)\n", + sps->bit_depth_luma); + return AVERROR_PATCHWELCOME; + } pps->cabac = get_bits1(&h->gb); pps->pic_order_present = get_bits1(&h->gb); @@ -615,6 +619,8 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length) goto fail; } + qp_bd_offset = 6 * (sps->bit_depth_luma - 8); + pps->weighted_pred = get_bits1(&h->gb); pps->weighted_bipred_idc = get_bits(&h->gb, 2); pps->init_qp = get_se_golomb(&h->gb) + 26 + qp_bd_offset; @@ -645,9 +651,9 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length) } build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], - h->sps.bit_depth_luma); + sps->bit_depth_luma); build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], - h->sps.bit_depth_luma); + sps->bit_depth_luma); if (pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) pps->chroma_qp_diff = 1; |