#ifndef AOM_AV1_ENCODER_ENCODER_H_
#define AOM_AV1_ENCODER_ENCODER_H_
#include <stdbool.h>
#include <stdio.h>
#include "config/aom_config.h"
#include "aom/aomcx.h"
#include "aom_util/aom_pthread.h"
#include "av1/common/alloccommon.h"
#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
#include "av1/common/entropymode.h"
#include "av1/common/enums.h"
#include "av1/common/reconintra.h"
#include "av1/common/resize.h"
#include "av1/common/thread_common.h"
#include "av1/common/timing.h"
#include "av1/encoder/aq_cyclicrefresh.h"
#include "av1/encoder/av1_quantize.h"
#include "av1/encoder/block.h"
#include "av1/encoder/context_tree.h"
#include "av1/encoder/enc_enums.h"
#include "av1/encoder/encodemb.h"
#include "av1/encoder/external_partition.h"
#include "av1/encoder/firstpass.h"
#include "av1/encoder/global_motion.h"
#include "av1/encoder/level.h"
#include "av1/encoder/lookahead.h"
#include "av1/encoder/mcomp.h"
#include "av1/encoder/pickcdef.h"
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rd.h"
#include "av1/encoder/speed_features.h"
#include "av1/encoder/svc_layercontext.h"
#include "av1/encoder/temporal_filter.h"
#if CONFIG_THREE_PASS
#include "av1/encoder/thirdpass.h"
#endif
#include "av1/encoder/tokenize.h"
#include "av1/encoder/tpl_model.h"
#include "av1/encoder/av1_noise_estimate.h"
#include "av1/encoder/bitstream.h"
#if CONFIG_INTERNAL_STATS
#include "aom_dsp/ssim.h"
#endif
#include "aom_dsp/variance.h"
#if CONFIG_DENOISE
#include "aom_dsp/noise_model.h"
#endif
#if CONFIG_TUNE_VMAF
#include "av1/encoder/tune_vmaf.h"
#endif
#if CONFIG_AV1_TEMPORAL_DENOISING
#include "av1/encoder/av1_temporal_denoiser.h"
#endif
#if CONFIG_TUNE_BUTTERAUGLI
#include "av1/encoder/tune_butteraugli.h"
#endif
#include "aom/internal/aom_codec_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SCENE_CUT_KEY_TEST_INTERVAL …
#define TF_LOOKAHEAD_IDX_THR …
#define HDR_QP_LEVELS …
#define CHROMA_CB_QP_SCALE …
#define CHROMA_CR_QP_SCALE …
#define CHROMA_QP_SCALE …
#define CHROMA_QP_OFFSET …
#define QP_SCALE_FACTOR …
#define DISABLE_HDR_LUMA_DELTAQ …
aom_rational64_t;
enum { … } UENUM1BYTE(…) …;
enum { … } UENUM1BYTE(…) …;
#if CONFIG_FPMT_TEST
enum {
PARALLEL_ENCODE = 0,
PARALLEL_SIMULATION_ENCODE,
NUM_FPMT_TEST_ENCODES
} UENUM1BYTE(FPMT_TEST_ENC_CFG);
#endif
#define MIN_PYR_LEVEL …
static inline int get_true_pyr_level(int frame_level, int frame_order,
int max_layer_depth) { … }
enum { … } UENUM1BYTE(…) …;
enum { … } UENUM1BYTE(…) …;
enum { … } UENUM1BYTE(…) …;
enum { … } UENUM1BYTE(…) …;
enum { … } UENUM1BYTE(…) …;
#define MAX_VBR_CORPUS_COMPLEXITY …
MULTI_THREADED_MODULES;
COST_UPDATE_TYPE;
LOOPFILTER_CONTROL;
SKIP_APPLY_POSTPROC_FILTER;
ResizeCfg;
PartitionCfg;
IntraModeCfg;
TxfmSizeTypeCfg;
CompoundTypeCfg;
SuperResCfg;
KeyFrameCfg;
RateControlCfg;
GFConfig;
TileConfig;
FrameDimensionCfg;
MotionModeCfg;
DecoderModelCfg;
CostUpdateFreq;
RefFrameCfg;
ColorCfg;
UnitTestCfg;
TuneCfg;
InputCfg;
QuantizationCfg;
AlgoCfg;
ToolCfg;
AV1EncoderConfig;
static inline int is_lossless_requested(const RateControlCfg *const rc_cfg) { … }
FrameProbInfo;
FRAME_COUNTS;
#define INTER_MODE_RD_DATA_OVERALL_SIZE …
InterModeRdModel;
RdIdxPair;
#define MAX_INTER_MODES …
InterModesInfo;
VPartVar;
VPVariance;
VP4x4;
VP8x8;
VP16x16;
VP32x32;
VP64x64;
VP128x128;
VarBasedPartitionInfo;
AV1EncRowMultiThreadSync;
TileDataEnc;
RD_COUNTS;
ThreadData;
struct EncWorkerData;
AV1EncRowMultiThreadInfo;
AV1EncAllIntraMultiThreadInfo;
#define NUM_RECODES_PER_FRAME …
#define MAX_PARALLEL_FRAMES …
RestoreStateBuffers;
RestUnitSearchInfo;
AV1LrPickStruct;
PrimaryMultiThreadInfo;
MultiThreadInfo;
ActiveMap;
ForceIntegerMVInfo;
#if CONFIG_INTERNAL_STATS
enum {
STAT_Y,
STAT_U,
STAT_V,
STAT_ALL,
NUM_STAT_TYPES
} UENUM1BYTE(StatType);
typedef struct IMAGE_STAT {
double stat[NUM_STAT_TYPES];
double worst;
} ImageStat;
#endif
EncRefCntBuffer;
MBMIExtFrameBufferInfo;
#if CONFIG_COLLECT_PARTITION_STATS
typedef struct FramePartitionTimingStats {
int partition_decisions[6][EXT_PARTITION_TYPES];
int partition_attempts[6][EXT_PARTITION_TYPES];
int64_t partition_times[6][EXT_PARTITION_TYPES];
int partition_redo;
} FramePartitionTimingStats;
#endif
#if CONFIG_COLLECT_COMPONENT_TIMING
#include "aom_ports/aom_timer.h"
enum {
av1_encode_strategy_time,
av1_get_one_pass_rt_params_time,
av1_get_second_pass_params_time,
denoise_and_encode_time,
apply_filtering_time,
av1_tpl_setup_stats_time,
encode_frame_to_data_rate_time,
encode_with_or_without_recode_time,
loop_filter_time,
cdef_time,
loop_restoration_time,
av1_pack_bitstream_final_time,
av1_encode_frame_time,
av1_compute_global_motion_time,
av1_setup_motion_field_time,
encode_sb_row_time,
rd_pick_partition_time,
rd_use_partition_time,
choose_var_based_partitioning_time,
av1_prune_partitions_time,
none_partition_search_time,
split_partition_search_time,
rectangular_partition_search_time,
ab_partitions_search_time,
rd_pick_4partition_time,
encode_sb_time,
rd_pick_sb_modes_time,
av1_rd_pick_intra_mode_sb_time,
av1_rd_pick_inter_mode_sb_time,
set_params_rd_pick_inter_mode_time,
skip_inter_mode_time,
handle_inter_mode_time,
evaluate_motion_mode_for_winner_candidates_time,
do_tx_search_time,
handle_intra_mode_time,
refine_winner_mode_tx_time,
av1_search_palette_mode_time,
handle_newmv_time,
compound_type_rd_time,
interpolation_filter_search_time,
motion_mode_rd_time,
nonrd_use_partition_time,
pick_sb_modes_nonrd_time,
hybrid_intra_mode_search_time,
nonrd_pick_inter_mode_sb_time,
encode_b_nonrd_time,
kTimingComponents,
} UENUM1BYTE(TIMING_COMPONENT);
static inline char const *get_component_name(int index) {
switch (index) {
case av1_encode_strategy_time: return "av1_encode_strategy_time";
case av1_get_one_pass_rt_params_time:
return "av1_get_one_pass_rt_params_time";
case av1_get_second_pass_params_time:
return "av1_get_second_pass_params_time";
case denoise_and_encode_time: return "denoise_and_encode_time";
case apply_filtering_time: return "apply_filtering_time";
case av1_tpl_setup_stats_time: return "av1_tpl_setup_stats_time";
case encode_frame_to_data_rate_time:
return "encode_frame_to_data_rate_time";
case encode_with_or_without_recode_time:
return "encode_with_or_without_recode_time";
case loop_filter_time: return "loop_filter_time";
case cdef_time: return "cdef_time";
case loop_restoration_time: return "loop_restoration_time";
case av1_pack_bitstream_final_time: return "av1_pack_bitstream_final_time";
case av1_encode_frame_time: return "av1_encode_frame_time";
case av1_compute_global_motion_time:
return "av1_compute_global_motion_time";
case av1_setup_motion_field_time: return "av1_setup_motion_field_time";
case encode_sb_row_time: return "encode_sb_row_time";
case rd_pick_partition_time: return "rd_pick_partition_time";
case rd_use_partition_time: return "rd_use_partition_time";
case choose_var_based_partitioning_time:
return "choose_var_based_partitioning_time";
case av1_prune_partitions_time: return "av1_prune_partitions_time";
case none_partition_search_time: return "none_partition_search_time";
case split_partition_search_time: return "split_partition_search_time";
case rectangular_partition_search_time:
return "rectangular_partition_search_time";
case ab_partitions_search_time: return "ab_partitions_search_time";
case rd_pick_4partition_time: return "rd_pick_4partition_time";
case encode_sb_time: return "encode_sb_time";
case rd_pick_sb_modes_time: return "rd_pick_sb_modes_time";
case av1_rd_pick_intra_mode_sb_time:
return "av1_rd_pick_intra_mode_sb_time";
case av1_rd_pick_inter_mode_sb_time:
return "av1_rd_pick_inter_mode_sb_time";
case set_params_rd_pick_inter_mode_time:
return "set_params_rd_pick_inter_mode_time";
case skip_inter_mode_time: return "skip_inter_mode_time";
case handle_inter_mode_time: return "handle_inter_mode_time";
case evaluate_motion_mode_for_winner_candidates_time:
return "evaluate_motion_mode_for_winner_candidates_time";
case do_tx_search_time: return "do_tx_search_time";
case handle_intra_mode_time: return "handle_intra_mode_time";
case refine_winner_mode_tx_time: return "refine_winner_mode_tx_time";
case av1_search_palette_mode_time: return "av1_search_palette_mode_time";
case handle_newmv_time: return "handle_newmv_time";
case compound_type_rd_time: return "compound_type_rd_time";
case interpolation_filter_search_time:
return "interpolation_filter_search_time";
case motion_mode_rd_time: return "motion_mode_rd_time";
case nonrd_use_partition_time: return "nonrd_use_partition_time";
case pick_sb_modes_nonrd_time: return "pick_sb_modes_nonrd_time";
case hybrid_intra_mode_search_time: return "hybrid_intra_mode_search_time";
case nonrd_pick_inter_mode_sb_time: return "nonrd_pick_inter_mode_sb_time";
case encode_b_nonrd_time: return "encode_b_nonrd_time";
default: assert(0);
}
return "error";
}
#endif
#define MAX_INTERNAL_ARFS …
GlobalMotionInfo;
InterpSearchFlags;
MotionVectorSearchParams;
RefreshFrameInfo;
ResizePendingParams;
RefFrameDistanceInfo;
WinnerModeParams;
ExtRefreshFrameFlagsInfo;
ExternalFlags;
MV_STATS;
WeberStats;
CODING_CONTEXT;
FRAME_INFO;
FRAME_INDEX_SET;
EncSegmentationInfo;
TimeStamps;
CoeffBufferPool;
#if !CONFIG_REALTIME_ONLY
enum {
DUCKY_ENCODE_FRAME_MODE_NONE,
DUCKY_ENCODE_FRAME_MODE_QINDEX,
DUCKY_ENCODE_FRAME_MODE_QINDEX_RDMULT,
} UENUM1BYTE(DUCKY_ENCODE_FRAME_MODE);
enum {
DUCKY_ENCODE_GOP_MODE_NONE,
DUCKY_ENCODE_GOP_MODE_RCL,
} UENUM1BYTE(DUCKY_ENCODE_GOP_MODE);
typedef struct DuckyEncodeFrameInfo {
DUCKY_ENCODE_FRAME_MODE qp_mode;
DUCKY_ENCODE_GOP_MODE gop_mode;
int q_index;
int rdmult;
int *superblock_encode_qindex;
int *superblock_encode_rdmult;
int delta_q_enabled;
} DuckyEncodeFrameInfo;
typedef struct DuckyEncodeFrameResult {
int global_order_idx;
int q_index;
int rdmult;
int rate;
int64_t dist;
double psnr;
} DuckyEncodeFrameResult;
typedef struct DuckyEncodeInfo {
DuckyEncodeFrameInfo frame_info;
DuckyEncodeFrameResult frame_result;
} DuckyEncodeInfo;
#endif
RTC_REF;
AV1_COMP_DATA;
AV1_PRIMARY;
AV1_COMP;
EncodeFrameInput;
EncodeFrameParams;
EncodeFrameResults;
void av1_initialize_enc(unsigned int usage, enum aom_rc_mode end_usage);
struct AV1_COMP *av1_create_compressor(AV1_PRIMARY *ppi,
const AV1EncoderConfig *oxcf,
BufferPool *const pool,
COMPRESSOR_STAGE stage,
int lap_lag_in_frames);
struct AV1_PRIMARY *av1_create_primary_compressor(
struct aom_codec_pkt_list *pkt_list_head, int num_lap_buffers,
const AV1EncoderConfig *oxcf);
void av1_remove_compressor(AV1_COMP *cpi);
void av1_remove_primary_compressor(AV1_PRIMARY *ppi);
#if CONFIG_ENTROPY_STATS
void print_entropy_stats(AV1_PRIMARY *const ppi);
#endif
#if CONFIG_INTERNAL_STATS
void print_internal_stats(AV1_PRIMARY *ppi);
#endif
void av1_change_config_seq(AV1_PRIMARY *ppi, const AV1EncoderConfig *oxcf,
bool *sb_size_changed);
void av1_change_config(AV1_COMP *cpi, const AV1EncoderConfig *oxcf,
bool sb_size_changed);
aom_codec_err_t av1_check_initial_width(AV1_COMP *cpi, int use_highbitdepth,
int subsampling_x, int subsampling_y);
void av1_post_encode_updates(AV1_COMP *const cpi,
const AV1_COMP_DATA *const cpi_data);
void av1_release_scaled_references_fpmt(AV1_COMP *cpi);
void av1_decrement_ref_counts_fpmt(BufferPool *buffer_pool,
int ref_buffers_used_map);
void av1_init_sc_decisions(AV1_PRIMARY *const ppi);
AV1_COMP *av1_get_parallel_frame_enc_data(AV1_PRIMARY *const ppi,
AV1_COMP_DATA *const first_cpi_data);
int av1_init_parallel_frame_context(const AV1_COMP_DATA *const first_cpi_data,
AV1_PRIMARY *const ppi,
int *ref_buffers_used_map);
int av1_receive_raw_frame(AV1_COMP *cpi, aom_enc_frame_flags_t frame_flags,
const YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time_stamp);
int av1_get_compressed_data(AV1_COMP *cpi, AV1_COMP_DATA *const cpi_data);
int av1_encode(AV1_COMP *const cpi, uint8_t *const dest, size_t dest_size,
const EncodeFrameInput *const frame_input,
const EncodeFrameParams *const frame_params,
EncodeFrameResults *const frame_results);
int av1_get_preview_raw_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *dest);
int av1_get_last_show_frame(AV1_COMP *cpi, YV12_BUFFER_CONFIG *frame);
aom_codec_err_t av1_copy_new_frame_enc(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *new_frame,
YV12_BUFFER_CONFIG *sd);
int av1_use_as_reference(int *ext_ref_frame_flags, int ref_frame_flags);
int av1_copy_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
int av1_set_reference_enc(AV1_COMP *cpi, int idx, YV12_BUFFER_CONFIG *sd);
void av1_set_frame_size(AV1_COMP *cpi, int width, int height);
void av1_set_mv_search_params(AV1_COMP *cpi);
int av1_set_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
int av1_get_active_map(AV1_COMP *cpi, unsigned char *map, int rows, int cols);
int av1_set_internal_size(AV1EncoderConfig *const oxcf,
ResizePendingParams *resize_pending_params,
AOM_SCALING_MODE horiz_mode,
AOM_SCALING_MODE vert_mode);
int av1_get_quantizer(struct AV1_COMP *cpi);
int av1_convert_sect5obus_to_annexb(uint8_t *buffer, size_t *input_size);
void av1_alloc_mb_wiener_var_pred_buf(AV1_COMMON *cm, ThreadData *td);
void av1_dealloc_mb_wiener_var_pred_buf(ThreadData *td);
void av1_set_screen_content_options(struct AV1_COMP *cpi,
FeatureFlags *features);
void av1_update_frame_size(AV1_COMP *cpi);
RefFrameMapPair;
static inline void init_ref_map_pair(
AV1_COMP *cpi, RefFrameMapPair ref_frame_map_pairs[REF_FRAMES]) { … }
#if CONFIG_FPMT_TEST
static inline void calc_frame_data_update_flag(
GF_GROUP *const gf_group, int gf_frame_index,
bool *const do_frame_data_update) {
*do_frame_data_update = true;
if (gf_group->frame_parallel_level[gf_frame_index] == 1) {
*do_frame_data_update = false;
} else if (gf_group->frame_parallel_level[gf_frame_index] == 2) {
for (int i = gf_frame_index + 1; i < gf_group->size; i++) {
if ((gf_group->frame_parallel_level[i] == 0 &&
(gf_group->update_type[i] == ARF_UPDATE ||
gf_group->update_type[i] == INTNL_ARF_UPDATE)) ||
gf_group->frame_parallel_level[i] == 1) {
break;
} else if (gf_group->frame_parallel_level[i] == 2) {
*do_frame_data_update = false;
break;
}
}
}
}
#endif
#define TICKS_PER_SEC …
static inline int64_t timebase_units_to_ticks(
const aom_rational64_t *timestamp_ratio, int64_t n) { … }
static inline int64_t ticks_to_timebase_units(
const aom_rational64_t *timestamp_ratio, int64_t n) { … }
static inline int frame_is_kf_gf_arf(const AV1_COMP *cpi) { … }
static inline int av1_use_hash_me(const AV1_COMP *const cpi) { … }
static inline const YV12_BUFFER_CONFIG *get_ref_frame_yv12_buf(
const AV1_COMMON *const cm, MV_REFERENCE_FRAME ref_frame) { … }
static inline void alloc_frame_mvs(AV1_COMMON *const cm, RefCntBuffer *buf) { … }
static inline unsigned int allocated_tokens(const TileInfo *tile,
int sb_size_log2, int num_planes) { … }
static inline void get_start_tok(AV1_COMP *cpi, int tile_row, int tile_col,
int mi_row, TokenExtra **tok, int sb_size_log2,
int num_planes) { … }
void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags);
#define ALT_MIN_LAG …
static inline int is_altref_enabled(int lag_in_frames, bool enable_auto_arf) { … }
static inline int can_disable_altref(const GFConfig *gf_cfg) { … }
static inline int get_num_blocks(const int frame_length, const int mb_length) { … }
static inline int is_stat_generation_stage(const AV1_COMP *const cpi) { … }
static inline int is_stat_consumption_stage_twopass(const AV1_COMP *const cpi) { … }
static inline int is_stat_consumption_stage(const AV1_COMP *const cpi) { … }
static inline bool av1_need_dv_costs(const AV1_COMP *const cpi) { … }
static inline int has_no_stats_stage(const AV1_COMP *const cpi) { … }
static inline int is_one_pass_rt_params(const AV1_COMP *cpi) { … }
static inline int use_rtc_reference_structure_one_layer(const AV1_COMP *cpi) { … }
static inline int allow_postencode_drop_rtc(const AV1_COMP *cpi) { … }
static inline int get_stats_buf_size(int num_lap_buffer, int num_lag_buffer) { … }
static inline void set_ref_ptrs(const AV1_COMMON *cm, MACROBLOCKD *xd,
MV_REFERENCE_FRAME ref0,
MV_REFERENCE_FRAME ref1) { … }
static inline int get_chessboard_index(int frame_index) { … }
static inline const int *cond_cost_list_const(const struct AV1_COMP *cpi,
const int *cost_list) { … }
static inline int *cond_cost_list(const struct AV1_COMP *cpi, int *cost_list) { … }
double av1_get_compression_ratio(const AV1_COMMON *const cm,
size_t encoded_frame_size);
void av1_new_framerate(AV1_COMP *cpi, double framerate);
void av1_setup_frame_size(AV1_COMP *cpi);
#define LAYER_IDS_TO_IDX(sl, tl, num_tl) …
static inline int av1_resize_scaled(const AV1_COMMON *cm) { … }
static inline int av1_frame_scaled(const AV1_COMMON *cm) { … }
static inline int encode_show_existing_frame(const AV1_COMMON *cm) { … }
static inline int get_mi_ext_idx(const int mi_row, const int mi_col,
const BLOCK_SIZE mi_alloc_bsize,
const int mbmi_ext_stride) { … }
static inline void set_mode_info_offsets(
const CommonModeInfoParams *const mi_params,
const MBMIExtFrameBufferInfo *const mbmi_ext_info, MACROBLOCK *const x,
MACROBLOCKD *const xd, int mi_row, int mi_col) { … }
static inline BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, int rows_left,
int cols_left, int *bh, int *bw) { … }
static const uint8_t av1_ref_frame_flag_list[REF_FRAMES] = …;
static const MV_REFERENCE_FRAME disable_order[] = …;
static const MV_REFERENCE_FRAME
ref_frame_priority_order[INTER_REFS_PER_FRAME] = …;
static inline int get_ref_frame_flags(const SPEED_FEATURES *const sf,
const int use_one_pass_rt_params,
const YV12_BUFFER_CONFIG **ref_frames,
const int ext_ref_frame_flags) { … }
aom_fixed_buf_t *av1_get_global_headers(AV1_PRIMARY *ppi);
#define MAX_GFUBOOST_FACTOR …
#define MIN_GFUBOOST_FACTOR …
static inline int is_frame_tpl_eligible(const GF_GROUP *const gf_group,
uint8_t index) { … }
static inline int is_frame_eligible_for_ref_pruning(const GF_GROUP *gf_group,
int selective_ref_frame,
int prune_ref_frames,
int gf_index) { … }
static inline FRAME_UPDATE_TYPE get_frame_update_type(const GF_GROUP *gf_group,
int gf_frame_index) { … }
static inline int av1_pixels_to_mi(int pixels) { … }
static inline int is_psnr_calc_enabled(const AV1_COMP *cpi) { … }
static inline int is_frame_resize_pending(const AV1_COMP *const cpi) { … }
static inline int is_loopfilter_used(const AV1_COMMON *const cm) { … }
static inline int is_cdef_used(const AV1_COMMON *const cm) { … }
static inline int is_restoration_used(const AV1_COMMON *const cm) { … }
static inline unsigned int derive_skip_apply_postproc_filters(
const AV1_COMP *cpi, int use_loopfilter, int use_cdef, int use_superres,
int use_restoration) { … }
static inline void set_postproc_filter_default_params(AV1_COMMON *cm) { … }
static inline int is_inter_tx_size_search_level_one(
const TX_SPEED_FEATURES *tx_sf) { … }
static inline int get_lpf_opt_level(const SPEED_FEATURES *sf) { … }
static inline bool is_switchable_motion_mode_allowed(bool allow_warped_motion,
bool enable_obmc) { … }
#if CONFIG_AV1_TEMPORAL_DENOISING
static inline int denoise_svc(const struct AV1_COMP *const cpi) { … }
#endif
#if CONFIG_COLLECT_PARTITION_STATS == 2
static inline void av1_print_fr_partition_timing_stats(
const FramePartitionTimingStats *part_stats, const char *filename) {
FILE *f = fopen(filename, "w");
if (!f) {
return;
}
fprintf(f, "bsize,redo,");
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "decision_%d,", part);
}
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "attempt_%d,", part);
}
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "time_%d,", part);
}
fprintf(f, "\n");
static const int bsizes[6] = { 128, 64, 32, 16, 8, 4 };
for (int bsize_idx = 0; bsize_idx < 6; bsize_idx++) {
fprintf(f, "%d,%d,", bsizes[bsize_idx], part_stats->partition_redo);
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "%d,", part_stats->partition_decisions[bsize_idx][part]);
}
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "%d,", part_stats->partition_attempts[bsize_idx][part]);
}
for (int part = 0; part < EXT_PARTITION_TYPES; part++) {
fprintf(f, "%ld,", part_stats->partition_times[bsize_idx][part]);
}
fprintf(f, "\n");
}
fclose(f);
}
#endif
#if CONFIG_COLLECT_PARTITION_STATS
static inline int av1_get_bsize_idx_for_part_stats(BLOCK_SIZE bsize) {
assert(bsize == BLOCK_128X128 || bsize == BLOCK_64X64 ||
bsize == BLOCK_32X32 || bsize == BLOCK_16X16 || bsize == BLOCK_8X8 ||
bsize == BLOCK_4X4);
switch (bsize) {
case BLOCK_128X128: return 0;
case BLOCK_64X64: return 1;
case BLOCK_32X32: return 2;
case BLOCK_16X16: return 3;
case BLOCK_8X8: return 4;
case BLOCK_4X4: return 5;
default: assert(0 && "Invalid bsize for partition_stats."); return -1;
}
}
#endif
#if CONFIG_COLLECT_COMPONENT_TIMING
static inline void start_timing(AV1_COMP *cpi, int component) {
aom_usec_timer_start(&cpi->component_timer[component]);
}
static inline void end_timing(AV1_COMP *cpi, int component) {
aom_usec_timer_mark(&cpi->component_timer[component]);
cpi->frame_component_time[component] +=
aom_usec_timer_elapsed(&cpi->component_timer[component]);
}
static inline char const *get_frame_type_enum(int type) {
switch (type) {
case 0: return "KEY_FRAME";
case 1: return "INTER_FRAME";
case 2: return "INTRA_ONLY_FRAME";
case 3: return "S_FRAME";
default: assert(0);
}
return "error";
}
#endif
#ifdef __cplusplus
}
#endif
#endif