2022-06-27 16:33:24 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
2022-07-02 19:14:43 +02:00
|
|
|
#include "h2645_vui.h"
|
2022-06-27 16:33:24 +02:00
|
|
|
#include "sei.h"
|
|
|
|
|
|
|
|
typedef struct H2645SEIA53Caption {
|
|
|
|
AVBufferRef *buf_ref;
|
|
|
|
} H2645SEIA53Caption;
|
|
|
|
|
2022-07-02 14:20:36 +02:00
|
|
|
typedef struct H2645SEIAFD {
|
2022-06-27 16:33:24 +02:00
|
|
|
int present;
|
|
|
|
uint8_t active_format_description;
|
2022-07-02 14:20:36 +02:00
|
|
|
} H2645SEIAFD;
|
2022-06-27 16:33:24 +02:00
|
|
|
|
|
|
|
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)
|
2022-06-29 12:24:28 +02:00
|
|
|
SEIFpaType arrangement_type;
|
2022-06-27 16:33:24 +02:00
|
|
|
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;
|
|
|
|
|
2023-01-10 00:03:01 +02:00
|
|
|
typedef struct H2645SEIAmbientViewingEnvironment {
|
|
|
|
int present;
|
|
|
|
uint32_t ambient_illuminance;
|
|
|
|
uint16_t ambient_light_x;
|
|
|
|
uint16_t ambient_light_y;
|
|
|
|
} H2645SEIAmbientViewingEnvironment;
|
|
|
|
|
2022-06-27 16:33:24 +02:00
|
|
|
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;
|
|
|
|
|
2023-07-11 22:40:45 +02:00
|
|
|
typedef struct H2645SEIMasteringDisplay {
|
|
|
|
int present;
|
|
|
|
uint16_t display_primaries[3][2];
|
|
|
|
uint16_t white_point[2];
|
|
|
|
uint32_t max_luminance;
|
|
|
|
uint32_t min_luminance;
|
|
|
|
} H2645SEIMasteringDisplay;
|
|
|
|
|
2023-07-12 18:57:13 +02:00
|
|
|
typedef struct H2645SEIContentLight {
|
|
|
|
int present;
|
|
|
|
uint16_t max_content_light_level;
|
|
|
|
uint16_t max_pic_average_light_level;
|
|
|
|
} H2645SEIContentLight;
|
|
|
|
|
2022-06-27 16:33:24 +02:00
|
|
|
typedef struct H2645SEI {
|
|
|
|
H2645SEIA53Caption a53_caption;
|
2022-07-02 14:20:36 +02:00
|
|
|
H2645SEIAFD afd;
|
2022-06-27 16:33:24 +02:00
|
|
|
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;
|
2023-01-10 00:03:01 +02:00
|
|
|
H2645SEIAmbientViewingEnvironment ambient_viewing_environment;
|
2023-07-11 22:40:45 +02:00
|
|
|
H2645SEIMasteringDisplay mastering_display;
|
2023-07-12 18:57:13 +02:00
|
|
|
H2645SEIContentLight content_light;
|
2022-06-27 16:33:24 +02:00
|
|
|
} 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);
|
|
|
|
|
2022-06-27 18:49:01 +02:00
|
|
|
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
|
|
|
|
|
2022-07-02 20:52:31 +02:00
|
|
|
void ff_h2645_sei_reset(H2645SEI *s);
|
|
|
|
|
2022-06-29 11:24:08 +02:00
|
|
|
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
|
|
|
|
enum AVCodecID codec_id,
|
2022-07-02 19:14:43 +02:00
|
|
|
AVCodecContext *avctx, const H2645VUI *vui,
|
|
|
|
unsigned bit_depth_luma, unsigned bit_depth_chroma,
|
|
|
|
int seed);
|
2022-06-29 11:24:08 +02:00
|
|
|
|
2022-06-27 16:33:24 +02:00
|
|
|
#endif /* AVCODEC_H2645_SEI_H */
|