/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
typedefenum { // encode_breakout is disabled.
ENCODE_BREAKOUT_DISABLED = 0, // encode_breakout is enabled.
ENCODE_BREAKOUT_ENABLED = 1, // encode_breakout is enabled with small max_thresh limit.
ENCODE_BREAKOUT_LIMITED = 2
} ENCODE_BREAKOUT_TYPE;
typedefenum { // Good Quality Fast Encoding. The encoder balances quality with the amount of // time it takes to encode the output. Speed setting controls how fast.
GOOD,
// The encoder places priority on the quality of the output over encoding // speed. The output is compressed at the highest possible quality. This // option takes the longest amount of time to encode. Speed setting ignored.
BEST,
// Realtime/Live Encoding. This mode is optimized for realtime encoding (for // example, capturing a television signal or feed from a live camera). Speed // setting controls how fast.
REALTIME
} MODE;
typedefenum {
NO_AQ = 0,
VARIANCE_AQ = 1,
COMPLEXITY_AQ = 2,
CYCLIC_REFRESH_AQ = 3,
EQUATOR360_AQ = 4,
PERCEPTUAL_AQ = 5,
PSNR_AQ = 6, // AQ based on lookahead temporal // variance (only valid for altref frames)
LOOKAHEAD_AQ = 7,
AQ_MODE_COUNT // This should always be the last member of the enum
} AQ_MODE;
typedefenum {
RESIZE_NONE = 0, // No frame resizing allowed (except for SVC).
RESIZE_FIXED = 1, // All frames are coded at the specified dimension.
RESIZE_DYNAMIC = 2 // Coded size of each frame is determined by the codec.
} RESIZE_TYPE;
typedefenum {
LOOPFILTER_ALL = 0,
LOOPFILTER_REFERENCE = 1, // Disable loopfilter on non reference frames.
NO_LOOPFILTER = 2, // Disable loopfilter on all frames.
} LOOPFILTER_CONTROL;
typedefstruct VP9EncoderConfig {
BITSTREAM_PROFILE profile;
vpx_bit_depth_t bit_depth; // Codec bit-depth. int width; // width of data passed to the compressor int height; // height of data passed to the compressor unsignedint input_bit_depth; // Input bit depth. double init_framerate; // set to passed in framerate
vpx_rational_t g_timebase; // equivalent to g_timebase in vpx_codec_enc_cfg_t
vpx_rational64_t g_timebase_in_ts; // g_timebase * TICKS_PER_SEC
int64_t target_bandwidth; // bandwidth to be used in bits per second
int noise_sensitivity; // pre processing blur: recommendation 0 int sharpness; // sharpening output: recommendation 0: int speed; // maximum allowed bitrate for any intra frame in % of bitrate target. unsignedint rc_max_intra_bitrate_pct; // maximum allowed bitrate for any inter frame in % of bitrate target. unsignedint rc_max_inter_bitrate_pct; // percent of rate boost for golden frame in CBR mode. unsignedint gf_cbr_boost_pct;
MODE mode; int pass;
// Key Framing Operations int auto_key; // autodetect cut scenes and set the keyframes int key_freq; // maximum distance to key frame.
int lag_in_frames; // how many frames lag before we start encoding
// ---------------------------------------------------------------- // DATARATE CONTROL OPTIONS
// Frame drop threshold. int drop_frames_water_mark;
// controlling quality int fixed_q; int worst_allowed_q; int best_allowed_q; int cq_level;
AQ_MODE aq_mode; // Adaptive Quantization mode
// Special handling of Adaptive Quantization for AltRef frames int alt_ref_aq;
// Internal frame size scaling.
RESIZE_TYPE resize_mode; int scaled_frame_width; int scaled_frame_height;
// Enable feature to reduce the frame quantization every x frames. int frame_periodic_boost;
// two pass datarate control int two_pass_vbrbias; // two pass datarate control tweaks int two_pass_vbrmin_section; int two_pass_vbrmax_section; int vbr_corpus_complexity; // 0 indicates corpus vbr disabled // END DATARATE CONTROL OPTIONS // ----------------------------------------------------------------
// Spatial and temporal scalability. int ss_number_layers; // Number of spatial layers. int ts_number_layers; // Number of temporal layers. // Bitrate allocation for spatial layers. int layer_target_bitrate[VPX_MAX_LAYERS]; int ss_target_bitrate[VPX_SS_MAX_LAYERS]; int ss_enable_auto_arf[VPX_SS_MAX_LAYERS]; // Bitrate allocation (CBR mode) and framerate factor, for temporal layers. int ts_rate_decimator[VPX_TS_MAX_LAYERS];
int enable_auto_arf;
int encode_breakout; // early breakout : for video conf recommend 800
/* Bitfield defining the error resiliency features to enable. * Can provide decodable frames after losses in previous * frames and decodable partitions after losses in the same frame.
*/ unsignedint error_resilient_mode;
/* Bitfield defining the parallel decoding mode where the * decoding in successive frames may be conducted in parallel * just by decoding the frame headers.
*/ unsignedint frame_parallel_decoding_mode;
int arnr_max_frames; int arnr_strength;
int min_gf_interval; int max_gf_interval;
int tile_columns; int tile_rows;
int enable_tpl_model;
int enable_keyframe_filtering;
int max_threads;
unsignedint target_level;
vpx_fixed_buf_t two_pass_stats_in;
vp8e_tuning tuning;
vp9e_tune_content content; #if CONFIG_VP9_HIGHBITDEPTH int use_highbitdepth; #endif
vpx_color_space_t color_space;
vpx_color_range_t color_range; int render_width; int render_height;
VP9E_TEMPORAL_LAYERING_MODE temporal_layering_mode;
int row_mt; unsignedint motion_vector_unit_test; int delta_q_uv; int use_simple_encode_api; // Use SimpleEncode APIs or not
} VP9EncoderConfig;
typedefstruct TplDepFrame {
uint8_t is_valid;
TplDepStats *tpl_stats_ptr; int stride; int width; int height; int mi_rows; int mi_cols; int base_qindex; #if CONFIG_NON_GREEDY_MV int lambda; int *mv_mode_arr[3]; double *rd_diff_arr[3]; #endif
} TplDepFrame;
#define TPL_DEP_COST_SCALE_LOG2 4
// TODO(jingning) All spatially adaptive variables should go to TileDataEnc. typedefstruct TileDataEnc {
TileInfo tile_info; int thresh_freq_fact[BLOCK_SIZES][MAX_MODES]; int thresh_freq_fact_prev[BLOCK_SIZES][MAX_MODES];
int8_t mode_map[BLOCK_SIZES][MAX_MODES];
FIRSTPASS_DATA fp_data;
VP9RowMTSync row_mt_sync;
// Used for adaptive_rd_thresh with row multithreading int *row_base_thresh_freq_fact; // The value of sb_rows when row_base_thresh_freq_fact is allocated. // The row_base_thresh_freq_fact array has sb_rows * BLOCK_SIZES * MAX_MODES // elements. int sb_rows;
MV firstpass_top_mv;
} TileDataEnc;
typedefstruct {
int8_t level_index;
uint8_t fail_flag; int max_frame_size; // in bits double max_cpb_size; // in bits
} LevelConstraint;
typedefstruct ARNRFilterData {
YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS]; int strength; int frame_count; int alt_ref_index; struct scale_factors sf;
YV12_BUFFER_CONFIG *dst;
} ARNRFilterData;
typedefstruct EncFrameBuf { int mem_valid; int released;
YV12_BUFFER_CONFIG frame;
} EncFrameBuf;
// Maximum operating frame buffer size needed for a GOP using ARF reference. // This is used to allocate the memory for TPL stats for a GOP. #define MAX_ARF_GOP_SIZE (2 * MAX_LAG_BUFFERS) #define MAX_KMEANS_GROUPS 8
typedefstruct KMEANS_DATA { double value; int pos; int group_idx;
} KMEANS_DATA;
#if CONFIG_RATE_CTRL typedefstruct PARTITION_INFO { int row; // row pixel offset of current 4x4 block int column; // column pixel offset of current 4x4 block int row_start; // row pixel offset of the start of the prediction block int column_start; // column pixel offset of the start of the prediction block int width; // prediction block width int height; // prediction block height
} PARTITION_INFO;
typedefstruct GOP_COMMAND { int use; // use this command to set gop or not. If not, use vp9's decision. int show_frame_count; int use_alt_ref;
} GOP_COMMAND;
staticINLINEvoid gop_command_on(GOP_COMMAND *gop_command, int show_frame_count, int use_alt_ref) {
gop_command->use = 1;
gop_command->show_frame_count = show_frame_count;
gop_command->use_alt_ref = use_alt_ref;
}
// TODO(angiebird): See if we can merge this one with FrameType in // simple_encode.h typedefenum ENCODE_FRAME_TYPE {
ENCODE_FRAME_TYPE_KEY,
ENCODE_FRAME_TYPE_INTER,
ENCODE_FRAME_TYPE_ALTREF,
ENCODE_FRAME_TYPE_OVERLAY,
ENCODE_FRAME_TYPE_GOLDEN,
ENCODE_FRAME_TYPES,
} ENCODE_FRAME_TYPE;
// TODO(angiebird): Merge this function with get_frame_type_from_update_type() staticINLINE ENCODE_FRAME_TYPE
get_encode_frame_type(FRAME_UPDATE_TYPE update_type) { switch (update_type) { case KF_UPDATE: return ENCODE_FRAME_TYPE_KEY; case ARF_UPDATE: return ENCODE_FRAME_TYPE_ALTREF; case GF_UPDATE: return ENCODE_FRAME_TYPE_GOLDEN; case OVERLAY_UPDATE: return ENCODE_FRAME_TYPE_OVERLAY; case LF_UPDATE: return ENCODE_FRAME_TYPE_INTER; default:
fprintf(stderr, "Unsupported update_type %d\n", update_type);
abort(); return ENCODE_FRAME_TYPE_INTER;
}
}
typedefstruct RATE_QSTEP_MODEL { // The rq model predicts the bit usage as follows. // rate = bias - ratio * log2(q_step) int ready; double bias; double ratio;
} RATE_QSTEP_MODEL;
typedefstruct ENCODE_COMMAND { int use_external_quantize_index; int external_quantize_index;
int use_external_target_frame_bits; int target_frame_bits; double target_frame_bits_error_percent;
// Returns number of units in size of 4, if not multiple not a multiple of 4, // round it up. For example, size is 7, return 2. staticINLINEint get_num_unit_4x4(int size) { return (size + 3) >> 2; } // Returns number of units in size of 16, if not multiple not a multiple of 16, // round it up. For example, size is 17, return 2. staticINLINEint get_num_unit_16x16(int size) { return (size + 15) >> 4; } #endif// CONFIG_RATE_CTRL
#if CONFIG_COLLECT_COMPONENT_TIMING #include"vpx_ports/vpx_timer.h" // Adjust the following to add new components. typedefenum {
vp9_get_compressed_data_time,
vp9_temporal_filter_time,
vp9_rc_get_second_pass_params_time,
setup_tpl_stats_time,
Pass2Encode_time,
staticINLINEcharconst *get_component_name(int index) { switch (index) { case vp9_get_compressed_data_time: return"vp9_get_compressed_data_time"; case vp9_temporal_filter_time: return"vp9_temporal_filter_time"; case vp9_rc_get_second_pass_params_time: return"vp9_rc_get_second_pass_params_time"; case setup_tpl_stats_time: return"setup_tpl_stats_time"; case Pass2Encode_time: return"Pass2Encode_time";
case encode_with_recode_loop_time: return"encode_with_recode_loop_time"; case loopfilter_frame_time: return"loopfilter_frame_time"; case vp9_pack_bitstream_time: return"vp9_pack_bitstream_time";
case encode_frame_internal_time: return"encode_frame_internal_time"; case rd_pick_partition_time: return"rd_pick_partition_time"; case rd_pick_sb_modes_time: return"rd_pick_sb_modes_time"; case encode_sb_time: return"encode_sb_time";
case vp9_rd_pick_inter_mode_sb_time: return"vp9_rd_pick_inter_mode_sb_time"; case vp9_rd_pick_inter_mode_sub8x8_time: return"vp9_rd_pick_inter_mode_sub8x8_time";
case intra_mode_search_time: return"intra_mode_search_time"; case handle_inter_mode_time: return"handle_inter_mode_time"; case single_motion_search_time: return"single_motion_search_time"; case joint_motion_search_time: return"joint_motion_search_time"; case interp_filter_time: return"interp_filter_time";
YV12_BUFFER_CONFIG *Source;
YV12_BUFFER_CONFIG *Last_Source; // NULL for first frame and alt_ref frames
YV12_BUFFER_CONFIG *un_scaled_source;
YV12_BUFFER_CONFIG scaled_source;
YV12_BUFFER_CONFIG *unscaled_last_source;
YV12_BUFFER_CONFIG scaled_last_source; #ifdef ENABLE_KF_DENOISE
YV12_BUFFER_CONFIG raw_unscaled_source;
YV12_BUFFER_CONFIG raw_scaled_source; #endif
YV12_BUFFER_CONFIG *raw_source_frame;
BLOCK_SIZE tpl_bsize;
TplDepFrame tpl_stats[MAX_ARF_GOP_SIZE]; // Used to store TPL stats before propagation
VpxTplGopStats tpl_gop_stats;
YV12_BUFFER_CONFIG *tpl_recon_frames[REF_FRAMES];
EncFrameBuf enc_frame_buf[REF_FRAMES]; #if CONFIG_MULTITHREAD
pthread_mutex_t kmeans_mutex; #endif int kmeans_data_arr_alloc;
KMEANS_DATA *kmeans_data_arr; int kmeans_data_size; int kmeans_data_stride; double kmeans_ctr_ls[MAX_KMEANS_GROUPS]; double kmeans_boundary_ls[MAX_KMEANS_GROUPS]; int kmeans_count_ls[MAX_KMEANS_GROUPS]; int kmeans_ctr_num; #if CONFIG_NON_GREEDY_MV
MotionFieldInfo motion_field_info; int tpl_ready;
int_mv *select_mv_arr; #endif
TileDataEnc *tile_data; int allocated_tiles; // Keep track of memory allocated for tiles.
int scaled_ref_idx[REFS_PER_FRAME]; int lst_fb_idx; int gld_fb_idx; int alt_fb_idx;
int ref_fb_idx[REF_FRAMES];
int refresh_last_frame; int refresh_golden_frame; int refresh_alt_ref_frame;
int ext_refresh_frame_flags_pending; int ext_refresh_last_frame; int ext_refresh_golden_frame; int ext_refresh_alt_ref_frame;
int ext_refresh_frame_context_pending; int ext_refresh_frame_context;
int64_t norm_wiener_variance;
int64_t *mb_wiener_variance; int mb_wiener_var_rows; int mb_wiener_var_cols; double *mi_ssim_rdmult_scaling_factors;
int interp_filter_selected[REF_FRAMES][SWITCHABLE];
struct vpx_codec_pkt_list *output_pkt_list;
MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS]; int mbgraph_n_frames; // number of frames filled in the above int static_mb_pct; // % forced skip mbs by segmentation int ref_frame_flags;
SPEED_FEATURES sf;
uint32_t max_mv_magnitude; int mv_step_param;
int allow_comp_inter_inter;
// Default value is 1. From first pass stats, encode_breakout may be disabled.
ENCODE_BREAKOUT_TYPE allow_encode_breakout;
// Get threshold from external input. A suggested threshold is 800 for HD // clips, and 300 for < HD clips. int encode_breakout;
uint8_t *segmentation_map;
uint8_t *skin_map;
// segment threshold for encode breakout int segment_encode_breakout[MAX_SEGMENTS];
int initial_width; int initial_height; int initial_mbs; // Number of MBs in the full-size frame; to be used to // normalize the firstpass stats. This will differ from the // number of MBs in the current frame when the frame is // scaled.
int last_coded_width; int last_coded_height;
int use_svc;
SVC svc;
// Store frame variance info in SOURCE_VAR_BASED_PARTITION search type.
Diff *source_diff_var; // The threshold used in SOURCE_VAR_BASED_PARTITION search type. unsignedint source_var_thresh; int frames_till_next_var_check;
int frame_flags;
search_site_config ss_cfg;
int mbmode_cost[INTRA_MODES]; unsignedint inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES]; int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES][INTRA_MODES]; int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; // Indices are: max_tx_size-1, tx_size_ctx, tx_size int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
int resize_pending;
RESIZE_STATE resize_state; int external_resize; int resize_scale_num; int resize_scale_den; int resize_avg_qp; int resize_buffer_underflow; int resize_count;
int use_skin_detection;
int target_level;
NOISE_ESTIMATE noise_estimate;
// Count on how many consecutive times a block uses small/zeromv for encoding.
uint8_t *consec_zero_mv;
// Previous Partition Info
BLOCK_SIZE *prev_partition;
int8_t *prev_segment_id; // Used to save the status of whether a block has a low variance in // choose_partitioning. 0 for 64x64, 1~2 for 64x32, 3~4 for 32x64, 5~8 for // 32x32, 9~24 for 16x16. // This is for the last frame and is copied to the current frame // when partition copy happens.
uint8_t *prev_variance_low;
uint8_t *copied_frame_cnt;
uint8_t max_copied_frame; // If the last frame is dropped, we don't copy partition.
uint8_t last_frame_dropped;
// For each superblock: keeps track of the last time (in frame distance) the // the superblock did not have low source sad.
uint8_t *content_state_sb_fd;
// Flag to keep track of dynamic change in deadline mode // (good/best/realtime).
MODE deadline_mode_previous_frame;
// Flag to disable scene detection when rtc rate control library is used. int disable_scene_detection_rtc_ratectrl;
#if CONFIG_COLLECT_COMPONENT_TIMING /*! * component_time[] are initialized to zero while encoder starts.
*/
uint64_t component_time[kTimingComponents]; /*! * Stores timing for individual components between calls of start_timing() * and end_timing().
*/ struct vpx_usec_timer component_timer[kTimingComponents]; /*! * frame_component_time[] are initialized to zero at beginning of each frame.
*/
uint64_t frame_component_time[kTimingComponents]; #endif
} VP9_COMP;
#if CONFIG_RATE_CTRL // Allocates memory for the partition information. // The unit size is each 4x4 block. // Only called once in vp9_create_compressor(). staticINLINEvoid partition_info_init(struct VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common; constint unit_width = get_num_unit_4x4(cpi->frame_info.frame_width); constint unit_height = get_num_unit_4x4(cpi->frame_info.frame_height);
CHECK_MEM_ERROR(&cm->error, cpi->partition_info,
(PARTITION_INFO *)vpx_calloc(unit_width * unit_height, sizeof(PARTITION_INFO)));
memset(cpi->partition_info, 0,
unit_width * unit_height * sizeof(PARTITION_INFO));
}
// Frees memory of the partition information. // Only called once in dealloc_compressor_data(). staticINLINEvoid free_partition_info(struct VP9_COMP *cpi) {
vpx_free(cpi->partition_info);
cpi->partition_info = NULL;
}
// Allocates memory for the motion vector information. // The unit size is each 4x4 block. // Only called once in vp9_create_compressor(). staticINLINEvoid motion_vector_info_init(struct VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common; constint unit_width = get_num_unit_4x4(cpi->frame_info.frame_width); constint unit_height = get_num_unit_4x4(cpi->frame_info.frame_height);
CHECK_MEM_ERROR(&cm->error, cpi->motion_vector_info,
(MOTION_VECTOR_INFO *)vpx_calloc(unit_width * unit_height, sizeof(MOTION_VECTOR_INFO)));
memset(cpi->motion_vector_info, 0,
unit_width * unit_height * sizeof(MOTION_VECTOR_INFO));
}
// Frees memory of the motion vector information. // Only called once in dealloc_compressor_data(). staticINLINEvoid free_motion_vector_info(struct VP9_COMP *cpi) {
vpx_free(cpi->motion_vector_info);
cpi->motion_vector_info = NULL;
}
// Allocates memory for the tpl stats information. // Only called once in vp9_create_compressor(). staticINLINEvoid tpl_stats_info_init(struct VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
CHECK_MEM_ERROR(
&cm->error, cpi->tpl_stats_info,
(TplDepStats *)vpx_calloc(MAX_LAG_BUFFERS, sizeof(TplDepStats)));
memset(cpi->tpl_stats_info, 0, MAX_LAG_BUFFERS * sizeof(TplDepStats));
}
// Frees memory of the tpl stats information. // Only called once in dealloc_compressor_data(). staticINLINEvoid free_tpl_stats_info(struct VP9_COMP *cpi) {
vpx_free(cpi->tpl_stats_info);
cpi->tpl_stats_info = NULL;
}
// Allocates memory for the first pass motion vector information. // The unit size is each 16x16 block. // Only called once in vp9_create_compressor(). staticINLINEvoid fp_motion_vector_info_init(struct VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common; constint unit_width = get_num_unit_16x16(cpi->frame_info.frame_width); constint unit_height = get_num_unit_16x16(cpi->frame_info.frame_height);
CHECK_MEM_ERROR(&cm->error, cpi->fp_motion_vector_info,
(MOTION_VECTOR_INFO *)vpx_calloc(unit_width * unit_height, sizeof(MOTION_VECTOR_INFO)));
}
staticINLINEvoid fp_motion_vector_info_reset( int frame_width, int frame_height,
MOTION_VECTOR_INFO *fp_motion_vector_info) { constint unit_width = get_num_unit_16x16(frame_width); constint unit_height = get_num_unit_16x16(frame_height); int i; for (i = 0; i < unit_width * unit_height; ++i) {
reset_mv_info(fp_motion_vector_info + i);
}
}
// Frees memory of the first pass motion vector information. // Only called once in dealloc_compressor_data(). staticINLINEvoid free_fp_motion_vector_info(struct VP9_COMP *cpi) {
vpx_free(cpi->fp_motion_vector_info);
cpi->fp_motion_vector_info = NULL;
}
// This is the c-version counter part of ImageBuffer typedefstruct IMAGE_BUFFER { int allocated; int plane_width[3]; int plane_height[3];
uint8_t *plane_buffer[3];
} IMAGE_BUFFER;
#define RATE_CTRL_MAX_RECODE_NUM 7
typedefstruct RATE_QINDEX_HISTORY { int recode_count; int q_index_history[RATE_CTRL_MAX_RECODE_NUM]; int rate_history[RATE_CTRL_MAX_RECODE_NUM]; int q_index_high; int q_index_low;
} RATE_QINDEX_HISTORY;
#endif// CONFIG_RATE_CTRL
typedefstruct ENCODE_FRAME_RESULT { int show_idx;
FRAME_UPDATE_TYPE update_type; #if CONFIG_RATE_CTRL int frame_coding_index; int ref_frame_coding_indexes[MAX_INTER_REF_FRAMES]; int ref_frame_valid_list[MAX_INTER_REF_FRAMES]; double psnr;
uint64_t sse;
FRAME_COUNTS frame_counts; const PARTITION_INFO *partition_info; const MOTION_VECTOR_INFO *motion_vector_info; const TplDepStats *tpl_stats_info;
IMAGE_BUFFER coded_frame;
RATE_QINDEX_HISTORY rq_history; #endif// CONFIG_RATE_CTRL int quantize_index;
} ENCODE_FRAME_RESULT;
// receive a frames worth of data. caller can assume that a copy of this // frame is made and not just a copy of the pointer.. int vp9_receive_raw_frame(VP9_COMP *cpi, vpx_enc_frame_flags_t frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time);
int vp9_get_compressed_data(VP9_COMP *cpi, unsignedint *frame_flags,
size_t *size, uint8_t *dest, size_t dest_size,
int64_t *time_stamp, int64_t *time_end, int flush,
ENCODE_FRAME_RESULT *encode_frame_result);
int vp9_get_preview_raw_frame(VP9_COMP *cpi, YV12_BUFFER_CONFIG *dest,
vp9_ppflags_t *flags);
int vp9_use_as_reference(VP9_COMP *cpi, int ref_frame_flags);
void vp9_update_reference(VP9_COMP *cpi, int ref_frame_flags);
int vp9_copy_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag,
YV12_BUFFER_CONFIG *sd);
int vp9_set_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag,
YV12_BUFFER_CONFIG *sd);
int vp9_update_entropy(VP9_COMP *cpi, int update);
int vp9_set_active_map(VP9_COMP *cpi, unsignedchar *new_map_16x16, int rows, int cols);
int vp9_get_active_map(VP9_COMP *cpi, unsignedchar *new_map_16x16, int rows, int cols);
int vp9_set_internal_size(VP9_COMP *cpi, VPX_SCALING_MODE horiz_mode,
VPX_SCALING_MODE vert_mode);
int vp9_set_size_literal(VP9_COMP *cpi, unsignedint width, unsignedint height);
void vp9_set_svc(VP9_COMP *cpi, int use_svc);
// Check for resetting the rc flags (rc_1_frame, rc_2_frame) if the // configuration change has a large change in avg_frame_bandwidth. // For SVC check for resetting based on spatial layer average bandwidth. // Also reset buffer level to optimal level. void vp9_check_reset_rc_flag(VP9_COMP *cpi);
void vp9_set_rc_buffer_sizes(VP9_COMP *cpi);
staticINLINEint stack_pop(int *stack, int stack_size) { int idx; constint r = stack[0]; for (idx = 1; idx < stack_size; ++idx) stack[idx - 1] = stack[idx];
staticINLINEint get_token_alloc(int mb_rows, int mb_cols) { // TODO(JBB): double check we can't exceed this token count if we have a // 32x32 transform crossing a boundary at a multiple of 16. // mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full // resolution. We assume up to 1 token per pixel, and then allow // a head room of 4.
// Use aligned mb_rows and mb_cols to better align with actual token sizes. constint aligned_mb_rows =
ALIGN_POWER_OF_TWO(mb_rows, MI_BLOCK_SIZE_LOG2 - 1); constint aligned_mb_cols =
ALIGN_POWER_OF_TWO(mb_cols, MI_BLOCK_SIZE_LOG2 - 1); return aligned_mb_rows * aligned_mb_cols * (16 * 16 * 3 + 4);
}
// Get the allocated token size for a tile. It does the same calculation as in // the frame token allocation. staticINLINEint allocated_tokens(TileInfo tile) { int tile_mb_rows = (tile.mi_row_end - tile.mi_row_start + 1) >> 1; int tile_mb_cols = (tile.mi_col_end - tile.mi_col_start + 1) >> 1;
void vp9_get_ref_frame_info(FRAME_UPDATE_TYPE update_type, int ref_frame_flags,
RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int *ref_frame_coding_indexes, int *ref_frame_valid_list);
void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv);
staticINLINEint get_level_index(VP9_LEVEL level) { int i; for (i = 0; i < VP9_LEVELS; ++i) { if (level == vp9_level_defs[i].level) return i;
} return -1;
}
// Return the log2 value of max column tiles corresponding to the level that // the picture size fits into. staticINLINEint log_tile_cols_from_picsize_level(uint32_t width,
uint32_t height) { int i; const uint32_t pic_size = width * height; const uint32_t pic_breadth = VPXMAX(width, height); for (i = LEVEL_1; i < LEVEL_MAX; ++i) { if (vp9_level_defs[i].max_luma_picture_size >= pic_size &&
vp9_level_defs[i].max_luma_picture_breadth >= pic_breadth) { return get_msb(vp9_level_defs[i].max_col_tiles);
}
} return INT_MAX;
}
vpx_codec_err_t vp9_set_roi_map(VP9_COMP *cpi, unsignedchar *map, unsignedint rows, unsignedint cols, int delta_q[8], int delta_lf[8], int skip[8], int ref_frame[8]);
staticINLINEint num_4x4_to_edge(int plane_4x4_dim, int mb_to_edge_dim, int subsampling_dim, int blk_dim) { return plane_4x4_dim + (mb_to_edge_dim >> (5 + subsampling_dim)) - blk_dim;
}
// Compute the sum of squares on all visible 4x4s in the transform block. static int64_t sum_squares_visible(const MACROBLOCKD *xd, conststruct macroblockd_plane *const pd, const int16_t *diff, constint diff_stride, int blk_row, int blk_col, const BLOCK_SIZE plane_bsize, const BLOCK_SIZE tx_bsize, int *visible_width, int *visible_height) {
int64_t sse; constint plane_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; constint plane_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; constint tx_4x4_w = num_4x4_blocks_wide_lookup[tx_bsize]; constint tx_4x4_h = num_4x4_blocks_high_lookup[tx_bsize]; constint b4x4s_to_right_edge = num_4x4_to_edge(
plane_4x4_w, xd->mb_to_right_edge, pd->subsampling_x, blk_col); constint b4x4s_to_bottom_edge = num_4x4_to_edge(
plane_4x4_h, xd->mb_to_bottom_edge, pd->subsampling_y, blk_row); if (tx_bsize == BLOCK_4X4 ||
(b4x4s_to_right_edge >= tx_4x4_w && b4x4s_to_bottom_edge >= tx_4x4_h)) {
assert(tx_4x4_w == tx_4x4_h);
sse = (int64_t)vpx_sum_squares_2d_i16(diff, diff_stride, tx_4x4_w << 2);
*visible_width = tx_4x4_w << 2;
*visible_height = tx_4x4_h << 2;
} else { int r, c; constint max_r = VPXMIN(b4x4s_to_bottom_edge, tx_4x4_h); constint max_c = VPXMIN(b4x4s_to_right_edge, tx_4x4_w);
sse = 0; // if we are in the unrestricted motion border. for (r = 0; r < max_r; ++r) { // Skip visiting the sub blocks that are wholly within the UMV. for (c = 0; c < max_c; ++c) {
sse += (int64_t)vpx_sum_squares_2d_i16(
diff + r * diff_stride * 4 + c * 4, diff_stride, 4);
}
}
*visible_width = max_c << 2;
*visible_height = max_r << 2;
} return sse;
}
// Check if trellis coefficient optimization of the transform block is enabled. staticINLINEint do_trellis_opt(conststruct macroblockd_plane *pd, const int16_t *src_diff, int diff_stride, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { conststruct encode_b_args *const args = (struct encode_b_args *)arg; const MACROBLOCK *const x = args->x;
switch (args->enable_trellis_opt) { case DISABLE_TRELLIS_OPT: return 0; case ENABLE_TRELLIS_OPT: return 1; case ENABLE_TRELLIS_OPT_TX_RD_SRC_VAR: {
vpx_clear_system_state();
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.