Go to the documentation of this file.
38 size_t dovi_size, ext_sz;
40 if (!
s->mapping || !
s->color)
60 #define COPY(t, a, b, last) memcpy(a, b, offsetof(t, last) + sizeof((b)->last))
65 for (
int i = 0;
i <
s->num_ext_blocks;
i++)
67 dovi->num_ext_blocks =
s->num_ext_blocks;
74 union { uint32_t u32;
float f32; } fpart;
93 union { uint32_t u32;
float f32; } fpart;
121 #define VALIDATE(VAR, MIN, MAX) \
123 if (VAR < MIN || VAR > MAX) { \
124 av_log(s->logctx, AV_LOG_ERROR, "RPU validation failed: " \
125 #MIN" <= "#VAR" = %d <= "#MAX"\n", (int) VAR); \
166 for (
int i = 0;
i < 4;
i++)
171 "Unknown Dolby Vision DM v1 level: %u\n", dm->
level);
178 const int denom = 32767;
185 int ext_block_length)
201 if (ext_block_length < 12)
204 if (ext_block_length < 13)
207 if (ext_block_length < 19)
209 for (
int i = 0;
i < 6;
i++)
211 if (ext_block_length < 25)
213 for (
int i = 0;
i < 6;
i++)
218 if (ext_block_length < 17)
230 if (ext_block_length < 21)
255 "Unknown Dolby Vision DM v2 level: %u\n", dm->
level);
261 int num_ext_blocks, ext_block_length, start_pos, parsed_bits;
268 if (!
s->ext_blocks) {
274 while (num_ext_blocks--) {
286 if (parsed_bits > ext_block_length * 8)
288 skip_bits(gb, ext_block_length * 8 - parsed_bits);
303 uint8_t vdr_seq_info_present;
304 uint8_t vdr_dm_metadata_present;
305 uint8_t use_prev_vdr_rpu;
313 if (
s->cfg.dv_profile == 10 ) {
328 const unsigned header_magic = 0x01be6841
u;
329 unsigned emdf_header, emdf_payload_size, emdf_protection;
333 VALIDATE(emdf_header, header_magic, header_magic);
335 VALIDATE(emdf_payload_size, 6, 512);
345 for (
int i = 0;
i < emdf_payload_size;
i++)
348 rpu_size = emdf_payload_size;
351 emdf_protection =
get_bits(gb, 5 + 12);
352 VALIDATE(emdf_protection, 0x400, 0x400);
359 while (rpu_size && rpu[rpu_size - 1] == 0)
363 if (!rpu_size || rpu[rpu_size - 1] != 0x80)
368 -1, rpu, rpu_size - 1));
383 "%"PRIu8
", ignoring\n", rpu_type);
395 if (vdr_seq_info_present) {
416 VALIDATE(bl_bit_depth_minus8, 0, 8);
417 VALIDATE(el_bit_depth_minus8, 0, 8);
418 VALIDATE(vdr_bit_depth_minus8, 0, 8);
444 if (use_prev_vdr_rpu) {
447 if (!
s->vdr[prev_vdr_rpu_id]) {
452 vdr =
s->vdr[prev_vdr_rpu_id];
457 if (!
s->vdr[vdr_rpu_id]) {
459 if (!
s->vdr[vdr_rpu_id])
463 vdr =
s->vdr[vdr_rpu_id];
470 for (
int c = 0;
c < 3;
c++) {
487 for (
int i = 0;
i < 2;
i++) {
505 for (
int c = 0;
c < 3;
c++) {
511 switch (mapping_idc) {
516 if (poly_order_minus1 == 0) {
518 if (linear_interp_flag) {
521 "linear interpolation");
531 int mmr_order_minus1 =
get_bits(gb, 2);
535 for (
int j = 0; j < curve->
mmr_order[
i]; j++) {
536 for (
int k = 0; k < 7; k++)
546 for (
int c = 0;
c < 3;
c++) {
560 if (vdr_dm_metadata_present) {
566 if (!
s->vdr[affected_dm_id]) {
568 if (!
s->vdr[affected_dm_id])
572 if (!
s->vdr[current_dm_id]) {
579 vdr =
s->vdr[current_dm_id];
583 vdr =
s->vdr[affected_dm_id];
585 color->dm_metadata_id = affected_dm_id;
587 for (
int i = 0;
i < 9;
i++)
589 for (
int i = 0;
i < 3;
i++) {
590 int denom =
profile == 4 ? (1 << 30) : (1 << 28);
599 for (
int i = 0;
i < 9;
i++)
617 s->num_ext_blocks = 0;
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVDOVINLQMethod nlq_method_idc
uint16_t trim_chroma_weight
#define AV_EF_EXPLODE
abort decoding on minor error detection
uint8_t saturation_vector_field[6]
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_dovi_ctx_unref(DOVIContext *s)
Completely reset a DOVIContext, preserving only logctx.
AVWhitepointCoefficients wp
#define u(width, name, range_min, range_max)
static int get_se_golomb_long(GetBitContext *gb)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
AVColorPrimariesDesc source_display_primaries
static int parse_ext_blocks(DOVIContext *s, GetBitContext *gb, int ver)
uint16_t trim_saturation_gain
static int get_bits_count(const GetBitContext *s)
uint8_t frame_rate_conversion
This structure describes decoded (raw) audio or video data.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
int64_t mmr_coef[AV_DOVI_MAX_PIECES][3][7]
uint8_t target_primary_index
enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES]
uint8_t target_display_index
uint8_t mapping_color_space
uint8_t hue_vector_field[6]
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
uint8_t reference_mode_flag
Dolby Vision metadata extension block.
int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition)
Parse the contents of a Dovi RPU NAL and update the parsed values in the DOVIContext struct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
uint8_t mmr_order[AV_DOVI_MAX_PIECES]
static int get_sbits(GetBitContext *s, int n)
uint8_t poly_order[AV_DOVI_MAX_PIECES]
uint64_t linear_deadzone_threshold
uint16_t target_mid_contrast
static int64_t get_se_coef(GetBitContext *gb, const AVDOVIRpuDataHeader *hdr)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
static void parse_ext_v2(DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm, int ext_block_length)
static unsigned int get_bits1(GetBitContext *s)
static void * ff_refstruct_allocz(size_t size)
Equivalent to ff_refstruct_alloc_ext(size, 0, NULL, NULL)
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
int64_t mmr_constant[AV_DOVI_MAX_PIECES]
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
uint8_t source_primary_index
Struct containing chromaticity x and y values for the standard CIE 1931 chromaticity definition.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
uint8_t target_display_index
AVColorPrimariesDesc target_display_primaries
AVDOVIDataMapping mapping
uint16_t trim_saturation_gain
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
static AVRational av_make_q(int num, int den)
Create an AVRational.
uint16_t trim_chroma_weight
int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame)
Attach the decoded AVDOVIMetadata as side data to an AVFrame.
int64_t poly_coef[AV_DOVI_MAX_PIECES][3]
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
#define i(width, name, range_min, range_max)
uint32_t num_y_partitions
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static AVCIExy get_cie_xy(GetBitContext *gb)
Coefficients of the non-linear inverse quantization.
AVDOVIReshapingCurve curves[3]
uint64_t linear_deadzone_slope
uint8_t mpeg_noise_reduction
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static const uint8_t * align_get_bits(GetBitContext *s)
#define COPY(t, a, b, last)
static uint64_t get_ue_coef(GetBitContext *gb, const AVDOVIRpuDataHeader *hdr)
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
uint8_t mapping_chroma_format_idc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define VALIDATE(VAR, MIN, MAX)
AVDOVIColorMetadata color
static unsigned get_variable_bits(GetBitContext *gb, int n)
A reference to a data buffer.
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define avpriv_request_sample(...)
Structure to hold side data for an AVFrame.
uint16_t pivots[AV_DOVI_MAX_PIECES+1]
AVPrimaryCoefficients prim
static void parse_ext_v1(DOVIContext *s, GetBitContext *gb, AVDOVIDmData *dm)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Dolby Vision RPU data mapping parameters.
uint32_t num_x_partitions
int ff_dovi_guess_profile_hevc(const AVDOVIRpuDataHeader *hdr)
Internal helper function to guess the correct DV profile for HEVC.