Make a new template file for common SEI messages - this will also apply to H.266.pull/371/head
parent
df4e2b923c
commit
4bf3384800
10 changed files with 250 additions and 304 deletions
@ -0,0 +1,60 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_CBS_SEI_H |
||||
#define AVCODEC_CBS_SEI_H |
||||
|
||||
#include <stddef.h> |
||||
#include <stdint.h> |
||||
#include "libavutil/buffer.h" |
||||
|
||||
|
||||
typedef struct SEIRawUserDataRegistered { |
||||
uint8_t itu_t_t35_country_code; |
||||
uint8_t itu_t_t35_country_code_extension_byte; |
||||
uint8_t *data; |
||||
AVBufferRef *data_ref; |
||||
size_t data_length; |
||||
} SEIRawUserDataRegistered; |
||||
|
||||
typedef struct SEIRawUserDataUnregistered { |
||||
uint8_t uuid_iso_iec_11578[16]; |
||||
uint8_t *data; |
||||
AVBufferRef *data_ref; |
||||
size_t data_length; |
||||
} SEIRawUserDataUnregistered; |
||||
|
||||
typedef struct SEIRawMasteringDisplayColourVolume { |
||||
uint16_t display_primaries_x[3]; |
||||
uint16_t display_primaries_y[3]; |
||||
uint16_t white_point_x; |
||||
uint16_t white_point_y; |
||||
uint32_t max_display_mastering_luminance; |
||||
uint32_t min_display_mastering_luminance; |
||||
} SEIRawMasteringDisplayColourVolume; |
||||
|
||||
typedef struct SEIRawContentLightLevelInfo { |
||||
uint16_t max_content_light_level; |
||||
uint16_t max_pic_average_light_level; |
||||
} SEIRawContentLightLevelInfo; |
||||
|
||||
typedef struct SEIRawAlternativeTransferCharacteristics { |
||||
uint8_t preferred_transfer_characteristics; |
||||
} SEIRawAlternativeTransferCharacteristics; |
||||
|
||||
#endif /* AVCODEC_CBS_SEI_H */ |
@ -0,0 +1,132 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
static int FUNC(sei_user_data_registered) |
||||
(CodedBitstreamContext *ctx, RWContext *rw, |
||||
SEIRawUserDataRegistered *current, uint32_t *payload_size) |
||||
{ |
||||
int err, i, j; |
||||
|
||||
HEADER("User Data Registered ITU-T T.35"); |
||||
|
||||
u(8, itu_t_t35_country_code, 0x00, 0xff); |
||||
if (current->itu_t_t35_country_code != 0xff) |
||||
i = 1; |
||||
else { |
||||
u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff); |
||||
i = 2; |
||||
} |
||||
|
||||
#ifdef READ |
||||
if (*payload_size < i) { |
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, |
||||
"Invalid SEI user data registered payload.\n"); |
||||
return AVERROR_INVALIDDATA; |
||||
} |
||||
current->data_length = *payload_size - i; |
||||
#else |
||||
*payload_size = i + current->data_length; |
||||
#endif |
||||
|
||||
allocate(current->data, current->data_length); |
||||
for (j = 0; j < current->data_length; j++) |
||||
xu(8, itu_t_t35_payload_byte[], current->data[j], 0x00, 0xff, 1, i + j); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int FUNC(sei_user_data_unregistered) |
||||
(CodedBitstreamContext *ctx, RWContext *rw, |
||||
SEIRawUserDataUnregistered *current, uint32_t *payload_size) |
||||
{ |
||||
int err, i; |
||||
|
||||
HEADER("User Data Unregistered"); |
||||
|
||||
#ifdef READ |
||||
if (*payload_size < 16) { |
||||
av_log(ctx->log_ctx, AV_LOG_ERROR, |
||||
"Invalid SEI user data unregistered payload.\n"); |
||||
return AVERROR_INVALIDDATA; |
||||
} |
||||
current->data_length = *payload_size - 16; |
||||
#else |
||||
*payload_size = 16 + current->data_length; |
||||
#endif |
||||
|
||||
for (i = 0; i < 16; i++) |
||||
us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i); |
||||
|
||||
allocate(current->data, current->data_length); |
||||
|
||||
for (i = 0; i < current->data_length; i++) |
||||
xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int FUNC(sei_mastering_display_colour_volume) |
||||
(CodedBitstreamContext *ctx, RWContext *rw, |
||||
SEIRawMasteringDisplayColourVolume *current) |
||||
{ |
||||
int err, c; |
||||
|
||||
HEADER("Mastering Display Colour Volume"); |
||||
|
||||
for (c = 0; c < 3; c++) { |
||||
us(16, display_primaries_x[c], 0, 50000, 1, c); |
||||
us(16, display_primaries_y[c], 0, 50000, 1, c); |
||||
} |
||||
|
||||
u(16, white_point_x, 0, 50000); |
||||
u(16, white_point_y, 0, 50000); |
||||
|
||||
u(32, max_display_mastering_luminance, |
||||
1, MAX_UINT_BITS(32)); |
||||
u(32, min_display_mastering_luminance, |
||||
0, current->max_display_mastering_luminance - 1); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int FUNC(sei_content_light_level) |
||||
(CodedBitstreamContext *ctx, RWContext *rw, |
||||
SEIRawContentLightLevelInfo *current) |
||||
{ |
||||
int err; |
||||
|
||||
HEADER("Content Light Level"); |
||||
|
||||
ub(16, max_content_light_level); |
||||
ub(16, max_pic_average_light_level); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int FUNC(sei_alternative_transfer_characteristics) |
||||
(CodedBitstreamContext *ctx, RWContext *rw, |
||||
SEIRawAlternativeTransferCharacteristics *current) |
||||
{ |
||||
int err; |
||||
|
||||
HEADER("Alternative Transfer Characteristics"); |
||||
|
||||
ub(8, preferred_transfer_characteristics); |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue