diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 092c3c964d..98841ed07c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -97,12 +97,12 @@ OBJS-$(CONFIG_H263DSP) += h263dsp.o OBJS-$(CONFIG_H264CHROMA) += h264chroma.o OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o OBJS-$(CONFIG_H264PARSE) += h264_parse.o h264_ps.o h2645data.o \ - h2645_parse.o + h2645_parse.o h2645_vui.o OBJS-$(CONFIG_H264PRED) += h264pred.o OBJS-$(CONFIG_H264QPEL) += h264qpel.o OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o hevc_ps.o hevc_data.o \ - h2645data.o h2645_parse.o + h2645data.o h2645_parse.o h2645_vui.o OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o h2645_sei.o \ dynamic_hdr10_plus.o dynamic_hdr_vivid.o OBJS-$(CONFIG_HPELDSP) += hpeldsp.o diff --git a/libavcodec/h2645_vui.c b/libavcodec/h2645_vui.c new file mode 100644 index 0000000000..0633fcbddd --- /dev/null +++ b/libavcodec/h2645_vui.c @@ -0,0 +1,91 @@ +/* + * Common H.264/HEVC VUI Parameter decoding + * + * Copyright (c) 2003 Michael Niedermayer + * Copyright (C) 2012 - 2013 Guillaume Martres + * Copyright (C) 2012 - 2013 Mickael Raulet + * Copyright (C) 2012 - 2013 Gildas Cocherel + * Copyright (C) 2013 Vittorio Giovara + * + * This file is part of FFmpeg. + * + * 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. + * + * 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/log.h" +#include "libavutil/pixdesc.h" + +#include "get_bits.h" +#include "golomb.h" +#include "h2645data.h" +#include "h2645_vui.h" + +#define EXTENDED_SAR 255 + +void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx) +{ + int aspect_ratio_info_present_flag; + + av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n"); + + aspect_ratio_info_present_flag = get_bits1(gb); + if (aspect_ratio_info_present_flag) { + uint8_t aspect_ratio_idc = get_bits(gb, 8); + if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) + vui->sar = ff_h2645_pixel_aspect[aspect_ratio_idc]; + else if (aspect_ratio_idc == EXTENDED_SAR) { + vui->sar.num = get_bits(gb, 16); + vui->sar.den = get_bits(gb, 16); + } else + av_log(logctx, AV_LOG_WARNING, + "Unknown SAR index: %u.\n", aspect_ratio_idc); + } else + vui->sar = (AVRational){ 0, 1 }; + + vui->overscan_info_present_flag = get_bits1(gb); + if (vui->overscan_info_present_flag) + vui->overscan_appropriate_flag = get_bits1(gb); + + vui->video_signal_type_present_flag = get_bits1(gb); + if (vui->video_signal_type_present_flag) { + vui->video_format = get_bits(gb, 3); + vui->video_full_range_flag = get_bits1(gb); + vui->colour_description_present_flag = get_bits1(gb); + if (vui->colour_description_present_flag) { + vui->colour_primaries = get_bits(gb, 8); + vui->transfer_characteristics = get_bits(gb, 8); + vui->matrix_coeffs = get_bits(gb, 8); + + // Set invalid values to "unspecified" + if (!av_color_primaries_name(vui->colour_primaries)) + vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; + if (!av_color_transfer_name(vui->transfer_characteristics)) + vui->transfer_characteristics = AVCOL_TRC_UNSPECIFIED; + if (!av_color_space_name(vui->matrix_coeffs)) + vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; + } + } + + vui->chroma_loc_info_present_flag = get_bits1(gb); + if (vui->chroma_loc_info_present_flag) { + vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb); + vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb); + if (vui->chroma_sample_loc_type_top_field <= 5U) + vui->chroma_location = vui->chroma_sample_loc_type_top_field + 1; + else + vui->chroma_location = AVCHROMA_LOC_UNSPECIFIED; + } else + vui->chroma_location = AVCHROMA_LOC_LEFT; +} diff --git a/libavcodec/h2645_vui.h b/libavcodec/h2645_vui.h new file mode 100644 index 0000000000..638da7c366 --- /dev/null +++ b/libavcodec/h2645_vui.h @@ -0,0 +1,49 @@ +/* + * This file is part of FFmpeg. + * + * 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. + * + * 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_H2645_VUI_H +#define AVCODEC_H2645_VUI_H + +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" + +#include "get_bits.h" + +typedef struct H2645VUI { + AVRational sar; + + int overscan_info_present_flag; + int overscan_appropriate_flag; + + int video_signal_type_present_flag; + int video_format; + int video_full_range_flag; + int colour_description_present_flag; + enum AVColorPrimaries colour_primaries; + enum AVColorTransferCharacteristic transfer_characteristics; + enum AVColorSpace matrix_coeffs; + + int chroma_loc_info_present_flag; + int chroma_sample_loc_type_top_field; + int chroma_sample_loc_type_bottom_field; + enum AVChromaLocation chroma_location; +} H2645VUI; + +void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx); + +#endif /* AVCODEC_H2645_VUI_H */ diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 874790a3a3..d0d1e65903 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -31,14 +31,12 @@ #include "mathops.h" #include "avcodec.h" #include "h264data.h" -#include "h2645data.h" +#include "h2645_vui.h" #include "h264_ps.h" #include "golomb.h" #define MIN_LOG2_MAX_FRAME_NUM 4 -#define EXTENDED_SAR 255 - static const uint8_t default_scaling4[2][16] = { { 6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42 }, @@ -133,62 +131,7 @@ static inline int decode_hrd_parameters(GetBitContext *gb, void *logctx, static inline int decode_vui_parameters(GetBitContext *gb, void *logctx, SPS *sps) { - int aspect_ratio_info_present_flag; - unsigned int aspect_ratio_idc; - - aspect_ratio_info_present_flag = get_bits1(gb); - - if (aspect_ratio_info_present_flag) { - aspect_ratio_idc = get_bits(gb, 8); - if (aspect_ratio_idc == EXTENDED_SAR) { - sps->sar.num = get_bits(gb, 16); - sps->sar.den = get_bits(gb, 16); - } else if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) { - sps->sar = ff_h2645_pixel_aspect[aspect_ratio_idc]; - } else { - av_log(logctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n", - aspect_ratio_idc); - } - } else { - sps->sar.num = - sps->sar.den = 0; - } - - if (get_bits1(gb)) /* overscan_info_present_flag */ - get_bits1(gb); /* overscan_appropriate_flag */ - - sps->video_signal_type_present_flag = get_bits1(gb); - if (sps->video_signal_type_present_flag) { - get_bits(gb, 3); /* video_format */ - sps->full_range = get_bits1(gb); /* video_full_range_flag */ - - sps->colour_description_present_flag = get_bits1(gb); - if (sps->colour_description_present_flag) { - sps->color_primaries = get_bits(gb, 8); /* colour_primaries */ - sps->color_trc = get_bits(gb, 8); /* transfer_characteristics */ - sps->colorspace = get_bits(gb, 8); /* matrix_coefficients */ - - // Set invalid values to "unspecified" - if (!av_color_primaries_name(sps->color_primaries)) - sps->color_primaries = AVCOL_PRI_UNSPECIFIED; - if (!av_color_transfer_name(sps->color_trc)) - sps->color_trc = AVCOL_TRC_UNSPECIFIED; - if (!av_color_space_name(sps->colorspace)) - sps->colorspace = AVCOL_SPC_UNSPECIFIED; - } - } - - /* chroma_location_info_present_flag */ - if (get_bits1(gb)) { - /* chroma_sample_location_type_top_field */ - sps->chroma_location = get_ue_golomb_31(gb); - if (sps->chroma_location <= 5U) - sps->chroma_location++; - else - sps->chroma_location = AVCHROMA_LOC_UNSPECIFIED; - get_ue_golomb_31(gb); /* chroma_sample_location_type_bottom_field */ - } else - sps->chroma_location = AVCHROMA_LOC_LEFT; + ff_h2645_decode_common_vui_params(gb, &sps->vui, logctx); if (show_bits1(gb) && get_bits_left(gb) < 10) { av_log(logctx, AV_LOG_WARNING, "Truncated VUI (%d)\n", get_bits_left(gb)); @@ -381,12 +324,12 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, sps->profile_idc = profile_idc; sps->constraint_set_flags = constraint_set_flags; sps->level_idc = level_idc; - sps->full_range = -1; + sps->vui.video_full_range_flag = -1; memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); sps->scaling_matrix_present = 0; - sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED + sps->vui.matrix_coeffs = AVCOL_SPC_UNSPECIFIED; if (sps->profile_idc == 100 || // High profile sps->profile_idc == 110 || // High10 profile @@ -603,8 +546,8 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, } } - if (!sps->sar.den) - sps->sar.den = 1; + if (!sps->vui.sar.den) + sps->vui.sar.den = 1; if (avctx->debug & FF_DEBUG_PICT_INFO) { static const char csp[4][5] = { "Gray", "420", "422", "444" }; diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h index dc52835ed4..5c35761fbc 100644 --- a/libavcodec/h264_ps.h +++ b/libavcodec/h264_ps.h @@ -33,6 +33,7 @@ #include "avcodec.h" #include "get_bits.h" #include "h264.h" +#include "h2645_vui.h" #define MAX_SPS_COUNT 32 #define MAX_PPS_COUNT 256 @@ -70,14 +71,7 @@ typedef struct SPS { unsigned int crop_top; ///< frame_cropping_rect_top_offset unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset int vui_parameters_present_flag; - AVRational sar; - int video_signal_type_present_flag; - int full_range; - int colour_description_present_flag; - enum AVColorPrimaries color_primaries; - enum AVColorTransferCharacteristic color_trc; - enum AVColorSpace colorspace; - enum AVChromaLocation chroma_location; + H2645VUI vui; int timing_info_present_flag; uint32_t num_units_in_tick; diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 02f647dfe0..0bacbb723f 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -327,7 +327,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, !h->ps.sps || h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma || h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc || - h->ps.sps->colorspace != h1->ps.sps->colorspace)) { + h->ps.sps->vui.matrix_coeffs != h1->ps.sps->vui.matrix_coeffs)) { need_reinit = 1; } @@ -937,7 +937,7 @@ static int h264_slice_header_init(H264Context *h) goto fail; } - ff_set_sar(h->avctx, sps->sar); + ff_set_sar(h->avctx, sps->vui.sar); av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt, &h->chroma_x_shift, &h->chroma_y_shift); @@ -1062,7 +1062,7 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl || (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0)))) must_reinit = 1; - if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio)) + if (first_slice && av_cmp_q(sps->vui.sar, h->avctx->sample_aspect_ratio)) must_reinit = 1; if (!h->setup_finished) { @@ -1084,15 +1084,15 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl init_dimensions(h); - if (sps->video_signal_type_present_flag) { - h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG - : AVCOL_RANGE_MPEG; - if (sps->colour_description_present_flag) { - if (h->avctx->colorspace != sps->colorspace) + if (sps->vui.video_signal_type_present_flag) { + h->avctx->color_range = sps->vui.video_full_range_flag > 0 ? AVCOL_RANGE_JPEG + : AVCOL_RANGE_MPEG; + if (sps->vui.colour_description_present_flag) { + if (h->avctx->colorspace != sps->vui.matrix_coeffs) needs_reinit = 1; - h->avctx->color_primaries = sps->color_primaries; - h->avctx->color_trc = sps->color_trc; - h->avctx->colorspace = sps->colorspace; + h->avctx->color_primaries = sps->vui.colour_primaries; + h->avctx->color_trc = sps->vui.transfer_characteristics; + h->avctx->colorspace = sps->vui.matrix_coeffs; } } @@ -1102,7 +1102,7 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl h->avctx->color_trc = h->sei.common.alternative_transfer.preferred_transfer_characteristics; } } - h->avctx->chroma_sample_location = sps->chroma_location; + h->avctx->chroma_sample_location = sps->vui.chroma_location; if (!h->context_initialized || must_reinit || needs_reinit) { int flush_changes = h->context_initialized; @@ -1250,14 +1250,14 @@ static int h264_export_frame_props(H264Context *h) } else { fgp->codec.h274.bit_depth_luma = sps->bit_depth_luma; fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma; - if (sps->video_signal_type_present_flag) - fgp->codec.h274.color_range = sps->full_range + 1; + if (sps->vui.video_signal_type_present_flag) + fgp->codec.h274.color_range = sps->vui.video_full_range_flag + 1; else fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED; - if (sps->colour_description_present_flag) { - fgp->codec.h274.color_primaries = sps->color_primaries; - fgp->codec.h274.color_trc = sps->color_trc; - fgp->codec.h274.color_space = sps->colorspace; + if (sps->vui.colour_description_present_flag) { + fgp->codec.h274.color_primaries = sps->vui.colour_primaries; + fgp->codec.h274.color_trc = sps->vui.transfer_characteristics; + fgp->codec.h274.color_space = sps->vui.matrix_coeffs; } else { fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED; fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED; diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index bfd4291bb9..5fe62ec35b 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -25,7 +25,7 @@ #include "libavutil/imgutils.h" #include "golomb.h" -#include "h2645data.h" +#include "h2645_vui.h" #include "hevc_data.h" #include "hevc_ps.h" @@ -568,47 +568,15 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, { VUI backup_vui, *vui = &sps->vui; GetBitContext backup; - int sar_present, alt = 0; - - av_log(avctx, AV_LOG_DEBUG, "Decoding VUI\n"); - - sar_present = get_bits1(gb); - if (sar_present) { - uint8_t sar_idx = get_bits(gb, 8); - if (sar_idx < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) - vui->sar = ff_h2645_pixel_aspect[sar_idx]; - else if (sar_idx == 255) { - vui->sar.num = get_bits(gb, 16); - vui->sar.den = get_bits(gb, 16); - } else - av_log(avctx, AV_LOG_WARNING, - "Unknown SAR index: %u.\n", sar_idx); - } + int alt = 0; - vui->overscan_info_present_flag = get_bits1(gb); - if (vui->overscan_info_present_flag) - vui->overscan_appropriate_flag = get_bits1(gb); + ff_h2645_decode_common_vui_params(gb, &sps->vui.common, avctx); - vui->video_signal_type_present_flag = get_bits1(gb); - if (vui->video_signal_type_present_flag) { - vui->video_format = get_bits(gb, 3); - vui->video_full_range_flag = get_bits1(gb); - vui->colour_description_present_flag = get_bits1(gb); - if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) + if (vui->common.video_signal_type_present_flag) { + if (vui->common.video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P) sps->pix_fmt = AV_PIX_FMT_YUVJ420P; - if (vui->colour_description_present_flag) { - vui->colour_primaries = get_bits(gb, 8); - vui->transfer_characteristic = get_bits(gb, 8); - vui->matrix_coeffs = get_bits(gb, 8); - - // Set invalid values to "unspecified" - if (!av_color_primaries_name(vui->colour_primaries)) - vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; - if (!av_color_transfer_name(vui->transfer_characteristic)) - vui->transfer_characteristic = AVCOL_TRC_UNSPECIFIED; - if (!av_color_space_name(vui->matrix_coeffs)) - vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; - if (vui->matrix_coeffs == AVCOL_SPC_RGB) { + if (vui->common.colour_description_present_flag) { + if (vui->common.matrix_coeffs == AVCOL_SPC_RGB) { switch (sps->pix_fmt) { case AV_PIX_FMT_YUV444P: sps->pix_fmt = AV_PIX_FMT_GBRP; @@ -624,12 +592,6 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, } } - vui->chroma_loc_info_present_flag = get_bits1(gb); - if (vui->chroma_loc_info_present_flag) { - vui->chroma_sample_loc_type_top_field = get_ue_golomb_long(gb); - vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_long(gb); - } - vui->neutra_chroma_indication_flag = get_bits1(gb); vui->field_seq_flag = get_bits1(gb); vui->frame_field_info_present_flag = get_bits1(gb); @@ -1104,7 +1066,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps->sps_temporal_mvp_enabled_flag = get_bits1(gb); sps->sps_strong_intra_smoothing_enable_flag = get_bits1(gb); - sps->vui.sar = (AVRational){0, 1}; + sps->vui.common.sar = (AVRational){0, 1}; vui_present = get_bits1(gb); if (vui_present) decode_vui(gb, avctx, apply_defdispwin, sps); diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index 2a1bbf6489..18894cfed1 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -29,6 +29,7 @@ #include "avcodec.h" #include "get_bits.h" +#include "h2645_vui.h" #include "hevc.h" typedef struct ShortTermRPS { @@ -47,22 +48,8 @@ typedef struct HEVCWindow { } HEVCWindow; typedef struct VUI { - AVRational sar; - - int overscan_info_present_flag; - int overscan_appropriate_flag; - - int video_signal_type_present_flag; - int video_format; - int video_full_range_flag; - int colour_description_present_flag; - uint8_t colour_primaries; - uint8_t transfer_characteristic; - uint8_t matrix_coeffs; - - int chroma_loc_info_present_flag; - int chroma_sample_loc_type_top_field; - int chroma_sample_loc_type_bottom_field; + H2645VUI common; + int neutra_chroma_indication_flag; int field_seq_flag; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index afe8fe4af2..5631f6ed49 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -339,18 +339,18 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps) avctx->profile = sps->ptl.general_ptl.profile_idc; avctx->level = sps->ptl.general_ptl.level_idc; - ff_set_sar(avctx, sps->vui.sar); + ff_set_sar(avctx, sps->vui.common.sar); - if (sps->vui.video_signal_type_present_flag) - avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG - : AVCOL_RANGE_MPEG; + if (sps->vui.common.video_signal_type_present_flag) + avctx->color_range = sps->vui.common.video_full_range_flag ? AVCOL_RANGE_JPEG + : AVCOL_RANGE_MPEG; else avctx->color_range = AVCOL_RANGE_MPEG; - if (sps->vui.colour_description_present_flag) { - avctx->color_primaries = sps->vui.colour_primaries; - avctx->color_trc = sps->vui.transfer_characteristic; - avctx->colorspace = sps->vui.matrix_coeffs; + if (sps->vui.common.colour_description_present_flag) { + avctx->color_primaries = sps->vui.common.colour_primaries; + avctx->color_trc = sps->vui.common.transfer_characteristics; + avctx->colorspace = sps->vui.common.matrix_coeffs; } else { avctx->color_primaries = AVCOL_PRI_UNSPECIFIED; avctx->color_trc = AVCOL_TRC_UNSPECIFIED; @@ -359,9 +359,9 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps) avctx->chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; if (sps->chroma_format_idc == 1) { - if (sps->vui.chroma_loc_info_present_flag) { - if (sps->vui.chroma_sample_loc_type_top_field <= 5) - avctx->chroma_sample_location = sps->vui.chroma_sample_loc_type_top_field + 1; + if (sps->vui.common.chroma_loc_info_present_flag) { + if (sps->vui.common.chroma_sample_loc_type_top_field <= 5) + avctx->chroma_sample_location = sps->vui.common.chroma_sample_loc_type_top_field + 1; } else avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; } @@ -2846,14 +2846,14 @@ static int set_side_data(HEVCContext *s) const VUI *vui = &sps->vui; fgp->codec.h274.bit_depth_luma = sps->bit_depth; fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma; - if (vui->video_signal_type_present_flag) - fgp->codec.h274.color_range = vui->video_full_range_flag + 1; + if (vui->common.video_signal_type_present_flag) + fgp->codec.h274.color_range = vui->common.video_full_range_flag + 1; else fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED; - if (vui->colour_description_present_flag) { - fgp->codec.h274.color_primaries = vui->colour_primaries; - fgp->codec.h274.color_trc = vui->transfer_characteristic; - fgp->codec.h274.color_space = vui->matrix_coeffs; + if (vui->common.colour_description_present_flag) { + fgp->codec.h274.color_primaries = vui->common.colour_primaries; + fgp->codec.h274.color_trc = vui->common.transfer_characteristics; + fgp->codec.h274.color_space = vui->common.matrix_coeffs; } else { fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED; fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED;