FFmpeg
Loading...
Searching...
No Matches
dovi_rpuenc.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "avcodec.h"
#include "dovi_rpu.h"
#include "itut35.h"
#include "put_bits.h"
#include "put_golomb.h"

Go to the source code of this file.

Macros

#define ANY6(arr)
 
#define ANY_XY(xy)
 
#define ANY_CSP(csp)
 

Functions

static av_cold int dovi_configure_ext (DOVIContext *s, enum AVCodecID codec_id, const AVDOVIMetadata *metadata, enum AVDOVICompression compression, int strict_std_compliance, int width, int height, AVRational framerate, enum AVPixelFormat pix_format, enum AVColorSpace color_space, enum AVColorPrimaries color_primaries, enum AVColorTransferCharacteristic color_trc, AVPacketSideData **coded_side_data, int *nb_coded_side_data)
 
av_cold int ff_dovi_configure_from_codedpar (DOVIContext *s, AVCodecParameters *par, const AVDOVIMetadata *metadata, enum AVDOVICompression compression, int strict_std_compliance)
 Configure the encoder for Dolby Vision encoding.
 
av_cold int ff_dovi_configure (DOVIContext *s, AVCodecContext *avctx)
 Variant of ff_dovi_configure_from_codedpar which infers the codec parameters from an AVCodecContext.
 
static int cmp_dm_level0 (const AVDOVIColorMetadata *dm1, const AVDOVIColorMetadata *dm2)
 
static int try_reuse_ext (DOVIExt *ext, const AVDOVIMetadata *metadata)
 
static void put_ue_coef (PutBitContext *pb, const AVDOVIRpuDataHeader *hdr, uint64_t coef)
 
static void put_se_coef (PutBitContext *pb, const AVDOVIRpuDataHeader *hdr, uint64_t coef)
 
static int validate_ue_golomb_value (uint64_t value)
 
static int validate_se_golomb_value (int64_t value)
 
static int validate_ue_coef (const AVDOVIRpuDataHeader *hdr, uint64_t coef)
 
static int validate_se_coef (const AVDOVIRpuDataHeader *hdr, int64_t coef)
 
static int validate_mapping_for_generation (const AVDOVIRpuDataHeader *hdr, const AVDOVIDataMapping *mapping)
 
static int av_q2den (AVRational q, int den)
 
static void generate_ext_v1 (PutBitContext *pb, const AVDOVIDmData *dm)
 
static void put_cie_xy (PutBitContext *pb, AVCIExy xy)
 
static void generate_ext_v2 (PutBitContext *pb, const AVDOVIDmData *dm)
 
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.
 

Variables

struct { 
 
   uint64_t   pps 
 
   int   width 
 
   int   main 
 
