typedefstruct AV1TplRowMultiThreadSync { #if CONFIG_MULTITHREAD // Synchronization objects for top-right dependency.
pthread_mutex_t *mutex_;
pthread_cond_t *cond_; #endif // Buffer to store the macroblock whose encoding is complete. // num_finished_cols[i] stores the number of macroblocks which finished // encoding in the ith macroblock row.
int *num_finished_cols; // Number of extra macroblocks of the top row to be complete for encoding // of the current macroblock to start. A value of 1 indicates top-right // dependency.
int sync_range; // Number of macroblock rows.
int rows; // Number of threads processing the current tile.
int num_threads_working;
} AV1TplRowMultiThreadSync;
typedefstruct AV1TplRowMultiThreadInfo { // Initialized to false, set to true by the worker thread that encounters an // error in order to abort the processing of other worker threads. bool tpl_mt_exit; #if CONFIG_MULTITHREAD // Mutex lock object used for error handling.
pthread_mutex_t *mutex_; #endif // Row synchronization related function pointers. void (*sync_read_ptr)(AV1TplRowMultiThreadSync *tpl_mt_sync, int r, int c); void (*sync_write_ptr)(AV1TplRowMultiThreadSync *tpl_mt_sync, int r, int c,
int cols);
} AV1TplRowMultiThreadInfo;
// TODO(jingning): This needs to be cleaned up next.
// TPL stats buffers are prepared for every frame in the GOP, // including (internal) overlays and (internal) arfs. // In addition, frames in the lookahead that are outside of the GOP // are also used. // Thus it should use // (gop_length) + (# overlays) + (MAX_LAG_BUFFERS - gop_len) = // MAX_LAG_BUFFERS + (# overlays) // 2 * MAX_LAG_BUFFERS is therefore a safe estimate. // TODO(bohanli): test setting it to 1.5 * MAX_LAG_BUFFER #define MAX_TPL_FRAME_IDX (2 * MAX_LAG_BUFFERS) // The first REF_FRAMES + 1 buffers are reserved. // tpl_data->tpl_frame starts after REF_FRAMES + 1 #define MAX_LENGTH_TPL_FRAME_STATS (MAX_TPL_FRAME_IDX + REF_FRAMES + 1) #define TPL_DEP_COST_SCALE_LOG2 4
#define TPL_EPSILON 0.0000001
typedefstruct TplTxfmStats {
int ready; // Whether abs_coeff_mean is ready double abs_coeff_sum[256]; // Assume we are using 16x16 transform block double abs_coeff_mean[256];
int txfm_block_count;
int coeff_num;
} TplTxfmStats;
typedefstruct TplDepFrame {
uint8_t is_valid;
TplDepStats *tpl_stats_ptr; const YV12_BUFFER_CONFIG *gf_picture;
YV12_BUFFER_CONFIG *rec_picture;
int ref_map_index[REF_FRAMES];
int stride; // width and height here is in the unit of 16x16 block.
int width;
int height;
int mi_rows;
int mi_cols;
int base_rdmult;
uint32_t frame_display_index; // When set, SAD metric is used for intra and inter mode decision.
int use_pred_sad;
} TplDepFrame;
/*! *\briefThisstructurestoresinformationneededforbitrateaccuracy *experiment.
*/ typedefstruct {
int ready; double total_bit_budget; // The total bit budget of the entire video
int show_frame_count; // Number of show frames in the entire video
int gop_showframe_count; // The number of show frames in the current gop double gop_bit_budget; // The bitbudget for the current gop double scale_factors[FRAME_UPDATE_TYPES]; // Scale factors to improve the // budget estimation double mv_scale_factors[FRAME_UPDATE_TYPES]; // Scale factors to improve // MV entropy estimation
// === Below this line are GOP related data that will be updated per GOP ===
int base_q_index; // Stores the base q index.
int q_index_list_ready;
int q_index_list[VBR_RC_INFO_MAX_FRAMES]; // q indices for the current // GOP
// Array to store qstep_ratio for each frame in a GOP double qstep_ratio_list[VBR_RC_INFO_MAX_FRAMES];
#if CONFIG_THREE_PASS
TplTxfmStats txfm_stats_list[VBR_RC_INFO_MAX_FRAMES];
FRAME_UPDATE_TYPE update_type_list[VBR_RC_INFO_MAX_FRAMES];
int gop_start_idx_list[VBR_RC_INFO_MAX_FRAMES];
int gop_length_list[VBR_RC_INFO_MAX_FRAMES];
int cur_gop_idx;
int total_frame_count;
int gop_count; #endif// CONFIG_THREE_PASS
} VBR_RATECTRL_INFO;
typedefstruct RD_COMMAND {
RD_OPTION option_ls[MAX_LENGTH_TPL_FRAME_STATS];
int q_index_ls[MAX_LENGTH_TPL_FRAME_STATS];
int rdmult_ls[MAX_LENGTH_TPL_FRAME_STATS];
int frame_count;
int frame_index;
} RD_COMMAND;
/*!\brief Allocate buffers used by tpl model * *\param[in]Top-levelencode/decodestructure *\param[in]lag_in_framesnumberoflookaheadframes * *\param[out]tpl_datatpldatastructure
*/
void av1_setup_tpl_buffers(struct AV1_PRIMARY *const ppi,
CommonModeInfoParams *const mi_params, int width,
int height, int byte_alignment, int lag_in_frames);
static inline bool tpl_alloc_temp_buffers(TplBuffers *tpl_tmp_buffers,
uint8_t tpl_bsize_1d) { // Number of pixels in a tpl block const int tpl_block_pels = tpl_bsize_1d * tpl_bsize_1d;
/*!\brief Compute the entropy of an exponential probability distribution *function(pdf)subjectedtouniformquantization. * *pdf(x)=b*exp(-b*x) * *\ingrouptpl_modelling * *\param[in]q_stepquantizerstepsize *\param[in]bparameterofexponentialdistribution * *\returnentropycost
*/ double av1_exponential_entropy(double q_step, double b);
/*!\brief Compute the entropy of a Laplace probability distribution *function(pdf)subjectedtonon-uniformquantization. * *pdf(x)=0.5*b*exp(-0.5*b*|x|) * *\ingrouptpl_modelling * *\param[in]q_stepquantizerstepsizefornon-zerobins *\param[in]bparameterofLaplacedistribution *\param[in]zero_bin_ratiozerobin'ssizeiszero_bin_ratio*q_step * *\returnentropycost
*/ double av1_laplace_entropy(double q_step, double b, double zero_bin_ratio);
#if CONFIG_BITRATE_ACCURACY /*!\brief Compute the frame rate using transform block stats * *AssumeeachpositioniinthetransformblockisofLaplacedistribution *withmeanabsolutedeviationabs_coeff_mean[i] * *Thenwecanuseav1_laplace_entropy()tocomputetheexpectedframe *rate. * *\ingrouptpl_modelling * *\param[in]q_indexquantizerindex *\param[in]block_countnumberoftransformblocks *\param[in]abs_coeff_meanarrayofmeanabsolutedeviation *\param[in]coeff_numnumberofcoefficientspertransformblock * *\returnexpectedframerate
*/ double av1_laplace_estimate_frame_rate(int q_index, int block_count, constdouble *abs_coeff_mean,
int coeff_num); #endif// CONFIG_BITRATE_ACCURACY
/*!\brief Compute the overlap area between two blocks with the same size * *\ingrouptpl_modelling * *Ifthereisnooverlap,thisfunctionshouldreturnzero. * *\param[in]row_arowpositionofthefirstblock *\param[in]col_acolumnpositionofthefirstblock *\param[in]row_browpositionofthesecondblock *\param[in]col_bcolumnpositionofthesecondblock *\param[in]widthwidthsharedbythetwoblocks *\param[in]heightheightsharedbythetwoblocks * *\returnoverlapareaofthetwoblocks
*/
int av1_get_overlap_area(int row_a, int col_a, int row_b, int col_b, int width,
int height);
/*!\brief Get current frame's q_index from tpl stats and leaf_qindex * *\param[in]tpl_dataTPLstruct *\param[in]gf_frame_indexcurrentframeindexintheGOP *\param[in]leaf_qindexqindexofleafframe *\param[in]bit_depthbitdepth * *\returnq_index
*/
int av1_tpl_get_q_index(const TplParams *tpl_data, int gf_frame_index,
int leaf_qindex, aom_bit_depth_t bit_depth);
/*!\brief Compute the ratio between arf q step and the leaf q step based on *TPLstats * *\param[in]tpl_dataTPLstruct *\param[in]gf_frame_indexcurrentframeindexintheGOP *\param[in]leaf_qindexqindexofleafframe *\param[in]bit_depthbitdepth * *\returnqstep_ratio
*/ double av1_tpl_get_qstep_ratio(const TplParams *tpl_data, int gf_frame_index);
/*!\brief Find a q index whose step size is near qstep_ratio * leaf_qstep * *\param[in]leaf_qindexqindexofleafframe *\param[in]qstep_ratiostepratiobetweentargetqindexand *leafqindex\param[in]bit_depthbitdepth * *\returnq_index
*/
int av1_get_q_index_from_qstep_ratio(int leaf_qindex, double qstep_ratio,
aom_bit_depth_t bit_depth);
/*!\brief Improve the motion vector estimation by taking neighbors into *account. * *UsetheupperandleftneighborblockasthereferenceMVs. *ComputetheminimumdifferencebetweencurrentMVandreferenceMV. * *\param[in]tpl_frameTplframestruct *\param[in]rowCurrentrow *\param[in]colCurrentcolumn *\param[in]stepStepparameterforav1_tpl_ptr_pos *\param[in]tpl_strideStrideparameterforav1_tpl_ptr_pos *\param[in]right_shiftRightshiftparameterfor *av1_tpl_ptr_pos
*/
int_mv av1_compute_mv_difference(const TplDepFrame *tpl_frame, int row, int col,
int step, int tpl_stride, int right_shift);
/*!\brief Compute the entropy of motion vectors for a single frame. * *\param[in]tpl_frameTPLframestruct *\param[in]right_shiftrightshiftvalueforstep * *\returnBitsusedbythemotionvectorsforoneframe.
*/ double av1_tpl_compute_frame_mv_entropy(const TplDepFrame *tpl_frame,
uint8_t right_shift);
/*!\brief Free the memory allocated for cpi->extrc_tpl_gop_stats. * *\param[in]extrc_tpl_gop_statsTPLstatsfortheGOPusedforexternalRC.
*/ void av1_free_tpl_gop_stats(AomTplGopStats *extrc_tpl_gop_stats);
#if CONFIG_RATECTRL_LOG typedefstruct {
int coding_frame_count;
int base_q_index;
// Encode decision
int q_index_list[VBR_RC_INFO_MAX_FRAMES]; double qstep_ratio_list[VBR_RC_INFO_MAX_FRAMES];
FRAME_UPDATE_TYPE update_type_list[VBR_RC_INFO_MAX_FRAMES];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.