Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-04-15 00:52:38 +0300
committerJames Almer <jamrial@gmail.com>2019-04-17 01:23:17 +0300
commitcfe220332a8ff821c5f4eb535b634502b5427ae3 (patch)
treec18ed590a078ed61eb8160a07443ee44c3af9032
parent5ba769214f91f099f93185d33bd28e0460cc3908 (diff)
avcodec/cbs_av1: add support for Scalability Metadata
Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/av1.h33
-rw-r--r--libavcodec/cbs_av1.h15
-rw-r--r--libavcodec/cbs_av1_syntax_template.c56
3 files changed, 101 insertions, 3 deletions
diff --git a/libavcodec/av1.h b/libavcodec/av1.h
index f2ec39c86b..6c0e32485b 100644
--- a/libavcodec/av1.h
+++ b/libavcodec/av1.h
@@ -127,4 +127,37 @@ enum {
AV1_CSP_COLOCATED = 2, // -> AVCHROMA_LOC_TOPLEFT.
};
+// Scalability modes (section 6.7.5)
+enum {
+ AV1_SCALABILITY_L1T2 = 0,
+ AV1_SCALABILITY_L1T3 = 1,
+ AV1_SCALABILITY_L2T1 = 2,
+ AV1_SCALABILITY_L2T2 = 3,
+ AV1_SCALABILITY_L2T3 = 4,
+ AV1_SCALABILITY_S2T1 = 5,
+ AV1_SCALABILITY_S2T2 = 6,
+ AV1_SCALABILITY_S2T3 = 7,
+ AV1_SCALABILITY_L2T1h = 8,
+ AV1_SCALABILITY_L2T2h = 9,
+ AV1_SCALABILITY_L2T3h = 10,
+ AV1_SCALABILITY_S2T1h = 11,
+ AV1_SCALABILITY_S2T2h = 12,
+ AV1_SCALABILITY_S2T3h = 13,
+ AV1_SCALABILITY_SS = 14,
+ AV1_SCALABILITY_L3T1 = 15,
+ AV1_SCALABILITY_L3T2 = 16,
+ AV1_SCALABILITY_L3T3 = 17,
+ AV1_SCALABILITY_S3T1 = 18,
+ AV1_SCALABILITY_S3T2 = 19,
+ AV1_SCALABILITY_S3T3 = 20,
+ AV1_SCALABILITY_L3T2_KEY = 21,
+ AV1_SCALABILITY_L3T3_KEY = 22,
+ AV1_SCALABILITY_L4T5_KEY = 23,
+ AV1_SCALABILITY_L4T7_KEY = 24,
+ AV1_SCALABILITY_L3T2_KEY_SHIFT = 25,
+ AV1_SCALABILITY_L3T3_KEY_SHIFT = 26,
+ AV1_SCALABILITY_L4T5_KEY_SHIFT = 27,
+ AV1_SCALABILITY_L4T7_KEY_SHIFT = 28,
+};
+
#endif /* AVCODEC_AV1_H */
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index e799964b72..1fb668ada4 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -325,7 +325,20 @@ typedef struct AV1RawMetadataHDRMDCV {
typedef struct AV1RawMetadataScalability {
uint8_t scalability_mode_idc;
- // TODO: more stuff.
+ uint8_t spatial_layers_cnt_minus_1;
+ uint8_t spatial_layer_dimensions_present_flag;
+ uint8_t spatial_layer_description_present_flag;
+ uint8_t temporal_group_description_present_flag;
+ uint8_t scalability_structure_reserved_3bits;
+ uint16_t spatial_layer_max_width[4];
+ uint16_t spatial_layer_max_height[4];
+ uint8_t spatial_layer_ref_id[4];
+ uint8_t temporal_group_size;
+ uint8_t temporal_group_temporal_id[255];
+ uint8_t temporal_group_temporal_switching_up_point_flag[255];
+ uint8_t temporal_group_spatial_switching_up_point_flag[255];
+ uint8_t temporal_group_ref_cnt[255];
+ uint8_t temporal_group_ref_pic_diff[255][7];
} AV1RawMetadataScalability;
typedef struct AV1RawMetadataITUTT35 {
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 0e019aa113..59a98b18c9 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1653,12 +1653,64 @@ static int FUNC(metadata_hdr_mdcv)(CodedBitstreamContext *ctx, RWContext *rw,
return 0;
}
+static int FUNC(scalability_structure)(CodedBitstreamContext *ctx, RWContext *rw,
+ AV1RawMetadataScalability *current)
+{
+ CodedBitstreamAV1Context *priv = ctx->priv_data;
+ const AV1RawSequenceHeader *seq;
+ int err, i, j;
+
+ if (!priv->sequence_header) {
+ av_log(ctx->log_ctx, AV_LOG_ERROR, "No sequence header available: "
+ "unable to parse scalability metadata.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ seq = priv->sequence_header;
+
+ fb(2, spatial_layers_cnt_minus_1);
+ flag(spatial_layer_dimensions_present_flag);
+ flag(spatial_layer_description_present_flag);
+ flag(temporal_group_description_present_flag);
+ fc(3, scalability_structure_reserved_3bits, 0, 0);
+ if (current->spatial_layer_dimensions_present_flag) {
+ for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++) {
+ fcs(16, spatial_layer_max_width[i],
+ 0, seq->max_frame_width_minus_1 + 1, 1, i);
+ fcs(16, spatial_layer_max_height[i],
+ 0, seq->max_frame_height_minus_1 + 1, 1, i);
+ }
+ }
+ if (current->spatial_layer_description_present_flag) {
+ for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++)
+ fbs(8, spatial_layer_ref_id[i], 1, i);
+ }
+ if (current->temporal_group_description_present_flag) {
+ fb(8, temporal_group_size);
+ for (i = 0; i < current->temporal_group_size; i++) {
+ fbs(3, temporal_group_temporal_id[i], 1, i);
+ flags(temporal_group_temporal_switching_up_point_flag[i], 1, i);
+ flags(temporal_group_spatial_switching_up_point_flag[i], 1, i);
+ fbs(3, temporal_group_ref_cnt[i], 1, i);
+ for (j = 0; j < current->temporal_group_ref_cnt[i]; j++) {
+ fbs(8, temporal_group_ref_pic_diff[i][j], 2, i, j);
+ }
+ }
+ }
+
+ return 0;
+}
+
static int FUNC(metadata_scalability)(CodedBitstreamContext *ctx, RWContext *rw,
AV1RawMetadataScalability *current)
{
- // TODO: scalability metadata.
+ int err;
- return AVERROR_PATCHWELCOME;
+ fb(8, scalability_mode_idc);
+
+ if (current->scalability_mode_idc == AV1_SCALABILITY_SS)
+ CHECK(FUNC(scalability_structure)(ctx, rw, current));
+
+ return 0;
}
static int FUNC(metadata_itut_t35)(CodedBitstreamContext *ctx, RWContext *rw,