Go to the documentation of this file.
40 [1] = {1280*720*24, 1280, 20, 50},
41 [2] = {1280*720*30, 1280, 20, 50},
42 [3] = {1920*1080*24, 1920, 20, 70},
43 [4] = {1920*1080*30, 2560, 20, 70},
44 [5] = {1920*1080*60, 3840, 20, 70},
45 [6] = {3840*2160*24, 3840, 25, 130},
46 [7] = {3840*2160*30, 3840, 25, 130},
47 [8] = {3840*2160*48, 3840, 40, 130},
48 [9] = {3840*2160*60, 3840, 40, 130},
49 [10] = {3840*2160*120, 3840, 60, 240},
50 [11] = {3840*2160*120, 7680, 60, 240},
51 [12] = {7680*4320*60, 7680, 120, 450},
52 [13] = {7680*4320*120
u, 7680, 240, 800},
60 int dv_profile, dv_level, bl_compat_id;
87 if (dv_profile == 9) {
104 "layers is currently unsupported.");
139 if (!dv_profile || bl_compat_id < 0) {
142 "not determine profile and compaatibility mode. Double-check "
143 "colorspace and format settings for compatibility?\n");
173 "exceed Dolby Vision limitations\n",
pps, avctx->
width);
177 "exceed Dolby Vision limitations. Ignoring, resulting file "
178 "may be non-conforming.\n",
pps, avctx->
width);
213 union { uint32_t u32;
float f32; } fpart;
231 union { uint32_t u32;
float f32; } fpart;
248 if (!q.
den || q.
den == den)
256 int ext_block_length, start_pos, pad_bits;
259 case 1: ext_block_length = 5;
break;
260 case 2: ext_block_length = 11;
break;
261 case 4: ext_block_length = 3;
break;
262 case 5: ext_block_length = 7;
break;
263 case 6: ext_block_length = 8;
break;
264 case 255: ext_block_length = 6;
break;
306 for (
int i = 0;
i < 4;
i++)
311 pad_bits = ext_block_length * 8 - (
put_bits_count(pb) - start_pos);
318 const int denom = 32767;
323 #define ANY6(arr) (arr[0] || arr[1] || arr[2] || arr[3] || arr[4] || arr[5])
324 #define ANY_XY(xy) (xy.x.num || xy.y.num)
325 #define ANY_CSP(csp) (ANY_XY(csp.prim.r) || ANY_XY(csp.prim.g) || \
326 ANY_XY(csp.prim.b) || ANY_XY(csp.wp))
330 int ext_block_length, start_pos, pad_bits;
333 case 3: ext_block_length = 5;
break;
336 ext_block_length = 25;
338 ext_block_length = 19;
340 ext_block_length = 13;
342 ext_block_length = 12;
344 ext_block_length = 10;
349 ext_block_length = 17;
351 ext_block_length = 1;
356 ext_block_length = 21;
358 ext_block_length = 5;
361 case 11: ext_block_length = 4;
break;
362 case 254: ext_block_length = 2;
break;
384 if (ext_block_length < 12)
387 if (ext_block_length < 13)
390 if (ext_block_length < 19)
392 for (
int i = 0;
i < 6;
i++)
394 if (ext_block_length < 25)
396 for (
int i = 0;
i < 6;
i++)
401 if (ext_block_length < 17)
413 if (ext_block_length < 21)
438 pad_bits = ext_block_length * 8 - (
put_bits_count(pb) - start_pos);
450 int vdr_dm_metadata_changed, vdr_rpu_id, use_prev_vdr_rpu,
profile,
451 buffer_size, rpu_size, pad, zero_run;
452 int num_ext_blocks_v1, num_ext_blocks_v2;
474 if (
s->vdr[
i] && !memcmp(&
s->vdr[
i]->mapping, mapping,
sizeof(*mapping))) {
482 if (!
s->vdr[vdr_rpu_id]) {
484 if (!
s->vdr[vdr_rpu_id])
488 if (!
s->vdr[
color->dm_metadata_id]) {
490 if (!
s->vdr[
color->dm_metadata_id])
494 num_ext_blocks_v1 = num_ext_blocks_v2 = 0;
521 vdr_dm_metadata_changed = !
s->color || memcmp(
s->color,
color,
sizeof(*
color));
522 use_prev_vdr_rpu = !memcmp(&
s->vdr[vdr_rpu_id]->mapping, mapping,
sizeof(*mapping));
524 buffer_size = 12 + 5 ;
525 buffer_size += num_ext_blocks_v1 * 13;
526 buffer_size += num_ext_blocks_v2 * 28;
527 if (!use_prev_vdr_rpu) {
529 for (
int c = 0;
c < 3;
c++) {
538 if (vdr_dm_metadata_changed)
569 put_bits(pb, 1, vdr_dm_metadata_changed);
572 s->mapping = &
s->vdr[vdr_rpu_id]->mapping;
574 if (!use_prev_vdr_rpu) {
577 for (
int c = 0;
c < 3;
c++) {
596 for (
int c = 0;
c < 3;
c++) {
612 for (
int j = 0; j < curve->
mmr_order[
i]; j++) {
613 for (
int k = 0; k < 7; k++)
623 for (
int c = 0;
c < 3;
c++) {
636 memcpy(&
s->vdr[vdr_rpu_id]->mapping, mapping,
sizeof(*mapping));
639 if (vdr_dm_metadata_changed) {
640 const int denom =
profile == 4 ? (1 << 30) : (1 << 28);
644 for (
int i = 0;
i < 9;
i++)
646 for (
int i = 0;
i < 3;
i++)
648 for (
int i = 0;
i < 9;
i++)
663 s->color = &
s->vdr[
color->dm_metadata_id]->color;
671 if (num_ext_blocks_v2) {
686 switch (
s->cfg.dv_profile) {
697 if (rpu_size > 0xFF) {
699 put_bits(pb, 8, (rpu_size >> 8) - 1);
718 *out_rpu = dst =
av_malloc(1 + rpu_size * 3 / 2);
723 for (
int i = 0;
i < rpu_size;
i++) {
725 if (
s->rpu_buf[
i] == 0) {
731 if ((
s->rpu_buf[
i] & ~3) == 0) {
735 zero_run =
s->rpu_buf[
i] == 0;
737 *dst++ =
s->rpu_buf[
i];
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVDOVINLQMethod nlq_method_idc
uint16_t trim_chroma_weight
uint8_t saturation_vector_field[6]
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
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
enum AVColorSpace colorspace
YUV colorspace type.
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
AVWhitepointCoefficients wp
static int put_bytes_output(const PutBitContext *s)
#define u(width, name, range_min, range_max)
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
AVColorPrimariesDesc source_display_primaries
uint16_t trim_saturation_gain
uint8_t frame_rate_conversion
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int64_t mmr_coef[AV_DOVI_MAX_PIECES][3][7]
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
uint8_t target_primary_index
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define AV_PIX_FMT_YUV420P10
enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES]
uint8_t target_display_index
uint8_t mapping_color_space
uint8_t hue_vector_field[6]
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
uint8_t reference_mode_flag
int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, uint8_t **out_rpu, int *out_size)
Synthesize a Dolby Vision RPU reflecting the current state.
#define FF_DOVI_AUTOMATIC
Enable tri-state.
static void generate_ext_v1(PutBitContext *pb, const AVDOVIDmData *dm)
Dolby Vision metadata extension block.
exp golomb vlc writing stuff
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
uint8_t mmr_order[AV_DOVI_MAX_PIECES]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void put_se_coef(PutBitContext *pb, const AVDOVIRpuDataHeader *hdr, uint64_t coef)
uint8_t poly_order[AV_DOVI_MAX_PIECES]
uint64_t linear_deadzone_threshold
uint16_t target_mid_contrast
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
uint8_t dv_bl_signal_compatibility_id
Rational number (pair of numerator and denominator).
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
static void put_cie_xy(PutBitContext *pb, AVCIExy xy)
static void * ff_refstruct_allocz(size_t size)
Equivalent to ff_refstruct_alloc_ext(size, 0, NULL, NULL)
int64_t mmr_constant[AV_DOVI_MAX_PIECES]
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
@ AVCOL_PRI_BT2020
ITU-R BT2020.
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
#define ITU_T_T35_PROVIDER_CODE_DOLBY
uint8_t target_display_index
static int av_q2den(AVRational q, int den)
AVColorPrimariesDesc target_display_primaries
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
static void set_se_golomb(PutBitContext *pb, int i)
write signed exp golomb code.
int64_t poly_coef[AV_DOVI_MAX_PIECES][3]
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
@ AVCOL_TRC_BT709
also ITU-R BT1361
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
static int put_bits_count(PutBitContext *s)
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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...
Coefficients of the non-linear inverse quantization.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void set_ue_golomb(PutBitContext *pb, int i)
write unsigned exp golomb code.
AVDOVIReshapingCurve curves[3]
uint64_t linear_deadzone_slope
static struct @93 dv_levels[]
static void generate_ext_v2(PutBitContext *pb, const AVDOVIDmData *dm)
int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
Configure the encoder for Dolby Vision encoding.
uint8_t mpeg_noise_reduction
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
main external API structure.
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
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.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define ITU_T_T35_COUNTRY_CODE_US
Structure to hold side data for an AVFrame.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
uint16_t pivots[AV_DOVI_MAX_PIECES+1]
AVPrimaryCoefficients prim
static const AVFrameSideData * av_frame_side_data_get(AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conver...
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
static void put_ue_coef(PutBitContext *pb, const AVDOVIRpuDataHeader *hdr, uint64_t coef)
Dolby Vision RPU data mapping parameters.
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
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.