summaryrefslogtreecommitdiff
path: root/libavcodec/h264_ps.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-07-02 18:39:37 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-12-01 11:00:41 +0100
commit8bf18018a3f469d638f72e01b86474a1287643e1 (patch)
tree3f3dae48b47d6ec9640590826da7bf550cc1b8a9 /libavcodec/h264_ps.c
parent1e38e7fd14492a71665bc7084cd871c6fb5e8d28 (diff)
avcodec/(h264|hevc)_ps: Factor common VUI code out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/h264_ps.c')
-rw-r--r--libavcodec/h264_ps.c69
1 files changed, 6 insertions, 63 deletions
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" };