forked from FFmpeg/FFmpeg
avcodec/cbs_sei: add support for Frame Packing Arrangement SEI parsing
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
0cb733d276
commit
826f55d5b3
5 changed files with 125 additions and 5 deletions
|
@ -293,6 +293,26 @@ typedef struct H264RawFilmGrainCharacteristics {
|
|||
uint8_t film_grain_characteristics_repetition_period;
|
||||
} H264RawFilmGrainCharacteristics;
|
||||
|
||||
typedef struct H264RawSEIFramePackingArrangement {
|
||||
uint32_t frame_packing_arrangement_id;
|
||||
uint8_t frame_packing_arrangement_cancel_flag;
|
||||
uint8_t frame_packing_arrangement_type;
|
||||
uint8_t quincunx_sampling_flag;
|
||||
uint8_t content_interpretation_type;
|
||||
uint8_t spatial_flipping_flag;
|
||||
uint8_t frame0_flipped_flag;
|
||||
uint8_t field_views_flag;
|
||||
uint8_t current_frame_is_frame0_flag;
|
||||
uint8_t frame0_self_contained_flag;
|
||||
uint8_t frame1_self_contained_flag;
|
||||
uint8_t frame0_grid_position_x;
|
||||
uint8_t frame0_grid_position_y;
|
||||
uint8_t frame1_grid_position_x;
|
||||
uint8_t frame1_grid_position_y;
|
||||
uint16_t frame_packing_arrangement_repetition_period;
|
||||
uint8_t frame_packing_arrangement_extension_flag;
|
||||
} H264RawSEIFramePackingArrangement;
|
||||
|
||||
typedef struct H264RawSEIDisplayOrientation {
|
||||
uint8_t display_orientation_cancel_flag;
|
||||
uint8_t hor_flip;
|
||||
|
|
|
@ -2128,6 +2128,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
|
|||
sizeof(SEIRawUserDataUnregistered),
|
||||
SEI_MESSAGE_RW(sei, user_data_unregistered),
|
||||
},
|
||||
{
|
||||
SEI_TYPE_FRAME_PACKING_ARRANGEMENT,
|
||||
1, 0,
|
||||
sizeof(SEIRawFramePackingArrangement),
|
||||
SEI_MESSAGE_RW(sei, frame_packing_arrangement),
|
||||
},
|
||||
{
|
||||
SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME,
|
||||
1, 0,
|
||||
|
@ -2186,6 +2192,12 @@ static const SEIMessageTypeDescriptor cbs_sei_h264_types[] = {
|
|||
sizeof(H264RawFilmGrainCharacteristics),
|
||||
SEI_MESSAGE_RW(h264, film_grain_characteristics),
|
||||
},
|
||||
{
|
||||
SEI_TYPE_FRAME_PACKING_ARRANGEMENT,
|
||||
1, 0,
|
||||
sizeof(H264RawSEIFramePackingArrangement),
|
||||
SEI_MESSAGE_RW(h264, sei_frame_packing_arrangement),
|
||||
},
|
||||
{
|
||||
SEI_TYPE_DISPLAY_ORIENTATION,
|
||||
1, 0,
|
||||
|
@ -2275,11 +2287,6 @@ const SEIMessageTypeDescriptor *ff_cbs_sei_find_type(CodedBitstreamContext *ctx,
|
|||
const SEIMessageTypeDescriptor *codec_list;
|
||||
int i;
|
||||
|
||||
for (i = 0; cbs_sei_common_types[i].type >= 0; i++) {
|
||||
if (cbs_sei_common_types[i].type == payload_type)
|
||||
return &cbs_sei_common_types[i];
|
||||
}
|
||||
|
||||
switch (ctx->codec->codec_id) {
|
||||
case AV_CODEC_ID_H264:
|
||||
codec_list = cbs_sei_h264_types;
|
||||
|
@ -2299,5 +2306,10 @@ const SEIMessageTypeDescriptor *ff_cbs_sei_find_type(CodedBitstreamContext *ctx,
|
|||
return &codec_list[i];
|
||||
}
|
||||
|
||||
for (i = 0; cbs_sei_common_types[i].type >= 0; i++) {
|
||||
if (cbs_sei_common_types[i].type == payload_type)
|
||||
return &cbs_sei_common_types[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -801,6 +801,40 @@ SEI_FUNC(film_grain_characteristics, (CodedBitstreamContext *ctx, RWContext *rw,
|
|||
return 0;
|
||||
}
|
||||
|
||||
SEI_FUNC(sei_frame_packing_arrangement, (CodedBitstreamContext *ctx, RWContext *rw,
|
||||
H264RawSEIFramePackingArrangement *current,
|
||||
SEIMessageState *sei))
|
||||
{
|
||||
int err;
|
||||
|
||||
HEADER("Frame Packing Arrangement");
|
||||
|
||||
ue(frame_packing_arrangement_id, 0, MAX_UINT_BITS(31));
|
||||
flag(frame_packing_arrangement_cancel_flag);
|
||||
if (!current->frame_packing_arrangement_cancel_flag) {
|
||||
u(7, frame_packing_arrangement_type, 0, 7);
|
||||
flag(quincunx_sampling_flag);
|
||||
u(6, content_interpretation_type, 0, 2);
|
||||
flag(spatial_flipping_flag);
|
||||
flag(frame0_flipped_flag);
|
||||
flag(field_views_flag);
|
||||
flag(current_frame_is_frame0_flag);
|
||||
flag(frame0_self_contained_flag);
|
||||
flag(frame1_self_contained_flag);
|
||||
if (!current->quincunx_sampling_flag && current->frame_packing_arrangement_type != 5) {
|
||||
ub(4, frame0_grid_position_x);
|
||||
ub(4, frame0_grid_position_y);
|
||||
ub(4, frame1_grid_position_x);
|
||||
ub(4, frame1_grid_position_y);
|
||||
}
|
||||
fixed(8, frame_packing_arrangement_reserved_byte, 0);
|
||||
ue(frame_packing_arrangement_repetition_period, 0, 16384);
|
||||
}
|
||||
flag(frame_packing_arrangement_extension_flag);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEI_FUNC(sei_display_orientation, (CodedBitstreamContext *ctx, RWContext *rw,
|
||||
H264RawSEIDisplayOrientation *current,
|
||||
SEIMessageState *sei))
|
||||
|
|
|
@ -43,6 +43,26 @@ typedef struct SEIRawUserDataUnregistered {
|
|||
size_t data_length;
|
||||
} SEIRawUserDataUnregistered;
|
||||
|
||||
typedef struct SEIRawFramePackingArrangement {
|
||||
uint32_t fp_arrangement_id;
|
||||
uint8_t fp_arrangement_cancel_flag;
|
||||
uint8_t fp_arrangement_type;
|
||||
uint8_t fp_quincunx_sampling_flag;
|
||||
uint8_t fp_content_interpretation_type;
|
||||
uint8_t fp_spatial_flipping_flag;
|
||||
uint8_t fp_frame0_flipped_flag;
|
||||
uint8_t fp_field_views_flag;
|
||||
uint8_t fp_current_frame_is_frame0_flag;
|
||||
uint8_t fp_frame0_self_contained_flag;
|
||||
uint8_t fp_frame1_self_contained_flag;
|
||||
uint8_t fp_frame0_grid_position_x;
|
||||
uint8_t fp_frame0_grid_position_y;
|
||||
uint8_t fp_frame1_grid_position_x;
|
||||
uint8_t fp_frame1_grid_position_y;
|
||||
uint8_t fp_arrangement_persistence_flag;
|
||||
uint8_t fp_upsampled_aspect_ratio_flag;
|
||||
} SEIRawFramePackingArrangement;
|
||||
|
||||
typedef struct SEIRawMasteringDisplayColourVolume {
|
||||
uint16_t display_primaries_x[3];
|
||||
uint16_t display_primaries_y[3];
|
||||
|
|
|
@ -94,6 +94,40 @@ SEI_FUNC(user_data_unregistered, (CodedBitstreamContext *ctx, RWContext *rw,
|
|||
return 0;
|
||||
}
|
||||
|
||||
SEI_FUNC(frame_packing_arrangement, (CodedBitstreamContext *ctx, RWContext *rw,
|
||||
SEIRawFramePackingArrangement *current,
|
||||
SEIMessageState *unused))
|
||||
{
|
||||
int err;
|
||||
|
||||
HEADER("Frame Packing Arrangement");
|
||||
|
||||
ue(fp_arrangement_id, 0, MAX_UINT_BITS(31));
|
||||
flag(fp_arrangement_cancel_flag);
|
||||
if (!current->fp_arrangement_cancel_flag) {
|
||||
u(7, fp_arrangement_type, 3, 5);
|
||||
flag(fp_quincunx_sampling_flag);
|
||||
u(6, fp_content_interpretation_type, 0, 2);
|
||||
flag(fp_spatial_flipping_flag);
|
||||
flag(fp_frame0_flipped_flag);
|
||||
flag(fp_field_views_flag);
|
||||
flag(fp_current_frame_is_frame0_flag);
|
||||
flag(fp_frame0_self_contained_flag);
|
||||
flag(fp_frame1_self_contained_flag);
|
||||
if (!current->fp_quincunx_sampling_flag && current->fp_arrangement_type != 5) {
|
||||
ub(4, fp_frame0_grid_position_x);
|
||||
ub(4, fp_frame0_grid_position_y);
|
||||
ub(4, fp_frame1_grid_position_x);
|
||||
ub(4, fp_frame1_grid_position_y);
|
||||
}
|
||||
fixed(8, fp_arrangement_reserved_byte, 0);
|
||||
flag(fp_arrangement_persistence_flag);
|
||||
}
|
||||
flag(fp_upsampled_aspect_ratio_flag);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEI_FUNC(mastering_display_colour_volume,
|
||||
(CodedBitstreamContext *ctx, RWContext *rw,
|
||||
SEIRawMasteringDisplayColourVolume *current,
|
||||
|
|
Loading…
Add table
Reference in a new issue