   int   high 
 
dv_levels [] 
 

Macro Definition Documentation

◆ ANY6

#define ANY6 ( arr)
Value:
(arr[0] || arr[1] || arr[2] || arr[3] || arr[4] || arr[5])

Definition at line 528 of file dovi_rpuenc.c.

Referenced by generate_ext_v2().

◆ ANY_XY

#define ANY_XY ( xy)
Value:
(xy.x.num || xy.y.num)

Definition at line 529 of file dovi_rpuenc.c.

◆ ANY_CSP

#define ANY_CSP ( csp)
Value:
(ANY_XY(csp.prim.r) || ANY_XY(csp.prim.g) || \
ANY_XY(csp.prim.b) || ANY_XY(csp.wp))
#define ANY_XY(xy)

Definition at line 530 of file dovi_rpuenc.c.

Referenced by generate_ext_v2().

Function Documentation

◆ dovi_configure_ext()

static av_cold int dovi_configure_ext ( DOVIContext * s,
enum AVCodecID codec_id,
const AVDOVIMetadata * metadata,
enum AVDOVICompression compression,
int strict_std_compliance,
int width,
int height,
AVRational framerate,
enum AVPixelFormat pix_format,
enum AVColorSpace color_space,
enum AVColorPrimaries color_primaries,
enum AVColorTransferCharacteristic color_trc,
AVPacketSideData ** coded_side_data,
int * nb_coded_side_data )
static

Definition at line 56 of file dovi_rpuenc.c.

Referenced by ff_dovi_configure(), and ff_dovi_configure_from_codedpar().

◆ ff_dovi_configure_from_codedpar()

av_cold int ff_dovi_configure_from_codedpar ( DOVIContext * s,
AVCodecParameters * codecpar,
const AVDOVIMetadata * metadata,
enum AVDOVICompression compression,
int strict_std_compliance )

Configure the encoder for Dolby Vision encoding.

Generates a configuration record in s->cfg, and attaches it to codecpar->coded_side_data. Sets the correct profile and compatibility ID based on the tagged AVCodecParameters colorspace metadata, and the correct level based on the resolution and tagged framerate.

metadata should point to the first frame's RPU, if available. If absent, auto-detection will be performed, but this can sometimes lead to inaccurate results (in particular for HEVC streams with enhancement layers).

Returns 0 or a negative error code.

Definition at line 248 of file dovi_rpuenc.c.

Referenced by dovi_rpu_init().

◆ ff_dovi_configure()

av_cold int ff_dovi_configure ( DOVIContext * s,
AVCodecContext * avctx )

Variant of ff_dovi_configure_from_codedpar which infers the codec parameters from an AVCodecContext.

Definition at line 260 of file dovi_rpuenc.c.

Referenced by aom_init(), eb_enc_init(), and libx265_encode_init().

◆ cmp_dm_level0()

static int cmp_dm_level0 ( const AVDOVIColorMetadata * dm1,
const AVDOVIColorMetadata * dm2 )
static

Definition at line 280 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ try_reuse_ext()

static int try_reuse_ext ( DOVIExt * ext,
const AVDOVIMetadata * metadata )
static

Definition at line 304 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ put_ue_coef()

static void put_ue_coef ( PutBitContext * pb,
const AVDOVIRpuDataHeader * hdr,
uint64_t coef )
inlinestatic

Definition at line 334 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ put_se_coef()

static void put_se_coef ( PutBitContext * pb,
const AVDOVIRpuDataHeader * hdr,
uint64_t coef )
inlinestatic

Definition at line 352 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ validate_ue_golomb_value()

static int validate_ue_golomb_value ( uint64_t value)
static

Definition at line 370 of file dovi_rpuenc.c.

Referenced by validate_ue_coef().

◆ validate_se_golomb_value()

static int validate_se_golomb_value ( int64_t value)
static

Definition at line 375 of file dovi_rpuenc.c.

Referenced by validate_se_coef().

◆ validate_ue_coef()

static int validate_ue_coef ( const AVDOVIRpuDataHeader * hdr,
uint64_t coef )
static

Definition at line 380 of file dovi_rpuenc.c.

Referenced by validate_mapping_for_generation().

◆ validate_se_coef()

static int validate_se_coef ( const AVDOVIRpuDataHeader * hdr,
int64_t coef )
static

Definition at line 387 of file dovi_rpuenc.c.

Referenced by validate_mapping_for_generation().

◆ validate_mapping_for_generation()

static int validate_mapping_for_generation ( const AVDOVIRpuDataHeader * hdr,
const AVDOVIDataMapping * mapping )
static

Definition at line 394 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ av_q2den()

static int av_q2den ( AVRational q,
int den )
static

Definition at line 451 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate(), and put_cie_xy().

◆ generate_ext_v1()

static void generate_ext_v1 ( PutBitContext * pb,
const AVDOVIDmData * dm )
static

Definition at line 459 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ put_cie_xy()

static void put_cie_xy ( PutBitContext * pb,
AVCIExy xy )
static

Definition at line 521 of file dovi_rpuenc.c.

Referenced by generate_ext_v2().

◆ generate_ext_v2()

static void generate_ext_v2 ( PutBitContext * pb,
const AVDOVIDmData * dm )
static

Definition at line 533 of file dovi_rpuenc.c.

Referenced by ff_dovi_rpu_generate().

◆ ff_dovi_rpu_generate()

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.

By default, the RPU is not encapsulated (see flags for more options). Note that this assumes all previous calls to ff_dovi_rpu_generate have been appropriately signalled, i.e. it will not re-send already transmitted redundant data.

Mutates the internal state of DOVIContext to reflect the change. Returns 0 or a negative error code.

Definition at line 644 of file dovi_rpuenc.c.

Referenced by aom_encode(), eb_send_frame(), libx265_encode_frame(), and update_rpu().

Variable Documentation

◆ pps

uint64_t pps

Definition at line 36 of file dovi_rpuenc.c.

Referenced by alf_get_edges(), alf_get_subblocks(), alloc_cu(), alloc_frame(), apply_averaging(), base_unit_to_vk(), base_unit_to_vk(), bcw_idx_decode(), build_qp_table(), can_split(), cbs_h2645_replace_ps(), cbs_h2645_replace_ps(), cbs_h264_write_nal_unit(), cbs_h265_write_nal_unit(), cbs_h266_read_nal_unit(), cbs_h266_replace_ps(), cbs_h266_write_nal_unit(), chroma_mc_bi(), chroma_mc_uni(), chroma_qp_offset_decode(), chroma_tc(), coding_tree_bth(), coding_tree_btv(), coding_tree_qt(), colour_mapping_octants(), colour_mapping_table(), ctu_nz_tl_init(), ctu_rs(), ctu_xy(), d3d12va_encode_h264_init_sequence_params(), d3d12va_encode_hevc_init_sequence_params(), deblocking_filter_CTB(), decode_ph(), decode_pps(), decode_scaling_matrices(), decode_slice_data(), delta_dlt(), derive_center_luma_intra_pred_mode(), derive_chroma_intra_pred_mode(), derive_dmvr_bdof_flag(), derive_spatial_merge_candidates(), derive_weight_uni(), dovi_configure_ext(), dual_tree_implicit_qt_split(), emulated_edge(), end_of_access_unit_found(), export_frame_params(), ff_dxva2_h264_fill_picture_parameters(), ff_dxva2_h264_fill_scaling_lists(), ff_dxva2_hevc_fill_picture_parameters(), ff_evc_derive_poc(), ff_evc_parse_pps(), ff_evc_parse_slice_header(), ff_h264_decode_picture_parameter_set(), ff_h264_execute_ref_pic_marking(), ff_h264_parse_ref_count(), ff_h264_queue_decode_slice(), ff_hevc_cabac_init(), ff_hevc_deblocking_boundary_strengths(), ff_hevc_decode_nal_pps(), ff_hevc_frame_nb_refs(), ff_hevc_hls_filter(), ff_hevc_hls_filters(), ff_hevc_hls_residual_coding(), ff_hevc_luma_mv_merge_mode(), ff_hevc_luma_mv_mvp_mode(), ff_hevc_save_states(), ff_hevc_set_qPy(), ff_hw_base_encode_init_params_h264(), ff_hw_base_encode_init_params_h265(), ff_intra_pred_8_16x16_msa(), ff_intra_pred_8_16x16_msa(), ff_intra_pred_8_32x32_msa(), ff_intra_pred_8_32x32_msa(), ff_isom_write_avcc(), ff_videotoolbox_hvcc_extradata_create(), ff_vvc_cabac_init(), ff_vvc_coding_tree_unit(), ff_vvc_frame_thread_init(), ff_vvc_slice_rpl(), ff_vvc_split_cu_flag(), fill_dmvr_info(), generate_missing_ref(), get_chroma_qp(), get_qp_y_pred(), get_qPy_pred(), h264_extradata_to_annexb(), h264_probe(), h264_redundant_pps_fixup_pps(), h264_redundant_pps_fixup_slice(), h264_slice_header_parse(), h265_metadata_guess_level(), hevc_frame_start(), hevc_luma_mv_mvp_mode(), hevc_parse_slice_header(), hevc_pps_free(), hevc_probe(), hls_coding_quadtree(), hls_coding_tree(), hls_coding_tree_unit(), hls_coding_unit(), hls_decode_entry(), hls_decode_entry_wpp(), hls_decode_neighbour(), hls_pcm_sample(), hls_prediction_unit(), hls_sao_param(), hls_slice_data_wpp(), hls_slice_header(), hls_transform_tree(), hls_transform_unit(), hls_transform_unit(), ibc_tl_init(), init_dequant4_coeff_table(), init_dequant8_coeff_table(), init_dequant_tables(), intra_luma_pred_modes(), intra_pred(), intra_pred(), is_diff_mer(), is_first_row(), ispmf_tl_init(), luma_mc_bi(), luma_mc_uni(), min_cb_nz_tl_init(), min_cb_tl_init(), min_pu_nz_tl_init(), min_pu_tl_init(), min_tu_nz_tl_init(), min_tu_tl_init(), msm_tl_init(), nvdec_h264_start_frame(), nvdec_hevc_start_frame(), palette_qp(), parse_feedback_units(), parse_feedback_units(), parse_nal_unit(), ph_derive(), ph_vb(), pic_arrays_init(), picture_header(), pixel_buffer_nz_tl_init(), pps(), pps(), pps(), pps_3d_extension(), pps_add_ctus(), pps_alloc(), pps_bd(), pps_chroma_qp_offset(), pps_derive(), pps_free(), pps_free(), pps_multi_tiles_slice(), pps_multilayer_extension(), pps_no_rect_slice(), pps_one_tile_slices(), pps_range_extensions(), pps_rect_slice(), pps_ref_wraparound_offset(), pps_scc_extension(), pps_single_slice_per_subpic(), pps_single_slice_picture(), pps_slice_map(), pps_subpic(), pps_subpic_less_than_one_tile_slice(), pps_subpic_one_or_more_tiles_slice(), pps_subpic_slice(), pps_width_height(), pred_get_y(), pred_weight_table(), ref_pic_lists(), restore_tqb_pixels(), sao_filter_CTB(), sao_get_edges(), sb_clip_location(), set_cb_pos(), set_cb_tab(), set_dmvr_info(), set_parser_ctx(), set_pps(), set_pps(), set_qp_c(), setup_pps(), sh_derive(), sh_entry_points(), sh_inter(), sh_qp_y(), sh_slice_address(), slice_header(), slice_header(), slice_segment_header(), subpic_get_rect(), subpic_tiles(), temporal_luma_motion_vector(), tile_xy(), vaapi_encode_h264_init_sequence_params(), vaapi_encode_h264_init_slice_params(), vaapi_encode_h265_init_sequence_params(), vaapi_encode_h265_init_slice_params(), vaapi_h264_start_frame(), vaapi_hevc_start_frame(), vaapi_vvc_decode_slice(), vaapi_vvc_start_frame(), vdpau_h264_start_frame(), vdpau_hevc_start_frame(), vk_hevc_end_frame(), vk_hevc_start_frame(), vvc_probe(), and z_scan_block_avail().

◆ width

int width

Definition at line 37 of file dovi_rpuenc.c.

◆ main

◆ high

◆ [struct]

const struct { ... } dv_levels[]
Initial value:
= {
[1] = {1280*720*24, 1280, 20, 50},
[2] = {1280*720*30, 1280, 20, 50},
[3] = {1920*1080*24, 1920, 20, 70},
[4] = {1920*1080*30, 2560, 20, 70},
[5] = {1920*1080*60, 3840, 20, 70},
[6] = {3840*2160*24, 3840, 25, 130},
[7] = {3840*2160*30, 3840, 25, 130},
[8] = {3840*2160*48, 3840, 40, 130},
[9] = {3840*2160*60, 3840, 40, 130},
[10] = {3840*2160*120, 3840, 60, 240},
[11] = {3840*2160*120, 7680, 60, 240},
[12] = {7680*4320*60, 7680, 120, 450},
[13] = {7680*4320*120u, 7680, 240, 800},
}

Referenced by dovi_configure_ext().