* [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type
@ 2022-07-02 22:20 Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads Andreas Rheinhardt
` (19 more replies)
0 siblings, 20 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:20 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/hevc_sei.c | 2 +-
libavcodec/hevc_sei.h | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 953633f4bd..631373e06f 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -550,7 +550,7 @@ static int decode_nal_sei_message(GetByteContext *gb, void *logctx, HEVCSEI *s,
}
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
- const HEVCParamSets *ps, int type)
+ const HEVCParamSets *ps, enum HEVCNALUnitType type)
{
GetByteContext gbyte;
int ret;
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index f198402333..ef987f6781 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -26,6 +26,7 @@
#include "libavutil/buffer.h"
#include "get_bits.h"
+#include "hevc.h"
#include "sei.h"
@@ -154,7 +155,7 @@ typedef struct HEVCSEI {
struct HEVCParamSets;
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
- const struct HEVCParamSets *ps, int type);
+ const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
/**
* Reset SEI values that are stored on the Context.
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 03/20] configure: Add (h264|hevc)_sei subsystems Andreas Rheinhardt
` (18 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
SEI NALUs and several SEI messages are naturally byte-aligned,
so reading them via the bytestream-API is more natural.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_sei.c | 145 ++++++++++++++++++++----------------------
libavcodec/h264_sei.h | 2 +-
2 files changed, 70 insertions(+), 77 deletions(-)
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 034ddb8f1c..d62a276779 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -33,6 +33,7 @@
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "atsc_a53.h"
+#include "bytestream.h"
#include "get_bits.h"
#include "golomb.h"
#include "h264_ps.h"
@@ -70,8 +71,10 @@ int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
void *logctx)
{
GetBitContext gb;
+ av_unused int ret;
- init_get_bits(&gb, h->payload, h->payload_size_bits);
+ ret = init_get_bits8(&gb, h->payload, h->payload_size_bytes);
+ av_assert1(ret >= 0);
if (sps->nal_hrd_parameters_present_flag ||
sps->vcl_hrd_parameters_present_flag) {
@@ -133,44 +136,36 @@ int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
return 0;
}
-static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
+static int decode_picture_timing(H264SEIPictureTiming *h, GetByteContext *gb,
void *logctx)
{
- int index = get_bits_count(gb);
- int size_bits = get_bits_left(gb);
- int size = (size_bits + 7) / 8;
+ int size = bytestream2_get_bytes_left(gb);
- if (index & 7) {
- av_log(logctx, AV_LOG_ERROR, "Unaligned SEI payload\n");
- return AVERROR_INVALIDDATA;
- }
if (size > sizeof(h->payload)) {
av_log(logctx, AV_LOG_ERROR, "Picture timing SEI payload too large\n");
return AVERROR_INVALIDDATA;
}
- memcpy(h->payload, gb->buffer + index / 8, size);
+ bytestream2_get_bufferu(gb, h->payload, size);
- h->payload_size_bits = size_bits;
+ h->payload_size_bytes = size;
h->present = 1;
return 0;
}
-static int decode_registered_user_data_afd(H264SEIAFD *h, GetBitContext *gb, int size)
+static int decode_registered_user_data_afd(H264SEIAFD *h, GetByteContext *gb)
{
int flag;
- if (size-- < 1)
+ if (bytestream2_get_bytes_left(gb) <= 0)
return AVERROR_INVALIDDATA;
- skip_bits(gb, 1); // 0
- flag = get_bits(gb, 1); // active_format_flag
- skip_bits(gb, 6); // reserved
+
+ flag = !!(bytestream2_get_byteu(gb) & 0x40); // active_format_flag
if (flag) {
- if (size-- < 1)
+ if (bytestream2_get_bytes_left(gb) <= 0)
return AVERROR_INVALIDDATA;
- skip_bits(gb, 4); // reserved
- h->active_format_description = get_bits(gb, 4);
+ h->active_format_description = bytestream2_get_byteu(gb) & 0xF;
h->present = 1;
}
@@ -178,31 +173,26 @@ static int decode_registered_user_data_afd(H264SEIAFD *h, GetBitContext *gb, int
}
static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h,
- GetBitContext *gb, void *logctx,
- int size)
+ GetByteContext *gb)
{
- if (size < 3)
- return AVERROR(EINVAL);
-
- return ff_parse_a53_cc(&h->buf_ref, gb->buffer + get_bits_count(gb) / 8, size);
+ return ff_parse_a53_cc(&h->buf_ref, gb->buffer,
+ bytestream2_get_bytes_left(gb));
}
-static int decode_registered_user_data(H264SEIContext *h, GetBitContext *gb,
- void *logctx, int size)
+static int decode_registered_user_data(H264SEIContext *h, GetByteContext *gb,
+ void *logctx)
{
int country_code, provider_code;
- if (size < 3)
+ if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
- size -= 3;
- country_code = get_bits(gb, 8); // itu_t_t35_country_code
+ country_code = bytestream2_get_byteu(gb); // itu_t_t35_country_code
if (country_code == 0xFF) {
- if (size < 1)
+ if (bytestream2_get_bytes_left(gb) < 3)
return AVERROR_INVALIDDATA;
- skip_bits(gb, 8); // itu_t_t35_country_code_extension_byte
- size--;
+ bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte
}
if (country_code != 0xB5) { // usa_country_code
@@ -213,23 +203,21 @@ static int decode_registered_user_data(H264SEIContext *h, GetBitContext *gb,
}
/* itu_t_t35_payload_byte follows */
- provider_code = get_bits(gb, 16);
+ provider_code = bytestream2_get_be16u(gb);
switch (provider_code) {
case 0x31: { // atsc_provider_code
uint32_t user_identifier;
- if (size < 4)
+ if (bytestream2_get_bytes_left(gb) < 4)
return AVERROR_INVALIDDATA;
- size -= 4;
- user_identifier = get_bits_long(gb, 32);
+ user_identifier = bytestream2_get_be32u(gb);
switch (user_identifier) {
case MKBETAG('D', 'T', 'G', '1'): // afd_data
- return decode_registered_user_data_afd(&h->afd, gb, size);
+ return decode_registered_user_data_afd(&h->afd, gb);
case MKBETAG('G', 'A', '9', '4'): // closed captions
- return decode_registered_user_data_closed_caption(&h->a53_caption, gb,
- logctx, size);
+ return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
default:
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
@@ -248,11 +236,11 @@ static int decode_registered_user_data(H264SEIContext *h, GetBitContext *gb,
return 0;
}
-static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext *gb,
- void *logctx, int size)
+static int decode_unregistered_user_data(H264SEIUnregistered *h, GetByteContext *gb,
+ void *logctx)
{
uint8_t *user_data;
- int e, build, i;
+ int e, build, size = bytestream2_get_bytes_left(gb);
AVBufferRef *buf_ref, **tmp;
if (size < 16 || size >= INT_MAX - 1)
@@ -268,10 +256,8 @@ static int decode_unregistered_user_data(H264SEIUnregistered *h, GetBitContext *
return AVERROR(ENOMEM);
user_data = buf_ref->data;
- for (i = 0; i < size; i++)
- user_data[i] = get_bits(gb, 8);
-
- user_data[i] = 0;
+ bytestream2_get_bufferu(gb, user_data, size);
+ user_data[size] = 0;
buf_ref->size = size;
h->buf_ref[h->nb_buf_ref++] = buf_ref;
@@ -384,36 +370,36 @@ static int decode_display_orientation(H264SEIDisplayOrientation *h,
return 0;
}
-static int decode_green_metadata(H264SEIGreenMetaData *h, GetBitContext *gb)
+static int decode_green_metadata(H264SEIGreenMetaData *h, GetByteContext *gb)
{
- h->green_metadata_type = get_bits(gb, 8);
+ h->green_metadata_type = bytestream2_get_byte(gb);
if (h->green_metadata_type == 0) {
- h->period_type = get_bits(gb, 8);
+ h->period_type = bytestream2_get_byte(gb);
if (h->period_type == 2)
- h->num_seconds = get_bits(gb, 16);
+ h->num_seconds = bytestream2_get_be16(gb);
else if (h->period_type == 3)
- h->num_pictures = get_bits(gb, 16);
+ h->num_pictures = bytestream2_get_be16(gb);
- h->percent_non_zero_macroblocks = get_bits(gb, 8);
- h->percent_intra_coded_macroblocks = get_bits(gb, 8);
- h->percent_six_tap_filtering = get_bits(gb, 8);
- h->percent_alpha_point_deblocking_instance = get_bits(gb, 8);
+ h->percent_non_zero_macroblocks = bytestream2_get_byte(gb);
+ h->percent_intra_coded_macroblocks = bytestream2_get_byte(gb);
+ h->percent_six_tap_filtering = bytestream2_get_byte(gb);
+ h->percent_alpha_point_deblocking_instance = bytestream2_get_byte(gb);
} else if (h->green_metadata_type == 1) {
- h->xsd_metric_type = get_bits(gb, 8);
- h->xsd_metric_value = get_bits(gb, 16);
+ h->xsd_metric_type = bytestream2_get_byte(gb);
+ h->xsd_metric_value = bytestream2_get_be16(gb);
}
return 0;
}
static int decode_alternative_transfer(H264SEIAlternativeTransfer *h,
- GetBitContext *gb)
+ GetByteContext *gb)
{
h->present = 1;
- h->preferred_transfer_characteristics = get_bits(gb, 8);
+ h->preferred_transfer_characteristics = bytestream2_get_byte(gb);
return 0;
}
@@ -463,45 +449,52 @@ static int decode_film_grain_characteristics(H264SEIFilmGrainCharacteristics *h,
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
const H264ParamSets *ps, void *logctx)
{
+ GetByteContext gbyte;
int master_ret = 0;
- while (get_bits_left(gb) > 16 && show_bits(gb, 16)) {
+ av_assert1((get_bits_count(gb) % 8) == 0);
+ bytestream2_init(&gbyte, gb->buffer + get_bits_count(gb) / 8,
+ get_bits_left(gb) / 8);
+
+ while (bytestream2_get_bytes_left(&gbyte) > 2 && bytestream2_peek_ne16(&gbyte)) {
+ GetByteContext gbyte_payload;
GetBitContext gb_payload;
int type = 0;
unsigned size = 0;
int ret = 0;
do {
- if (get_bits_left(gb) < 8)
+ if (bytestream2_get_bytes_left(&gbyte) <= 0)
return AVERROR_INVALIDDATA;
- type += show_bits(gb, 8);
- } while (get_bits(gb, 8) == 255);
+ type += bytestream2_peek_byteu(&gbyte);
+ } while (bytestream2_get_byteu(&gbyte) == 255);
do {
- if (get_bits_left(gb) < 8)
+ if (bytestream2_get_bytes_left(&gbyte) <= 0)
return AVERROR_INVALIDDATA;
- size += show_bits(gb, 8);
- } while (get_bits(gb, 8) == 255);
+ size += bytestream2_peek_byteu(&gbyte);
+ } while (bytestream2_get_byteu(&gbyte) == 255);
- if (size > get_bits_left(gb) / 8) {
+ if (size > bytestream2_get_bytes_left(&gbyte)) {
av_log(logctx, AV_LOG_ERROR, "SEI type %d size %d truncated at %d\n",
- type, 8*size, get_bits_left(gb));
+ type, size, bytestream2_get_bytes_left(&gbyte));
return AVERROR_INVALIDDATA;
}
- ret = init_get_bits8(&gb_payload, gb->buffer + get_bits_count(gb) / 8, size);
+ bytestream2_init (&gbyte_payload, gbyte.buffer, size);
+ ret = init_get_bits8(&gb_payload, gbyte.buffer, size);
if (ret < 0)
return ret;
switch (type) {
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
- ret = decode_picture_timing(&h->picture_timing, &gb_payload, logctx);
+ ret = decode_picture_timing(&h->picture_timing, &gbyte_payload, logctx);
break;
case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
- ret = decode_registered_user_data(h, &gb_payload, logctx, size);
+ ret = decode_registered_user_data(h, &gbyte_payload, logctx);
break;
case SEI_TYPE_USER_DATA_UNREGISTERED:
- ret = decode_unregistered_user_data(&h->unregistered, &gb_payload, logctx, size);
+ ret = decode_unregistered_user_data(&h->unregistered, &gbyte_payload, logctx);
break;
case SEI_TYPE_RECOVERY_POINT:
ret = decode_recovery_point(&h->recovery_point, &gb_payload, logctx);
@@ -516,10 +509,10 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
ret = decode_display_orientation(&h->display_orientation, &gb_payload);
break;
case SEI_TYPE_GREEN_METADATA:
- ret = decode_green_metadata(&h->green_metadata, &gb_payload);
+ ret = decode_green_metadata(&h->green_metadata, &gbyte_payload);
break;
case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
- ret = decode_alternative_transfer(&h->alternative_transfer, &gb_payload);
+ ret = decode_alternative_transfer(&h->alternative_transfer, &gbyte_payload);
break;
case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
ret = decode_film_grain_characteristics(&h->film_grain_characteristics, &gb_payload);
@@ -537,7 +530,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
type, -get_bits_left(&gb_payload));
}
- skip_bits_long(gb, 8 * size);
+ bytestream2_skipu(&gbyte, size);
}
return master_ret;
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index f9166b45df..d7866f42ad 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -66,7 +66,7 @@ typedef struct H264SEITimeCode {
typedef struct H264SEIPictureTiming {
// maximum size of pic_timing according to the spec should be 274 bits
uint8_t payload[40];
- int payload_size_bits;
+ int payload_size_bytes;
int present;
H264_SEI_PicStructType pic_struct;
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 03/20] configure: Add (h264|hevc)_sei subsystems
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 04/20] avcodec/sei: Add tag to SEI enumeration Andreas Rheinhardt
` (17 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Currently, several components select atsc_a53, despite
not using anything from it themselves. They only select
it because parsing SEI messages adds an indirect dependency.
But using direct dependencies is more natural, so add
dedicated subsystems for them.
It already allows to remove a superfluous dependency of
the HEVC QSV encoder on hevc_sei and atsc_a53.
Adding new subsystems only becomes effective after a reconfiguration.
In order to force this, some needed headers (which are only included
implicitly before this commit) were included explicitly in
libavformat/allformats.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
configure | 14 +++++++++-----
libavcodec/Makefile | 9 +++++----
libavformat/allformats.c | 3 +++
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/configure b/configure
index fea512e8ef..65c368df8c 100755
--- a/configure
+++ b/configure
@@ -2459,7 +2459,9 @@ CONFIG_EXTRA="
h264parse
h264pred
h264qpel
+ h264_sei
hevcparse
+ hevc_sei
hpeldsp
huffman
huffyuvdsp
@@ -2728,7 +2730,9 @@ faandct_select="fdctdsp"
faanidct_deps="faan"
faanidct_select="idctdsp"
h264dsp_select="startcode"
-hevcparse_select="atsc_a53 golomb"
+h264_sei_select="atsc_a53 golomb"
+hevcparse_select="golomb"
+hevc_sei_select="atsc_a53 golomb"
frame_thread_encoder_deps="encoders threads"
inflate_wrapper_deps="zlib"
intrax8_select="blockdsp idctdsp"
@@ -2835,12 +2839,12 @@ h263_encoder_select="h263dsp mpegvideoenc"
h263i_decoder_select="h263_decoder"
h263p_decoder_select="h263_decoder"
h263p_encoder_select="h263_encoder"
-h264_decoder_select="atsc_a53 cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp"
+h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel h264_sei videodsp"
h264_decoder_suggest="error_resilience"
hap_decoder_select="snappy texturedsp"
hap_encoder_deps="libsnappy"
hap_encoder_select="texturedspenc"
-hevc_decoder_select="atsc_a53 bswapdsp cabac dovi_rpu golomb hevcparse videodsp"
+hevc_decoder_select="atsc_a53 bswapdsp cabac dovi_rpu golomb hevcparse hevc_sei videodsp"
huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
hymt_decoder_select="huffyuv_decoder"
@@ -3252,8 +3256,8 @@ av1_qsv_decoder_select="qsvdec"
# parsers
aac_parser_select="adts_header mpeg4audio"
av1_parser_select="cbs_av1"
-h264_parser_select="atsc_a53 golomb h264dsp h264parse"
-hevc_parser_select="hevcparse"
+h264_parser_select="golomb h264dsp h264parse h264_sei"
+hevc_parser_select="hevcparse hevc_sei"
mpegaudio_parser_select="mpegaudioheader"
mpegvideo_parser_select="mpegvideo"
mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 050934101c..52ea46e645 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -100,8 +100,9 @@ OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
-OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_sei.o hevc_data.o \
- dynamic_hdr10_plus.o dynamic_hdr_vivid.o
+OBJS-$(CONFIG_H264_SEI) += h264_sei.o
+OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_data.o
+OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o dynamic_hdr10_plus.o dynamic_hdr_vivid.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
@@ -383,7 +384,7 @@ OBJS-$(CONFIG_H263_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
h264_direct.o h264_loopfilter.o \
h264_mb.o h264_picture.o \
- h264_refs.o h264_sei.o \
+ h264_refs.o \
h264_slice.o h264data.o h274.o
OBJS-$(CONFIG_H264_AMF_ENCODER) += amfenc_h264.o
OBJS-$(CONFIG_H264_CUVID_DECODER) += cuviddec.o
@@ -1138,7 +1139,7 @@ OBJS-$(CONFIG_GIF_PARSER) += gif_parser.o
OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
-OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
+OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264data.o
OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
OBJS-$(CONFIG_IPU_PARSER) += ipu_parser.o
OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8b84b52c64..20e0e06ca0 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -20,6 +20,9 @@
*/
#include <stdatomic.h>
+#include <stddef.h>
+#include <stdint.h>
+
#include "libavformat/internal.h"
#include "avformat.h"
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 04/20] avcodec/sei: Add tag to SEI enumeration
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 03/20] configure: Add (h264|hevc)_sei subsystems Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 05/20] fftools/ffprobe: Improve description of AFD side data Andreas Rheinhardt
` (16 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This makes it a usable type.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/sei.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/sei.h b/libavcodec/sei.h
index 5513590b51..f13c37c308 100644
--- a/libavcodec/sei.h
+++ b/libavcodec/sei.h
@@ -26,7 +26,7 @@
// The content of the payload data depends on the standard, though
// many generic parts have the same interpretation everywhere (such as
// mastering-display-colour-volume and user-data-unregistered).
-enum {
+enum SEIType {
SEI_TYPE_BUFFERING_PERIOD = 0,
SEI_TYPE_PIC_TIMING = 1,
SEI_TYPE_PAN_SCAN_RECT = 2,
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 05/20] fftools/ffprobe: Improve description of AFD side data
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (2 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 04/20] avcodec/sei: Add tag to SEI enumeration Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 06/20] fate/h264: Add Active Format Descriptor test Andreas Rheinhardt
` (15 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
fftools/ffprobe.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 5020ba484c..4430f72239 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2361,6 +2361,8 @@ static void print_pkt_side_data(WriterContext *w,
if (do_show_data)
writer_print_data(w, "data", sd->data, sd->size);
writer_print_data_hash(w, "data_hash", sd->data, sd->size);
+ } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
+ print_int("active_format", *sd->data);
}
writer_print_section_footer(w);
}
@@ -2633,6 +2635,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1);
print_int("rotation", av_display_rotation_get((int32_t *)sd->data));
+ } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
+ print_int("active_format", *sd->data);
} else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 06/20] fate/h264: Add Active Format Descriptor test
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (3 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 05/20] fftools/ffprobe: Improve description of AFD side data Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 07/20] avcodec/h2645_sei: Factor parsing common SEI messages out Andreas Rheinhardt
` (14 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Some samples contain Active Format Descriptors, yet the output
of no test depends upon them, so that they are de-facto untested.
So add a dedicated test for them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
tests/fate/h264.mak | 2 +
tests/ref/fate/h264-afd | 282 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 284 insertions(+)
create mode 100644 tests/ref/fate/h264-afd
diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak
index 44e20f7259..b883f3a3ff 100644
--- a/tests/fate/h264.mak
+++ b/tests/fate/h264.mak
@@ -231,6 +231,7 @@ FATE_H264-$(call FRAMECRC, MXF, H264, PCM_S24LE_DECODER SCALE_FILTER ARESAMPLE_F
FATE_H264-$(call FRAMECRC, MOV, H264) += fate-h264-attachment-631
FATE_H264-$(call FRAMECRC, MPEGTS, H264, H264_PARSER MP3_DECODER SCALE_FILTER ARESAMPLE_FILTER) += fate-h264-skip-nokey fate-h264-skip-nointra
FATE_H264_FFPROBE-$(call DEMDEC, MATROSKA, H264) += fate-h264-dts_5frames
+FATE_H264_FFPROBE-$(call PARSERDEMDEC, H264, H264, H264) += fate-h264-afd
FATE_SAMPLES_AVCONV += $(FATE_H264-yes)
FATE_SAMPLES_FFPROBE += $(FATE_H264_FFPROBE-yes)
@@ -450,6 +451,7 @@ fate-h264-timecode: CMD = framecrc -i $(TARGET_SAM
fate-h264-reinit-%: CMD = framecrc -i $(TARGET_SAMPLES)/h264/$(@:fate-h264-%=%).h264 -vf scale,format=yuv444p10le,scale=w=352:h=288
fate-h264-dts_5frames: CMD = probeframes $(TARGET_SAMPLES)/h264/dts_5frames.mkv
+fate-h264-afd: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -bitexact -show_entries frame_side_data_list $(TARGET_SAMPLES)/h264/bbc2.sample.h264
fate-h264-encparams: CMD = venc_data $(TARGET_SAMPLES)/h264-conformance/FRext/FRExt_MMCO4_Sony_B.264 0 1
FATE_SAMPLES_DUMP_DATA += fate-h264-encparams
diff --git a/tests/ref/fate/h264-afd b/tests/ref/fate/h264-afd
new file mode 100644
index 0000000000..a45e899eea
--- /dev/null
+++ b/tests/ref/fate/h264-afd
@@ -0,0 +1,282 @@
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=14
+[/SIDE_DATA]
+[/FRAME]
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 07/20] avcodec/h2645_sei: Factor parsing common SEI messages out
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (4 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 06/20] fate/h264: Add Active Format Descriptor test Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 08/20] avcodec/h2645_sei: Factor updating H.2645 SEIs out Andreas Rheinhardt
` (13 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 4 +-
libavcodec/h2645_sei.c | 391 +++++++++++++++++++++++++++++++++++++++
libavcodec/h2645_sei.h | 133 +++++++++++++
libavcodec/h264_parser.c | 6 +-
libavcodec/h264_sei.c | 259 ++------------------------
libavcodec/h264_sei.h | 69 +------
libavcodec/h264_slice.c | 81 ++++----
libavcodec/h264dec.c | 6 +-
libavcodec/hevc_sei.c | 304 ++----------------------------
libavcodec/hevc_sei.h | 54 +-----
libavcodec/hevcdec.c | 109 +++++------
11 files changed, 664 insertions(+), 752 deletions(-)
create mode 100644 libavcodec/h2645_sei.c
create mode 100644 libavcodec/h2645_sei.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 52ea46e645..c86184f9fd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -100,9 +100,9 @@ OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
-OBJS-$(CONFIG_H264_SEI) += h264_sei.o
+OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o
OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_data.o
-OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o dynamic_hdr10_plus.o dynamic_hdr_vivid.o
+OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o h2645_sei.o dynamic_hdr10_plus.o dynamic_hdr_vivid.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
new file mode 100644
index 0000000000..5ff62bfac1
--- /dev/null
+++ b/libavcodec/h2645_sei.c
@@ -0,0 +1,391 @@
+/*
+ * Common H.264 and HEVC Supplementary Enhancement Information messages
+ *
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2012 - 2013 Gildas Cocherel
+ * Copyright (C) 2013 Vittorio Giovara
+ *
+ * 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
+ */
+
+#include "config_components.h"
+
+#include "libavutil/display.h"
+#include "libavutil/film_grain_params.h"
+#include "libavutil/pixdesc.h"
+
+#include "atsc_a53.h"
+#include "avcodec.h"
+#include "dynamic_hdr10_plus.h"
+#include "dynamic_hdr_vivid.h"
+#include "get_bits.h"
+#include "golomb.h"
+#include "h2645_sei.h"
+
+#define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI)
+#define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI)
+
+#if CONFIG_HEVC_SEI
+static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
+ GetByteContext *gb)
+{
+ size_t meta_size;
+ int err;
+ AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
+ if (!metadata)
+ return AVERROR(ENOMEM);
+
+ err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(metadata, gb->buffer,
+ bytestream2_get_bytes_left(gb));
+ if (err < 0) {
+ av_free(metadata);
+ return err;
+ }
+
+ av_buffer_unref(&s->info);
+ s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
+ if (!s->info) {
+ av_free(metadata);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+
+static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s,
+ GetByteContext *gb)
+{
+ size_t meta_size;
+ int err;
+ AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size);
+ if (!metadata)
+ return AVERROR(ENOMEM);
+
+ err = ff_parse_itu_t_t35_to_dynamic_hdr_vivid(metadata,
+ gb->buffer, bytestream2_get_bytes_left(gb));
+ if (err < 0) {
+ av_free(metadata);
+ return err;
+ }
+
+ av_buffer_unref(&s->info);
+ s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
+ if (!s->info) {
+ av_free(metadata);
+ return AVERROR(ENOMEM);
+ }
+
+ return 0;
+}
+#endif
+
+static int decode_registered_user_data_afd(H264SEIAFD *h, GetByteContext *gb)
+{
+ int flag;
+
+ if (bytestream2_get_bytes_left(gb) <= 0)
+ return AVERROR_INVALIDDATA;
+
+ flag = !!(bytestream2_get_byteu(gb) & 0x40); // active_format_flag
+
+ if (flag) {
+ if (bytestream2_get_bytes_left(gb) <= 0)
+ return AVERROR_INVALIDDATA;
+ h->active_format_description = bytestream2_get_byteu(gb) & 0xF;
+ h->present = 1;
+ }
+
+ return 0;
+}
+
+static int decode_registered_user_data_closed_caption(H2645SEIA53Caption *h,
+ GetByteContext *gb)
+{
+ return ff_parse_a53_cc(&h->buf_ref, gb->buffer,
+ bytestream2_get_bytes_left(gb));
+}
+
+static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
+ enum AVCodecID codec_id, void *logctx)
+{
+ int country_code, provider_code;
+
+ if (bytestream2_get_bytes_left(gb) < 3)
+ return AVERROR_INVALIDDATA;
+
+ country_code = bytestream2_get_byteu(gb); // itu_t_t35_country_code
+ if (country_code == 0xFF) {
+ if (bytestream2_get_bytes_left(gb) < 3)
+ return AVERROR_INVALIDDATA;
+
+ bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte
+ }
+
+ if (country_code != 0xB5 && country_code != 0x26) { // usa_country_code and cn_country_code
+ av_log(logctx, AV_LOG_VERBOSE,
+ "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n",
+ country_code);
+ return 0;
+ }
+
+ /* itu_t_t35_payload_byte follows */
+ provider_code = bytestream2_get_be16u(gb);
+
+ switch (provider_code) {
+ case 0x31: { // atsc_provider_code
+ uint32_t user_identifier;
+
+ if (bytestream2_get_bytes_left(gb) < 4)
+ return AVERROR_INVALIDDATA;
+
+ user_identifier = bytestream2_get_be32u(gb);
+ switch (user_identifier) {
+ case MKBETAG('D', 'T', 'G', '1'): // afd_data
+ if (!IS_H264(codec_id))
+ goto unsupported;
+ return decode_registered_user_data_afd(&h->afd, gb);
+ case MKBETAG('G', 'A', '9', '4'): // closed captions
+ return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
+ default:
+ unsupported:
+ av_log(logctx, AV_LOG_VERBOSE,
+ "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
+ user_identifier);
+ break;
+ }
+ break;
+ }
+#if CONFIG_HEVC_SEI
+ case 0x04: { // cuva_provider_code
+ const uint16_t cuva_provider_oriented_code = 0x0005;
+ uint16_t provider_oriented_code;
+
+ if (!IS_HEVC(codec_id))
+ goto unsupported_provider_code;
+
+ if (bytestream2_get_bytes_left(gb) < 2)
+ return AVERROR_INVALIDDATA;
+
+ provider_oriented_code = bytestream2_get_be16u(gb);
+ if (provider_oriented_code == cuva_provider_oriented_code) {
+ return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
+ }
+ break;
+ }
+ case 0x3C: { // smpte_provider_code
+ // A/341 Amendment - 2094-40
+ const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
+ const uint8_t smpte2094_40_application_identifier = 0x04;
+ uint16_t provider_oriented_code;
+ uint8_t application_identifier;
+
+ if (!IS_HEVC(codec_id))
+ goto unsupported_provider_code;
+
+ if (bytestream2_get_bytes_left(gb) < 3)
+ return AVERROR_INVALIDDATA;
+
+ provider_oriented_code = bytestream2_get_be16u(gb);
+ application_identifier = bytestream2_get_byteu(gb);
+ if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
+ application_identifier == smpte2094_40_application_identifier) {
+ return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
+ }
+ break;
+ }
+ unsupported_provider_code:
+#endif
+ default:
+ av_log(logctx, AV_LOG_VERBOSE,
+ "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
+ provider_code);
+ break;
+ }
+
+ return 0;
+}
+
+static int decode_unregistered_user_data(H2645SEIUnregistered *h,
+ GetByteContext *gb,
+ enum AVCodecID codec_id)
+{
+ uint8_t *user_data;
+ int size = bytestream2_get_bytes_left(gb);
+ AVBufferRef *buf_ref, **tmp;
+
+ if (size < 16 || size >= INT_MAX - 1)
+ return AVERROR_INVALIDDATA;
+
+ tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+ h->buf_ref = tmp;
+
+ buf_ref = av_buffer_alloc(size + 1);
+ if (!buf_ref)
+ return AVERROR(ENOMEM);
+ user_data = buf_ref->data;
+
+ bytestream2_get_bufferu(gb, user_data, size);
+ user_data[size] = 0;
+ buf_ref->size = size;
+ h->buf_ref[h->nb_buf_ref++] = buf_ref;
+
+ if (IS_H264(codec_id)) {
+ int e, build;
+ e = sscanf(user_data + 16, "x264 - core %d", &build);
+ if (e == 1 && build > 0)
+ h->x264_build = build;
+ if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16))
+ h->x264_build = 67;
+ }
+
+ return 0;
+}
+
+static int decode_display_orientation(H2645SEIDisplayOrientation *h,
+ GetBitContext *gb)
+{
+ h->present = !get_bits1(gb); // display_orientation_cancel_flag
+
+ if (h->present) {
+ h->hflip = get_bits1(gb); // hor_flip
+ h->vflip = get_bits1(gb); // ver_flip
+
+ h->anticlockwise_rotation = get_bits(gb, 16);
+ // This is followed by display_orientation_repetition_period
+ // and display_orientation_extension_flag for H.264
+ // and by display_orientation_persistence_flag for HEVC.
+ }
+
+ return 0;
+}
+
+static int decode_frame_packing_arrangement(H2645SEIFramePacking *h,
+ GetBitContext *gb,
+ enum AVCodecID codec_id)
+{
+ h->arrangement_id = get_ue_golomb_long(gb);
+ h->arrangement_cancel_flag = get_bits1(gb);
+ h->present = !h->arrangement_cancel_flag;
+
+ if (h->present) {
+ h->arrangement_type = get_bits(gb, 7);
+ h->quincunx_sampling_flag = get_bits1(gb);
+ h->content_interpretation_type = get_bits(gb, 6);
+
+ // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
+ skip_bits(gb, 3);
+ h->current_frame_is_frame0_flag = get_bits1(gb);
+ // frame0_self_contained_flag, frame1_self_contained_flag
+ skip_bits(gb, 2);
+
+ if (!h->quincunx_sampling_flag && h->arrangement_type != 5)
+ skip_bits(gb, 16); // frame[01]_grid_position_[xy]
+ skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
+ if (IS_H264(codec_id))
+ h->arrangement_repetition_period = get_ue_golomb_long(gb);
+ else
+ skip_bits1(gb); // frame_packing_arrangement_persistence_flag
+ }
+ // H.264: frame_packing_arrangement_extension_flag,
+ // HEVC: upsampled_aspect_ratio_flag
+ skip_bits1(gb);
+
+ return 0;
+}
+
+static int decode_alternative_transfer(H2645SEIAlternativeTransfer *s,
+ GetByteContext *gb)
+{
+ if (bytestream2_get_bytes_left(gb) < 1)
+ return AVERROR_INVALIDDATA;
+
+ s->present = 1;
+ s->preferred_transfer_characteristics = bytestream2_get_byteu(gb);
+
+ return 0;
+}
+
+static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h,
+ enum AVCodecID codec_id, GetBitContext *gb)
+{
+ h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
+
+ if (h->present) {
+ memset(h, 0, sizeof(*h));
+ h->model_id = get_bits(gb, 2);
+ h->separate_colour_description_present_flag = get_bits1(gb);
+ if (h->separate_colour_description_present_flag) {
+ h->bit_depth_luma = get_bits(gb, 3) + 8;
+ h->bit_depth_chroma = get_bits(gb, 3) + 8;
+ h->full_range = get_bits1(gb);
+ h->color_primaries = get_bits(gb, 8);
+ h->transfer_characteristics = get_bits(gb, 8);
+ h->matrix_coeffs = get_bits(gb, 8);
+ }
+ h->blending_mode_id = get_bits(gb, 2);
+ h->log2_scale_factor = get_bits(gb, 4);
+ for (int c = 0; c < 3; c++)
+ h->comp_model_present_flag[c] = get_bits1(gb);
+ for (int c = 0; c < 3; c++) {
+ if (h->comp_model_present_flag[c]) {
+ h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
+ h->num_model_values[c] = get_bits(gb, 3) + 1;
+ if (h->num_model_values[c] > 6)
+ return AVERROR_INVALIDDATA;
+ for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
+ h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
+ h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
+ for (int j = 0; j < h->num_model_values[c]; j++)
+ h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
+ }
+ }
+ }
+ if (IS_HEVC(codec_id))
+ h->persistence_flag = get_bits1(gb);
+ else
+ h->repetition_period = get_ue_golomb_long(gb);
+
+ h->present = 1;
+ }
+
+ return 0;
+}
+
+int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
+ enum AVCodecID codec_id, GetBitContext *gb,
+ GetByteContext *gbyte, void *logctx)
+{
+ switch (type) {
+ case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+ return decode_registered_user_data(h, gbyte, codec_id, logctx);
+ case SEI_TYPE_USER_DATA_UNREGISTERED:
+ return decode_unregistered_user_data(&h->unregistered, gbyte, codec_id);
+ case SEI_TYPE_DISPLAY_ORIENTATION:
+ return decode_display_orientation(&h->display_orientation, gb);
+ case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
+ return decode_film_grain_characteristics(&h->film_grain_characteristics, codec_id, gb);
+ case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
+ return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id);
+ case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
+ return decode_alternative_transfer(&h->alternative_transfer, gbyte);
+ default:
+ return FF_H2645_SEI_MESSAGE_UNHANDLED;
+ }
+}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
new file mode 100644
index 0000000000..4128ff7940
--- /dev/null
+++ b/libavcodec/h2645_sei.h
@@ -0,0 +1,133 @@
+/*
+ * 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_H2645_SEI_H
+#define AVCODEC_H2645_SEI_H
+
+#include <stdint.h>
+
+#include "libavutil/buffer.h"
+#include "libavutil/frame.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "codec_id.h"
+#include "get_bits.h"
+#include "sei.h"
+
+typedef struct H2645SEIA53Caption {
+ AVBufferRef *buf_ref;
+} H2645SEIA53Caption;
+
+typedef struct H264SEIAFD {
+ int present;
+ uint8_t active_format_description;
+} H264SEIAFD;
+
+typedef struct HEVCSEIDynamicHDRPlus {
+ AVBufferRef *info;
+} HEVCSEIDynamicHDRPlus;
+
+typedef struct HEVCSEIDynamicHDRVivid {
+ AVBufferRef *info;
+} HEVCSEIDynamicHDRVivid;
+
+typedef struct H2645SEIUnregistered {
+ AVBufferRef **buf_ref;
+ unsigned nb_buf_ref;
+ int x264_build; //< H.264 only
+} H2645SEIUnregistered;
+
+typedef struct H2645SEIFramePacking {
+ int present;
+ int arrangement_id;
+ int arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received (currently H.264 only)
+ int arrangement_type;
+ int arrangement_repetition_period;
+ int content_interpretation_type;
+ int quincunx_sampling_flag;
+ int current_frame_is_frame0_flag;
+} H2645SEIFramePacking;
+
+typedef struct H2645SEIDisplayOrientation {
+ int present;
+ int anticlockwise_rotation;
+ int hflip, vflip;
+} H2645SEIDisplayOrientation;
+
+typedef struct H2645SEIAlternativeTransfer {
+ int present;
+ int preferred_transfer_characteristics;
+} H2645SEIAlternativeTransfer;
+
+typedef struct H2645SEIFilmGrainCharacteristics {
+ int present;
+ int model_id;
+ int separate_colour_description_present_flag;
+ int bit_depth_luma;
+ int bit_depth_chroma;
+ int full_range;
+ int color_primaries;
+ int transfer_characteristics;
+ int matrix_coeffs;
+ int blending_mode_id;
+ int log2_scale_factor;
+ int comp_model_present_flag[3];
+ uint16_t num_intensity_intervals[3];
+ uint8_t num_model_values[3];
+ uint8_t intensity_interval_lower_bound[3][256];
+ uint8_t intensity_interval_upper_bound[3][256];
+ int16_t comp_model_value[3][256][6];
+ int repetition_period; //< H.264 only
+ int persistence_flag; //< HEVC only
+} H2645SEIFilmGrainCharacteristics;
+
+typedef struct H2645SEI {
+ H2645SEIA53Caption a53_caption;
+ H264SEIAFD afd; //< H.264 only
+ HEVCSEIDynamicHDRPlus dynamic_hdr_plus; //< HEVC only
+ HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; //< HEVC only
+ H2645SEIUnregistered unregistered;
+ H2645SEIFramePacking frame_packing;
+ H2645SEIDisplayOrientation display_orientation;
+ H2645SEIAlternativeTransfer alternative_transfer;
+ H2645SEIFilmGrainCharacteristics film_grain_characteristics;
+} H2645SEI;
+
+enum {
+ FF_H2645_SEI_MESSAGE_HANDLED = 0,
+ FF_H2645_SEI_MESSAGE_UNHANDLED,
+};
+
+/**
+ * Decode a single SEI message.
+ *
+ * This function may either use gb or gbyte to decode the SEI message.
+ *
+ * @param[in, out] gb GetBitContext that needs to be at the start
+ * of the payload (i.e. after the payload_size bytes);
+ * it needs to be initially byte-aligned
+ * @param[in, out] gbyte a GetByteContext for the same data as gb
+ * @return < 0 on error, FF_H2645_SEI_MESSAGE_HANDLED if the SEI message
+ * has been handled or FF_H2645_SEI_MESSAGE_UNHANDLED if not.
+ */
+int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
+ enum AVCodecID codec_id, GetBitContext *gb,
+ GetByteContext *gbyte, void *logctx);
+
+#endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 50810f1789..3ed23fb9ca 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -274,8 +274,8 @@ static inline int parse_nal_units(AVCodecParserContext *s,
s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
ff_h264_sei_uninit(&p->sei);
- p->sei.frame_packing.arrangement_cancel_flag = -1;
- p->sei.unregistered.x264_build = -1;
+ p->sei.common.frame_packing.arrangement_cancel_flag = -1;
+ p->sei.common.unregistered.x264_build = -1;
if (!buf_size)
return 0;
@@ -565,7 +565,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
}
if (sps->timing_info_present_flag) {
int64_t den = sps->time_scale;
- if (p->sei.unregistered.x264_build < 44U)
+ if (p->sei.common.unregistered.x264_build < 44U)
den *= 2;
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index d62a276779..c62aef9246 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -32,7 +32,6 @@
#include "libavutil/log.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
-#include "atsc_a53.h"
#include "bytestream.h"
#include "get_bits.h"
#include "golomb.h"
@@ -55,16 +54,16 @@ void ff_h264_sei_uninit(H264SEIContext *h)
h->picture_timing.present = 0;
h->buffering_period.present = 0;
- h->frame_packing.present = 0;
- h->film_grain_characteristics.present = 0;
- h->display_orientation.present = 0;
- h->afd.present = 0;
-
- av_buffer_unref(&h->a53_caption.buf_ref);
- for (int i = 0; i < h->unregistered.nb_buf_ref; i++)
- av_buffer_unref(&h->unregistered.buf_ref[i]);
- h->unregistered.nb_buf_ref = 0;
- av_freep(&h->unregistered.buf_ref);
+ h->common.frame_packing.present = 0;
+ h->common.film_grain_characteristics.present = 0;
+ h->common.display_orientation.present = 0;
+ h->common.afd.present = 0;
+
+ av_buffer_unref(&h->common.a53_caption.buf_ref);
+ for (int i = 0; i < h->common.unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&h->common.unregistered.buf_ref[i]);
+ h->common.unregistered.nb_buf_ref = 0;
+ av_freep(&h->common.unregistered.buf_ref);
}
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
@@ -153,123 +152,6 @@ static int decode_picture_timing(H264SEIPictureTiming *h, GetByteContext *gb,
return 0;
}
-static int decode_registered_user_data_afd(H264SEIAFD *h, GetByteContext *gb)
-{
- int flag;
-
- if (bytestream2_get_bytes_left(gb) <= 0)
- return AVERROR_INVALIDDATA;
-
- flag = !!(bytestream2_get_byteu(gb) & 0x40); // active_format_flag
-
- if (flag) {
- if (bytestream2_get_bytes_left(gb) <= 0)
- return AVERROR_INVALIDDATA;
- h->active_format_description = bytestream2_get_byteu(gb) & 0xF;
- h->present = 1;
- }
-
- return 0;
-}
-
-static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h,
- GetByteContext *gb)
-{
- return ff_parse_a53_cc(&h->buf_ref, gb->buffer,
- bytestream2_get_bytes_left(gb));
-}
-
-static int decode_registered_user_data(H264SEIContext *h, GetByteContext *gb,
- void *logctx)
-{
- int country_code, provider_code;
-
- if (bytestream2_get_bytes_left(gb) < 3)
- return AVERROR_INVALIDDATA;
-
- country_code = bytestream2_get_byteu(gb); // itu_t_t35_country_code
- if (country_code == 0xFF) {
- if (bytestream2_get_bytes_left(gb) < 3)
- return AVERROR_INVALIDDATA;
-
- bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte
- }
-
- if (country_code != 0xB5) { // usa_country_code
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n",
- country_code);
- return 0;
- }
-
- /* itu_t_t35_payload_byte follows */
- provider_code = bytestream2_get_be16u(gb);
-
- switch (provider_code) {
- case 0x31: { // atsc_provider_code
- uint32_t user_identifier;
-
- if (bytestream2_get_bytes_left(gb) < 4)
- return AVERROR_INVALIDDATA;
-
- user_identifier = bytestream2_get_be32u(gb);
- switch (user_identifier) {
- case MKBETAG('D', 'T', 'G', '1'): // afd_data
- return decode_registered_user_data_afd(&h->afd, gb);
- case MKBETAG('G', 'A', '9', '4'): // closed captions
- return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
- default:
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
- user_identifier);
- break;
- }
- break;
- }
- default:
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
- provider_code);
- break;
- }
-
- return 0;
-}
-
-static int decode_unregistered_user_data(H264SEIUnregistered *h, GetByteContext *gb,
- void *logctx)
-{
- uint8_t *user_data;
- int e, build, size = bytestream2_get_bytes_left(gb);
- AVBufferRef *buf_ref, **tmp;
-
- if (size < 16 || size >= INT_MAX - 1)
- return AVERROR_INVALIDDATA;
-
- tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
- if (!tmp)
- return AVERROR(ENOMEM);
- h->buf_ref = tmp;
-
- buf_ref = av_buffer_alloc(size + 1);
- if (!buf_ref)
- return AVERROR(ENOMEM);
- user_data = buf_ref->data;
-
- bytestream2_get_bufferu(gb, user_data, size);
- user_data[size] = 0;
- buf_ref->size = size;
- h->buf_ref[h->nb_buf_ref++] = buf_ref;
-
- e = sscanf(user_data + 16, "x264 - core %d", &build);
- if (e == 1 && build > 0)
- h->x264_build = build;
- if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16))
- h->x264_build = 67;
-
- return 0;
-}
-
static int decode_recovery_point(H264SEIRecoveryPoint *h, GetBitContext *gb, void *logctx)
{
unsigned recovery_frame_cnt = get_ue_golomb_long(gb);
@@ -325,51 +207,6 @@ static int decode_buffering_period(H264SEIBufferingPeriod *h, GetBitContext *gb,
return 0;
}
-static int decode_frame_packing_arrangement(H264SEIFramePacking *h,
- GetBitContext *gb)
-{
- h->arrangement_id = get_ue_golomb_long(gb);
- h->arrangement_cancel_flag = get_bits1(gb);
- h->present = !h->arrangement_cancel_flag;
-
- if (h->present) {
- h->arrangement_type = get_bits(gb, 7);
- h->quincunx_sampling_flag = get_bits1(gb);
- h->content_interpretation_type = get_bits(gb, 6);
-
- // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
- skip_bits(gb, 3);
- h->current_frame_is_frame0_flag = get_bits1(gb);
- // frame0_self_contained_flag, frame1_self_contained_flag
- skip_bits(gb, 2);
-
- if (!h->quincunx_sampling_flag && h->arrangement_type != 5)
- skip_bits(gb, 16); // frame[01]_grid_position_[xy]
- skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
- h->arrangement_repetition_period = get_ue_golomb_long(gb);
- }
- skip_bits1(gb); // frame_packing_arrangement_extension_flag
-
- return 0;
-}
-
-static int decode_display_orientation(H264SEIDisplayOrientation *h,
- GetBitContext *gb)
-{
- h->present = !get_bits1(gb);
-
- if (h->present) {
- h->hflip = get_bits1(gb); // hor_flip
- h->vflip = get_bits1(gb); // ver_flip
-
- h->anticlockwise_rotation = get_bits(gb, 16);
- get_ue_golomb_long(gb); // display_orientation_repetition_period
- skip_bits1(gb); // display_orientation_extension_flag
- }
-
- return 0;
-}
-
static int decode_green_metadata(H264SEIGreenMetaData *h, GetByteContext *gb)
{
h->green_metadata_type = bytestream2_get_byte(gb);
@@ -395,57 +232,6 @@ static int decode_green_metadata(H264SEIGreenMetaData *h, GetByteContext *gb)
return 0;
}
-static int decode_alternative_transfer(H264SEIAlternativeTransfer *h,
- GetByteContext *gb)
-{
- h->present = 1;
- h->preferred_transfer_characteristics = bytestream2_get_byte(gb);
- return 0;
-}
-
-static int decode_film_grain_characteristics(H264SEIFilmGrainCharacteristics *h,
- GetBitContext *gb)
-{
- h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
-
- if (h->present) {
- memset(h, 0, sizeof(*h));
- h->model_id = get_bits(gb, 2);
- h->separate_colour_description_present_flag = get_bits1(gb);
- if (h->separate_colour_description_present_flag) {
- h->bit_depth_luma = get_bits(gb, 3) + 8;
- h->bit_depth_chroma = get_bits(gb, 3) + 8;
- h->full_range = get_bits1(gb);
- h->color_primaries = get_bits(gb, 8);
- h->transfer_characteristics = get_bits(gb, 8);
- h->matrix_coeffs = get_bits(gb, 8);
- }
- h->blending_mode_id = get_bits(gb, 2);
- h->log2_scale_factor = get_bits(gb, 4);
- for (int c = 0; c < 3; c++)
- h->comp_model_present_flag[c] = get_bits1(gb);
- for (int c = 0; c < 3; c++) {
- if (h->comp_model_present_flag[c]) {
- h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
- h->num_model_values[c] = get_bits(gb, 3) + 1;
- if (h->num_model_values[c] > 6)
- return AVERROR_INVALIDDATA;
- for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
- h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
- h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
- for (int j = 0; j < h->num_model_values[c]; j++)
- h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
- }
- }
- }
- h->repetition_period = get_ue_golomb_long(gb);
-
- h->present = 1;
- }
-
- return 0;
-}
-
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
const H264ParamSets *ps, void *logctx)
{
@@ -490,35 +276,20 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
case SEI_TYPE_PIC_TIMING: // Picture timing SEI
ret = decode_picture_timing(&h->picture_timing, &gbyte_payload, logctx);
break;
- case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
- ret = decode_registered_user_data(h, &gbyte_payload, logctx);
- break;
- case SEI_TYPE_USER_DATA_UNREGISTERED:
- ret = decode_unregistered_user_data(&h->unregistered, &gbyte_payload, logctx);
- break;
case SEI_TYPE_RECOVERY_POINT:
ret = decode_recovery_point(&h->recovery_point, &gb_payload, logctx);
break;
case SEI_TYPE_BUFFERING_PERIOD:
ret = decode_buffering_period(&h->buffering_period, &gb_payload, ps, logctx);
break;
- case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
- ret = decode_frame_packing_arrangement(&h->frame_packing, &gb_payload);
- break;
- case SEI_TYPE_DISPLAY_ORIENTATION:
- ret = decode_display_orientation(&h->display_orientation, &gb_payload);
- break;
case SEI_TYPE_GREEN_METADATA:
ret = decode_green_metadata(&h->green_metadata, &gbyte_payload);
break;
- case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
- ret = decode_alternative_transfer(&h->alternative_transfer, &gbyte_payload);
- break;
- case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
- ret = decode_film_grain_characteristics(&h->film_grain_characteristics, &gb_payload);
- break;
default:
- av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
+ ret = ff_h2645_sei_message_decode(&h->common, type, AV_CODEC_ID_H264,
+ &gb_payload, &gbyte_payload, logctx);
+ if (ret == FF_H2645_SEI_MESSAGE_UNHANDLED)
+ av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
}
if (ret < 0 && ret != AVERROR_PS_NOT_FOUND)
return ret;
@@ -536,7 +307,7 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
return master_ret;
}
-const char *ff_h264_sei_stereo_mode(const H264SEIFramePacking *h)
+const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h)
{
if (h->arrangement_cancel_flag == 0) {
switch (h->arrangement_type) {
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index d7866f42ad..7a53d01ac5 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -20,6 +20,7 @@
#define AVCODEC_H264_SEI_H
#include "get_bits.h"
+#include "h2645_sei.h"
#include "h264_ps.h"
#include "sei.h"
@@ -99,21 +100,6 @@ typedef struct H264SEIPictureTiming {
int timecode_cnt;
} H264SEIPictureTiming;
-typedef struct H264SEIAFD {
- int present;
- uint8_t active_format_description;
-} H264SEIAFD;
-
-typedef struct H264SEIA53Caption {
- AVBufferRef *buf_ref;
-} H264SEIA53Caption;
-
-typedef struct H264SEIUnregistered {
- int x264_build;
- AVBufferRef **buf_ref;
- int nb_buf_ref;
-} H264SEIUnregistered;
-
typedef struct H264SEIRecoveryPoint {
/**
* recovery_frame_cnt
@@ -130,23 +116,6 @@ typedef struct H264SEIBufferingPeriod {
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
} H264SEIBufferingPeriod;
-typedef struct H264SEIFramePacking {
- int present;
- int arrangement_id;
- int arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received
- H264_SEI_FpaType arrangement_type;
- int arrangement_repetition_period;
- int content_interpretation_type;
- int quincunx_sampling_flag;
- int current_frame_is_frame0_flag;
-} H264SEIFramePacking;
-
-typedef struct H264SEIDisplayOrientation {
- int present;
- int anticlockwise_rotation;
- int hflip, vflip;
-} H264SEIDisplayOrientation;
-
typedef struct H264SEIGreenMetaData {
uint8_t green_metadata_type;
uint8_t period_type;
@@ -160,44 +129,12 @@ typedef struct H264SEIGreenMetaData {
uint16_t xsd_metric_value;
} H264SEIGreenMetaData;
-typedef struct H264SEIAlternativeTransfer {
- int present;
- int preferred_transfer_characteristics;
-} H264SEIAlternativeTransfer;
-
-typedef struct H264SEIFilmGrainCharacteristics {
- int present;
- int model_id;
- int separate_colour_description_present_flag;
- int bit_depth_luma;
- int bit_depth_chroma;
- int full_range;
- int color_primaries;
- int transfer_characteristics;
- int matrix_coeffs;
- int blending_mode_id;
- int log2_scale_factor;
- int comp_model_present_flag[3];
- uint16_t num_intensity_intervals[3];
- uint8_t num_model_values[3];
- uint8_t intensity_interval_lower_bound[3][256];
- uint8_t intensity_interval_upper_bound[3][256];
- int16_t comp_model_value[3][256][6];
- int repetition_period;
-} H264SEIFilmGrainCharacteristics;
-
typedef struct H264SEIContext {
+ H2645SEI common;
H264SEIPictureTiming picture_timing;
- H264SEIAFD afd;
- H264SEIA53Caption a53_caption;
- H264SEIUnregistered unregistered;
H264SEIRecoveryPoint recovery_point;
H264SEIBufferingPeriod buffering_period;
- H264SEIFramePacking frame_packing;
- H264SEIDisplayOrientation display_orientation;
H264SEIGreenMetaData green_metadata;
- H264SEIAlternativeTransfer alternative_transfer;
- H264SEIFilmGrainCharacteristics film_grain_characteristics;
} H264SEIContext;
struct H264ParamSets;
@@ -213,7 +150,7 @@ void ff_h264_sei_uninit(H264SEIContext *h);
/**
* Get stereo_mode string from the h264 frame_packing_arrangement
*/
-const char *ff_h264_sei_stereo_mode(const H264SEIFramePacking *h);
+const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h);
/**
* Parse the contents of a picture timing message given an active SPS.
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index d56722a5c2..a6d8d2bdac 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -433,29 +433,30 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
h->frame_recovered = h1->frame_recovered;
- ret = av_buffer_replace(&h->sei.a53_caption.buf_ref, h1->sei.a53_caption.buf_ref);
+ ret = av_buffer_replace(&h->sei.common.a53_caption.buf_ref,
+ h1->sei.common.a53_caption.buf_ref);
if (ret < 0)
return ret;
- for (i = 0; i < h->sei.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&h->sei.unregistered.buf_ref[i]);
- h->sei.unregistered.nb_buf_ref = 0;
+ for (i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&h->sei.common.unregistered.buf_ref[i]);
+ h->sei.common.unregistered.nb_buf_ref = 0;
- if (h1->sei.unregistered.nb_buf_ref) {
- ret = av_reallocp_array(&h->sei.unregistered.buf_ref,
- h1->sei.unregistered.nb_buf_ref,
- sizeof(*h->sei.unregistered.buf_ref));
+ if (h1->sei.common.unregistered.nb_buf_ref) {
+ ret = av_reallocp_array(&h->sei.common.unregistered.buf_ref,
+ h1->sei.common.unregistered.nb_buf_ref,
+ sizeof(*h->sei.common.unregistered.buf_ref));
if (ret < 0)
return ret;
- for (i = 0; i < h1->sei.unregistered.nb_buf_ref; i++) {
- h->sei.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.unregistered.buf_ref[i]);
- if (!h->sei.unregistered.buf_ref[i])
+ for (i = 0; i < h1->sei.common.unregistered.nb_buf_ref; i++) {
+ h->sei.common.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.common.unregistered.buf_ref[i]);
+ if (!h->sei.common.unregistered.buf_ref[i])
return AVERROR(ENOMEM);
- h->sei.unregistered.nb_buf_ref++;
+ h->sei.common.unregistered.nb_buf_ref++;
}
}
- h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
+ h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
if (!h->cur_pic_ptr)
return 0;
@@ -528,7 +529,7 @@ static int h264_frame_start(H264Context *h)
pic->f->crop_top = h->crop_top;
pic->f->crop_bottom = h->crop_bottom;
- pic->needs_fg = h->sei.film_grain_characteristics.present && !h->avctx->hwaccel &&
+ pic->needs_fg = h->sei.common.film_grain_characteristics.present && !h->avctx->hwaccel &&
!(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
if ((ret = alloc_picture(h, pic)) < 0)
@@ -579,8 +580,8 @@ static int h264_frame_start(H264Context *h)
h->mb_aff_frame = h->ps.sps->mb_aff && (h->picture_structure == PICT_FRAME);
- if (h->sei.unregistered.x264_build >= 0)
- h->x264_build = h->sei.unregistered.x264_build;
+ if (h->sei.common.unregistered.x264_build >= 0)
+ h->x264_build = h->sei.common.unregistered.x264_build;
assert(h->cur_pic_ptr->long_ref == 0);
@@ -1114,10 +1115,10 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
}
}
- if (h->sei.alternative_transfer.present &&
- av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) &&
- h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
- h->avctx->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics;
+ if (h->sei.common.alternative_transfer.present &&
+ av_color_transfer_name(h->sei.common.alternative_transfer.preferred_transfer_characteristics) &&
+ h->sei.common.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
+ h->avctx->color_trc = h->sei.common.alternative_transfer.preferred_transfer_characteristics;
}
}
h->avctx->chroma_sample_location = sps->chroma_location;
@@ -1243,11 +1244,11 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.frame_packing.present &&
- h->sei.frame_packing.arrangement_type <= 6 &&
- h->sei.frame_packing.content_interpretation_type > 0 &&
- h->sei.frame_packing.content_interpretation_type < 3) {
- H264SEIFramePacking *fp = &h->sei.frame_packing;
+ if (h->sei.common.frame_packing.present &&
+ h->sei.common.frame_packing.arrangement_type <= 6 &&
+ h->sei.common.frame_packing.content_interpretation_type > 0 &&
+ h->sei.common.frame_packing.content_interpretation_type < 3) {
+ H2645SEIFramePacking *fp = &h->sei.common.frame_packing;
AVStereo3D *stereo = av_stereo3d_create_side_data(out);
if (stereo) {
switch (fp->arrangement_type) {
@@ -1289,11 +1290,11 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.display_orientation.present &&
- (h->sei.display_orientation.anticlockwise_rotation ||
- h->sei.display_orientation.hflip ||
- h->sei.display_orientation.vflip)) {
- H264SEIDisplayOrientation *o = &h->sei.display_orientation;
+ if (h->sei.common.display_orientation.present &&
+ (h->sei.common.display_orientation.anticlockwise_rotation ||
+ h->sei.common.display_orientation.hflip ||
+ h->sei.common.display_orientation.vflip)) {
+ H2645SEIDisplayOrientation *o = &h->sei.common.display_orientation;
double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
AVFrameSideData *rotation = av_frame_new_side_data(out,
AV_FRAME_DATA_DISPLAYMATRIX,
@@ -1314,18 +1315,18 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.afd.present) {
+ if (h->sei.common.afd.present) {
AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD,
sizeof(uint8_t));
if (sd) {
- *sd->data = h->sei.afd.active_format_description;
- h->sei.afd.present = 0;
+ *sd->data = h->sei.common.afd.active_format_description;
+ h->sei.common.afd.present = 0;
}
}
- if (h->sei.a53_caption.buf_ref) {
- H264SEIA53Caption *a53 = &h->sei.a53_caption;
+ if (h->sei.common.a53_caption.buf_ref) {
+ H2645SEIA53Caption *a53 = &h->sei.common.a53_caption;
AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref);
if (!sd)
@@ -1335,8 +1336,8 @@ static int h264_export_frame_props(H264Context *h)
h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
}
- for (int i = 0; i < h->sei.unregistered.nb_buf_ref; i++) {
- H264SEIUnregistered *unreg = &h->sei.unregistered;
+ for (int i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++) {
+ H2645SEIUnregistered *unreg = &h->sei.common.unregistered;
if (unreg->buf_ref[i]) {
AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
@@ -1347,10 +1348,10 @@ static int h264_export_frame_props(H264Context *h)
unreg->buf_ref[i] = NULL;
}
}
- h->sei.unregistered.nb_buf_ref = 0;
+ h->sei.common.unregistered.nb_buf_ref = 0;
- if (h->sei.film_grain_characteristics.present) {
- H264SEIFilmGrainCharacteristics *fgc = &h->sei.film_grain_characteristics;
+ if (h->sei.common.film_grain_characteristics.present) {
+ H2645SEIFilmGrainCharacteristics *fgc = &h->sei.common.film_grain_characteristics;
AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out);
if (!fgp)
return AVERROR(ENOMEM);
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index d80bc6b17f..49f4db90e3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -296,8 +296,8 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
h->recovery_frame = -1;
h->frame_recovered = 0;
h->poc.prev_frame_num = -1;
- h->sei.frame_packing.arrangement_cancel_flag = -1;
- h->sei.unregistered.x264_build = -1;
+ h->sei.common.frame_packing.arrangement_cancel_flag = -1;
+ h->sei.common.unregistered.x264_build = -1;
h->next_outputed_poc = INT_MIN;
for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
@@ -848,7 +848,7 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
if (srcp->needs_fg && (ret = av_frame_copy_props(dst, srcp->f)) < 0)
return ret;
- av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(&h->sei.frame_packing), 0);
+ av_dict_set(&dst->metadata, "stereo_mode", ff_h264_sei_stereo_mode(&h->sei.common.frame_packing), 0);
if (srcp->sei_recovery_frame_cnt == 0)
dst->key_frame = 1;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 631373e06f..b0a4a8b035 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -22,10 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "atsc_a53.h"
#include "bytestream.h"
-#include "dynamic_hdr10_plus.h"
-#include "dynamic_hdr_vivid.h"
#include "golomb.h"
#include "hevc_ps.h"
#include "hevc_sei.h"
@@ -98,38 +95,6 @@ static int decode_nal_sei_content_light_info(HEVCSEIContentLight *s,
return 0;
}
-static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetBitContext *gb)
-{
- get_ue_golomb_long(gb); // frame_packing_arrangement_id
- s->present = !get_bits1(gb);
-
- if (s->present) {
- s->arrangement_type = get_bits(gb, 7);
- s->quincunx_subsampling = get_bits1(gb);
- s->content_interpretation_type = get_bits(gb, 6);
-
- // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
- skip_bits(gb, 3);
- s->current_frame_is_frame0_flag = get_bits1(gb);
- }
- return 0;
-}
-
-static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetBitContext *gb)
-{
- s->present = !get_bits1(gb);
-
- if (s->present) {
- s->hflip = get_bits1(gb); // hor_flip
- s->vflip = get_bits1(gb); // ver_flip
-
- s->anticlockwise_rotation = get_bits(gb, 16);
- // skip_bits1(gb); // display_orientation_persistence_flag
- }
-
- return 0;
-}
-
static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
const HEVCParamSets *ps, void *logctx)
{
@@ -161,182 +126,6 @@ static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb,
return 0;
}
-static int decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s,
- GetByteContext *gb)
-{
- int ret;
-
- ret = ff_parse_a53_cc(&s->buf_ref, gb->buffer,
- bytestream2_get_bytes_left(gb));
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s,
- GetByteContext *gb)
-{
- AVBufferRef *buf_ref, **tmp;
- int size = bytestream2_get_bytes_left(gb);
-
- if (size < 16 || size >= INT_MAX - 1)
- return AVERROR_INVALIDDATA;
-
- tmp = av_realloc_array(s->buf_ref, s->nb_buf_ref + 1, sizeof(*s->buf_ref));
- if (!tmp)
- return AVERROR(ENOMEM);
- s->buf_ref = tmp;
-
- buf_ref = av_buffer_alloc(size + 1);
- if (!buf_ref)
- return AVERROR(ENOMEM);
-
- bytestream2_get_bufferu(gb, buf_ref->data, size);
- buf_ref->data[size] = 0;
- buf_ref->size = size;
- s->buf_ref[s->nb_buf_ref++] = buf_ref;
-
- return 0;
-}
-
-static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
- GetByteContext *gb)
-{
- size_t meta_size;
- int err;
- AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
- if (!metadata)
- return AVERROR(ENOMEM);
-
- err = ff_parse_itu_t_t35_to_dynamic_hdr10_plus(metadata, gb->buffer,
- bytestream2_get_bytes_left(gb));
- if (err < 0) {
- av_free(metadata);
- return err;
- }
-
- av_buffer_unref(&s->info);
- s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
- if (!s->info) {
- av_free(metadata);
- return AVERROR(ENOMEM);
- }
-
- return 0;
-}
-
-static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s,
- GetByteContext *gb)
-{
- size_t meta_size;
- int err;
- AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size);
- if (!metadata)
- return AVERROR(ENOMEM);
-
- err = ff_parse_itu_t_t35_to_dynamic_hdr_vivid(metadata,
- gb->buffer, bytestream2_get_bytes_left(gb));
- if (err < 0) {
- av_free(metadata);
- return err;
- }
-
- av_buffer_unref(&s->info);
- s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
- if (!s->info) {
- av_free(metadata);
- return AVERROR(ENOMEM);
- }
-
- return 0;
-}
-
-static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetByteContext *gb,
- void *logctx)
-{
- int country_code, provider_code;
-
- if (bytestream2_get_bytes_left(gb) < 3)
- return AVERROR_INVALIDDATA;
-
- country_code = bytestream2_get_byteu(gb);
- if (country_code == 0xFF) {
- if (bytestream2_get_bytes_left(gb) < 3)
- return AVERROR_INVALIDDATA;
-
- bytestream2_skipu(gb, 1);
- }
-
- if (country_code != 0xB5 && country_code != 0x26) { // usa_country_code and cn_country_code
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (country_code = 0x%x)\n",
- country_code);
- return 0;
- }
-
- provider_code = bytestream2_get_be16u(gb);
-
- switch (provider_code) {
- case 0x04: { // cuva_provider_code
- const uint16_t cuva_provider_oriented_code = 0x0005;
- uint16_t provider_oriented_code;
-
- if (bytestream2_get_bytes_left(gb) < 2)
- return AVERROR_INVALIDDATA;
-
- provider_oriented_code = bytestream2_get_be16u(gb);
- if (provider_oriented_code == cuva_provider_oriented_code) {
- return decode_registered_user_data_dynamic_hdr_vivid(&s->dynamic_hdr_vivid, gb);
- }
- break;
- }
- case 0x3C: { // smpte_provider_code
- // A/341 Amendment - 2094-40
- const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
- const uint8_t smpte2094_40_application_identifier = 0x04;
- uint16_t provider_oriented_code;
- uint8_t application_identifier;
-
- if (bytestream2_get_bytes_left(gb) < 3)
- return AVERROR_INVALIDDATA;
-
- provider_oriented_code = bytestream2_get_be16u(gb);
- application_identifier = bytestream2_get_byteu(gb);
- if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
- application_identifier == smpte2094_40_application_identifier) {
- return decode_registered_user_data_dynamic_hdr_plus(&s->dynamic_hdr_plus, gb);
- }
- break;
- }
- case 0x31: { // atsc_provider_code
- uint32_t user_identifier;
-
- if (bytestream2_get_bytes_left(gb) < 4)
- return AVERROR_INVALIDDATA;
-
- user_identifier = bytestream2_get_be32u(gb);
- switch (user_identifier) {
- case MKBETAG('G', 'A', '9', '4'):
- return decode_registered_user_data_closed_caption(&s->a53_caption, gb);
- default:
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
- user_identifier);
- break;
- }
- break;
- }
- default:
- av_log(logctx, AV_LOG_VERBOSE,
- "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
- provider_code);
- break;
- }
-
- return 0;
-}
-
static int decode_nal_sei_active_parameter_sets(HEVCSEI *s, GetBitContext *gb, void *logctx)
{
int num_sps_ids_minus1;
@@ -362,18 +151,6 @@ static int decode_nal_sei_active_parameter_sets(HEVCSEI *s, GetBitContext *gb, v
return 0;
}
-static int decode_nal_sei_alternative_transfer(HEVCSEIAlternativeTransfer *s,
- GetByteContext *gb)
-{
- if (bytestream2_get_bytes_left(gb) < 1)
- return AVERROR_INVALIDDATA;
-
- s->present = 1;
- s->preferred_transfer_characteristics = bytestream2_get_byteu(gb);
-
- return 0;
-}
-
static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
{
s->num_clock_ts = get_bits(gb, 2);
@@ -420,49 +197,6 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
return 0;
}
-static int decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h,
- GetBitContext *gb)
-{
- h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
-
- if (h->present) {
- memset(h, 0, sizeof(*h));
- h->model_id = get_bits(gb, 2);
- h->separate_colour_description_present_flag = get_bits1(gb);
- if (h->separate_colour_description_present_flag) {
- h->bit_depth_luma = get_bits(gb, 3) + 8;
- h->bit_depth_chroma = get_bits(gb, 3) + 8;
- h->full_range = get_bits1(gb);
- h->color_primaries = get_bits(gb, 8);
- h->transfer_characteristics = get_bits(gb, 8);
- h->matrix_coeffs = get_bits(gb, 8);
- }
- h->blending_mode_id = get_bits(gb, 2);
- h->log2_scale_factor = get_bits(gb, 4);
- for (int c = 0; c < 3; c++)
- h->comp_model_present_flag[c] = get_bits1(gb);
- for (int c = 0; c < 3; c++) {
- if (h->comp_model_present_flag[c]) {
- h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
- h->num_model_values[c] = get_bits(gb, 3) + 1;
- if (h->num_model_values[c] > 6)
- return AVERROR_INVALIDDATA;
- for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
- h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
- h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
- for (int j = 0; j < h->num_model_values[c]; j++)
- h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
- }
- }
- }
- h->persistence_flag = get_bits1(gb);
-
- h->present = 1;
- }
-
- return 0;
-}
-
static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
void *logctx, HEVCSEI *s,
const HEVCParamSets *ps, int type)
@@ -470,10 +204,6 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
switch (type) {
case 256: // Mismatched value from HM 8.1
return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gbyte);
- case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
- return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
- case SEI_TYPE_DISPLAY_ORIENTATION:
- return decode_nal_sei_display_orientation(&s->display_orientation, gb);
case SEI_TYPE_PIC_TIMING:
return decode_nal_sei_pic_timing(s, gb, ps, logctx);
case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
@@ -482,19 +212,15 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
return decode_nal_sei_content_light_info(&s->content_light, gbyte);
case SEI_TYPE_ACTIVE_PARAMETER_SETS:
return decode_nal_sei_active_parameter_sets(s, gb, logctx);
- case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
- return decode_nal_sei_user_data_registered_itu_t_t35(s, gbyte, logctx);
- case SEI_TYPE_USER_DATA_UNREGISTERED:
- return decode_nal_sei_user_data_unregistered(&s->unregistered, gbyte);
- case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
- return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gbyte);
case SEI_TYPE_TIME_CODE:
return decode_nal_sei_timecode(&s->timecode, gb);
- case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
- return decode_film_grain_characteristics(&s->film_grain_characteristics, gb);
- default:
- av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
- return 0;
+ default: {
+ int ret = ff_h2645_sei_message_decode(&s->common, type, AV_CODEC_ID_HEVC,
+ gb, gbyte, logctx);
+ if (ret == FF_H2645_SEI_MESSAGE_UNHANDLED)
+ av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
+ return ret;
+ }
}
}
@@ -569,12 +295,12 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
void ff_hevc_reset_sei(HEVCSEI *s)
{
- av_buffer_unref(&s->a53_caption.buf_ref);
-
- for (int i = 0; i < s->unregistered.nb_buf_ref; i++)
- av_buffer_unref(&s->unregistered.buf_ref[i]);
- s->unregistered.nb_buf_ref = 0;
- av_freep(&s->unregistered.buf_ref);
- av_buffer_unref(&s->dynamic_hdr_plus.info);
- av_buffer_unref(&s->dynamic_hdr_vivid.info);
+ av_buffer_unref(&s->common.a53_caption.buf_ref);
+
+ for (int i = 0; i < s->common.unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&s->common.unregistered.buf_ref[i]);
+ s->common.unregistered.nb_buf_ref = 0;
+ av_freep(&s->common.unregistered.buf_ref);
+ av_buffer_unref(&s->common.dynamic_hdr_plus.info);
+ av_buffer_unref(&s->common.dynamic_hdr_vivid.info);
}
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index ef987f6781..8ea0245802 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -27,6 +27,7 @@
#include "get_bits.h"
#include "hevc.h"
+#include "h2645_sei.h"
#include "sei.h"
@@ -48,25 +49,10 @@ typedef struct HEVCSEIFramePacking {
int current_frame_is_frame0_flag;
} HEVCSEIFramePacking;
-typedef struct HEVCSEIDisplayOrientation {
- int present;
- int anticlockwise_rotation;
- int hflip, vflip;
-} HEVCSEIDisplayOrientation;
-
typedef struct HEVCSEIPictureTiming {
int picture_struct;
} HEVCSEIPictureTiming;
-typedef struct HEVCSEIA53Caption {
- AVBufferRef *buf_ref;
-} HEVCSEIA53Caption;
-
-typedef struct HEVCSEIUnregistered {
- AVBufferRef **buf_ref;
- int nb_buf_ref;
-} HEVCSEIUnregistered;
-
typedef struct HEVCSEIMasteringDisplay {
int present;
uint16_t display_primaries[3][2];
@@ -75,14 +61,6 @@ typedef struct HEVCSEIMasteringDisplay {
uint32_t min_luminance;
} HEVCSEIMasteringDisplay;
-typedef struct HEVCSEIDynamicHDRPlus {
- AVBufferRef *info;
-} HEVCSEIDynamicHDRPlus;
-
-typedef struct HEVCSEIDynamicHDRVivid {
- AVBufferRef *info;
-} HEVCSEIDynamicHDRVivid;
-
typedef struct HEVCSEIContentLight {
int present;
uint16_t max_content_light_level;
@@ -114,42 +92,14 @@ typedef struct HEVCSEITimeCode {
int32_t time_offset_value[3];
} HEVCSEITimeCode;
-typedef struct HEVCSEIFilmGrainCharacteristics {
- int present;
- int model_id;
- int separate_colour_description_present_flag;
- int bit_depth_luma;
- int bit_depth_chroma;
- int full_range;
- int color_primaries;
- int transfer_characteristics;
- int matrix_coeffs;
- int blending_mode_id;
- int log2_scale_factor;
- int comp_model_present_flag[3];
- uint16_t num_intensity_intervals[3];
- uint8_t num_model_values[3];
- uint8_t intensity_interval_lower_bound[3][256];
- uint8_t intensity_interval_upper_bound[3][256];
- int16_t comp_model_value[3][256][6];
- int persistence_flag;
-} HEVCSEIFilmGrainCharacteristics;
-
typedef struct HEVCSEI {
+ H2645SEI common;
HEVCSEIPictureHash picture_hash;
- HEVCSEIFramePacking frame_packing;
- HEVCSEIDisplayOrientation display_orientation;
HEVCSEIPictureTiming picture_timing;
- HEVCSEIA53Caption a53_caption;
- HEVCSEIUnregistered unregistered;
HEVCSEIMasteringDisplay mastering_display;
- HEVCSEIDynamicHDRPlus dynamic_hdr_plus;
- HEVCSEIDynamicHDRVivid dynamic_hdr_vivid;
HEVCSEIContentLight content_light;
int active_seq_parameter_set_id;
- HEVCSEIAlternativeTransfer alternative_transfer;
HEVCSEITimeCode timecode;
- HEVCSEIFilmGrainCharacteristics film_grain_characteristics;
} HEVCSEI;
struct HEVCParamSets;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index f222f20706..69e65482dd 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -382,16 +382,16 @@ static int export_stream_params_from_sei(HEVCContext *s)
{
AVCodecContext *avctx = s->avctx;
- if (s->sei.a53_caption.buf_ref)
+ if (s->sei.common.a53_caption.buf_ref)
s->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
- if (s->sei.alternative_transfer.present &&
- av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics) &&
- s->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
- avctx->color_trc = s->sei.alternative_transfer.preferred_transfer_characteristics;
+ if (s->sei.common.alternative_transfer.present &&
+ av_color_transfer_name(s->sei.common.alternative_transfer.preferred_transfer_characteristics) &&
+ s->sei.common.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) {
+ avctx->color_trc = s->sei.common.alternative_transfer.preferred_transfer_characteristics;
}
- if (s->sei.film_grain_characteristics.present)
+ if (s->sei.common.film_grain_characteristics.present)
avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
return 0;
@@ -2731,18 +2731,18 @@ static int set_side_data(HEVCContext *s)
AVFrame *out = s->ref->frame;
int ret;
- if (s->sei.frame_packing.present &&
- s->sei.frame_packing.arrangement_type >= 3 &&
- s->sei.frame_packing.arrangement_type <= 5 &&
- s->sei.frame_packing.content_interpretation_type > 0 &&
- s->sei.frame_packing.content_interpretation_type < 3) {
+ if (s->sei.common.frame_packing.present &&
+ s->sei.common.frame_packing.arrangement_type >= 3 &&
+ s->sei.common.frame_packing.arrangement_type <= 5 &&
+ s->sei.common.frame_packing.content_interpretation_type > 0 &&
+ s->sei.common.frame_packing.content_interpretation_type < 3) {
AVStereo3D *stereo = av_stereo3d_create_side_data(out);
if (!stereo)
return AVERROR(ENOMEM);
- switch (s->sei.frame_packing.arrangement_type) {
+ switch (s->sei.common.frame_packing.arrangement_type) {
case 3:
- if (s->sei.frame_packing.quincunx_subsampling)
+ if (s->sei.common.frame_packing.quincunx_sampling_flag)
stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
else
stereo->type = AV_STEREO3D_SIDEBYSIDE;
@@ -2755,21 +2755,21 @@ static int set_side_data(HEVCContext *s)
break;
}
- if (s->sei.frame_packing.content_interpretation_type == 2)
+ if (s->sei.common.frame_packing.content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
- if (s->sei.frame_packing.arrangement_type == 5) {
- if (s->sei.frame_packing.current_frame_is_frame0_flag)
+ if (s->sei.common.frame_packing.arrangement_type == 5) {
+ if (s->sei.common.frame_packing.current_frame_is_frame0_flag)
stereo->view = AV_STEREO3D_VIEW_LEFT;
else
stereo->view = AV_STEREO3D_VIEW_RIGHT;
}
}
- if (s->sei.display_orientation.present &&
- (s->sei.display_orientation.anticlockwise_rotation ||
- s->sei.display_orientation.hflip || s->sei.display_orientation.vflip)) {
- double angle = s->sei.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16);
+ if (s->sei.common.display_orientation.present &&
+ (s->sei.common.display_orientation.anticlockwise_rotation ||
+ s->sei.common.display_orientation.hflip || s->sei.common.display_orientation.vflip)) {
+ double angle = s->sei.common.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16);
AVFrameSideData *rotation = av_frame_new_side_data(out,
AV_FRAME_DATA_DISPLAYMATRIX,
sizeof(int32_t) * 9);
@@ -2784,12 +2784,12 @@ static int set_side_data(HEVCContext *s)
* an arbitatry axis and O(phi) is the proper rotation by phi)
* we can create display matrices as desired by negating
* the degree once for every flip applied. */
- angle = -angle * (1 - 2 * !!s->sei.display_orientation.hflip)
- * (1 - 2 * !!s->sei.display_orientation.vflip);
+ angle = -angle * (1 - 2 * !!s->sei.common.display_orientation.hflip)
+ * (1 - 2 * !!s->sei.common.display_orientation.vflip);
av_display_rotation_set((int32_t *)rotation->data, angle);
av_display_matrix_flip((int32_t *)rotation->data,
- s->sei.display_orientation.hflip,
- s->sei.display_orientation.vflip);
+ s->sei.common.display_orientation.hflip,
+ s->sei.common.display_orientation.vflip);
}
// Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1
@@ -2861,8 +2861,8 @@ static int set_side_data(HEVCContext *s)
metadata->MaxCLL, metadata->MaxFALL);
}
- if (s->sei.a53_caption.buf_ref) {
- HEVCSEIA53Caption *a53 = &s->sei.a53_caption;
+ if (s->sei.common.a53_caption.buf_ref) {
+ H2645SEIA53Caption *a53 = &s->sei.common.a53_caption;
AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref);
if (!sd)
@@ -2870,8 +2870,8 @@ static int set_side_data(HEVCContext *s)
a53->buf_ref = NULL;
}
- for (int i = 0; i < s->sei.unregistered.nb_buf_ref; i++) {
- HEVCSEIUnregistered *unreg = &s->sei.unregistered;
+ for (int i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++) {
+ H2645SEIUnregistered *unreg = &s->sei.common.unregistered;
if (unreg->buf_ref[i]) {
AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
@@ -2882,7 +2882,7 @@ static int set_side_data(HEVCContext *s)
unreg->buf_ref[i] = NULL;
}
}
- s->sei.unregistered.nb_buf_ref = 0;
+ s->sei.common.unregistered.nb_buf_ref = 0;
if (s->sei.timecode.present) {
uint32_t *tc_sd;
@@ -2910,8 +2910,8 @@ static int set_side_data(HEVCContext *s)
s->sei.timecode.num_clock_ts = 0;
}
- if (s->sei.film_grain_characteristics.present) {
- HEVCSEIFilmGrainCharacteristics *fgc = &s->sei.film_grain_characteristics;
+ if (s->sei.common.film_grain_characteristics.present) {
+ H2645SEIFilmGrainCharacteristics *fgc = &s->sei.common.film_grain_characteristics;
AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out);
if (!fgp)
return AVERROR(ENOMEM);
@@ -2965,8 +2965,8 @@ static int set_side_data(HEVCContext *s)
fgc->present = fgc->persistence_flag;
}
- if (s->sei.dynamic_hdr_plus.info) {
- AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_plus.info);
+ if (s->sei.common.dynamic_hdr_plus.info) {
+ AVBufferRef *info_ref = av_buffer_ref(s->sei.common.dynamic_hdr_plus.info);
if (!info_ref)
return AVERROR(ENOMEM);
@@ -2987,8 +2987,8 @@ static int set_side_data(HEVCContext *s)
if ((ret = ff_dovi_attach_side_data(&s->dovi_ctx, out)) < 0)
return ret;
- if (s->sei.dynamic_hdr_vivid.info) {
- AVBufferRef *info_ref = av_buffer_ref(s->sei.dynamic_hdr_vivid.info);
+ if (s->sei.common.dynamic_hdr_vivid.info) {
+ AVBufferRef *info_ref = av_buffer_ref(s->sei.common.dynamic_hdr_vivid.info);
if (!info_ref)
return AVERROR(ENOMEM);
@@ -3034,7 +3034,7 @@ static int hevc_frame_start(HEVCContext *s)
s->ref->frame->key_frame = IS_IRAP(s);
- s->ref->needs_fg = s->sei.film_grain_characteristics.present &&
+ s->ref->needs_fg = s->sei.common.film_grain_characteristics.present &&
!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
!s->avctx->hwaccel;
@@ -3745,30 +3745,32 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->max_ra = INT_MAX;
}
- ret = av_buffer_replace(&s->sei.a53_caption.buf_ref, s0->sei.a53_caption.buf_ref);
+ ret = av_buffer_replace(&s->sei.common.a53_caption.buf_ref,
+ s0->sei.common.a53_caption.buf_ref);
if (ret < 0)
return ret;
- for (i = 0; i < s->sei.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&s->sei.unregistered.buf_ref[i]);
- s->sei.unregistered.nb_buf_ref = 0;
+ for (i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&s->sei.common.unregistered.buf_ref[i]);
+ s->sei.common.unregistered.nb_buf_ref = 0;
- if (s0->sei.unregistered.nb_buf_ref) {
- ret = av_reallocp_array(&s->sei.unregistered.buf_ref,
- s0->sei.unregistered.nb_buf_ref,
- sizeof(*s->sei.unregistered.buf_ref));
+ if (s0->sei.common.unregistered.nb_buf_ref) {
+ ret = av_reallocp_array(&s->sei.common.unregistered.buf_ref,
+ s0->sei.common.unregistered.nb_buf_ref,
+ sizeof(*s->sei.common.unregistered.buf_ref));
if (ret < 0)
return ret;
- for (i = 0; i < s0->sei.unregistered.nb_buf_ref; i++) {
- s->sei.unregistered.buf_ref[i] = av_buffer_ref(s0->sei.unregistered.buf_ref[i]);
- if (!s->sei.unregistered.buf_ref[i])
+ for (i = 0; i < s0->sei.common.unregistered.nb_buf_ref; i++) {
+ s->sei.common.unregistered.buf_ref[i] = av_buffer_ref(s0->sei.common.unregistered.buf_ref[i]);
+ if (!s->sei.common.unregistered.buf_ref[i])
return AVERROR(ENOMEM);
- s->sei.unregistered.nb_buf_ref++;
+ s->sei.common.unregistered.nb_buf_ref++;
}
}
- ret = av_buffer_replace(&s->sei.dynamic_hdr_plus.info, s0->sei.dynamic_hdr_plus.info);
+ ret = av_buffer_replace(&s->sei.common.dynamic_hdr_plus.info,
+ s0->sei.common.dynamic_hdr_plus.info);
if (ret < 0)
return ret;
@@ -3780,15 +3782,16 @@ static int hevc_update_thread_context(AVCodecContext *dst,
if (ret < 0)
return ret;
- ret = av_buffer_replace(&s->sei.dynamic_hdr_vivid.info, s0->sei.dynamic_hdr_vivid.info);
+ ret = av_buffer_replace(&s->sei.common.dynamic_hdr_vivid.info,
+ s0->sei.common.dynamic_hdr_vivid.info);
if (ret < 0)
return ret;
- s->sei.frame_packing = s0->sei.frame_packing;
- s->sei.display_orientation = s0->sei.display_orientation;
+ s->sei.common.frame_packing = s0->sei.common.frame_packing;
+ s->sei.common.display_orientation = s0->sei.common.display_orientation;
+ s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer;
s->sei.mastering_display = s0->sei.mastering_display;
s->sei.content_light = s0->sei.content_light;
- s->sei.alternative_transfer = s0->sei.alternative_transfer;
ret = export_stream_params_from_sei(s);
if (ret < 0)
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 08/20] avcodec/h2645_sei: Factor updating H.2645 SEIs out
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (5 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 07/20] avcodec/h2645_sei: Factor parsing common SEI messages out Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 09/20] avcodec/h2645_sei: Factor out freeing common SEI parts Andreas Rheinhardt
` (12 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 29 +++++++++++++++++++++++++++++
libavcodec/h2645_sei.h | 2 ++
libavcodec/h264_sei.h | 6 ++++++
libavcodec/h264_slice.c | 21 +--------------------
libavcodec/hevc_sei.h | 5 +++++
libavcodec/hevcdec.c | 22 +---------------------
6 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 5ff62bfac1..21208fa920 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -389,3 +389,32 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
return FF_H2645_SEI_MESSAGE_UNHANDLED;
}
}
+
+int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
+{
+ int ret = av_buffer_replace(&dst->a53_caption.buf_ref,
+ src->a53_caption.buf_ref);
+ if (ret < 0)
+ return ret;
+
+ for (unsigned i = 0; i < dst->unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&dst->unregistered.buf_ref[i]);
+ dst->unregistered.nb_buf_ref = 0;
+
+ if (src->unregistered.nb_buf_ref) {
+ ret = av_reallocp_array(&dst->unregistered.buf_ref,
+ src->unregistered.nb_buf_ref,
+ sizeof(*dst->unregistered.buf_ref));
+ if (ret < 0)
+ return ret;
+
+ for (unsigned i = 0; i < src->unregistered.nb_buf_ref; i++) {
+ dst->unregistered.buf_ref[i] = av_buffer_ref(src->unregistered.buf_ref[i]);
+ if (!dst->unregistered.buf_ref[i])
+ return AVERROR(ENOMEM);
+ dst->unregistered.nb_buf_ref++;
+ }
+ }
+
+ return 0;
+}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 4128ff7940..e87a669b3e 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -130,4 +130,6 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
enum AVCodecID codec_id, GetBitContext *gb,
GetByteContext *gbyte, void *logctx);
+int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
+
#endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 7a53d01ac5..003f427ac3 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -142,6 +142,12 @@ struct H264ParamSets;
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
const struct H264ParamSets *ps, void *logctx);
+static inline int ff_h264_sei_ctx_replace(H264SEIContext *dst,
+ const H264SEIContext *src)
+{
+ return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
+}
+
/**
* Reset SEI values at the beginning of the frame.
*/
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a6d8d2bdac..fb7aed998b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -433,29 +433,10 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
h->frame_recovered = h1->frame_recovered;
- ret = av_buffer_replace(&h->sei.common.a53_caption.buf_ref,
- h1->sei.common.a53_caption.buf_ref);
+ ret = ff_h264_sei_ctx_replace(&h->sei, &h1->sei);
if (ret < 0)
return ret;
- for (i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&h->sei.common.unregistered.buf_ref[i]);
- h->sei.common.unregistered.nb_buf_ref = 0;
-
- if (h1->sei.common.unregistered.nb_buf_ref) {
- ret = av_reallocp_array(&h->sei.common.unregistered.buf_ref,
- h1->sei.common.unregistered.nb_buf_ref,
- sizeof(*h->sei.common.unregistered.buf_ref));
- if (ret < 0)
- return ret;
-
- for (i = 0; i < h1->sei.common.unregistered.nb_buf_ref; i++) {
- h->sei.common.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.common.unregistered.buf_ref[i]);
- if (!h->sei.common.unregistered.buf_ref[i])
- return AVERROR(ENOMEM);
- h->sei.common.unregistered.nb_buf_ref++;
- }
- }
h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
if (!h->cur_pic_ptr)
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 8ea0245802..2bb6b7e48b 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -107,6 +107,11 @@ struct HEVCParamSets;
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
+static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src)
+{
+ return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
+}
+
/**
* Reset SEI values that are stored on the Context.
* e.g. Caption data that was extracted during NAL
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 69e65482dd..698fb50a6c 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3745,30 +3745,10 @@ static int hevc_update_thread_context(AVCodecContext *dst,
s->max_ra = INT_MAX;
}
- ret = av_buffer_replace(&s->sei.common.a53_caption.buf_ref,
- s0->sei.common.a53_caption.buf_ref);
+ ret = ff_h2645_sei_ctx_replace(&s->sei.common, &s0->sei.common);
if (ret < 0)
return ret;
- for (i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&s->sei.common.unregistered.buf_ref[i]);
- s->sei.common.unregistered.nb_buf_ref = 0;
-
- if (s0->sei.common.unregistered.nb_buf_ref) {
- ret = av_reallocp_array(&s->sei.common.unregistered.buf_ref,
- s0->sei.common.unregistered.nb_buf_ref,
- sizeof(*s->sei.common.unregistered.buf_ref));
- if (ret < 0)
- return ret;
-
- for (i = 0; i < s0->sei.common.unregistered.nb_buf_ref; i++) {
- s->sei.common.unregistered.buf_ref[i] = av_buffer_ref(s0->sei.common.unregistered.buf_ref[i]);
- if (!s->sei.common.unregistered.buf_ref[i])
- return AVERROR(ENOMEM);
- s->sei.common.unregistered.nb_buf_ref++;
- }
- }
-
ret = av_buffer_replace(&s->sei.common.dynamic_hdr_plus.info,
s0->sei.common.dynamic_hdr_plus.info);
if (ret < 0)
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 09/20] avcodec/h2645_sei: Factor out freeing common SEI parts
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (6 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 08/20] avcodec/h2645_sei: Factor updating H.2645 SEIs out Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames Andreas Rheinhardt
` (11 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This commit only factors out freeing the common SEI parts,
not whether the fields indicating whether an SEI is present
shall be reset. H.264 and HEVC differ in this regard
(ff_h264_sei_uninit() really resets, whereas ff_hevc_reset_sei()
only uninits.) and neither actually honours the persistency
as prescribed by the relevant specs.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 12 ++++++++++++
libavcodec/h2645_sei.h | 2 ++
libavcodec/h264_sei.c | 6 +-----
libavcodec/hevc_sei.c | 12 ------------
libavcodec/hevc_sei.h | 7 +++++--
5 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 21208fa920..6be3d97c92 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -418,3 +418,15 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
return 0;
}
+
+void ff_h2645_sei_reset(H2645SEI *s)
+{
+ av_buffer_unref(&s->a53_caption.buf_ref);
+
+ for (int i = 0; i < s->unregistered.nb_buf_ref; i++)
+ av_buffer_unref(&s->unregistered.buf_ref[i]);
+ s->unregistered.nb_buf_ref = 0;
+ av_freep(&s->unregistered.buf_ref);
+ av_buffer_unref(&s->dynamic_hdr_plus.info);
+ av_buffer_unref(&s->dynamic_hdr_vivid.info);
+}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index e87a669b3e..3e088f3307 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -132,4 +132,6 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
+void ff_h2645_sei_reset(H2645SEI *s);
+
#endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index c62aef9246..f11f8371f6 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -59,11 +59,7 @@ void ff_h264_sei_uninit(H264SEIContext *h)
h->common.display_orientation.present = 0;
h->common.afd.present = 0;
- av_buffer_unref(&h->common.a53_caption.buf_ref);
- for (int i = 0; i < h->common.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&h->common.unregistered.buf_ref[i]);
- h->common.unregistered.nb_buf_ref = 0;
- av_freep(&h->common.unregistered.buf_ref);
+ ff_h2645_sei_reset(&h->common);
}
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index b0a4a8b035..3c6bde1b62 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -292,15 +292,3 @@ int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
} while (bytestream2_get_bytes_left(&gbyte) > 0);
return 1;
}
-
-void ff_hevc_reset_sei(HEVCSEI *s)
-{
- av_buffer_unref(&s->common.a53_caption.buf_ref);
-
- for (int i = 0; i < s->common.unregistered.nb_buf_ref; i++)
- av_buffer_unref(&s->common.unregistered.buf_ref[i]);
- s->common.unregistered.nb_buf_ref = 0;
- av_freep(&s->common.unregistered.buf_ref);
- av_buffer_unref(&s->common.dynamic_hdr_plus.info);
- av_buffer_unref(&s->common.dynamic_hdr_vivid.info);
-}
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2bb6b7e48b..4189f5e6f7 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -117,8 +117,11 @@ static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src)
* e.g. Caption data that was extracted during NAL
* parsing.
*
- * @param s HEVCContext.
+ * @param sei HEVCSEI.
*/
-void ff_hevc_reset_sei(HEVCSEI *s);
+static inline void ff_hevc_reset_sei(HEVCSEI *sei)
+{
+ ff_h2645_sei_reset(&sei->common);
+}
#endif /* AVCODEC_HEVC_SEI_H */
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (7 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 09/20] avcodec/h2645_sei: Factor out freeing common SEI parts Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic Andreas Rheinhardt
` (10 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 57 +++++++++++++++++++++++++++++++++++++++++
libavcodec/h2645_sei.h | 4 +++
libavcodec/h264_slice.c | 53 +++-----------------------------------
libavcodec/hevcdec.c | 51 +++---------------------------------
4 files changed, 68 insertions(+), 97 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 6be3d97c92..6c7a6ea291 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -419,6 +419,63 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
return 0;
}
+int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
+ enum AVCodecID codec_id,
+ AVCodecContext *avctx)
+{
+ if (sei->display_orientation.present &&
+ (sei->display_orientation.anticlockwise_rotation ||
+ sei->display_orientation.hflip ||
+ sei->display_orientation.vflip)) {
+ H2645SEIDisplayOrientation *o = &sei->display_orientation;
+ double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
+ AVFrameSideData *rotation = av_frame_new_side_data(frame,
+ AV_FRAME_DATA_DISPLAYMATRIX,
+ sizeof(int32_t) * 9);
+ if (!rotation)
+ return AVERROR(ENOMEM);
+
+ /* av_display_rotation_set() expects the angle in the clockwise
+ * direction, hence the first minus.
+ * The below code applies the flips after the rotation, yet
+ * the H.2645 specs require flipping to be applied first.
+ * Because of R O(phi) = O(-phi) R (where R is flipping around
+ * an arbitatry axis and O(phi) is the proper rotation by phi)
+ * we can create display matrices as desired by negating
+ * the degree once for every flip applied. */
+ angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip);
+ av_display_rotation_set((int32_t *)rotation->data, angle);
+ av_display_matrix_flip((int32_t *)rotation->data,
+ o->hflip, o->vflip);
+ }
+
+ if (sei->a53_caption.buf_ref) {
+ H2645SEIA53Caption *a53 = &sei->a53_caption;
+ AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, a53->buf_ref);
+ if (!sd)
+ av_buffer_unref(&a53->buf_ref);
+ a53->buf_ref = NULL;
+ if (avctx)
+ avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
+ }
+
+ for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) {
+ H2645SEIUnregistered *unreg = &sei->unregistered;
+
+ if (unreg->buf_ref[i]) {
+ AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame,
+ AV_FRAME_DATA_SEI_UNREGISTERED,
+ unreg->buf_ref[i]);
+ if (!sd)
+ av_buffer_unref(&unreg->buf_ref[i]);
+ unreg->buf_ref[i] = NULL;
+ }
+ }
+ sei->unregistered.nb_buf_ref = 0;
+
+ return 0;
+}
+
void ff_h2645_sei_reset(H2645SEI *s)
{
av_buffer_unref(&s->a53_caption.buf_ref);
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 3e088f3307..4600caab29 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -134,4 +134,8 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
void ff_h2645_sei_reset(H2645SEI *s);
+int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
+ enum AVCodecID codec_id,
+ AVCodecContext *avctx);
+
#endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index fb7aed998b..18b9ae5b09 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1144,6 +1144,7 @@ static int h264_export_frame_props(H264Context *h)
const SPS *sps = h->ps.sps;
H264Picture *cur = h->cur_pic_ptr;
AVFrame *out = cur->f;
+ int ret;
out->interlaced_frame = 0;
out->repeat_pict = 0;
@@ -1271,31 +1272,6 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.common.display_orientation.present &&
- (h->sei.common.display_orientation.anticlockwise_rotation ||
- h->sei.common.display_orientation.hflip ||
- h->sei.common.display_orientation.vflip)) {
- H2645SEIDisplayOrientation *o = &h->sei.common.display_orientation;
- double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
- AVFrameSideData *rotation = av_frame_new_side_data(out,
- AV_FRAME_DATA_DISPLAYMATRIX,
- sizeof(int32_t) * 9);
- if (rotation) {
- /* av_display_rotation_set() expects the angle in the clockwise
- * direction, hence the first minus.
- * The below code applies the flips after the rotation, yet
- * the H.2645 specs require flipping to be applied first.
- * Because of R O(phi) = O(-phi) R (where R is flipping around
- * an arbitatry axis and O(phi) is the proper rotation by phi)
- * we can create display matrices as desired by negating
- * the degree once for every flip applied. */
- angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip);
- av_display_rotation_set((int32_t *)rotation->data, angle);
- av_display_matrix_flip((int32_t *)rotation->data,
- o->hflip, o->vflip);
- }
- }
-
if (h->sei.common.afd.present) {
AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD,
sizeof(uint8_t));
@@ -1306,30 +1282,9 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.common.a53_caption.buf_ref) {
- H2645SEIA53Caption *a53 = &h->sei.common.a53_caption;
-
- AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref);
- if (!sd)
- av_buffer_unref(&a53->buf_ref);
- a53->buf_ref = NULL;
-
- h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
- }
-
- for (int i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++) {
- H2645SEIUnregistered *unreg = &h->sei.common.unregistered;
-
- if (unreg->buf_ref[i]) {
- AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
- AV_FRAME_DATA_SEI_UNREGISTERED,
- unreg->buf_ref[i]);
- if (!sd)
- av_buffer_unref(&unreg->buf_ref[i]);
- unreg->buf_ref[i] = NULL;
- }
- }
- h->sei.common.unregistered.nb_buf_ref = 0;
+ ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx);
+ if (ret < 0)
+ return ret;
if (h->sei.common.film_grain_characteristics.present) {
H2645SEIFilmGrainCharacteristics *fgc = &h->sei.common.film_grain_characteristics;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 698fb50a6c..465015069c 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2766,32 +2766,6 @@ static int set_side_data(HEVCContext *s)
}
}
- if (s->sei.common.display_orientation.present &&
- (s->sei.common.display_orientation.anticlockwise_rotation ||
- s->sei.common.display_orientation.hflip || s->sei.common.display_orientation.vflip)) {
- double angle = s->sei.common.display_orientation.anticlockwise_rotation * 360 / (double) (1 << 16);
- AVFrameSideData *rotation = av_frame_new_side_data(out,
- AV_FRAME_DATA_DISPLAYMATRIX,
- sizeof(int32_t) * 9);
- if (!rotation)
- return AVERROR(ENOMEM);
-
- /* av_display_rotation_set() expects the angle in the clockwise
- * direction, hence the first minus.
- * The below code applies the flips after the rotation, yet
- * the H.2645 specs require flipping to be applied first.
- * Because of R O(phi) = O(-phi) R (where R is flipping around
- * an arbitatry axis and O(phi) is the proper rotation by phi)
- * we can create display matrices as desired by negating
- * the degree once for every flip applied. */
- angle = -angle * (1 - 2 * !!s->sei.common.display_orientation.hflip)
- * (1 - 2 * !!s->sei.common.display_orientation.vflip);
- av_display_rotation_set((int32_t *)rotation->data, angle);
- av_display_matrix_flip((int32_t *)rotation->data,
- s->sei.common.display_orientation.hflip,
- s->sei.common.display_orientation.vflip);
- }
-
// Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1
// so the side data persists for the entire coded video sequence.
if (s->sei.mastering_display.present > 0 &&
@@ -2861,28 +2835,9 @@ static int set_side_data(HEVCContext *s)
metadata->MaxCLL, metadata->MaxFALL);
}
- if (s->sei.common.a53_caption.buf_ref) {
- H2645SEIA53Caption *a53 = &s->sei.common.a53_caption;
-
- AVFrameSideData *sd = av_frame_new_side_data_from_buf(out, AV_FRAME_DATA_A53_CC, a53->buf_ref);
- if (!sd)
- av_buffer_unref(&a53->buf_ref);
- a53->buf_ref = NULL;
- }
-
- for (int i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++) {
- H2645SEIUnregistered *unreg = &s->sei.common.unregistered;
-
- if (unreg->buf_ref[i]) {
- AVFrameSideData *sd = av_frame_new_side_data_from_buf(out,
- AV_FRAME_DATA_SEI_UNREGISTERED,
- unreg->buf_ref[i]);
- if (!sd)
- av_buffer_unref(&unreg->buf_ref[i]);
- unreg->buf_ref[i] = NULL;
- }
- }
- s->sei.common.unregistered.nb_buf_ref = 0;
+ ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, NULL);
+ if (ret < 0)
+ return ret;
if (s->sei.timecode.present) {
uint32_t *tc_sd;
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (8 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 12/20] avcodec/h2645_sei: Attach AVStereo3D side data generically Andreas Rheinhardt
` (9 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.h | 2 +-
libavcodec/h264_sei.c | 14 +++++++-------
libavcodec/h264_sei.h | 13 -------------
libavcodec/h264_slice.c | 16 ++++++++--------
libavcodec/sei.h | 17 +++++++++++++++++
5 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 4600caab29..4713b89e1f 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -57,7 +57,7 @@ typedef struct H2645SEIFramePacking {
int present;
int arrangement_id;
int arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received (currently H.264 only)
- int arrangement_type;
+ SEIFpaType arrangement_type;
int arrangement_repetition_period;
int content_interpretation_type;
int quincunx_sampling_flag;
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index f11f8371f6..668204959f 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -307,37 +307,37 @@ const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h)
{
if (h->arrangement_cancel_flag == 0) {
switch (h->arrangement_type) {
- case H264_SEI_FPA_TYPE_CHECKERBOARD:
+ case SEI_FPA_H264_TYPE_CHECKERBOARD:
if (h->content_interpretation_type == 2)
return "checkerboard_rl";
else
return "checkerboard_lr";
- case H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN:
+ case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
if (h->content_interpretation_type == 2)
return "col_interleaved_rl";
else
return "col_interleaved_lr";
- case H264_SEI_FPA_TYPE_INTERLEAVE_ROW:
+ case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
if (h->content_interpretation_type == 2)
return "row_interleaved_rl";
else
return "row_interleaved_lr";
- case H264_SEI_FPA_TYPE_SIDE_BY_SIDE:
+ case SEI_FPA_TYPE_SIDE_BY_SIDE:
if (h->content_interpretation_type == 2)
return "right_left";
else
return "left_right";
- case H264_SEI_FPA_TYPE_TOP_BOTTOM:
+ case SEI_FPA_TYPE_TOP_BOTTOM:
if (h->content_interpretation_type == 2)
return "bottom_top";
else
return "top_bottom";
- case H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
+ case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
if (h->content_interpretation_type == 2)
return "block_rl";
else
return "block_lr";
- case H264_SEI_FPA_TYPE_2D:
+ case SEI_FPA_H264_TYPE_2D:
default:
return "mono";
}
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 003f427ac3..bb9275e569 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -40,19 +40,6 @@ typedef enum {
H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
} H264_SEI_PicStructType;
-/**
- * frame_packing_arrangement types
- */
-typedef enum {
- H264_SEI_FPA_TYPE_CHECKERBOARD = 0,
- H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN = 1,
- H264_SEI_FPA_TYPE_INTERLEAVE_ROW = 2,
- H264_SEI_FPA_TYPE_SIDE_BY_SIDE = 3,
- H264_SEI_FPA_TYPE_TOP_BOTTOM = 4,
- H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL = 5,
- H264_SEI_FPA_TYPE_2D = 6,
-} H264_SEI_FpaType;
-
typedef struct H264SEITimeCode {
/* When not continuously receiving full timecodes, we have to reference
the previous timecode received */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 18b9ae5b09..cd9f9bfa27 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1234,28 +1234,28 @@ static int h264_export_frame_props(H264Context *h)
AVStereo3D *stereo = av_stereo3d_create_side_data(out);
if (stereo) {
switch (fp->arrangement_type) {
- case H264_SEI_FPA_TYPE_CHECKERBOARD:
+ case SEI_FPA_H264_TYPE_CHECKERBOARD:
stereo->type = AV_STEREO3D_CHECKERBOARD;
break;
- case H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN:
+ case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
stereo->type = AV_STEREO3D_COLUMNS;
break;
- case H264_SEI_FPA_TYPE_INTERLEAVE_ROW:
+ case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
stereo->type = AV_STEREO3D_LINES;
break;
- case H264_SEI_FPA_TYPE_SIDE_BY_SIDE:
+ case SEI_FPA_TYPE_SIDE_BY_SIDE:
if (fp->quincunx_sampling_flag)
stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
else
stereo->type = AV_STEREO3D_SIDEBYSIDE;
break;
- case H264_SEI_FPA_TYPE_TOP_BOTTOM:
+ case SEI_FPA_TYPE_TOP_BOTTOM:
stereo->type = AV_STEREO3D_TOPBOTTOM;
break;
- case H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
+ case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
stereo->type = AV_STEREO3D_FRAMESEQUENCE;
break;
- case H264_SEI_FPA_TYPE_2D:
+ case SEI_FPA_H264_TYPE_2D:
stereo->type = AV_STEREO3D_2D;
break;
}
@@ -1263,7 +1263,7 @@ static int h264_export_frame_props(H264Context *h)
if (fp->content_interpretation_type == 2)
stereo->flags = AV_STEREO3D_FLAG_INVERT;
- if (fp->arrangement_type == H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
+ if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
if (fp->current_frame_is_frame0_flag)
stereo->view = AV_STEREO3D_VIEW_LEFT;
else
diff --git a/libavcodec/sei.h b/libavcodec/sei.h
index f13c37c308..f96b7b647b 100644
--- a/libavcodec/sei.h
+++ b/libavcodec/sei.h
@@ -137,4 +137,21 @@ enum SEIType {
SEI_TYPE_SAMPLE_ASPECT_RATIO_INFO = 204,
};
+/**
+ * frame_packing_arrangement types. H.265 and H.274 use only 3..5
+ * with all the other values being reserved. H.264 uses a few more values
+ * that are prefixed with SEI_FPA_H264 in the enum below.
+ *
+ * The semantics of the common values are the same for all standards.
+ */
+typedef enum {
+ SEI_FPA_H264_TYPE_CHECKERBOARD = 0,
+ SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN = 1,
+ SEI_FPA_H264_TYPE_INTERLEAVE_ROW = 2,
+ SEI_FPA_TYPE_SIDE_BY_SIDE = 3,
+ SEI_FPA_TYPE_TOP_BOTTOM = 4,
+ SEI_FPA_TYPE_INTERLEAVE_TEMPORAL = 5,
+ SEI_FPA_H264_TYPE_2D = 6,
+} SEIFpaType;
+
#endif /* AVCODEC_SEI_H */
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 12/20] avcodec/h2645_sei: Attach AVStereo3D side data generically
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (9 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 13/20] avcodec/h2645_sei: Also support Active Format Descriptor for HEVC Andreas Rheinhardt
` (8 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
There are only slight differences between H.264 and HEVC
for this side data, so it makes sense to share the code.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 64 +++++++++++++++++++++++++++++++++++++++++
libavcodec/h264_slice.c | 47 ------------------------------
libavcodec/hevcdec.c | 36 -----------------------
3 files changed, 64 insertions(+), 83 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 6c7a6ea291..3575846f9a 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -28,6 +28,7 @@
#include "libavutil/display.h"
#include "libavutil/film_grain_params.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/stereo3d.h"
#include "atsc_a53.h"
#include "avcodec.h"
@@ -419,10 +420,73 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
return 0;
}
+static int is_frame_packing_type_valid(SEIFpaType type, enum AVCodecID codec_id)
+{
+ if (IS_H264(codec_id))
+ return type <= SEI_FPA_H264_TYPE_2D &&
+ type >= SEI_FPA_H264_TYPE_CHECKERBOARD;
+ else
+ return type <= SEI_FPA_TYPE_INTERLEAVE_TEMPORAL &&
+ type >= SEI_FPA_TYPE_SIDE_BY_SIDE;
+}
+
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
enum AVCodecID codec_id,
AVCodecContext *avctx)
{
+ H2645SEIFramePacking *fp = &sei->frame_packing;
+
+ if (fp->present &&
+ is_frame_packing_type_valid(fp->arrangement_type, codec_id) &&
+ fp->content_interpretation_type > 0 &&
+ fp->content_interpretation_type < 3) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
+
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ switch (fp->arrangement_type) {
+#if CONFIG_H264_SEI
+ case SEI_FPA_H264_TYPE_CHECKERBOARD:
+ stereo->type = AV_STEREO3D_CHECKERBOARD;
+ break;
+ case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
+ stereo->type = AV_STEREO3D_COLUMNS;
+ break;
+ case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
+ stereo->type = AV_STEREO3D_LINES;
+ break;
+#endif
+ case SEI_FPA_TYPE_SIDE_BY_SIDE:
+ if (fp->quincunx_sampling_flag)
+ stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ else
+ stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ break;
+ case SEI_FPA_TYPE_TOP_BOTTOM:
+ stereo->type = AV_STEREO3D_TOPBOTTOM;
+ break;
+ case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
+ stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+ break;
+#if CONFIG_H264_SEI
+ case SEI_FPA_H264_TYPE_2D:
+ stereo->type = AV_STEREO3D_2D;
+ break;
+#endif
+ }
+
+ if (fp->content_interpretation_type == 2)
+ stereo->flags = AV_STEREO3D_FLAG_INVERT;
+
+ if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
+ if (fp->current_frame_is_frame0_flag)
+ stereo->view = AV_STEREO3D_VIEW_LEFT;
+ else
+ stereo->view = AV_STEREO3D_VIEW_RIGHT;
+ }
+ }
+
if (sei->display_orientation.present &&
(sei->display_orientation.anticlockwise_rotation ||
sei->display_orientation.hflip ||
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cd9f9bfa27..cc8bec8d9b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -31,7 +31,6 @@
#include "libavutil/display.h"
#include "libavutil/film_grain_params.h"
#include "libavutil/pixdesc.h"
-#include "libavutil/stereo3d.h"
#include "libavutil/timecode.h"
#include "internal.h"
#include "cabac.h"
@@ -1226,52 +1225,6 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.common.frame_packing.present &&
- h->sei.common.frame_packing.arrangement_type <= 6 &&
- h->sei.common.frame_packing.content_interpretation_type > 0 &&
- h->sei.common.frame_packing.content_interpretation_type < 3) {
- H2645SEIFramePacking *fp = &h->sei.common.frame_packing;
- AVStereo3D *stereo = av_stereo3d_create_side_data(out);
- if (stereo) {
- switch (fp->arrangement_type) {
- case SEI_FPA_H264_TYPE_CHECKERBOARD:
- stereo->type = AV_STEREO3D_CHECKERBOARD;
- break;
- case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
- stereo->type = AV_STEREO3D_COLUMNS;
- break;
- case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
- stereo->type = AV_STEREO3D_LINES;
- break;
- case SEI_FPA_TYPE_SIDE_BY_SIDE:
- if (fp->quincunx_sampling_flag)
- stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
- else
- stereo->type = AV_STEREO3D_SIDEBYSIDE;
- break;
- case SEI_FPA_TYPE_TOP_BOTTOM:
- stereo->type = AV_STEREO3D_TOPBOTTOM;
- break;
- case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
- stereo->type = AV_STEREO3D_FRAMESEQUENCE;
- break;
- case SEI_FPA_H264_TYPE_2D:
- stereo->type = AV_STEREO3D_2D;
- break;
- }
-
- if (fp->content_interpretation_type == 2)
- stereo->flags = AV_STEREO3D_FLAG_INVERT;
-
- if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
- if (fp->current_frame_is_frame0_flag)
- stereo->view = AV_STEREO3D_VIEW_LEFT;
- else
- stereo->view = AV_STEREO3D_VIEW_RIGHT;
- }
- }
- }
-
if (h->sei.common.afd.present) {
AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD,
sizeof(uint8_t));
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 465015069c..fdb8de5b15 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -34,7 +34,6 @@
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
-#include "libavutil/stereo3d.h"
#include "libavutil/timecode.h"
#include "bswapdsp.h"
@@ -2731,41 +2730,6 @@ static int set_side_data(HEVCContext *s)
AVFrame *out = s->ref->frame;
int ret;
- if (s->sei.common.frame_packing.present &&
- s->sei.common.frame_packing.arrangement_type >= 3 &&
- s->sei.common.frame_packing.arrangement_type <= 5 &&
- s->sei.common.frame_packing.content_interpretation_type > 0 &&
- s->sei.common.frame_packing.content_interpretation_type < 3) {
- AVStereo3D *stereo = av_stereo3d_create_side_data(out);
- if (!stereo)
- return AVERROR(ENOMEM);
-
- switch (s->sei.common.frame_packing.arrangement_type) {
- case 3:
- if (s->sei.common.frame_packing.quincunx_sampling_flag)
- stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
- else
- stereo->type = AV_STEREO3D_SIDEBYSIDE;
- break;
- case 4:
- stereo->type = AV_STEREO3D_TOPBOTTOM;
- break;
- case 5:
- stereo->type = AV_STEREO3D_FRAMESEQUENCE;
- break;
- }
-
- if (s->sei.common.frame_packing.content_interpretation_type == 2)
- stereo->flags = AV_STEREO3D_FLAG_INVERT;
-
- if (s->sei.common.frame_packing.arrangement_type == 5) {
- if (s->sei.common.frame_packing.current_frame_is_frame0_flag)
- stereo->view = AV_STEREO3D_VIEW_LEFT;
- else
- stereo->view = AV_STEREO3D_VIEW_RIGHT;
- }
- }
-
// Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1
// so the side data persists for the entire coded video sequence.
if (s->sei.mastering_display.present > 0 &&
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 13/20] avcodec/h2645_sei: Also support Active Format Descriptor for HEVC
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (10 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 12/20] avcodec/h2645_sei: Attach AVStereo3D side data generically Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 14/20] avcodec/h264_ps: Don't error out on unknown aspect ratio Andreas Rheinhardt
` (7 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is valid for HEVC; in fact, the ATSC-HEVC spec [1] simply
refers to the relevant H.264 spec.
It is also trivial to implement now: Just move applying AFD
to ff_h2645_sei_to_frame() and stop ignoring AFD when parsing
a HEVC SEI containing it.
A FATE-test for this has been added.
[1]: https://www.atsc.org/atsc-documents/a3412017-video-hevc/
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 15 ++-
libavcodec/h2645_sei.h | 6 +-
libavcodec/h264_slice.c | 10 --
tests/fate/hevc.mak | 3 +
tests/ref/fate/hevc-afd-tc-sei | 204 +++++++++++++++++++++++++++++++++
5 files changed, 221 insertions(+), 17 deletions(-)
create mode 100644 tests/ref/fate/hevc-afd-tc-sei
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 3575846f9a..1793c07285 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -95,7 +95,7 @@ static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid
}
#endif
-static int decode_registered_user_data_afd(H264SEIAFD *h, GetByteContext *gb)
+static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
{
int flag;
@@ -157,13 +157,10 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
user_identifier = bytestream2_get_be32u(gb);
switch (user_identifier) {
case MKBETAG('D', 'T', 'G', '1'): // afd_data
- if (!IS_H264(codec_id))
- goto unsupported;
return decode_registered_user_data_afd(&h->afd, gb);
case MKBETAG('G', 'A', '9', '4'): // closed captions
return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
default:
- unsupported:
av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
user_identifier);
@@ -537,6 +534,16 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
}
sei->unregistered.nb_buf_ref = 0;
+ if (sei->afd.present) {
+ AVFrameSideData *sd = av_frame_new_side_data(frame, AV_FRAME_DATA_AFD,
+ sizeof(uint8_t));
+
+ if (sd) {
+ *sd->data = sei->afd.active_format_description;
+ sei->afd.present = 0;
+ }
+ }
+
return 0;
}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 4713b89e1f..eb00107abb 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -34,10 +34,10 @@ typedef struct H2645SEIA53Caption {
AVBufferRef *buf_ref;
} H2645SEIA53Caption;
-typedef struct H264SEIAFD {
+typedef struct H2645SEIAFD {
int present;
uint8_t active_format_description;
-} H264SEIAFD;
+} H2645SEIAFD;
typedef struct HEVCSEIDynamicHDRPlus {
AVBufferRef *info;
@@ -99,7 +99,7 @@ typedef struct H2645SEIFilmGrainCharacteristics {
typedef struct H2645SEI {
H2645SEIA53Caption a53_caption;
- H264SEIAFD afd; //< H.264 only
+ H2645SEIAFD afd;
HEVCSEIDynamicHDRPlus dynamic_hdr_plus; //< HEVC only
HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; //< HEVC only
H2645SEIUnregistered unregistered;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cc8bec8d9b..205ad5f97b 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1225,16 +1225,6 @@ static int h264_export_frame_props(H264Context *h)
}
}
- if (h->sei.common.afd.present) {
- AVFrameSideData *sd = av_frame_new_side_data(out, AV_FRAME_DATA_AFD,
- sizeof(uint8_t));
-
- if (sd) {
- *sd->data = h->sei.common.afd.active_format_description;
- h->sei.common.afd.present = 0;
- }
- }
-
ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx);
if (ret < 0)
return ret;
diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 2f16e3a29f..41180dd7b3 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -236,6 +236,9 @@ FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-paired-fields
fate-hevc-monochrome-crop: CMD = probeframes -show_entries frame=width,height:stream=width,height $(TARGET_SAMPLES)/hevc/hevc-monochrome.hevc
FATE_HEVC_FFPROBE-$(call PARSERDEMDEC, HEVC, HEVC, HEVC) += fate-hevc-monochrome-crop
+fate-hevc-afd-tc-sei: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -bitexact -show_entries frame_side_data_list -select_streams v $(TARGET_SAMPLES)/mpegts/loewe.ts
+FATE_HEVC_FFPROBE-$(call PARSERDEMDEC, HEVC, HEVC, HEVC) += fate-hevc-afd-tc-sei
+
fate-hevc-hdr10-plus-metadata: CMD = probeframes -show_entries frame=side_data_list $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc
FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-hdr10-plus-metadata
diff --git a/tests/ref/fate/hevc-afd-tc-sei b/tests/ref/fate/hevc-afd-tc-sei
new file mode 100644
index 0000000000..27eb3fc8d7
--- /dev/null
+++ b/tests/ref/fate/hevc-afd-tc-sei
@@ -0,0 +1,204 @@
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Active format description
+active_format=8
+[/SIDE_DATA]
+[SIDE_DATA]
+side_data_type=SMPTE 12-1 timecode
+[TIMECODE]
+value=00:00:00:00
+[/TIMECODE]
+[/SIDE_DATA]
+[/FRAME]
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 14/20] avcodec/h264_ps: Don't error out on unknown aspect ratio
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (11 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 13/20] avcodec/h2645_sei: Also support Active Format Descriptor for HEVC Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 15/20] avcodec/h264data: Deduplicate H.26[45] aspect ratio table Andreas Rheinhardt
` (6 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Values 17..254 are actually only reserved and not invalid.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_ps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index e16da68dec..55ef5ce0d3 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -145,8 +145,8 @@ static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
} else if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h264_pixel_aspect)) {
sps->sar = ff_h264_pixel_aspect[aspect_ratio_idc];
} else {
- av_log(logctx, AV_LOG_ERROR, "illegal aspect ratio\n");
- return AVERROR_INVALIDDATA;
+ av_log(logctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n",
+ aspect_ratio_idc);
}
} else {
sps->sar.num =
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 15/20] avcodec/h264data: Deduplicate H.26[45] aspect ratio table
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (12 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 14/20] avcodec/h264_ps: Don't error out on unknown aspect ratio Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 16/20] avcodec/hevc_ps: Fix wrong copyright years Andreas Rheinhardt
` (5 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 17 +++++++++------
libavcodec/h2645data.c | 39 ++++++++++++++++++++++++++++++++++
libavcodec/h2645data.h | 26 +++++++++++++++++++++++
libavcodec/h264_metadata_bsf.c | 17 +++++----------
libavcodec/h264_ps.c | 5 +++--
libavcodec/h264data.h | 20 -----------------
libavcodec/h265_metadata_bsf.c | 17 +++++----------
libavcodec/hevc_ps.c | 25 +++-------------------
libavcodec/vaapi_encode_h264.c | 16 +++++---------
libavcodec/vaapi_encode_h265.c | 16 +++++---------
10 files changed, 102 insertions(+), 96 deletions(-)
create mode 100644 libavcodec/h2645data.c
create mode 100644 libavcodec/h2645data.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c86184f9fd..5d6aedeba7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -97,11 +97,12 @@ OBJS-$(CONFIG_GOLOMB) += golomb.o
OBJS-$(CONFIG_H263DSP) += h263dsp.o
OBJS-$(CONFIG_H264CHROMA) += h264chroma.o
OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
-OBJS-$(CONFIG_H264PARSE) += h264_parse.o h2645_parse.o h264_ps.o
+OBJS-$(CONFIG_H264PARSE) += h264_parse.o h264_ps.o h2645data.o h2645_parse.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o
-OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o h2645_parse.o hevc_ps.o hevc_data.o
+OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o hevc_ps.o hevc_data.o \
+ h2645data.o h2645_parse.o
OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o h2645_sei.o dynamic_hdr10_plus.o dynamic_hdr_vivid.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
@@ -396,7 +397,8 @@ OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_H264_RKMPP_DECODER) += rkmppdec.o
-OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o h264_levels.o
+OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o h264_levels.o \
+ h2645data.o
OBJS-$(CONFIG_H264_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_H264_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_H264_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
@@ -417,7 +419,8 @@ OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o \
hevc_data.o
OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
-OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o
+OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o \
+ h2645data.o
OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
@@ -1183,11 +1186,13 @@ OBJS-$(CONFIG_EAC3_CORE_BSF) += eac3_core_bsf.o
OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF) += extract_extradata_bsf.o \
av1_parse.o h2645_parse.o
OBJS-$(CONFIG_FILTER_UNITS_BSF) += filter_units_bsf.o
-OBJS-$(CONFIG_H264_METADATA_BSF) += h264_metadata_bsf.o h264_levels.o
+OBJS-$(CONFIG_H264_METADATA_BSF) += h264_metadata_bsf.o h264_levels.o \
+ h2645data.o
OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o
OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
OBJS-$(CONFIG_HAPQA_EXTRACT_BSF) += hapqa_extract_bsf.o hap.o
-OBJS-$(CONFIG_HEVC_METADATA_BSF) += h265_metadata_bsf.o h265_profile_level.o
+OBJS-$(CONFIG_HEVC_METADATA_BSF) += h265_metadata_bsf.o h265_profile_level.o \
+ h2645data.o
OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += hevc_mp4toannexb_bsf.o
OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o
OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o
diff --git a/libavcodec/h2645data.c b/libavcodec/h2645data.c
new file mode 100644
index 0000000000..9897ca3186
--- /dev/null
+++ b/libavcodec/h2645data.c
@@ -0,0 +1,39 @@
+/*
+ * 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
+ */
+
+#include "h2645data.h"
+
+const AVRational ff_h2645_pixel_aspect[] = {
+ { 0, 1 },
+ { 1, 1 },
+ { 12, 11 },
+ { 10, 11 },
+ { 16, 11 },
+ { 40, 33 },
+ { 24, 11 },
+ { 20, 11 },
+ { 32, 11 },
+ { 80, 33 },
+ { 18, 11 },
+ { 15, 11 },
+ { 64, 33 },
+ { 160, 99 },
+ { 4, 3 },
+ { 3, 2 },
+ { 2, 1 },
+};
diff --git a/libavcodec/h2645data.h b/libavcodec/h2645data.h
new file mode 100644
index 0000000000..bc56d76870
--- /dev/null
+++ b/libavcodec/h2645data.h
@@ -0,0 +1,26 @@
+/*
+ * 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_H2645DATA_H
+#define AVCODEC_H2645DATA_H
+
+#include "libavutil/rational.h"
+
+extern const AVRational ff_h2645_pixel_aspect[17];
+
+#endif /* AVCODEC_H2645DATA_H */
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index e905982d26..82b57a32fd 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -29,6 +29,7 @@
#include "h264.h"
#include "h264_levels.h"
#include "h264_sei.h"
+#include "h2645data.h"
enum {
FLIP_HORIZONTAL = 1,
@@ -144,25 +145,17 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
int crop_unit_x, crop_unit_y;
if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
- // Table E-1.
- static const AVRational sar_idc[] = {
- { 0, 0 }, // Unspecified (never written here).
- { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
- { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
- { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
- { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
- };
int num, den, i;
av_reduce(&num, &den, ctx->sample_aspect_ratio.num,
ctx->sample_aspect_ratio.den, 65535);
- for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
- if (num == sar_idc[i].num &&
- den == sar_idc[i].den)
+ for (i = 1; i < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect); i++) {
+ if (num == ff_h2645_pixel_aspect[i].num &&
+ den == ff_h2645_pixel_aspect[i].den)
break;
}
- if (i == FF_ARRAY_ELEMS(sar_idc)) {
+ if (i == FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
sps->vui.aspect_ratio_idc = 255;
sps->vui.sar_width = num;
sps->vui.sar_height = den;
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 55ef5ce0d3..1fd7375a13 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -31,6 +31,7 @@
#include "mathops.h"
#include "avcodec.h"
#include "h264data.h"
+#include "h2645data.h"
#include "h264_ps.h"
#include "golomb.h"
@@ -142,8 +143,8 @@ static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
if (aspect_ratio_idc == EXTENDED_SAR) {
sps->sar.num = get_bits(gb, 16);
sps->sar.den = get_bits(gb, 16);
- } else if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h264_pixel_aspect)) {
- sps->sar = ff_h264_pixel_aspect[aspect_ratio_idc];
+ } else if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
+ sps->sar = ff_h2645_pixel_aspect[aspect_ratio_idc];
} else {
av_log(logctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n",
aspect_ratio_idc);
diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h
index 4efe76a34d..f809886ae6 100644
--- a/libavcodec/h264data.h
+++ b/libavcodec/h264data.h
@@ -49,26 +49,6 @@ extern const PMbInfo ff_h264_p_sub_mb_type_info[4];
extern const PMbInfo ff_h264_b_mb_type_info[23];
extern const PMbInfo ff_h264_b_sub_mb_type_info[13];
-static const AVRational ff_h264_pixel_aspect[17] = {
- { 0, 1 },
- { 1, 1 },
- { 12, 11 },
- { 10, 11 },
- { 16, 11 },
- { 40, 33 },
- { 24, 11 },
- { 20, 11 },
- { 32, 11 },
- { 80, 33 },
- { 18, 11 },
- { 15, 11 },
- { 64, 33 },
- { 160, 99 },
- { 4, 3 },
- { 3, 2 },
- { 2, 1 },
-};
-
extern const uint8_t ff_h264_dequant4_coeff_init[6][3];
extern const uint8_t ff_h264_dequant8_coeff_init_scan[16];
extern const uint8_t ff_h264_dequant8_coeff_init[6][6];
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index f01c8e4cd7..5edd984069 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -24,6 +24,7 @@
#include "cbs.h"
#include "cbs_bsf.h"
#include "cbs_h265.h"
+#include "h2645data.h"
#include "hevc.h"
#include "h265_profile_level.h"
@@ -194,25 +195,17 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
int crop_unit_x, crop_unit_y;
if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
- // Table E-1.
- static const AVRational sar_idc[] = {
- { 0, 0 }, // Unspecified (never written here).
- { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
- { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
- { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
- { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
- };
int num, den, i;
av_reduce(&num, &den, ctx->sample_aspect_ratio.num,
ctx->sample_aspect_ratio.den, 65535);
- for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
- if (num == sar_idc[i].num &&
- den == sar_idc[i].den)
+ for (i = 1; i < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect); i++) {
+ if (num == ff_h2645_pixel_aspect[i].num &&
+ den == ff_h2645_pixel_aspect[i].den)
break;
}
- if (i == FF_ARRAY_ELEMS(sar_idc)) {
+ if (i == FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
sps->vui.aspect_ratio_idc = 255;
sps->vui.sar_width = num;
sps->vui.sar_height = den;
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a955f585d9..832abc0ada 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -25,6 +25,7 @@
#include "libavutil/imgutils.h"
#include "golomb.h"
+#include "h2645data.h"
#include "hevc_data.h"
#include "hevc_ps.h"
@@ -50,26 +51,6 @@ static const uint8_t default_scaling_list_inter[] = {
24, 25, 28, 33, 41, 54, 71, 91
};
-static const AVRational vui_sar[] = {
- { 0, 1 },
- { 1, 1 },
- { 12, 11 },
- { 10, 11 },
- { 16, 11 },
- { 40, 33 },
- { 24, 11 },
- { 20, 11 },
- { 32, 11 },
- { 80, 33 },
- { 18, 11 },
- { 15, 11 },
- { 64, 33 },
- { 160, 99 },
- { 4, 3 },
- { 3, 2 },
- { 2, 1 },
-};
-
static const uint8_t hevc_sub_width_c[] = {
1, 2, 2, 1
};
@@ -597,8 +578,8 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
sar_present = get_bits1(gb);
if (sar_present) {
uint8_t sar_idx = get_bits(gb, 8);
- if (sar_idx < FF_ARRAY_ELEMS(vui_sar))
- vui->sar = vui_sar[sar_idx];
+ if (sar_idx < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
+ vui->sar = ff_h2645_pixel_aspect[sar_idx];
else if (sar_idx == 255) {
vui->sar.num = get_bits(gb, 16);
vui->sar.den = get_bits(gb, 16);
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 7a6b54ab6f..b2379fdf38 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -33,6 +33,7 @@
#include "h264.h"
#include "h264_levels.h"
#include "h264_sei.h"
+#include "h2645data.h"
#include "vaapi_encode.h"
#include "version.h"
@@ -378,24 +379,17 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
if (avctx->sample_aspect_ratio.num != 0 &&
avctx->sample_aspect_ratio.den != 0) {
- static const AVRational sar_idc[] = {
- { 0, 0 },
- { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
- { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
- { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
- { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
- };
int num, den, i;
av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
avctx->sample_aspect_ratio.den, 65535);
- for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
- if (num == sar_idc[i].num &&
- den == sar_idc[i].den) {
+ for (i = 0; i < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect); i++) {
+ if (num == ff_h2645_pixel_aspect[i].num &&
+ den == ff_h2645_pixel_aspect[i].den) {
sps->vui.aspect_ratio_idc = i;
break;
}
}
- if (i >= FF_ARRAY_ELEMS(sar_idc)) {
+ if (i >= FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
sps->vui.aspect_ratio_idc = 255;
sps->vui.sar_width = num;
sps->vui.sar_height = den;
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 456307d570..d0e2a82da3 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -31,6 +31,7 @@
#include "cbs.h"
#include "cbs_h265.h"
#include "codec_internal.h"
+#include "h2645data.h"
#include "h265_profile_level.h"
#include "hevc.h"
#include "hevc_sei.h"
@@ -496,24 +497,17 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
if (avctx->sample_aspect_ratio.num != 0 &&
avctx->sample_aspect_ratio.den != 0) {
- static const AVRational sar_idc[] = {
- { 0, 0 },
- { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
- { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
- { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
- { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
- };
int num, den, i;
av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
avctx->sample_aspect_ratio.den, 65535);
- for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
- if (num == sar_idc[i].num &&
- den == sar_idc[i].den) {
+ for (i = 0; i < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect); i++) {
+ if (num == ff_h2645_pixel_aspect[i].num &&
+ den == ff_h2645_pixel_aspect[i].den) {
vui->aspect_ratio_idc = i;
break;
}
}
- if (i >= FF_ARRAY_ELEMS(sar_idc)) {
+ if (i >= FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
vui->aspect_ratio_idc = 255;
vui->sar_width = num;
vui->sar_height = den;
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 16/20] avcodec/hevc_ps: Fix wrong copyright years
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (13 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 15/20] avcodec/h264data: Deduplicate H.26[45] aspect ratio table Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 17/20] avcodec/h264_ps: Don't output invalid chroma location Andreas Rheinhardt
` (4 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/hevc_ps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 832abc0ada..25620357de 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1,8 +1,8 @@
/*
* HEVC Parameter Set decoding
*
- * Copyright (C) 2012 - 2103 Guillaume Martres
- * Copyright (C) 2012 - 2103 Mickael Raulet
+ * Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2012 - 2013 Mickael Raulet
* Copyright (C) 2012 - 2013 Gildas Cocherel
* Copyright (C) 2013 Vittorio Giovara
*
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 17/20] avcodec/h264_ps: Don't output invalid chroma location
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (14 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 16/20] avcodec/hevc_ps: Fix wrong copyright years Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 18/20] avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type Andreas Rheinhardt
` (3 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_ps.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 1fd7375a13..874790a3a3 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -181,7 +181,11 @@ static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
/* chroma_location_info_present_flag */
if (get_bits1(gb)) {
/* chroma_sample_location_type_top_field */
- sps->chroma_location = get_ue_golomb_31(gb) + 1;
+ sps->chroma_location = get_ue_golomb_31(gb);
+ if (sps->chroma_location <= 5U)
+ sps->chroma_location++;
+ else
+ sps->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
get_ue_golomb_31(gb); /* chroma_sample_location_type_bottom_field */
} else
sps->chroma_location = AVCHROMA_LOC_LEFT;
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 18/20] avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (15 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 17/20] avcodec/h264_ps: Don't output invalid chroma location Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 19/20] avcodec/(h264|hevc)_ps: Factor common VUI code out Andreas Rheinhardt
` (2 subsequent siblings)
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_metadata_bsf.c | 2 +-
libavcodec/h265_metadata_bsf.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 82b57a32fd..d318bf0cee 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -618,7 +618,7 @@ static const AVOption h264_metadata_options[] = {
{ "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
- { .i64 = -1 }, -1, 6, FLAGS },
+ { .i64 = -1 }, -1, 5, FLAGS },
{ "tick_rate", "Set VUI tick rate (time_scale / num_units_in_tick)",
OFFSET(tick_rate), AV_OPT_TYPE_RATIONAL,
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 5edd984069..6787bd14a1 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -430,7 +430,7 @@ static const AVOption h265_metadata_options[] = {
{ "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
- { .i64 = -1 }, -1, 6, FLAGS },
+ { .i64 = -1 }, -1, 5, FLAGS },
{ "tick_rate",
"Set VPS and VUI tick rate (time_scale / num_units_in_tick)",
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 19/20] avcodec/(h264|hevc)_ps: Factor common VUI code out
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (16 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 18/20] avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type Andreas Rheinhardt
@ 2022-07-02 22:21 ` Andreas Rheinhardt
2022-07-02 22:22 ` [FFmpeg-devel] [PATCH 20/20] avcodec/h2645_sei: Factor attaching film grain side-data to frame out Andreas Rheinhardt
2022-07-02 23:28 ` [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Soft Works
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:21 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 5 ++-
libavcodec/h2645_vui.c | 91 +++++++++++++++++++++++++++++++++++++++++
libavcodec/h2645_vui.h | 49 ++++++++++++++++++++++
libavcodec/h264_ps.c | 69 +++----------------------------
libavcodec/h264_ps.h | 10 +----
libavcodec/h264_slice.c | 36 ++++++++--------
libavcodec/hevc_ps.c | 54 ++++--------------------
libavcodec/hevc_ps.h | 19 ++-------
libavcodec/hevcdec.c | 34 +++++++--------
9 files changed, 197 insertions(+), 170 deletions(-)
create mode 100644 libavcodec/h2645_vui.c
create mode 100644 libavcodec/h2645_vui.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5d6aedeba7..a210c46f49 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -97,12 +97,13 @@ OBJS-$(CONFIG_GOLOMB) += golomb.o
OBJS-$(CONFIG_H263DSP) += h263dsp.o
OBJS-$(CONFIG_H264CHROMA) += h264chroma.o
OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
-OBJS-$(CONFIG_H264PARSE) += h264_parse.o h264_ps.o h2645data.o h2645_parse.o
+OBJS-$(CONFIG_H264PARSE) += h264_parse.o h264_ps.o h2645data.o \
+ h2645_parse.o h2645_vui.o
OBJS-$(CONFIG_H264PRED) += h264pred.o
OBJS-$(CONFIG_H264QPEL) += h264qpel.o
OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o
OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o hevc_ps.o hevc_data.o \
- h2645data.o h2645_parse.o
+ h2645data.o h2645_parse.o h2645_vui.o
OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o h2645_sei.o dynamic_hdr10_plus.o dynamic_hdr_vivid.o
OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
OBJS-$(CONFIG_HUFFMAN) += huffman.o
diff --git a/libavcodec/h2645_vui.c b/libavcodec/h2645_vui.c
new file mode 100644
index 0000000000..fcc4b37105
--- /dev/null
+++ b/libavcodec/h2645_vui.c
@@ -0,0 +1,91 @@
+/*
+ * Common H.264/HEVC VUI Parameter decoding
+ *
+ * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (C) 2012 - 2013 Guillaume Martres
+ * Copyright (C) 2012 - 2013 Mickael Raulet
+ * Copyright (C) 2012 - 2013 Gildas Cocherel
+ * Copyright (C) 2013 Vittorio Giovara
+ *
+ * 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
+ */
+
+#include "libavutil/log.h"
+#include "libavutil/pixdesc.h"
+
+#include "get_bits.h"
+#include "golomb.h"
+#include "h2645data.h"
+#include "h2645_vui.h"
+
+#define EXTENDED_SAR 255
+
+void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
+{
+ int aspect_ratio_info_present_flag;
+
+ av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n");
+
+ aspect_ratio_info_present_flag = get_bits1(gb);
+ if (aspect_ratio_info_present_flag) {
+ uint8_t aspect_ratio_idc = get_bits(gb, 8);
+ if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
+ vui->sar = ff_h2645_pixel_aspect[aspect_ratio_idc];
+ else if (aspect_ratio_idc == EXTENDED_SAR) {
+ vui->sar.num = get_bits(gb, 16);
+ vui->sar.den = get_bits(gb, 16);
+ } else
+ av_log(logctx, AV_LOG_WARNING,
+ "Unknown SAR index: %u.\n", aspect_ratio_idc);
+ } else
+ vui->sar = (AVRational){ 0, 1 };
+
+ vui->overscan_info_present_flag = get_bits1(gb);
+ if (vui->overscan_info_present_flag)
+ vui->overscan_appropriate_flag = get_bits1(gb);
+
+ vui->video_signal_type_present_flag = get_bits1(gb);
+ if (vui->video_signal_type_present_flag) {
+ vui->video_format = get_bits(gb, 3);
+ vui->video_full_range_flag = get_bits1(gb);
+ vui->colour_description_present_flag = get_bits1(gb);
+ if (vui->colour_description_present_flag) {
+ vui->colour_primaries = get_bits(gb, 8);
+ vui->transfer_characteristics = get_bits(gb, 8);
+ vui->matrix_coeffs = get_bits(gb, 8);
+
+ // Set invalid values to "unspecified"
+ if (!av_color_primaries_name(vui->colour_primaries))
+ vui->colour_primaries = AVCOL_PRI_UNSPECIFIED;
+ if (!av_color_transfer_name(vui->transfer_characteristics))
+ vui->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
+ if (!av_color_space_name(vui->matrix_coeffs))
+ vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
+ }
+ }
+
+ vui->chroma_loc_info_present_flag = get_bits1(gb);
+ if (vui->chroma_loc_info_present_flag) {
+ vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb);
+ vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb);
+ if (vui->chroma_sample_loc_type_top_field <= 5U)
+ vui->chroma_location = vui->chroma_sample_loc_type_top_field + 1;
+ else
+ vui->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
+ } else
+ vui->chroma_location = AVCHROMA_LOC_LEFT;
+}
\ No newline at end of file
diff --git a/libavcodec/h2645_vui.h b/libavcodec/h2645_vui.h
new file mode 100644
index 0000000000..7b9bbad2d3
--- /dev/null
+++ b/libavcodec/h2645_vui.h
@@ -0,0 +1,49 @@
+/*
+ * 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_H2645_VUI_H
+#define AVCODEC_H2645_VUI_H
+
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+
+#include "get_bits.h"
+
+typedef struct H2645VUI {
+ AVRational sar;
+
+ int overscan_info_present_flag;
+ int overscan_appropriate_flag;
+
+ int video_signal_type_present_flag;
+ int video_format;
+ int video_full_range_flag;
+ int colour_description_present_flag;
+ enum AVColorPrimaries colour_primaries;
+ enum AVColorTransferCharacteristic transfer_characteristics;
+ enum AVColorSpace matrix_coeffs;
+
+ int chroma_loc_info_present_flag;
+ int chroma_sample_loc_type_top_field;
+ int chroma_sample_loc_type_bottom_field;
+ enum AVChromaLocation chroma_location;
+} H2645VUI;
+
+void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx);
+
+#endif /* AVCODEC_H2645_VUI_H */
\ No newline at end of file
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 874790a3a3..d0d1e65903 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -31,14 +31,12 @@
#include "mathops.h"
#include "avcodec.h"
#include "h264data.h"
-#include "h2645data.h"
+#include "h2645_vui.h"
#include "h264_ps.h"
#include "golomb.h"
#define MIN_LOG2_MAX_FRAME_NUM 4
-#define EXTENDED_SAR 255
-
static const uint8_t default_scaling4[2][16] = {
{ 6, 13, 20, 28, 13, 20, 28, 32,
20, 28, 32, 37, 28, 32, 37, 42 },
@@ -133,62 +131,7 @@ static inline int decode_hrd_parameters(GetBitContext *gb, void *logctx,
static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
SPS *sps)
{
- int aspect_ratio_info_present_flag;
- unsigned int aspect_ratio_idc;
-
- aspect_ratio_info_present_flag = get_bits1(gb);
-
- if (aspect_ratio_info_present_flag) {
- aspect_ratio_idc = get_bits(gb, 8);
- if (aspect_ratio_idc == EXTENDED_SAR) {
- sps->sar.num = get_bits(gb, 16);
- sps->sar.den = get_bits(gb, 16);
- } else if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) {
- sps->sar = ff_h2645_pixel_aspect[aspect_ratio_idc];
- } else {
- av_log(logctx, AV_LOG_WARNING, "Unknown SAR index: %u.\n",
- aspect_ratio_idc);
- }
- } else {
- sps->sar.num =
- sps->sar.den = 0;
- }
-
- if (get_bits1(gb)) /* overscan_info_present_flag */
- get_bits1(gb); /* overscan_appropriate_flag */
-
- sps->video_signal_type_present_flag = get_bits1(gb);
- if (sps->video_signal_type_present_flag) {
- get_bits(gb, 3); /* video_format */
- sps->full_range = get_bits1(gb); /* video_full_range_flag */
-
- sps->colour_description_present_flag = get_bits1(gb);
- if (sps->colour_description_present_flag) {
- sps->color_primaries = get_bits(gb, 8); /* colour_primaries */
- sps->color_trc = get_bits(gb, 8); /* transfer_characteristics */
- sps->colorspace = get_bits(gb, 8); /* matrix_coefficients */
-
- // Set invalid values to "unspecified"
- if (!av_color_primaries_name(sps->color_primaries))
- sps->color_primaries = AVCOL_PRI_UNSPECIFIED;
- if (!av_color_transfer_name(sps->color_trc))
- sps->color_trc = AVCOL_TRC_UNSPECIFIED;
- if (!av_color_space_name(sps->colorspace))
- sps->colorspace = AVCOL_SPC_UNSPECIFIED;
- }
- }
-
- /* chroma_location_info_present_flag */
- if (get_bits1(gb)) {
- /* chroma_sample_location_type_top_field */
- sps->chroma_location = get_ue_golomb_31(gb);
- if (sps->chroma_location <= 5U)
- sps->chroma_location++;
- else
- sps->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
- get_ue_golomb_31(gb); /* chroma_sample_location_type_bottom_field */
- } else
- sps->chroma_location = AVCHROMA_LOC_LEFT;
+ ff_h2645_decode_common_vui_params(gb, &sps->vui, logctx);
if (show_bits1(gb) && get_bits_left(gb) < 10) {
av_log(logctx, AV_LOG_WARNING, "Truncated VUI (%d)\n", get_bits_left(gb));
@@ -381,12 +324,12 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
sps->profile_idc = profile_idc;
sps->constraint_set_flags = constraint_set_flags;
sps->level_idc = level_idc;
- sps->full_range = -1;
+ sps->vui.video_full_range_flag = -1;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
sps->scaling_matrix_present = 0;
- sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED
+ sps->vui.matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
if (sps->profile_idc == 100 || // High profile
sps->profile_idc == 110 || // High10 profile
@@ -603,8 +546,8 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
}
}
- if (!sps->sar.den)
- sps->sar.den = 1;
+ if (!sps->vui.sar.den)
+ sps->vui.sar.den = 1;
if (avctx->debug & FF_DEBUG_PICT_INFO) {
static const char csp[4][5] = { "Gray", "420", "422", "444" };
diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
index dc52835ed4..5c35761fbc 100644
--- a/libavcodec/h264_ps.h
+++ b/libavcodec/h264_ps.h
@@ -33,6 +33,7 @@
#include "avcodec.h"
#include "get_bits.h"
#include "h264.h"
+#include "h2645_vui.h"
#define MAX_SPS_COUNT 32
#define MAX_PPS_COUNT 256
@@ -70,14 +71,7 @@ typedef struct SPS {
unsigned int crop_top; ///< frame_cropping_rect_top_offset
unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
int vui_parameters_present_flag;
- AVRational sar;
- int video_signal_type_present_flag;
- int full_range;
- int colour_description_present_flag;
- enum AVColorPrimaries color_primaries;
- enum AVColorTransferCharacteristic color_trc;
- enum AVColorSpace colorspace;
- enum AVChromaLocation chroma_location;
+ H2645VUI vui;
int timing_info_present_flag;
uint32_t num_units_in_tick;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 205ad5f97b..ba873254ce 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -326,7 +326,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
!h->ps.sps ||
h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma ||
h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc ||
- h->ps.sps->colorspace != h1->ps.sps->colorspace)) {
+ h->ps.sps->vui.matrix_coeffs != h1->ps.sps->vui.matrix_coeffs)) {
need_reinit = 1;
}
@@ -936,7 +936,7 @@ static int h264_slice_header_init(H264Context *h)
goto fail;
}
- ff_set_sar(h->avctx, sps->sar);
+ ff_set_sar(h->avctx, sps->vui.sar);
av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
&h->chroma_x_shift, &h->chroma_y_shift);
@@ -1061,7 +1061,7 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
|| (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0))))
must_reinit = 1;
- if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio))
+ if (first_slice && av_cmp_q(sps->vui.sar, h->avctx->sample_aspect_ratio))
must_reinit = 1;
if (!h->setup_finished) {
@@ -1083,15 +1083,15 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
init_dimensions(h);
- if (sps->video_signal_type_present_flag) {
- h->avctx->color_range = sps->full_range > 0 ? AVCOL_RANGE_JPEG
- : AVCOL_RANGE_MPEG;
- if (sps->colour_description_present_flag) {
- if (h->avctx->colorspace != sps->colorspace)
+ if (sps->vui.video_signal_type_present_flag) {
+ h->avctx->color_range = sps->vui.video_full_range_flag > 0 ? AVCOL_RANGE_JPEG
+ : AVCOL_RANGE_MPEG;
+ if (sps->vui.colour_description_present_flag) {
+ if (h->avctx->colorspace != sps->vui.matrix_coeffs)
needs_reinit = 1;
- h->avctx->color_primaries = sps->color_primaries;
- h->avctx->color_trc = sps->color_trc;
- h->avctx->colorspace = sps->colorspace;
+ h->avctx->color_primaries = sps->vui.colour_primaries;
+ h->avctx->color_trc = sps->vui.transfer_characteristics;
+ h->avctx->colorspace = sps->vui.matrix_coeffs;
}
}
@@ -1101,7 +1101,7 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
h->avctx->color_trc = h->sei.common.alternative_transfer.preferred_transfer_characteristics;
}
}
- h->avctx->chroma_sample_location = sps->chroma_location;
+ h->avctx->chroma_sample_location = sps->vui.chroma_location;
if (!h->context_initialized || must_reinit || needs_reinit) {
int flush_changes = h->context_initialized;
@@ -1249,14 +1249,14 @@ static int h264_export_frame_props(H264Context *h)
} else {
fgp->codec.h274.bit_depth_luma = sps->bit_depth_luma;
fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma;
- if (sps->video_signal_type_present_flag)
- fgp->codec.h274.color_range = sps->full_range + 1;
+ if (sps->vui.video_signal_type_present_flag)
+ fgp->codec.h274.color_range = sps->vui.video_full_range_flag + 1;
else
fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED;
- if (sps->colour_description_present_flag) {
- fgp->codec.h274.color_primaries = sps->color_primaries;
- fgp->codec.h274.color_trc = sps->color_trc;
- fgp->codec.h274.color_space = sps->colorspace;
+ if (sps->vui.colour_description_present_flag) {
+ fgp->codec.h274.color_primaries = sps->vui.colour_primaries;
+ fgp->codec.h274.color_trc = sps->vui.transfer_characteristics;
+ fgp->codec.h274.color_space = sps->vui.matrix_coeffs;
} else {
fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED;
fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED;
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 25620357de..b68656e352 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -25,7 +25,7 @@
#include "libavutil/imgutils.h"
#include "golomb.h"
-#include "h2645data.h"
+#include "h2645_vui.h"
#include "hevc_data.h"
#include "hevc_ps.h"
@@ -571,47 +571,15 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
{
VUI backup_vui, *vui = &sps->vui;
GetBitContext backup;
- int sar_present, alt = 0;
-
- av_log(avctx, AV_LOG_DEBUG, "Decoding VUI\n");
-
- sar_present = get_bits1(gb);
- if (sar_present) {
- uint8_t sar_idx = get_bits(gb, 8);
- if (sar_idx < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
- vui->sar = ff_h2645_pixel_aspect[sar_idx];
- else if (sar_idx == 255) {
- vui->sar.num = get_bits(gb, 16);
- vui->sar.den = get_bits(gb, 16);
- } else
- av_log(avctx, AV_LOG_WARNING,
- "Unknown SAR index: %u.\n", sar_idx);
- }
+ int alt = 0;
- vui->overscan_info_present_flag = get_bits1(gb);
- if (vui->overscan_info_present_flag)
- vui->overscan_appropriate_flag = get_bits1(gb);
+ ff_h2645_decode_common_vui_params(gb, &sps->vui.common, avctx);
- vui->video_signal_type_present_flag = get_bits1(gb);
- if (vui->video_signal_type_present_flag) {
- vui->video_format = get_bits(gb, 3);
- vui->video_full_range_flag = get_bits1(gb);
- vui->colour_description_present_flag = get_bits1(gb);
- if (vui->video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P)
+ if (vui->common.video_signal_type_present_flag) {
+ if (vui->common.video_full_range_flag && sps->pix_fmt == AV_PIX_FMT_YUV420P)
sps->pix_fmt = AV_PIX_FMT_YUVJ420P;
- if (vui->colour_description_present_flag) {
- vui->colour_primaries = get_bits(gb, 8);
- vui->transfer_characteristic = get_bits(gb, 8);
- vui->matrix_coeffs = get_bits(gb, 8);
-
- // Set invalid values to "unspecified"
- if (!av_color_primaries_name(vui->colour_primaries))
- vui->colour_primaries = AVCOL_PRI_UNSPECIFIED;
- if (!av_color_transfer_name(vui->transfer_characteristic))
- vui->transfer_characteristic = AVCOL_TRC_UNSPECIFIED;
- if (!av_color_space_name(vui->matrix_coeffs))
- vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
- if (vui->matrix_coeffs == AVCOL_SPC_RGB) {
+ if (vui->common.colour_description_present_flag) {
+ if (vui->common.matrix_coeffs == AVCOL_SPC_RGB) {
switch (sps->pix_fmt) {
case AV_PIX_FMT_YUV444P:
sps->pix_fmt = AV_PIX_FMT_GBRP;
@@ -627,12 +595,6 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
}
}
- vui->chroma_loc_info_present_flag = get_bits1(gb);
- if (vui->chroma_loc_info_present_flag) {
- vui->chroma_sample_loc_type_top_field = get_ue_golomb_long(gb);
- vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_long(gb);
- }
-
vui->neutra_chroma_indication_flag = get_bits1(gb);
vui->field_seq_flag = get_bits1(gb);
vui->frame_field_info_present_flag = get_bits1(gb);
@@ -1107,7 +1069,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->sps_temporal_mvp_enabled_flag = get_bits1(gb);
sps->sps_strong_intra_smoothing_enable_flag = get_bits1(gb);
- sps->vui.sar = (AVRational){0, 1};
+ sps->vui.common.sar = (AVRational){0, 1};
vui_present = get_bits1(gb);
if (vui_present)
decode_vui(gb, avctx, apply_defdispwin, sps);
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 2a1bbf6489..18894cfed1 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -29,6 +29,7 @@
#include "avcodec.h"
#include "get_bits.h"
+#include "h2645_vui.h"
#include "hevc.h"
typedef struct ShortTermRPS {
@@ -47,22 +48,8 @@ typedef struct HEVCWindow {
} HEVCWindow;
typedef struct VUI {
- AVRational sar;
-
- int overscan_info_present_flag;
- int overscan_appropriate_flag;
-
- int video_signal_type_present_flag;
- int video_format;
- int video_full_range_flag;
- int colour_description_present_flag;
- uint8_t colour_primaries;
- uint8_t transfer_characteristic;
- uint8_t matrix_coeffs;
-
- int chroma_loc_info_present_flag;
- int chroma_sample_loc_type_top_field;
- int chroma_sample_loc_type_bottom_field;
+ H2645VUI common;
+
int neutra_chroma_indication_flag;
int field_seq_flag;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index fdb8de5b15..7147944bc6 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -337,18 +337,18 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
avctx->profile = sps->ptl.general_ptl.profile_idc;
avctx->level = sps->ptl.general_ptl.level_idc;
- ff_set_sar(avctx, sps->vui.sar);
+ ff_set_sar(avctx, sps->vui.common.sar);
- if (sps->vui.video_signal_type_present_flag)
- avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG
- : AVCOL_RANGE_MPEG;
+ if (sps->vui.common.video_signal_type_present_flag)
+ avctx->color_range = sps->vui.common.video_full_range_flag ? AVCOL_RANGE_JPEG
+ : AVCOL_RANGE_MPEG;
else
avctx->color_range = AVCOL_RANGE_MPEG;
- if (sps->vui.colour_description_present_flag) {
- avctx->color_primaries = sps->vui.colour_primaries;
- avctx->color_trc = sps->vui.transfer_characteristic;
- avctx->colorspace = sps->vui.matrix_coeffs;
+ if (sps->vui.common.colour_description_present_flag) {
+ avctx->color_primaries = sps->vui.common.colour_primaries;
+ avctx->color_trc = sps->vui.common.transfer_characteristics;
+ avctx->colorspace = sps->vui.common.matrix_coeffs;
} else {
avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
avctx->color_trc = AVCOL_TRC_UNSPECIFIED;
@@ -357,9 +357,9 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
avctx->chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;
if (sps->chroma_format_idc == 1) {
- if (sps->vui.chroma_loc_info_present_flag) {
- if (sps->vui.chroma_sample_loc_type_top_field <= 5)
- avctx->chroma_sample_location = sps->vui.chroma_sample_loc_type_top_field + 1;
+ if (sps->vui.common.chroma_loc_info_present_flag) {
+ if (sps->vui.common.chroma_sample_loc_type_top_field <= 5)
+ avctx->chroma_sample_location = sps->vui.common.chroma_sample_loc_type_top_field + 1;
} else
avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
}
@@ -2851,14 +2851,14 @@ static int set_side_data(HEVCContext *s)
const VUI *vui = &sps->vui;
fgp->codec.h274.bit_depth_luma = sps->bit_depth;
fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma;
- if (vui->video_signal_type_present_flag)
- fgp->codec.h274.color_range = vui->video_full_range_flag + 1;
+ if (vui->common.video_signal_type_present_flag)
+ fgp->codec.h274.color_range = vui->common.video_full_range_flag + 1;
else
fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED;
- if (vui->colour_description_present_flag) {
- fgp->codec.h274.color_primaries = vui->colour_primaries;
- fgp->codec.h274.color_trc = vui->transfer_characteristic;
- fgp->codec.h274.color_space = vui->matrix_coeffs;
+ if (vui->common.colour_description_present_flag) {
+ fgp->codec.h274.color_primaries = vui->common.colour_primaries;
+ fgp->codec.h274.color_trc = vui->common.transfer_characteristics;
+ fgp->codec.h274.color_space = vui->common.matrix_coeffs;
} else {
fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED;
fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED;
--
2.34.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] 24+ messages in thread
* [FFmpeg-devel] [PATCH 20/20] avcodec/h2645_sei: Factor attaching film grain side-data to frame out
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (17 preceding siblings ...)
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 19/20] avcodec/(h264|hevc)_ps: Factor common VUI code out Andreas Rheinhardt
@ 2022-07-02 22:22 ` Andreas Rheinhardt
2022-07-02 23:28 ` [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Soft Works
19 siblings, 0 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-07-02 22:22 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This unfortunately involved adding some parameters
to ff_h2645_sei_to_frame() that will be mostly unused.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h2645_sei.c | 67 ++++++++++++++++++++++++++++++++++++++++-
libavcodec/h2645_sei.h | 5 ++-
libavcodec/h264_slice.c | 59 ++----------------------------------
libavcodec/hevcdec.c | 60 +++---------------------------------
4 files changed, 77 insertions(+), 114 deletions(-)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 1793c07285..72b976f92e 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -429,7 +429,9 @@ static int is_frame_packing_type_valid(SEIFpaType type, enum AVCodecID codec_id)
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
enum AVCodecID codec_id,
- AVCodecContext *avctx)
+ AVCodecContext *avctx, const H2645VUI *vui,
+ unsigned bit_depth_luma, unsigned bit_depth_chroma,
+ int seed)
{
H2645SEIFramePacking *fp = &sei->frame_packing;
@@ -544,6 +546,69 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
}
}
+ if (sei->film_grain_characteristics.present) {
+ H2645SEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics;
+ AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame);
+ AVFilmGrainH274Params *h274;
+
+ if (!fgp)
+ return AVERROR(ENOMEM);
+
+ fgp->type = AV_FILM_GRAIN_PARAMS_H274;
+ h274 = &fgp->codec.h274;
+
+ fgp->seed = seed;
+
+ h274->model_id = fgc->model_id;
+ if (fgc->separate_colour_description_present_flag) {
+ h274->bit_depth_luma = fgc->bit_depth_luma;
+ h274->bit_depth_chroma = fgc->bit_depth_chroma;
+ h274->color_range = fgc->full_range + 1;
+ h274->color_primaries = fgc->color_primaries;
+ h274->color_trc = fgc->transfer_characteristics;
+ h274->color_space = fgc->matrix_coeffs;
+ } else {
+ h274->bit_depth_luma = bit_depth_luma;
+ h274->bit_depth_chroma = bit_depth_chroma;
+ if (vui->video_signal_type_present_flag)
+ h274->color_range = vui->video_full_range_flag + 1;
+ else
+ h274->color_range = AVCOL_RANGE_UNSPECIFIED;
+ if (vui->colour_description_present_flag) {
+ h274->color_primaries = vui->colour_primaries;
+ h274->color_trc = vui->transfer_characteristics;
+ h274->color_space = vui->matrix_coeffs;
+ } else {
+ h274->color_primaries = AVCOL_PRI_UNSPECIFIED;
+ h274->color_trc = AVCOL_TRC_UNSPECIFIED;
+ h274->color_space = AVCOL_SPC_UNSPECIFIED;
+ }
+ }
+ h274->blending_mode_id = fgc->blending_mode_id;
+ h274->log2_scale_factor = fgc->log2_scale_factor;
+
+ memcpy(&h274->component_model_present, &fgc->comp_model_present_flag,
+ sizeof(h274->component_model_present));
+ memcpy(&h274->num_intensity_intervals, &fgc->num_intensity_intervals,
+ sizeof(h274->num_intensity_intervals));
+ memcpy(&h274->num_model_values, &fgc->num_model_values,
+ sizeof(h274->num_model_values));
+ memcpy(&h274->intensity_interval_lower_bound, &fgc->intensity_interval_lower_bound,
+ sizeof(h274->intensity_interval_lower_bound));
+ memcpy(&h274->intensity_interval_upper_bound, &fgc->intensity_interval_upper_bound,
+ sizeof(h274->intensity_interval_upper_bound));
+ memcpy(&h274->comp_model_value, &fgc->comp_model_value,
+ sizeof(h274->comp_model_value));
+
+ if (IS_H264(codec_id))
+ fgc->present = !!fgc->repetition_period;
+ else
+ fgc->present = fgc->persistence_flag;
+
+ if (avctx)
+ avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
+ }
+
return 0;
}
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index eb00107abb..f3ee9af524 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -28,6 +28,7 @@
#include "bytestream.h"
#include "codec_id.h"
#include "get_bits.h"
+#include "h2645_vui.h"
#include "sei.h"
typedef struct H2645SEIA53Caption {
@@ -136,6 +137,8 @@ void ff_h2645_sei_reset(H2645SEI *s);
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
enum AVCodecID codec_id,
- AVCodecContext *avctx);
+ AVCodecContext *avctx, const H2645VUI *vui,
+ unsigned bit_depth_luma, unsigned bit_depth_chroma,
+ int seed);
#endif /* AVCODEC_H2645_SEI_H */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index ba873254ce..51d8d944be 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1225,65 +1225,12 @@ static int h264_export_frame_props(H264Context *h)
}
}
- ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx);
+ ret = ff_h2645_sei_to_frame(out, &h->sei.common, AV_CODEC_ID_H264, h->avctx,
+ &sps->vui, sps->bit_depth_luma, sps->bit_depth_chroma,
+ cur->poc + (h->poc_offset << 5));
if (ret < 0)
return ret;
- if (h->sei.common.film_grain_characteristics.present) {
- H2645SEIFilmGrainCharacteristics *fgc = &h->sei.common.film_grain_characteristics;
- AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out);
- if (!fgp)
- return AVERROR(ENOMEM);
-
- fgp->type = AV_FILM_GRAIN_PARAMS_H274;
- fgp->seed = cur->poc + (h->poc_offset << 5);
-
- fgp->codec.h274.model_id = fgc->model_id;
- if (fgc->separate_colour_description_present_flag) {
- fgp->codec.h274.bit_depth_luma = fgc->bit_depth_luma;
- fgp->codec.h274.bit_depth_chroma = fgc->bit_depth_chroma;
- fgp->codec.h274.color_range = fgc->full_range + 1;
- fgp->codec.h274.color_primaries = fgc->color_primaries;
- fgp->codec.h274.color_trc = fgc->transfer_characteristics;
- fgp->codec.h274.color_space = fgc->matrix_coeffs;
- } else {
- fgp->codec.h274.bit_depth_luma = sps->bit_depth_luma;
- fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma;
- if (sps->vui.video_signal_type_present_flag)
- fgp->codec.h274.color_range = sps->vui.video_full_range_flag + 1;
- else
- fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED;
- if (sps->vui.colour_description_present_flag) {
- fgp->codec.h274.color_primaries = sps->vui.colour_primaries;
- fgp->codec.h274.color_trc = sps->vui.transfer_characteristics;
- fgp->codec.h274.color_space = sps->vui.matrix_coeffs;
- } else {
- fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED;
- fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED;
- fgp->codec.h274.color_space = AVCOL_SPC_UNSPECIFIED;
- }
- }
- fgp->codec.h274.blending_mode_id = fgc->blending_mode_id;
- fgp->codec.h274.log2_scale_factor = fgc->log2_scale_factor;
-
- memcpy(&fgp->codec.h274.component_model_present, &fgc->comp_model_present_flag,
- sizeof(fgp->codec.h274.component_model_present));
- memcpy(&fgp->codec.h274.num_intensity_intervals, &fgc->num_intensity_intervals,
- sizeof(fgp->codec.h274.num_intensity_intervals));
- memcpy(&fgp->codec.h274.num_model_values, &fgc->num_model_values,
- sizeof(fgp->codec.h274.num_model_values));
- memcpy(&fgp->codec.h274.intensity_interval_lower_bound, &fgc->intensity_interval_lower_bound,
- sizeof(fgp->codec.h274.intensity_interval_lower_bound));
- memcpy(&fgp->codec.h274.intensity_interval_upper_bound, &fgc->intensity_interval_upper_bound,
- sizeof(fgp->codec.h274.intensity_interval_upper_bound));
- memcpy(&fgp->codec.h274.comp_model_value, &fgc->comp_model_value,
- sizeof(fgp->codec.h274.comp_model_value));
-
- fgc->present = !!fgc->repetition_period;
-
- h->avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
- }
-
if (h->sei.picture_timing.timecode_cnt > 0) {
uint32_t *tc_sd;
char tcbuf[AV_TIMECODE_STR_SIZE];
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 7147944bc6..298edb782b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2799,7 +2799,10 @@ static int set_side_data(HEVCContext *s)
metadata->MaxCLL, metadata->MaxFALL);
}
- ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, NULL);
+ ret = ff_h2645_sei_to_frame(out, &s->sei.common, AV_CODEC_ID_HEVC, NULL,
+ &s->ps.sps->vui.common,
+ s->ps.sps->bit_depth, s->ps.sps->bit_depth_chroma,
+ s->ref->poc /* no poc_offset in HEVC */);
if (ret < 0)
return ret;
@@ -2829,61 +2832,6 @@ static int set_side_data(HEVCContext *s)
s->sei.timecode.num_clock_ts = 0;
}
- if (s->sei.common.film_grain_characteristics.present) {
- H2645SEIFilmGrainCharacteristics *fgc = &s->sei.common.film_grain_characteristics;
- AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(out);
- if (!fgp)
- return AVERROR(ENOMEM);
-
- fgp->type = AV_FILM_GRAIN_PARAMS_H274;
- fgp->seed = s->ref->poc; /* no poc_offset in HEVC */
-
- fgp->codec.h274.model_id = fgc->model_id;
- if (fgc->separate_colour_description_present_flag) {
- fgp->codec.h274.bit_depth_luma = fgc->bit_depth_luma;
- fgp->codec.h274.bit_depth_chroma = fgc->bit_depth_chroma;
- fgp->codec.h274.color_range = fgc->full_range + 1;
- fgp->codec.h274.color_primaries = fgc->color_primaries;
- fgp->codec.h274.color_trc = fgc->transfer_characteristics;
- fgp->codec.h274.color_space = fgc->matrix_coeffs;
- } else {
- const HEVCSPS *sps = s->ps.sps;
- const VUI *vui = &sps->vui;
- fgp->codec.h274.bit_depth_luma = sps->bit_depth;
- fgp->codec.h274.bit_depth_chroma = sps->bit_depth_chroma;
- if (vui->common.video_signal_type_present_flag)
- fgp->codec.h274.color_range = vui->common.video_full_range_flag + 1;
- else
- fgp->codec.h274.color_range = AVCOL_RANGE_UNSPECIFIED;
- if (vui->common.colour_description_present_flag) {
- fgp->codec.h274.color_primaries = vui->common.colour_primaries;
- fgp->codec.h274.color_trc = vui->common.transfer_characteristics;
- fgp->codec.h274.color_space = vui->common.matrix_coeffs;
- } else {
- fgp->codec.h274.color_primaries = AVCOL_PRI_UNSPECIFIED;
- fgp->codec.h274.color_trc = AVCOL_TRC_UNSPECIFIED;
- fgp->codec.h274.color_space = AVCOL_SPC_UNSPECIFIED;
- }
- }
- fgp->codec.h274.blending_mode_id = fgc->blending_mode_id;
- fgp->codec.h274.log2_scale_factor = fgc->log2_scale_factor;
-
- memcpy(&fgp->codec.h274.component_model_present, &fgc->comp_model_present_flag,
- sizeof(fgp->codec.h274.component_model_present));
- memcpy(&fgp->codec.h274.num_intensity_intervals, &fgc->num_intensity_intervals,
- sizeof(fgp->codec.h274.num_intensity_intervals));
- memcpy(&fgp->codec.h274.num_model_values, &fgc->num_model_values,
- sizeof(fgp->codec.h274.num_model_values));
- memcpy(&fgp->codec.h274.intensity_interval_lower_bound, &fgc->intensity_interval_lower_bound,
- sizeof(fgp->codec.h274.intensity_interval_lower_bound));
- memcpy(&fgp->codec.h274.intensity_interval_upper_bound, &fgc->intensity_interval_upper_bound,
- sizeof(fgp->codec.h274.intensity_interval_upper_bound));
- memcpy(&fgp->codec.h274.comp_model_value, &fgc->comp_model_value,
- sizeof(fgp->codec.h274.comp_model_value));
-
- fgc->present = fgc->persistence_flag;
- }
-
if (s->sei.common.dynamic_hdr_plus.info) {
AVBufferRef *info_ref = av_buffer_ref(s->sei.common.dynamic_hdr_plus.info);
if (!info_ref)
--
2.34.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] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
` (18 preceding siblings ...)
2022-07-02 22:22 ` [FFmpeg-devel] [PATCH 20/20] avcodec/h2645_sei: Factor attaching film grain side-data to frame out Andreas Rheinhardt
@ 2022-07-02 23:28 ` Soft Works
2022-11-23 3:19 ` Andreas Rheinhardt
19 siblings, 1 reply; 24+ messages in thread
From: Soft Works @ 2022-07-02 23:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Sunday, July 3, 2022 12:21 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Subject: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper
> type for NALU type
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
Nice! That's helpful for the QSV SEI parsing. The one missing bit
is the HDR data (AVMasteringDisplayMetadata and AVContentLightMetadata)
assignment which still seems to remain in hevcdec. Would it make sense
for factor this out as well?
Thank you very much,
softworkz
_______________________________________________
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] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type
2022-07-02 23:28 ` [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Soft Works
@ 2022-11-23 3:19 ` Andreas Rheinhardt
2022-11-23 4:15 ` Soft Works
2022-11-23 5:05 ` Soft Works
0 siblings, 2 replies; 24+ messages in thread
From: Andreas Rheinhardt @ 2022-11-23 3:19 UTC (permalink / raw)
To: Soft Works, FFmpeg development discussions and patches
Soft Works:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Andreas Rheinhardt
>> Sent: Sunday, July 3, 2022 12:21 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> Subject: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper
>> type for NALU type
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>
> Nice! That's helpful for the QSV SEI parsing. The one missing bit
> is the HDR data (AVMasteringDisplayMetadata and AVContentLightMetadata)
> assignment which still seems to remain in hevcdec. Would it make sense
> for factor this out as well?
>
While the H.264 and HEVC syntax and semantics for these coincide, the
HEVC implementation of it is not completely spec-compliant with respect
to its persistency: The persistence ends when the coded video sequence
ends and if the new coded video sequence does not have these SEIs, then
we would need to attach an AVMasteringDisplayMetadata and/or
AVContentLightMetadata just to cancel the earlier values. I just don't
want to enter this and this includes not extending it to H.264.
Anyway, I have now rebased this patchset on top of master:
https://github.com/mkver/FFmpeg/tree/h2645_sei (with no noteworthy
conflicts; basically the only change is that the second to last commit
now adds proper newlines to the newly created files). I intend to apply
it in two days unless there are objections.
- Andreas
_______________________________________________
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] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type
2022-11-23 3:19 ` Andreas Rheinhardt
@ 2022-11-23 4:15 ` Soft Works
2022-11-23 5:05 ` Soft Works
1 sibling, 0 replies; 24+ messages in thread
From: Soft Works @ 2022-11-23 4:15 UTC (permalink / raw)
To: Andreas Rheinhardt, FFmpeg development discussions and patches
> -----Original Message-----
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Sent: Wednesday, November 23, 2022 4:20 AM
> To: Soft Works <softworkz@hotmail.com>; FFmpeg development
> discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use
> proper type for NALU type
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Sunday, July 3, 2022 12:21 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Subject: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper
> >> type for NALU type
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >
> > Nice! That's helpful for the QSV SEI parsing. The one missing bit
> > is the HDR data (AVMasteringDisplayMetadata and
> AVContentLightMetadata)
> > assignment which still seems to remain in hevcdec. Would it make
> sense
> > for factor this out as well?
> >
>
> While the H.264 and HEVC syntax and semantics for these coincide, the
> HEVC implementation of it is not completely spec-compliant with
> respect
> to its persistency: The persistence ends when the coded video
> sequence
> ends and if the new coded video sequence does not have these SEIs,
> then
> we would need to attach an AVMasteringDisplayMetadata and/or
> AVContentLightMetadata just to cancel the earlier values. I just
> don't
> want to enter this and this includes not extending it to H.264.
> Anyway, I have now rebased this patchset on top of master:
> https://github.com/mkver/FFmpeg/tree/h2645_sei (with no noteworthy
> conflicts; basically the only change is that the second to last
> commit
> now adds proper newlines to the newly created files). I intend to
> apply
> it in two days unless there are objections.
>
> - Andreas
Hi,
I'm not sure whether you seen the patchset I had submitted
meanwhile? It doesn't go as far as yours in a way that I didn't
try to merge H264/5 functionality, but now it consequently splits
out the bits that are meant for common use.
I was able to eliminate all those makefile dependencies which you
had criticized (for valid reasons).
I hadn't seen any hint from you whether you are intending to
proceed with your patchset, that's why I didn't know whether
I should have waited. But I don't mind when you apply yours
now, I will look into it and adapt.
Maybe you find the time to take only a quick look and let me
know whether this goes into the right direction?
https://github.com/ffstaging/FFmpeg/pull/31/files
Thanks,
softworkz
_______________________________________________
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] 24+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type
2022-11-23 3:19 ` Andreas Rheinhardt
2022-11-23 4:15 ` Soft Works
@ 2022-11-23 5:05 ` Soft Works
1 sibling, 0 replies; 24+ messages in thread
From: Soft Works @ 2022-11-23 5:05 UTC (permalink / raw)
To: Andreas Rheinhardt, FFmpeg development discussions and patches
> -----Original Message-----
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Sent: Wednesday, November 23, 2022 4:20 AM
> To: Soft Works <softworkz@hotmail.com>; FFmpeg development
> discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use
> proper type for NALU type
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Sunday, July 3, 2022 12:21 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Subject: [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper
> >> type for NALU type
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >
> > Nice! That's helpful for the QSV SEI parsing. The one missing bit
> > is the HDR data (AVMasteringDisplayMetadata and
> AVContentLightMetadata)
> > assignment which still seems to remain in hevcdec. Would it make
> sense
> > for factor this out as well?
> >
>
> While the H.264 and HEVC syntax and semantics for these coincide, the
> HEVC implementation of it is not completely spec-compliant with
> respect
> to its persistency: The persistence ends when the coded video
> sequence
> ends and if the new coded video sequence does not have these SEIs,
> then
> we would need to attach an AVMasteringDisplayMetadata and/or
> AVContentLightMetadata just to cancel the earlier values. I just
> don't
> want to enter this and this includes not extending it to H.264.
Just to clarify - by "factoring out" AVMasteringDisplayMetadata
and AVContentLightMetadata, I didn't mean in a way that it gets
unified to handle H.264 and H.265. I just meant to move it into
a separate module, so that it can be used by qsvdec.c without needing
to link to the whole H.265 implementation.
sw
_______________________________________________
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] 24+ messages in thread
end of thread, other threads:[~2022-11-23 5:05 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-02 22:20 [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 02/20] avcodec/h264_sei: Don't use GetBit-API for byte-aligned reads Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 03/20] configure: Add (h264|hevc)_sei subsystems Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 04/20] avcodec/sei: Add tag to SEI enumeration Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 05/20] fftools/ffprobe: Improve description of AFD side data Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 06/20] fate/h264: Add Active Format Descriptor test Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 07/20] avcodec/h2645_sei: Factor parsing common SEI messages out Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 08/20] avcodec/h2645_sei: Factor updating H.2645 SEIs out Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 09/20] avcodec/h2645_sei: Factor out freeing common SEI parts Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 10/20] avcodec/h2645_sei: Factor out applying SEIs to frames Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 12/20] avcodec/h2645_sei: Attach AVStereo3D side data generically Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 13/20] avcodec/h2645_sei: Also support Active Format Descriptor for HEVC Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 14/20] avcodec/h264_ps: Don't error out on unknown aspect ratio Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 15/20] avcodec/h264data: Deduplicate H.26[45] aspect ratio table Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 16/20] avcodec/hevc_ps: Fix wrong copyright years Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 17/20] avcodec/h264_ps: Don't output invalid chroma location Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 18/20] avcodec/h26[45]_metadata_bsf: Fix range of chroma_sample_loc_type Andreas Rheinhardt
2022-07-02 22:21 ` [FFmpeg-devel] [PATCH 19/20] avcodec/(h264|hevc)_ps: Factor common VUI code out Andreas Rheinhardt
2022-07-02 22:22 ` [FFmpeg-devel] [PATCH 20/20] avcodec/h2645_sei: Factor attaching film grain side-data to frame out Andreas Rheinhardt
2022-07-02 23:28 ` [FFmpeg-devel] [PATCH 01/20] avcodec/hevc_sei: Use proper type for NALU type Soft Works
2022-11-23 3:19 ` Andreas Rheinhardt
2022-11-23 4:15 ` Soft Works
2022-11-23 5:05 ` Soft Works
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