* [FFmpeg-devel] [PATCH] cbs_h266: add range extension support
@ 2023-07-05 11:38 Nuo Mi
2023-07-05 11:45 ` James Almer
0 siblings, 1 reply; 4+ messages in thread
From: Nuo Mi @ 2023-07-05 11:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: frankplow
From: frankplow <post@frankplowman.com>
---
libavcodec/cbs_h266.h | 18 ++++++
libavcodec/cbs_h266_syntax_template.c | 79 +++++++++++++++++++++++++--
2 files changed, 93 insertions(+), 4 deletions(-)
diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
index e33d08a0f5..40aba9eb13 100644
--- a/libavcodec/cbs_h266.h
+++ b/libavcodec/cbs_h266.h
@@ -120,6 +120,13 @@ typedef struct H266GeneralConstraintsInfo {
uint8_t gci_no_virtual_boundaries_constraint_flag;
uint8_t gci_num_reserved_bits;
uint8_t gci_reserved_zero_bit[255];
+
+ uint8_t gci_all_rap_pictures_constraint_flag;
+ uint8_t gci_no_extended_precision_processing_constraint_flag;
+ uint8_t gci_no_ts_residual_coding_rice_constraint_flag;
+ uint8_t gci_no_rrc_rice_extension_constraint_flag;
+ uint8_t gci_no_persistent_rice_adaptation_constraint_flag;
+ uint8_t gci_no_reverse_last_sig_coeff_constraint_flag;
} H266GeneralConstraintsInfo;
typedef struct H266RawProfileTierLevel {
@@ -451,6 +458,15 @@ typedef struct H266RawSPS {
uint8_t sps_extension_flag;
+ uint8_t sps_range_extension_flag;
+ uint8_t sps_extension_7bits;
+
+ uint8_t sps_extended_precision_flag;
+ uint8_t sps_ts_residual_coding_rice_present_in_sh_flag;
+ uint8_t sps_rrc_rice_extension_flag;
+ uint8_t sps_persistent_rice_adaptation_enabled_flag;
+ uint8_t sps_reverse_last_sig_coeff_enabled_flag;
+
H266RawExtensionData extension_data;
} H266RawSPS;
@@ -734,6 +750,8 @@ typedef struct H266RawSliceHeader {
uint8_t sh_sign_data_hiding_used_flag;
uint8_t sh_ts_residual_coding_disabled_flag;
+ uint8_t sh_ts_residual_coding_rice_idx_minus1;
+ uint8_t sh_reverse_last_sig_coeff_flag;
uint16_t sh_slice_header_extension_length;
uint8_t sh_slice_header_extension_data_byte[256];
diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index 485c02f590..893fa55369 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -61,7 +61,7 @@ static int FUNC(general_constraints_info) (CodedBitstreamContext *ctx,
RWContext *rw,
H266GeneralConstraintsInfo *current)
{
- int err, i;
+ int err, i, num_additional_bits_used;
flag(gci_present_flag);
if (current->gci_present_flag) {
@@ -149,7 +149,25 @@ static int FUNC(general_constraints_info) (CodedBitstreamContext *ctx,
flag(gci_no_ladf_constraint_flag);
flag(gci_no_virtual_boundaries_constraint_flag);
ub(8, gci_num_reserved_bits);
- for (i = 0; i < current->gci_num_reserved_bits; i++) {
+ if (current->gci_num_reserved_bits > 5) {
+ flag(gci_all_rap_pictures_constraint_flag);
+ flag(gci_no_extended_precision_processing_constraint_flag);
+ flag(gci_no_ts_residual_coding_rice_constraint_flag);
+ flag(gci_no_rrc_rice_extension_constraint_flag);
+ flag(gci_no_persistent_rice_adaptation_constraint_flag);
+ flag(gci_no_reverse_last_sig_coeff_constraint_flag);
+ num_additional_bits_used = 6;
+ } else {
+ infer(gci_all_rap_pictures_constraint_flag, 0);
+ infer(gci_no_extended_precision_processing_constraint_flag, 0);
+ infer(gci_no_ts_residual_coding_rice_constraint_flag, 0);
+ infer(gci_no_rrc_rice_extension_constraint_flag, 0);
+ infer(gci_no_persistent_rice_adaptation_constraint_flag, 0);
+ infer(gci_no_reverse_last_sig_coeff_constraint_flag, 0);
+ num_additional_bits_used = 0;
+ }
+
+ for (i = 0; i < current->gci_num_reserved_bits - num_additional_bits_used; i++) {
flags(gci_reserved_zero_bit[i], 1, i);
}
}
@@ -963,6 +981,23 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw,
return 0;
}
+static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
+ H266RawSPS *current)
+{
+ int err;
+
+ flag(sps_extended_precision_flag);
+ if (current->sps_transform_skip_enabled_flag) {
+ flag(sps_ts_residual_coding_rice_present_in_sh_flag);
+ } else {
+ infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
+ }
+ flag(sps_rrc_rice_extension_flag);
+ flag(sps_persistent_rice_adaptation_enabled_flag);
+ flag(sps_reverse_last_sig_coeff_enabled_flag);
+
+ return 0;
+}
static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
H266RawSPS *current)
@@ -1518,9 +1553,33 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
} else {
CHECK(FUNC(vui_parameters_default) (ctx, rw, ¤t->vui));
}
+
flag(sps_extension_flag);
- if (current->sps_extension_flag)
- CHECK(FUNC(extension_data) (ctx, rw, ¤t->extension_data));
+ if (current->sps_extension_flag) {
+ flag(sps_range_extension_flag);
+ ub(7, sps_extension_7bits);
+
+ if (current->sps_range_extension_flag) {
+ CHECK(FUNC(sps_range_extension)(ctx, rw, current));
+ } else {
+ infer(sps_extended_precision_flag, 0);
+ infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
+ infer(sps_rrc_rice_extension_flag, 0);
+ infer(sps_persistent_rice_adaptation_enabled_flag, 0);
+ infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
+ }
+ } else {
+ infer(sps_range_extension_flag, 0);
+ infer(sps_extension_7bits, 0);
+ infer(sps_extended_precision_flag, 0);
+ infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
+ infer(sps_rrc_rice_extension_flag, 0);
+ infer(sps_persistent_rice_adaptation_enabled_flag, 0);
+ infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
+ }
+
+ if (current->sps_extension_7bits)
+ CHECK(FUNC(extension_data)(ctx, rw, ¤t->extension_data));
CHECK(FUNC(rbsp_trailing_bits) (ctx, rw));
@@ -3005,6 +3064,18 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw,
flag(sh_ts_residual_coding_disabled_flag);
else
infer(sh_ts_residual_coding_disabled_flag, 0);
+
+ if (!current->sh_ts_residual_coding_disabled_flag &&
+ sps->sps_ts_residual_coding_rice_present_in_sh_flag)
+ ub(3, sh_ts_residual_coding_rice_idx_minus1);
+ else
+ infer(sh_ts_residual_coding_rice_idx_minus1, 0);
+
+ if (sps->sps_reverse_last_sig_coeff_enabled_flag)
+ flag(sh_reverse_last_sig_coeff_flag);
+ else
+ infer(sh_reverse_last_sig_coeff_flag, 0);
+
if (pps->pps_slice_header_extension_present_flag) {
ue(sh_slice_header_extension_length, 0, 256);
for (i = 0; i < current->sh_slice_header_extension_length; i++)
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] cbs_h266: add range extension support
2023-07-05 11:38 [FFmpeg-devel] [PATCH] cbs_h266: add range extension support Nuo Mi
@ 2023-07-05 11:45 ` James Almer
2023-07-05 12:38 ` Frank Plowman
0 siblings, 1 reply; 4+ messages in thread
From: James Almer @ 2023-07-05 11:45 UTC (permalink / raw)
To: ffmpeg-devel
On 7/5/2023 8:38 AM, Nuo Mi wrote:
> From: frankplow <post@frankplowman.com>
>
> ---
> libavcodec/cbs_h266.h | 18 ++++++
> libavcodec/cbs_h266_syntax_template.c | 79 +++++++++++++++++++++++++--
> 2 files changed, 93 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
> index e33d08a0f5..40aba9eb13 100644
> --- a/libavcodec/cbs_h266.h
> +++ b/libavcodec/cbs_h266.h
> @@ -120,6 +120,13 @@ typedef struct H266GeneralConstraintsInfo {
> uint8_t gci_no_virtual_boundaries_constraint_flag;
> uint8_t gci_num_reserved_bits;
> uint8_t gci_reserved_zero_bit[255];
> +
> + uint8_t gci_all_rap_pictures_constraint_flag;
> + uint8_t gci_no_extended_precision_processing_constraint_flag;
> + uint8_t gci_no_ts_residual_coding_rice_constraint_flag;
> + uint8_t gci_no_rrc_rice_extension_constraint_flag;
> + uint8_t gci_no_persistent_rice_adaptation_constraint_flag;
> + uint8_t gci_no_reverse_last_sig_coeff_constraint_flag;
> } H266GeneralConstraintsInfo;
>
> typedef struct H266RawProfileTierLevel {
> @@ -451,6 +458,15 @@ typedef struct H266RawSPS {
>
> uint8_t sps_extension_flag;
>
> + uint8_t sps_range_extension_flag;
> + uint8_t sps_extension_7bits;
> +
> + uint8_t sps_extended_precision_flag;
> + uint8_t sps_ts_residual_coding_rice_present_in_sh_flag;
> + uint8_t sps_rrc_rice_extension_flag;
> + uint8_t sps_persistent_rice_adaptation_enabled_flag;
> + uint8_t sps_reverse_last_sig_coeff_enabled_flag;
> +
> H266RawExtensionData extension_data;
>
> } H266RawSPS;
> @@ -734,6 +750,8 @@ typedef struct H266RawSliceHeader {
>
> uint8_t sh_sign_data_hiding_used_flag;
> uint8_t sh_ts_residual_coding_disabled_flag;
> + uint8_t sh_ts_residual_coding_rice_idx_minus1;
> + uint8_t sh_reverse_last_sig_coeff_flag;
> uint16_t sh_slice_header_extension_length;
> uint8_t sh_slice_header_extension_data_byte[256];
>
> diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
> index 485c02f590..893fa55369 100644
> --- a/libavcodec/cbs_h266_syntax_template.c
> +++ b/libavcodec/cbs_h266_syntax_template.c
> @@ -61,7 +61,7 @@ static int FUNC(general_constraints_info) (CodedBitstreamContext *ctx,
> RWContext *rw,
> H266GeneralConstraintsInfo *current)
> {
> - int err, i;
> + int err, i, num_additional_bits_used;
>
> flag(gci_present_flag);
> if (current->gci_present_flag) {
> @@ -149,7 +149,25 @@ static int FUNC(general_constraints_info) (CodedBitstreamContext *ctx,
> flag(gci_no_ladf_constraint_flag);
> flag(gci_no_virtual_boundaries_constraint_flag);
> ub(8, gci_num_reserved_bits);
This should be renamed to gci_num_additional_bits while at it.
> - for (i = 0; i < current->gci_num_reserved_bits; i++) {
> + if (current->gci_num_reserved_bits > 5) {
> + flag(gci_all_rap_pictures_constraint_flag);
> + flag(gci_no_extended_precision_processing_constraint_flag);
> + flag(gci_no_ts_residual_coding_rice_constraint_flag);
> + flag(gci_no_rrc_rice_extension_constraint_flag);
> + flag(gci_no_persistent_rice_adaptation_constraint_flag);
> + flag(gci_no_reverse_last_sig_coeff_constraint_flag);
> + num_additional_bits_used = 6;
> + } else {
> + infer(gci_all_rap_pictures_constraint_flag, 0);
> + infer(gci_no_extended_precision_processing_constraint_flag, 0);
> + infer(gci_no_ts_residual_coding_rice_constraint_flag, 0);
> + infer(gci_no_rrc_rice_extension_constraint_flag, 0);
> + infer(gci_no_persistent_rice_adaptation_constraint_flag, 0);
> + infer(gci_no_reverse_last_sig_coeff_constraint_flag, 0);
> + num_additional_bits_used = 0;
> + }
> +
> + for (i = 0; i < current->gci_num_reserved_bits - num_additional_bits_used; i++) {
> flags(gci_reserved_zero_bit[i], 1, i);
> }
> }
> @@ -963,6 +981,23 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw,
> return 0;
> }
>
> +static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
> + H266RawSPS *current)
> +{
> + int err;
> +
> + flag(sps_extended_precision_flag);
> + if (current->sps_transform_skip_enabled_flag) {
> + flag(sps_ts_residual_coding_rice_present_in_sh_flag);
> + } else {
> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
> + }
> + flag(sps_rrc_rice_extension_flag);
> + flag(sps_persistent_rice_adaptation_enabled_flag);
> + flag(sps_reverse_last_sig_coeff_enabled_flag);
> +
> + return 0;
> +}
>
> static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
> H266RawSPS *current)
> @@ -1518,9 +1553,33 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
> } else {
> CHECK(FUNC(vui_parameters_default) (ctx, rw, ¤t->vui));
> }
> +
> flag(sps_extension_flag);
> - if (current->sps_extension_flag)
> - CHECK(FUNC(extension_data) (ctx, rw, ¤t->extension_data));
> + if (current->sps_extension_flag) {
> + flag(sps_range_extension_flag);
> + ub(7, sps_extension_7bits);
> +
> + if (current->sps_range_extension_flag) {
> + CHECK(FUNC(sps_range_extension)(ctx, rw, current));
> + } else {
> + infer(sps_extended_precision_flag, 0);
> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
> + infer(sps_rrc_rice_extension_flag, 0);
> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
> + }
> + } else {
> + infer(sps_range_extension_flag, 0);
> + infer(sps_extension_7bits, 0);
> + infer(sps_extended_precision_flag, 0);
> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
> + infer(sps_rrc_rice_extension_flag, 0);
> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
> + }
> +
> + if (current->sps_extension_7bits)
> + CHECK(FUNC(extension_data)(ctx, rw, ¤t->extension_data));
>
> CHECK(FUNC(rbsp_trailing_bits) (ctx, rw));
>
> @@ -3005,6 +3064,18 @@ static int FUNC(slice_header) (CodedBitstreamContext *ctx, RWContext *rw,
> flag(sh_ts_residual_coding_disabled_flag);
> else
> infer(sh_ts_residual_coding_disabled_flag, 0);
> +
> + if (!current->sh_ts_residual_coding_disabled_flag &&
> + sps->sps_ts_residual_coding_rice_present_in_sh_flag)
> + ub(3, sh_ts_residual_coding_rice_idx_minus1);
> + else
> + infer(sh_ts_residual_coding_rice_idx_minus1, 0);
> +
> + if (sps->sps_reverse_last_sig_coeff_enabled_flag)
> + flag(sh_reverse_last_sig_coeff_flag);
> + else
> + infer(sh_reverse_last_sig_coeff_flag, 0);
Do you know what sample if any in the conformance suite covers this?
> +
> if (pps->pps_slice_header_extension_present_flag) {
> ue(sh_slice_header_extension_length, 0, 256);
> for (i = 0; i < current->sh_slice_header_extension_length; i++)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] cbs_h266: add range extension support
2023-07-05 11:45 ` James Almer
@ 2023-07-05 12:38 ` Frank Plowman
2023-07-05 12:50 ` Frank Plowman
0 siblings, 1 reply; 4+ messages in thread
From: Frank Plowman @ 2023-07-05 12:38 UTC (permalink / raw)
To: ffmpeg-devel
On 05/07/2023 12:45, James Almer wrote:
> On 7/5/2023 8:38 AM, Nuo Mi wrote:
>> From: frankplow <post@frankplowman.com>
>>
>> ---
>> libavcodec/cbs_h266.h | 18 ++++++
>> libavcodec/cbs_h266_syntax_template.c | 79 +++++++++++++++++++++++++--
>> 2 files changed, 93 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
>> index e33d08a0f5..40aba9eb13 100644
>> --- a/libavcodec/cbs_h266.h
>> +++ b/libavcodec/cbs_h266.h
>> @@ -120,6 +120,13 @@ typedef struct H266GeneralConstraintsInfo {
>> uint8_t gci_no_virtual_boundaries_constraint_flag;
>> uint8_t gci_num_reserved_bits;
>> uint8_t gci_reserved_zero_bit[255];
>> +
>> + uint8_t gci_all_rap_pictures_constraint_flag;
>> + uint8_t gci_no_extended_precision_processing_constraint_flag;
>> + uint8_t gci_no_ts_residual_coding_rice_constraint_flag;
>> + uint8_t gci_no_rrc_rice_extension_constraint_flag;
>> + uint8_t gci_no_persistent_rice_adaptation_constraint_flag;
>> + uint8_t gci_no_reverse_last_sig_coeff_constraint_flag;
>> } H266GeneralConstraintsInfo;
>> typedef struct H266RawProfileTierLevel {
>> @@ -451,6 +458,15 @@ typedef struct H266RawSPS {
>> uint8_t sps_extension_flag;
>> + uint8_t sps_range_extension_flag;
>> + uint8_t sps_extension_7bits;
>> +
>> + uint8_t sps_extended_precision_flag;
>> + uint8_t sps_ts_residual_coding_rice_present_in_sh_flag;
>> + uint8_t sps_rrc_rice_extension_flag;
>> + uint8_t sps_persistent_rice_adaptation_enabled_flag;
>> + uint8_t sps_reverse_last_sig_coeff_enabled_flag;
>> +
>> H266RawExtensionData extension_data;
>> } H266RawSPS;
>> @@ -734,6 +750,8 @@ typedef struct H266RawSliceHeader {
>> uint8_t sh_sign_data_hiding_used_flag;
>> uint8_t sh_ts_residual_coding_disabled_flag;
>> + uint8_t sh_ts_residual_coding_rice_idx_minus1;
>> + uint8_t sh_reverse_last_sig_coeff_flag;
>> uint16_t sh_slice_header_extension_length;
>> uint8_t sh_slice_header_extension_data_byte[256];
>> diff --git a/libavcodec/cbs_h266_syntax_template.c
>> b/libavcodec/cbs_h266_syntax_template.c
>> index 485c02f590..893fa55369 100644
>> --- a/libavcodec/cbs_h266_syntax_template.c
>> +++ b/libavcodec/cbs_h266_syntax_template.c
>> @@ -61,7 +61,7 @@ static int FUNC(general_constraints_info)
>> (CodedBitstreamContext *ctx,
>> RWContext *rw,
>> H266GeneralConstraintsInfo *current)
>> {
>> - int err, i;
>> + int err, i, num_additional_bits_used;
>> flag(gci_present_flag);
>> if (current->gci_present_flag) {
>> @@ -149,7 +149,25 @@ static int FUNC(general_constraints_info)
>> (CodedBitstreamContext *ctx,
>> flag(gci_no_ladf_constraint_flag);
>> flag(gci_no_virtual_boundaries_constraint_flag);
>> ub(8, gci_num_reserved_bits);
>
> This should be renamed to gci_num_additional_bits while at it.
>
>> - for (i = 0; i < current->gci_num_reserved_bits; i++) {
>> + if (current->gci_num_reserved_bits > 5) {
>> + flag(gci_all_rap_pictures_constraint_flag);
>> + flag(gci_no_extended_precision_processing_constraint_flag);
>> + flag(gci_no_ts_residual_coding_rice_constraint_flag);
>> + flag(gci_no_rrc_rice_extension_constraint_flag);
>> + flag(gci_no_persistent_rice_adaptation_constraint_flag);
>> + flag(gci_no_reverse_last_sig_coeff_constraint_flag);
>> + num_additional_bits_used = 6;
>> + } else {
>> + infer(gci_all_rap_pictures_constraint_flag, 0);
>> + infer(gci_no_extended_precision_processing_constraint_flag, 0);
>> + infer(gci_no_ts_residual_coding_rice_constraint_flag, 0);
>> + infer(gci_no_rrc_rice_extension_constraint_flag, 0);
>> + infer(gci_no_persistent_rice_adaptation_constraint_flag, 0);
>> + infer(gci_no_reverse_last_sig_coeff_constraint_flag, 0);
>> + num_additional_bits_used = 0;
>> + }
>> +
>> + for (i = 0; i < current->gci_num_reserved_bits -
>> num_additional_bits_used; i++) {
>> flags(gci_reserved_zero_bit[i], 1, i);
>> }
>> }
>> @@ -963,6 +981,23 @@ static int FUNC(vps) (CodedBitstreamContext
>> *ctx, RWContext *rw,
>> return 0;
>> }
>> +static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx,
>> RWContext *rw,
>> + H266RawSPS *current)
>> +{
>> + int err;
>> +
>> + flag(sps_extended_precision_flag);
>> + if (current->sps_transform_skip_enabled_flag) {
>> + flag(sps_ts_residual_coding_rice_present_in_sh_flag);
>> + } else {
>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>> + }
>> + flag(sps_rrc_rice_extension_flag);
>> + flag(sps_persistent_rice_adaptation_enabled_flag);
>> + flag(sps_reverse_last_sig_coeff_enabled_flag);
>> +
>> + return 0;
>> +}
>> static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
>> H266RawSPS *current)
>> @@ -1518,9 +1553,33 @@ static int FUNC(sps)(CodedBitstreamContext
>> *ctx, RWContext *rw,
>> } else {
>> CHECK(FUNC(vui_parameters_default) (ctx, rw, ¤t->vui));
>> }
>> +
>> flag(sps_extension_flag);
>> - if (current->sps_extension_flag)
>> - CHECK(FUNC(extension_data) (ctx, rw,
>> ¤t->extension_data));
>> + if (current->sps_extension_flag) {
>> + flag(sps_range_extension_flag);
>> + ub(7, sps_extension_7bits);
>> +
>> + if (current->sps_range_extension_flag) {
>> + CHECK(FUNC(sps_range_extension)(ctx, rw, current));
>> + } else {
>> + infer(sps_extended_precision_flag, 0);
>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>> + infer(sps_rrc_rice_extension_flag, 0);
>> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
>> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
>> + }
>> + } else {
>> + infer(sps_range_extension_flag, 0);
>> + infer(sps_extension_7bits, 0);
>> + infer(sps_extended_precision_flag, 0);
>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>> + infer(sps_rrc_rice_extension_flag, 0);
>> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
>> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
>> + }
>> +
>> + if (current->sps_extension_7bits)
>> + CHECK(FUNC(extension_data)(ctx, rw, ¤t->extension_data));
>> CHECK(FUNC(rbsp_trailing_bits) (ctx, rw));
>> @@ -3005,6 +3064,18 @@ static int FUNC(slice_header)
>> (CodedBitstreamContext *ctx, RWContext *rw,
>> flag(sh_ts_residual_coding_disabled_flag);
>> else
>> infer(sh_ts_residual_coding_disabled_flag, 0);
>> +
>> + if (!current->sh_ts_residual_coding_disabled_flag &&
>> + sps->sps_ts_residual_coding_rice_present_in_sh_flag)
>> + ub(3, sh_ts_residual_coding_rice_idx_minus1);
>> + else
>> + infer(sh_ts_residual_coding_rice_idx_minus1, 0);
>> +
>> + if (sps->sps_reverse_last_sig_coeff_enabled_flag)
>> + flag(sh_reverse_last_sig_coeff_flag);
>> + else
>> + infer(sh_reverse_last_sig_coeff_flag, 0);
>
> Do you know what sample if any in the conformance suite covers this?
A matrix showing which test bitstreams test which range extension
features is available here:
https://github.com/ffvvc/FFmpeg/issues/83#issuecomment-1575658232
>
>> +
>> if (pps->pps_slice_header_extension_present_flag) {
>> ue(sh_slice_header_extension_length, 0, 256);
>> for (i = 0; i < current->sh_slice_header_extension_length;
>> i++)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] cbs_h266: add range extension support
2023-07-05 12:38 ` Frank Plowman
@ 2023-07-05 12:50 ` Frank Plowman
0 siblings, 0 replies; 4+ messages in thread
From: Frank Plowman @ 2023-07-05 12:50 UTC (permalink / raw)
To: ffmpeg-devel
On 05/07/2023 13:38, Frank Plowman wrote:
> On 05/07/2023 12:45, James Almer wrote:
>> On 7/5/2023 8:38 AM, Nuo Mi wrote:
>>> From: frankplow <post@frankplowman.com>
>>>
>>> ---
>>> libavcodec/cbs_h266.h | 18 ++++++
>>> libavcodec/cbs_h266_syntax_template.c | 79
>>> +++++++++++++++++++++++++--
>>> 2 files changed, 93 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
>>> index e33d08a0f5..40aba9eb13 100644
>>> --- a/libavcodec/cbs_h266.h
>>> +++ b/libavcodec/cbs_h266.h
>>> @@ -120,6 +120,13 @@ typedef struct H266GeneralConstraintsInfo {
>>> uint8_t gci_no_virtual_boundaries_constraint_flag;
>>> uint8_t gci_num_reserved_bits;
>>> uint8_t gci_reserved_zero_bit[255];
>>> +
>>> + uint8_t gci_all_rap_pictures_constraint_flag;
>>> + uint8_t gci_no_extended_precision_processing_constraint_flag;
>>> + uint8_t gci_no_ts_residual_coding_rice_constraint_flag;
>>> + uint8_t gci_no_rrc_rice_extension_constraint_flag;
>>> + uint8_t gci_no_persistent_rice_adaptation_constraint_flag;
>>> + uint8_t gci_no_reverse_last_sig_coeff_constraint_flag;
>>> } H266GeneralConstraintsInfo;
>>> typedef struct H266RawProfileTierLevel {
>>> @@ -451,6 +458,15 @@ typedef struct H266RawSPS {
>>> uint8_t sps_extension_flag;
>>> + uint8_t sps_range_extension_flag;
>>> + uint8_t sps_extension_7bits;
>>> +
>>> + uint8_t sps_extended_precision_flag;
>>> + uint8_t sps_ts_residual_coding_rice_present_in_sh_flag;
>>> + uint8_t sps_rrc_rice_extension_flag;
>>> + uint8_t sps_persistent_rice_adaptation_enabled_flag;
>>> + uint8_t sps_reverse_last_sig_coeff_enabled_flag;
>>> +
>>> H266RawExtensionData extension_data;
>>> } H266RawSPS;
>>> @@ -734,6 +750,8 @@ typedef struct H266RawSliceHeader {
>>> uint8_t sh_sign_data_hiding_used_flag;
>>> uint8_t sh_ts_residual_coding_disabled_flag;
>>> + uint8_t sh_ts_residual_coding_rice_idx_minus1;
>>> + uint8_t sh_reverse_last_sig_coeff_flag;
>>> uint16_t sh_slice_header_extension_length;
>>> uint8_t sh_slice_header_extension_data_byte[256];
>>> diff --git a/libavcodec/cbs_h266_syntax_template.c
>>> b/libavcodec/cbs_h266_syntax_template.c
>>> index 485c02f590..893fa55369 100644
>>> --- a/libavcodec/cbs_h266_syntax_template.c
>>> +++ b/libavcodec/cbs_h266_syntax_template.c
>>> @@ -61,7 +61,7 @@ static int FUNC(general_constraints_info)
>>> (CodedBitstreamContext *ctx,
>>> RWContext *rw,
>>> H266GeneralConstraintsInfo *current)
>>> {
>>> - int err, i;
>>> + int err, i, num_additional_bits_used;
>>> flag(gci_present_flag);
>>> if (current->gci_present_flag) {
>>> @@ -149,7 +149,25 @@ static int FUNC(general_constraints_info)
>>> (CodedBitstreamContext *ctx,
>>> flag(gci_no_ladf_constraint_flag);
>>> flag(gci_no_virtual_boundaries_constraint_flag);
>>> ub(8, gci_num_reserved_bits);
>>
>> This should be renamed to gci_num_additional_bits while at it.
>>
>>> - for (i = 0; i < current->gci_num_reserved_bits; i++) {
>>> + if (current->gci_num_reserved_bits > 5) {
>>> + flag(gci_all_rap_pictures_constraint_flag);
>>> + flag(gci_no_extended_precision_processing_constraint_flag);
>>> + flag(gci_no_ts_residual_coding_rice_constraint_flag);
>>> + flag(gci_no_rrc_rice_extension_constraint_flag);
>>> + flag(gci_no_persistent_rice_adaptation_constraint_flag);
>>> + flag(gci_no_reverse_last_sig_coeff_constraint_flag);
>>> + num_additional_bits_used = 6;
>>> + } else {
>>> + infer(gci_all_rap_pictures_constraint_flag, 0);
>>> + infer(gci_no_extended_precision_processing_constraint_flag, 0);
>>> + infer(gci_no_ts_residual_coding_rice_constraint_flag, 0);
>>> + infer(gci_no_rrc_rice_extension_constraint_flag, 0);
>>> + infer(gci_no_persistent_rice_adaptation_constraint_flag, 0);
>>> + infer(gci_no_reverse_last_sig_coeff_constraint_flag, 0);
>>> + num_additional_bits_used = 0;
>>> + }
>>> +
>>> + for (i = 0; i < current->gci_num_reserved_bits -
>>> num_additional_bits_used; i++) {
>>> flags(gci_reserved_zero_bit[i], 1, i);
>>> }
>>> }
>>> @@ -963,6 +981,23 @@ static int FUNC(vps) (CodedBitstreamContext
>>> *ctx, RWContext *rw,
>>> return 0;
>>> }
>>> +static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx,
>>> RWContext *rw,
>>> + H266RawSPS *current)
>>> +{
>>> + int err;
>>> +
>>> + flag(sps_extended_precision_flag);
>>> + if (current->sps_transform_skip_enabled_flag) {
>>> + flag(sps_ts_residual_coding_rice_present_in_sh_flag);
>>> + } else {
>>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>>> + }
>>> + flag(sps_rrc_rice_extension_flag);
>>> + flag(sps_persistent_rice_adaptation_enabled_flag);
>>> + flag(sps_reverse_last_sig_coeff_enabled_flag);
>>> +
>>> + return 0;
>>> +}
>>> static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
>>> H266RawSPS *current)
>>> @@ -1518,9 +1553,33 @@ static int FUNC(sps)(CodedBitstreamContext
>>> *ctx, RWContext *rw,
>>> } else {
>>> CHECK(FUNC(vui_parameters_default) (ctx, rw, ¤t->vui));
>>> }
>>> +
>>> flag(sps_extension_flag);
>>> - if (current->sps_extension_flag)
>>> - CHECK(FUNC(extension_data) (ctx, rw,
>>> ¤t->extension_data));
>>> + if (current->sps_extension_flag) {
>>> + flag(sps_range_extension_flag);
>>> + ub(7, sps_extension_7bits);
>>> +
>>> + if (current->sps_range_extension_flag) {
>>> + CHECK(FUNC(sps_range_extension)(ctx, rw, current));
>>> + } else {
>>> + infer(sps_extended_precision_flag, 0);
>>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>>> + infer(sps_rrc_rice_extension_flag, 0);
>>> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
>>> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
>>> + }
>>> + } else {
>>> + infer(sps_range_extension_flag, 0);
>>> + infer(sps_extension_7bits, 0);
>>> + infer(sps_extended_precision_flag, 0);
>>> + infer(sps_ts_residual_coding_rice_present_in_sh_flag, 0);
>>> + infer(sps_rrc_rice_extension_flag, 0);
>>> + infer(sps_persistent_rice_adaptation_enabled_flag, 0);
>>> + infer(sps_reverse_last_sig_coeff_enabled_flag, 0);
>>> + }
>>> +
>>> + if (current->sps_extension_7bits)
>>> + CHECK(FUNC(extension_data)(ctx, rw,
>>> ¤t->extension_data));
>>> CHECK(FUNC(rbsp_trailing_bits) (ctx, rw));
>>> @@ -3005,6 +3064,18 @@ static int FUNC(slice_header)
>>> (CodedBitstreamContext *ctx, RWContext *rw,
>>> flag(sh_ts_residual_coding_disabled_flag);
>>> else
>>> infer(sh_ts_residual_coding_disabled_flag, 0);
>>> +
>>> + if (!current->sh_ts_residual_coding_disabled_flag &&
>>> + sps->sps_ts_residual_coding_rice_present_in_sh_flag)
>>> + ub(3, sh_ts_residual_coding_rice_idx_minus1);
>>> + else
>>> + infer(sh_ts_residual_coding_rice_idx_minus1, 0);
>>> +
>>> + if (sps->sps_reverse_last_sig_coeff_enabled_flag)
>>> + flag(sh_reverse_last_sig_coeff_flag);
>>> + else
>>> + infer(sh_reverse_last_sig_coeff_flag, 0);
>>
>> Do you know what sample if any in the conformance suite covers this?
>
> A matrix showing which test bitstreams test which range extension
> features is available here:
> https://github.com/ffvvc/FFmpeg/issues/83#issuecomment-1575658232
Apologies, I see now this is in the slice header rather than the SPS.
This particular logic is tested by the following bitstreams:
* 12b444vvc1_E_Sony_2
* 12b444Ietsrc_A_Kwai_2
* 10b444P16_D_Sony_2
* 12b444Iepp_A_Sharp_2
* 12b444SPetsrc_B_Kwai_2
* 10b444P16_A_Sony_2
* 12b444vvc1_D_Sony_2
* 10b444P16_C_Sony_2
* 12b444vvc1_A_Sony_2
* 10b444P12_C_Sony_2
* 12b444SPvvc1_A_Alibaba_2
* 12b420SPvvc1_A_KDDI_2
* 12b444SPetsrc_H_Kwai_2
* 10b444P12_A_Sony_2
* 12b444SPepp_A_Sharp_2
* 12b444SPetsrc_D_Kwai_2
* 12b444SPetsrc_F_Kwai_2
* 10b444P16_E_Sony_2
* 12b444Ivvc1_A_Alibaba_2
* 12b444vvc1_B_Sony_2
* 10b444P16_B_Sony_2
* 12b420Ivvc1_A_InterDigital_2
* 10b444P12_E_Sony_2
* 12b444vvc1_C_Sony_2
* 12b420vvc1_A_Alibaba_2
* 12b444SPetsrc_A_Kwai_2
* 12b444SPetsrc_C_Kwai_2
* 12b444SPetsrc_E_Kwai_2
* 12b444SPetsrc_G_Kwai_2
* HRD_A_Fujitsu_4
* 12b444etsrc_A_Kwai_2
* 10b444P12_B_Sony_2
* 12b444epp_A_Sharp_2
* 10b444P12_D_Sony_2
>
>>
>>> +
>>> if (pps->pps_slice_header_extension_present_flag) {
>>> ue(sh_slice_header_extension_length, 0, 256);
>>> for (i = 0; i < current->sh_slice_header_extension_length;
>>> i++)
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-05 12:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 11:38 [FFmpeg-devel] [PATCH] cbs_h266: add range extension support Nuo Mi
2023-07-05 11:45 ` James Almer
2023-07-05 12:38 ` Frank Plowman
2023-07-05 12:50 ` Frank Plowman
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git