FFmpeg
Macros | Functions | Variables
dovi_rpuenc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "dovi_rpu.h"
#include "itut35.h"
#include "put_bits.h"
#include "put_golomb.h"
#include "refstruct.h"

Go to the source code of this file.

Macros

#define ANY6(arr)   (arr[0] || arr[1] || arr[2] || arr[3] || arr[4] || arr[5])
 
#define ANY_XY(xy)   (xy.x.num || xy.y.num)
 
#define ANY_CSP(csp)
 

Functions

int ff_dovi_configure (DOVIContext *s, AVCodecContext *avctx)
 Configure the encoder for Dolby Vision encoding. More...
 
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 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, uint8_t **out_rpu, int *out_size)
 Synthesize a Dolby Vision RPU reflecting the current state. More...
 

Variables

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

Macro Definition Documentation

◆ ANY6

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

Definition at line 317 of file dovi_rpuenc.c.

◆ ANY_XY

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

Definition at line 318 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))

Definition at line 319 of file dovi_rpuenc.c.

Function Documentation

◆ ff_dovi_configure()

int ff_dovi_configure ( DOVIContext s,
AVCodecContext avctx 
)

Configure the encoder for Dolby Vision encoding.

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

Returns 0 or a negative error code.

Definition at line 55 of file dovi_rpuenc.c.

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

◆ put_ue_coef()

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

Definition at line 204 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 222 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 240 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 248 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 310 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 322 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,
uint8_t **  out_rpu,
int out_size 
)

Synthesize a Dolby Vision RPU reflecting the current state.

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.

This generates a fully formed RPU ready for inclusion in the bitstream, including the EMDF header (profile 10) or NAL encapsulation (otherwise).

Definition at line 437 of file dovi_rpuenc.c.

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

Variable Documentation

◆ pps

uint64_t pps

Definition at line 35 of file dovi_rpuenc.c.

Referenced by alloc_cu(), alloc_frame(), bcw_idx_decode(), bs_tl_init(), build_qp_table(), can_split(), cbs_h264_read_nal_unit(), cbs_h264_write_nal_unit(), cbs_h265_read_nal_unit(), cbs_h265_write_nal_unit(), cbs_h266_read_nal_unit(), 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_tl_init(), ctu_xy(), 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(), derive_weight_uni(), dual_tree_implicit_qt_split(), emulated_edge(), end_of_access_unit_found(), export_frame_params(), ff_dovi_configure(), 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_intra_pred_8_16x16_msa(), ff_intra_pred_8_32x32_msa(), ff_isom_write_avcc(), ff_videotoolbox_hvcc_extradata_create(), ff_vvc_alf_filter(), 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(), ibc_tl_init(), init_dequant4_coeff_table(), init_dequant8_coeff_table(), init_dequant_tables(), intra_luma_pred_modes(), intra_pred(), is_diff_mer(), is_first_row(), ispmf_tl_init(), luma_mc_bi(), luma_mc_uni(), min_cb_tl_init(), min_pu_tl_init(), min_tu_tl_init(), msm_tl_init(), nvdec_h264_start_frame(), nvdec_hevc_start_frame(), parse_nal_unit(), ph_derive(), pic_arrays_init(), pixel_buffer_nz_tl_init(), pps_3d_extension(), pps_add_ctus(), pps_alloc(), pps_bd(), pps_chroma_qp_offset(), pps_derive(), 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(), restore_tqb_pixels(), sao_filter_CTB(), sb_clip_location(), set_cb_pos(), set_cb_tab(), set_dmvr_info(), set_parser_ctx(), set_pps(), set_qp_c(), setup_pps(), sh_derive(), sh_entry_points(), sh_inter(), sh_qp_y(), sh_slice_address(), 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(), vdpau_h264_start_frame(), vdpau_hevc_start_frame(), vk_hevc_end_frame(), vk_hevc_start_frame(), vvc_deblock_bs(), and vvc_probe().

◆ width

int width

Definition at line 36 of file dovi_rpuenc.c.

◆ main

int main

◆ high

int high

◆ dv_levels

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 ff_dovi_configure().

u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:251
ANY_XY
#define ANY_XY(xy)
Definition: dovi_rpuenc.c:318