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},
58 int strict_std_compliance)
62 int dv_profile, dv_level, bl_compat_id = -1;
103 if (dv_profile == 9) {
112 switch (dv_profile) {
117 "layers is currently unsupported.");
149 if (!dv_profile || bl_compat_id < 0) {
152 "not determine profile and compatibility mode. Double-check "
153 "colorspace and format settings for compatibility?\n");
162 "is not permitted for profiles 7 and earlier. (dv_profile: %d, "
163 "compression: %d)\n", dv_profile, compression);
168 "compression is experimental and not supported by "
171 }
else if (dv_profile == 8) {
173 "for profile 8 is known to be unsupported by many devices, "
174 "use with caution.\n");
202 "exceed Dolby Vision limitations\n",
pps, codecpar->
width);
206 "exceed Dolby Vision limitations. Ignoring, resulting file "
207 "may be non-conforming.\n",
pps, codecpar->
width);
310 if (!memcmp(&ext->
dm_static[j], dm,
sizeof(*dm))) {
332 union { uint32_t u32;
float f32; } fpart;
350 union { uint32_t u32;
float f32; } fpart;
367 if (!q.
den || q.
den == den)
375 int ext_block_length, start_pos, pad_bits;
378 case 1: ext_block_length = 5;
break;
379 case 2: ext_block_length = 11;
break;
380 case 4: ext_block_length = 3;
break;
381 case 5: ext_block_length = 7;
break;
382 case 6: ext_block_length = 8;
break;
383 case 255: ext_block_length = 6;
break;
425 for (
int i = 0;
i < 4;
i++)
430 pad_bits = ext_block_length * 8 - (
put_bits_count(pb) - start_pos);
437 const int denom = 32767;
442 #define ANY6(arr) (arr[0] || arr[1] || arr[2] || arr[3] || arr[4] || arr[5])
443 #define ANY_XY(xy) (xy.x.num || xy.y.num)
444 #define ANY_CSP(csp) (ANY_XY(csp.prim.r) || ANY_XY(csp.prim.g) || \
445 ANY_XY(csp.prim.b) || ANY_XY(csp.wp))
449 int ext_block_length, start_pos, pad_bits;
452 case 3: ext_block_length = 5;
break;
455 ext_block_length = 25;
457 ext_block_length = 19;
459 ext_block_length = 13;
461 ext_block_length = 12;
463 ext_block_length = 10;
468 ext_block_length = 17;
470 ext_block_length = 1;
475 ext_block_length = 21;
477 ext_block_length = 5;
480 case 11: ext_block_length = 4;
break;
481 case 254: ext_block_length = 2;
break;
503 if (ext_block_length < 12)
506 if (ext_block_length < 13)
509 if (ext_block_length < 19)
511 for (
int i = 0;
i < 6;
i++)
513 if (ext_block_length < 25)
515 for (
int i = 0;
i < 6;
i++)
520 if (ext_block_length < 17)
532 if (ext_block_length < 21)
557 pad_bits = ext_block_length * 8 - (
put_bits_count(pb) - start_pos);
569 int vdr_dm_metadata_present, vdr_rpu_id, use_prev_vdr_rpu,
profile,
570 buffer_size, rpu_size, pad, zero_run, dm_compression;
571 int num_ext_blocks_v1, num_ext_blocks_v2;
572 int dv_md_compression =
s->cfg.dv_md_compression;
601 use_prev_vdr_rpu = 0;
603 if (!
s->vdr[vdr_rpu_id]) {
605 if (!
s->vdr[vdr_rpu_id])
609 switch (dv_md_compression) {
616 if (
s->vdr[vdr_rpu_id])
617 use_prev_vdr_rpu = !memcmp(
s->vdr[vdr_rpu_id], mapping,
sizeof(*mapping));
640 vdr_dm_metadata_present = 1;
642 if (vdr_dm_metadata_present && !
s->dm) {
654 num_ext_blocks_v1 = num_ext_blocks_v2 = 0;
684 buffer_size = 12 + 5 ;
685 buffer_size += num_ext_blocks_v1 * 13;
686 buffer_size += num_ext_blocks_v2 * 28;
687 if (!use_prev_vdr_rpu) {
689 for (
int c = 0;
c < 3;
c++) {
698 if (vdr_dm_metadata_present)
730 put_bits(pb, 1, vdr_dm_metadata_present);
733 s->mapping =
s->vdr[vdr_rpu_id];
737 if (!use_prev_vdr_rpu) {
740 for (
int c = 0;
c < 3;
c++) {
759 for (
int c = 0;
c < 3;
c++) {
775 for (
int j = 0; j < curve->
mmr_order[
i]; j++) {
776 for (
int k = 0; k < 7; k++)
786 for (
int c = 0;
c < 3;
c++) {
799 memcpy(
s->vdr[vdr_rpu_id], mapping,
sizeof(*mapping));
802 if (vdr_dm_metadata_present) {
804 const int denom =
profile == 4 ? (1 << 30) : (1 << 28);
808 if (!dm_compression) {
809 for (
int i = 0;
i < 9;
i++)
811 for (
int i = 0;
i < 3;
i++)
813 for (
int i = 0;
i < 9;
i++)
841 if (num_ext_blocks_v2) {
861 else if (!dm_compression)
887 if (rpu_size > 0xFF) {
889 put_bits(pb, 8, (rpu_size >> 8) - 1);
911 for (
int i = 0;
i < rpu_size;
i++) {
913 if (
s->rpu_buf[
i] == 0) {
919 if ((
s->rpu_buf[
i] & ~3) == 0) {
923 zero_run =
s->rpu_buf[
i] == 0;
925 *
dst++ =
s->rpu_buf[
i];
931 *out_rpu =
s->rpu_buf;
#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.
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.
int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, int flags, uint8_t **out_rpu, int *out_size)
Synthesize a Dolby Vision RPU reflecting the current state.
AVWhitepointCoefficients wp
static int put_bytes_output(const PutBitContext *s)
This struct describes the properties of an encoded stream.
#define u(width, name, range_min, range_max)
enum AVColorSpace color_space
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
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
const AVDOVIColorMetadata ff_dovi_color_default
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]
AVRational framerate
Video only.
uint8_t target_display_index
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
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....
enum AVColorPrimaries color_primaries
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
uint8_t dv_md_compression
@ FF_DOVI_WRAP_T35
wrap inside T.35+EMDF
#define FF_DOVI_AUTOMATIC
Enable tri-state.
@ FF_DOVI_COMPRESS_RPU
enable compression for this RPU
static void generate_ext_v1(PutBitContext *pb, const AVDOVIDmData *dm)
enum AVColorTransferCharacteristic color_trc
Dolby Vision metadata extension block.
exp golomb vlc writing stuff
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, const AVDOVIMetadata *metadata, enum AVDOVICompression compression, int strict_std_compliance)
Configure the encoder for Dolby Vision encoding.
uint8_t mmr_order[AV_DOVI_MAX_PIECES]
AVDOVIDmData dm_static[7]
static extension blocks
#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)
int nb_coded_side_data
Amount of entries in coded_side_data.
@ AVCOL_SPC_IPT_C2
SMPTE ST 2128, IPT-C2.
uint8_t poly_order[AV_DOVI_MAX_PIECES]
uint64_t linear_deadzone_threshold
uint16_t target_mid_contrast
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
uint8_t dv_bl_signal_compatibility_id
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
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
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int try_reuse_ext(DOVIExt *ext, const AVDOVIMetadata *metadata)
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
AVDOVIDmData dm_dynamic[25]
dynamic extension blocks
static void set_se_golomb(PutBitContext *pb, int i)
write signed exp golomb code.
static struct @108 dv_levels[]
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
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
#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.
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
static void set_ue_golomb(PutBitContext *pb, int i)
write unsigned exp golomb code.
AVDOVIReshapingCurve curves[3]
uint64_t linear_deadzone_slope
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static void generate_ext_v2(PutBitContext *pb, const AVDOVIDmData *dm)
int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx)
Helper wrapper around ff_dovi_configure_ext which infers the codec parameters from an AVCodecContext.
uint8_t mpeg_noise_reduction
#define FFSWAP(type, a, b)
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.
@ FF_DOVI_WRAP_NAL
wrap inside NAL RBSP
static int ff_dovi_rpu_extension_is_static(int level)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define ITU_T_T35_COUNTRY_CODE_US
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Structure to hold side data for an AVFrame.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
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...
#define flags(name, subs,...)
#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 int cmp_dm_level0(const AVDOVIColorMetadata *dm1, const AVDOVIColorMetadata *dm2)
void ff_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
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.