diff options
Diffstat (limited to 'libavcodec/hevc_ps.c')
-rw-r--r-- | libavcodec/hevc_ps.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 372ce2896b..1684d77672 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -6,25 +6,24 @@ * Copyright (C) 2012 - 2013 Gildas Cocherel * Copyright (C) 2013 Vittorio Giovara * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/imgutils.h" - #include "golomb.h" #include "hevc.h" @@ -73,7 +72,7 @@ static const AVRational vui_sar[] = { int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header) { - HEVCLocalContext *lc = &s->HEVClc; + HEVCLocalContext *lc = s->HEVClc; uint8_t rps_predict = 0; int delta_poc; int k0 = 0; @@ -196,7 +195,8 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl) { int i; - GetBitContext *gb = &s->HEVClc.gb; + HEVCLocalContext *lc = s->HEVClc; + GetBitContext *gb = &lc->gb; ptl->profile_space = get_bits(gb, 2); ptl->tier_flag = get_bits1(gb); @@ -225,7 +225,8 @@ static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl) static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers) { int i; - GetBitContext *gb = &s->HEVClc.gb; + HEVCLocalContext *lc = s->HEVClc; + GetBitContext *gb = &lc->gb; decode_profile_tier_level(s, &ptl->general_ptl); ptl->general_ptl.level_idc = get_bits(gb, 8); @@ -233,7 +234,7 @@ static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers) ptl->sub_layer_profile_present_flag[i] = get_bits1(gb); ptl->sub_layer_level_present_flag[i] = get_bits1(gb); } - if (max_num_sub_layers - 1 > 0) + if (max_num_sub_layers - 1> 0) for (i = max_num_sub_layers - 1; i < 8; i++) skip_bits(gb, 2); // reserved_zero_2bits[i] for (i = 0; i < max_num_sub_layers - 1; i++) { @@ -247,7 +248,7 @@ static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers) static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb, int subpic_params_present) { - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; int i; for (i = 0; i < nb_cpb; i++) { @@ -265,7 +266,7 @@ static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb, static void decode_hrd(HEVCContext *s, int common_inf_present, int max_sublayers) { - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; int nal_params_present = 0, vcl_params_present = 0; int subpic_params_present = 0; int i; @@ -322,7 +323,7 @@ static void decode_hrd(HEVCContext *s, int common_inf_present, int ff_hevc_decode_nal_vps(HEVCContext *s) { int i,j; - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; int vps_id = 0; HEVCVPS *vps; AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps)); @@ -418,7 +419,7 @@ err: static void decode_vui(HEVCContext *s, HEVCSPS *sps) { VUI *vui = &sps->vui; - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; int sar_present; av_log(s->avctx, AV_LOG_DEBUG, "Decoding VUI\n"); @@ -498,6 +499,7 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps) } vui->vui_timing_info_present_flag = get_bits1(gb); + if (vui->vui_timing_info_present_flag) { vui->vui_num_units_in_tick = get_bits(gb, 32); vui->vui_time_scale = get_bits(gb, 32); @@ -550,7 +552,7 @@ static void set_default_scaling_list_data(ScalingList *sl) static int scaling_list_data(HEVCContext *s, ScalingList *sl) { - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; uint8_t scaling_list_pred_mode_flag[4][6]; int32_t scaling_list_dc_coef[2][6]; int size_id, matrix_id, i, pos, delta; @@ -608,7 +610,7 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl) int ff_hevc_decode_nal_sps(HEVCContext *s) { const AVPixFmtDescriptor *desc; - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; int ret = 0; int sps_id = 0; int log2_diff_max_min_transform_block_size; @@ -633,6 +635,12 @@ int ff_hevc_decode_nal_sps(HEVCContext *s) goto err; } + if (!s->vps_list[sps->vps_id]) { + av_log(s->avctx, AV_LOG_ERROR, "VPS does not exist \n"); + ret = AVERROR_INVALIDDATA; + goto err; + } + sps->max_sub_layers = get_bits(gb, 3) + 1; if (sps->max_sub_layers > MAX_SUB_LAYERS) { av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n", @@ -976,7 +984,7 @@ static void hevc_pps_free(void *opaque, uint8_t *data) int ff_hevc_decode_nal_pps(HEVCContext *s) { - GetBitContext *gb = &s->HEVClc.gb; + GetBitContext *gb = &s->HEVClc->gb; HEVCSPS *sps = NULL; int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs; int log2_diff_ctb_min_tb_size; |