1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

h264: Use common SEI types

This commit is contained in:
Mark Thompson 2021-01-21 14:37:49 +00:00
parent 9ef32649d0
commit 64b3aac8d0
7 changed files with 40 additions and 56 deletions

View File

@ -1384,18 +1384,18 @@ static void cbs_h265_close(CodedBitstreamContext *ctx)
static void cbs_h264_free_sei_payload(H264RawSEIPayload *payload)
{
switch (payload->payload_type) {
case H264_SEI_TYPE_BUFFERING_PERIOD:
case H264_SEI_TYPE_PIC_TIMING:
case H264_SEI_TYPE_PAN_SCAN_RECT:
case H264_SEI_TYPE_RECOVERY_POINT:
case H264_SEI_TYPE_DISPLAY_ORIENTATION:
case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
case SEI_TYPE_BUFFERING_PERIOD:
case SEI_TYPE_PIC_TIMING:
case SEI_TYPE_PAN_SCAN_RECT:
case SEI_TYPE_RECOVERY_POINT:
case SEI_TYPE_DISPLAY_ORIENTATION:
case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
break;
case H264_SEI_TYPE_USER_DATA_REGISTERED:
case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
av_buffer_unref(&payload->payload.user_data_registered.data_ref);
break;
case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
case SEI_TYPE_USER_DATA_UNREGISTERED:
av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
break;
default:

View File

@ -747,45 +747,45 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw,
#endif
switch (current->payload_type) {
case H264_SEI_TYPE_BUFFERING_PERIOD:
case SEI_TYPE_BUFFERING_PERIOD:
CHECK(FUNC(sei_buffering_period)
(ctx, rw, &current->payload.buffering_period));
break;
case H264_SEI_TYPE_PIC_TIMING:
case SEI_TYPE_PIC_TIMING:
CHECK(FUNC(sei_pic_timing)
(ctx, rw, &current->payload.pic_timing));
break;
case H264_SEI_TYPE_PAN_SCAN_RECT:
case SEI_TYPE_PAN_SCAN_RECT:
CHECK(FUNC(sei_pan_scan_rect)
(ctx, rw, &current->payload.pan_scan_rect));
break;
case H264_SEI_TYPE_FILLER_PAYLOAD:
case SEI_TYPE_FILLER_PAYLOAD:
{
for (i = 0; i < current->payload_size; i++)
fixed(8, ff_byte, 0xff);
}
break;
case H264_SEI_TYPE_USER_DATA_REGISTERED:
case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
CHECK(FUNC_SEI(sei_user_data_registered)
(ctx, rw, &current->payload.user_data_registered, &current->payload_size));
break;
case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
case SEI_TYPE_USER_DATA_UNREGISTERED:
CHECK(FUNC_SEI(sei_user_data_unregistered)
(ctx, rw, &current->payload.user_data_unregistered, &current->payload_size));
break;
case H264_SEI_TYPE_RECOVERY_POINT:
case SEI_TYPE_RECOVERY_POINT:
CHECK(FUNC(sei_recovery_point)
(ctx, rw, &current->payload.recovery_point));
break;
case H264_SEI_TYPE_DISPLAY_ORIENTATION:
case SEI_TYPE_DISPLAY_ORIENTATION:
CHECK(FUNC(sei_display_orientation)
(ctx, rw, &current->payload.display_orientation));
break;
case H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
CHECK(FUNC_SEI(sei_mastering_display_colour_volume)
(ctx, rw, &current->payload.mastering_display_colour_volume));
break;
case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
CHECK(FUNC_SEI(sei_alternative_transfer_characteristics)
(ctx, rw, &current->payload.alternative_transfer_characteristics));
break;

View File

@ -435,7 +435,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
for (j = sei->payload_count - 1; j >= 0; j--) {
if (sei->payload[j].payload_type ==
H264_SEI_TYPE_FILLER_PAYLOAD)
SEI_TYPE_FILLER_PAYLOAD)
ff_cbs_h264_delete_sei_message(au, &au->units[i], j);
}
}
@ -454,7 +454,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
int32_t *matrix;
if (sei->payload[j].payload_type !=
H264_SEI_TYPE_DISPLAY_ORIENTATION)
SEI_TYPE_DISPLAY_ORIENTATION)
continue;
disp = &sei->payload[j].payload.display_orientation;
@ -492,7 +492,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
}
if (ctx->display_orientation == INSERT) {
H264RawSEIPayload payload = {
.payload_type = H264_SEI_TYPE_DISPLAY_ORIENTATION,
.payload_type = SEI_TYPE_DISPLAY_ORIENTATION,
};
H264RawSEIDisplayOrientation *disp =
&payload.payload.display_orientation;
@ -590,7 +590,7 @@ static int h264_metadata_init(AVBSFContext *bsf)
int j;
ctx->sei_user_data_payload.payload_type =
H264_SEI_TYPE_USER_DATA_UNREGISTERED;
SEI_TYPE_USER_DATA_UNREGISTERED;
// Parse UUID. It must be a hex string of length 32, possibly
// containing '-'s between hex digits (which we ignore).

View File

@ -444,31 +444,31 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
return ret;
switch (type) {
case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
ret = decode_picture_timing(&h->picture_timing, &gb_payload, logctx);
break;
case H264_SEI_TYPE_USER_DATA_REGISTERED:
case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
ret = decode_registered_user_data(h, &gb_payload, logctx, size);
break;
case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
case SEI_TYPE_USER_DATA_UNREGISTERED:
ret = decode_unregistered_user_data(&h->unregistered, &gb_payload, logctx, size);
break;
case H264_SEI_TYPE_RECOVERY_POINT:
case SEI_TYPE_RECOVERY_POINT:
ret = decode_recovery_point(&h->recovery_point, &gb_payload, logctx);
break;
case H264_SEI_TYPE_BUFFERING_PERIOD:
case SEI_TYPE_BUFFERING_PERIOD:
ret = decode_buffering_period(&h->buffering_period, &gb_payload, ps, logctx);
break;
case H264_SEI_TYPE_FRAME_PACKING:
case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
ret = decode_frame_packing_arrangement(&h->frame_packing, &gb_payload);
break;
case H264_SEI_TYPE_DISPLAY_ORIENTATION:
case SEI_TYPE_DISPLAY_ORIENTATION:
ret = decode_display_orientation(&h->display_orientation, &gb_payload);
break;
case H264_SEI_TYPE_GREEN_METADATA:
case SEI_TYPE_GREEN_METADATA:
ret = decode_green_metadata(&h->green_metadata, &gb_payload);
break;
case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
ret = decode_alternative_transfer(&h->alternative_transfer, &gb_payload);
break;
default:

View File

@ -21,24 +21,8 @@
#include "get_bits.h"
#include "h264_ps.h"
#include "sei.h"
/**
* SEI message types
*/
typedef enum {
H264_SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
H264_SEI_TYPE_PIC_TIMING = 1, ///< picture timing
H264_SEI_TYPE_PAN_SCAN_RECT = 2, ///< pan-scan rectangle
H264_SEI_TYPE_FILLER_PAYLOAD = 3, ///< filler data
H264_SEI_TYPE_USER_DATA_REGISTERED = 4, ///< registered user data as specified by Rec. ITU-T T.35
H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
H264_SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync)
H264_SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement
H264_SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation
H264_SEI_TYPE_GREEN_METADATA = 56, ///< GreenMPEG information
H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME = 137, ///< mastering display properties
H264_SEI_TYPE_ALTERNATIVE_TRANSFER = 147, ///< alternative transfer
} H264_SEI_Type;
/**
* pic_struct in picture timing SEI message

View File

@ -231,22 +231,22 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
i = 0;
if (priv->sei_needed & SEI_IDENTIFIER) {
sei->payload[i].payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED;
sei->payload[i].payload_type = SEI_TYPE_USER_DATA_UNREGISTERED;
sei->payload[i].payload.user_data_unregistered = priv->sei_identifier;
++i;
}
if (priv->sei_needed & SEI_TIMING) {
if (pic->type == PICTURE_TYPE_IDR) {
sei->payload[i].payload_type = H264_SEI_TYPE_BUFFERING_PERIOD;
sei->payload[i].payload_type = SEI_TYPE_BUFFERING_PERIOD;
sei->payload[i].payload.buffering_period = priv->sei_buffering_period;
++i;
}
sei->payload[i].payload_type = H264_SEI_TYPE_PIC_TIMING;
sei->payload[i].payload_type = SEI_TYPE_PIC_TIMING;
sei->payload[i].payload.pic_timing = priv->sei_pic_timing;
++i;
}
if (priv->sei_needed & SEI_RECOVERY_POINT) {
sei->payload[i].payload_type = H264_SEI_TYPE_RECOVERY_POINT;
sei->payload[i].payload_type = SEI_TYPE_RECOVERY_POINT;
sei->payload[i].payload.recovery_point = priv->sei_recovery_point;
++i;
}

View File

@ -1751,7 +1751,7 @@ static int copy_replace_length_codes(
remaining_dst_size--;
wrote_bytes = write_sei(sei,
H264_SEI_TYPE_USER_DATA_REGISTERED,
SEI_TYPE_USER_DATA_REGISTERED,
dst_data,
remaining_dst_size);
@ -1807,7 +1807,7 @@ static int copy_replace_length_codes(
return status;
wrote_bytes = write_sei(sei,
H264_SEI_TYPE_USER_DATA_REGISTERED,
SEI_TYPE_USER_DATA_REGISTERED,
new_sei,
remaining_dst_size - old_sei_length);
if (wrote_bytes < 0)
@ -1903,7 +1903,7 @@ static int vtenc_cm_to_avpacket(
if (sei) {
size_t msg_size = get_sei_msg_bytes(sei,
H264_SEI_TYPE_USER_DATA_REGISTERED);
SEI_TYPE_USER_DATA_REGISTERED);
sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1;
}