You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
This commit is contained in:
@ -2311,6 +2311,12 @@ static const SEIMessageTypeDescriptor cbs_sei_h266_types[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const SEIMessageTypeDescriptor cbs_sei_h274_types[] = {
|
static const SEIMessageTypeDescriptor cbs_sei_h274_types[] = {
|
||||||
|
{
|
||||||
|
SEI_TYPE_FILM_GRAIN_CHARACTERISTICS,
|
||||||
|
1, 0,
|
||||||
|
sizeof(SEIRawFilmGrainCharacteristics),
|
||||||
|
SEI_MESSAGE_RW(sei, film_grain_characteristics),
|
||||||
|
},
|
||||||
SEI_MESSAGE_TYPE_END,
|
SEI_MESSAGE_TYPE_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,6 +97,27 @@ typedef struct SEIRawAmbientViewingEnvironment {
|
|||||||
uint16_t ambient_light_y;
|
uint16_t ambient_light_y;
|
||||||
} SEIRawAmbientViewingEnvironment;
|
} SEIRawAmbientViewingEnvironment;
|
||||||
|
|
||||||
|
typedef struct SEIRawFilmGrainCharacteristics {
|
||||||
|
uint8_t fg_characteristics_cancel_flag;
|
||||||
|
uint8_t fg_model_id;
|
||||||
|
uint8_t fg_separate_colour_description_present_flag;
|
||||||
|
uint8_t fg_bit_depth_luma_minus8;
|
||||||
|
uint8_t fg_bit_depth_chroma_minus8;
|
||||||
|
uint8_t fg_full_range_flag;
|
||||||
|
uint8_t fg_colour_primaries;
|
||||||
|
uint8_t fg_transfer_characteristics;
|
||||||
|
uint8_t fg_matrix_coeffs;
|
||||||
|
uint8_t fg_blending_mode_id;
|
||||||
|
uint8_t fg_log2_scale_factor;
|
||||||
|
uint8_t fg_comp_model_present_flag[3];
|
||||||
|
uint8_t fg_num_intensity_intervals_minus1[3];
|
||||||
|
uint8_t fg_num_model_values_minus1[3];
|
||||||
|
uint8_t fg_intensity_interval_lower_bound[3][256];
|
||||||
|
uint8_t fg_intensity_interval_upper_bound[3][256];
|
||||||
|
int16_t fg_comp_model_value[3][256][6];
|
||||||
|
uint8_t fg_characteristics_persistence_flag;
|
||||||
|
} SEIRawFilmGrainCharacteristics;
|
||||||
|
|
||||||
typedef struct SEIRawMessage {
|
typedef struct SEIRawMessage {
|
||||||
uint32_t payload_type;
|
uint32_t payload_type;
|
||||||
uint32_t payload_size;
|
uint32_t payload_size;
|
||||||
|
@ -224,6 +224,59 @@ SEI_FUNC(ambient_viewing_environment,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SEI_FUNC(film_grain_characteristics,
|
||||||
|
(CodedBitstreamContext *ctx, RWContext *rw,
|
||||||
|
SEIRawFilmGrainCharacteristics *current,
|
||||||
|
SEIMessageState *state))
|
||||||
|
{
|
||||||
|
int err, c, i, j;
|
||||||
|
|
||||||
|
HEADER("Film Grain Characteristics");
|
||||||
|
|
||||||
|
flag(fg_characteristics_cancel_flag);
|
||||||
|
if (!current->fg_characteristics_cancel_flag) {
|
||||||
|
int filmGrainBitDepth[3];
|
||||||
|
|
||||||
|
u(2, fg_model_id, 0, 1);
|
||||||
|
flag(fg_separate_colour_description_present_flag);
|
||||||
|
if (current->fg_separate_colour_description_present_flag) {
|
||||||
|
ub(3, fg_bit_depth_luma_minus8);
|
||||||
|
ub(3, fg_bit_depth_chroma_minus8);
|
||||||
|
flag(fg_full_range_flag);
|
||||||
|
ub(8, fg_colour_primaries);
|
||||||
|
ub(8, fg_transfer_characteristics);
|
||||||
|
ub(8, fg_matrix_coeffs);
|
||||||
|
}
|
||||||
|
|
||||||
|
filmGrainBitDepth[0] = current->fg_bit_depth_luma_minus8 + 8;
|
||||||
|
filmGrainBitDepth[1] =
|
||||||
|
filmGrainBitDepth[2] = current->fg_bit_depth_chroma_minus8 + 8;
|
||||||
|
|
||||||
|
u(2, fg_blending_mode_id, 0, 1);
|
||||||
|
ub(4, fg_log2_scale_factor);
|
||||||
|
for (c = 0; c < 3; c++)
|
||||||
|
flags(fg_comp_model_present_flag[c], 1, c);
|
||||||
|
|
||||||
|
for (c = 0; c < 3; c++) {
|
||||||
|
if (current->fg_comp_model_present_flag[c]) {
|
||||||
|
ubs(8, fg_num_intensity_intervals_minus1[c], 1, c);
|
||||||
|
us(3, fg_num_model_values_minus1[c], 0, 5, 1, c);
|
||||||
|
for (i = 0; i <= current->fg_num_intensity_intervals_minus1[c]; i++) {
|
||||||
|
ubs(8, fg_intensity_interval_lower_bound[c][i], 2, c, i);
|
||||||
|
ubs(8, fg_intensity_interval_upper_bound[c][i], 2, c, i);
|
||||||
|
for (j = 0; j <= current->fg_num_model_values_minus1[c]; j++)
|
||||||
|
ses(fg_comp_model_value[c][i][j], 0 - current->fg_model_id * (1 << (filmGrainBitDepth[c] - 1)),
|
||||||
|
((1 << filmGrainBitDepth[c]) - 1) - current->fg_model_id * (1 << (filmGrainBitDepth[c] - 1)),
|
||||||
|
3, c, i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flag(fg_characteristics_persistence_flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
|
static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
|
||||||
SEIRawMessage *current)
|
SEIRawMessage *current)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user