diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-07-02 18:39:37 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-12-01 11:00:41 +0100 |
commit | 8bf18018a3f469d638f72e01b86474a1287643e1 (patch) | |
tree | 3f3dae48b47d6ec9640590826da7bf550cc1b8a9 /libavcodec/hevc_ps.c | |
parent | 1e38e7fd14492a71665bc7084cd871c6fb5e8d28 (diff) | |
download | ffmpeg-8bf18018a3f469d638f72e01b86474a1287643e1.tar.gz |
avcodec/(h264|hevc)_ps: Factor common VUI code out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/hevc_ps.c')
-rw-r--r-- | libavcodec/hevc_ps.c | 54 |
1 files changed, 8 insertions, 46 deletions
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); |