Commit 41cae6a6 authored by Sebastien Alaiwan's avatar Sebastien Alaiwan

Remove XIPHRC experiment

This experiment has been abandonned for AV1.

Change-Id: Ib83ebbe13e8f50e4151f9de3d0158a5463436177
parent 90243cf9
......@@ -478,13 +478,6 @@ endif ()
${AOM_AV1_COMMON_SOURCES}
"${AOM_ROOT}/av1/common/token_cdfs.h")
if (CONFIG_XIPHRC)
set(AOM_AV1_ENCODER_SOURCES
${AOM_AV1_ENCODER_SOURCES}
"${AOM_ROOT}/av1/encoder/ratectrl_xiph.c"
"${AOM_ROOT}/av1/encoder/ratectrl_xiph.h")
endif ()
# Setup AV1 common/decoder/encoder targets. The libaom target must exist before
# this function is called.
function (setup_av1_targets)
......
......@@ -73,9 +73,6 @@ AV1_CX_SRCS-yes += encoder/mcomp.h
AV1_CX_SRCS-yes += encoder/encoder.h
AV1_CX_SRCS-yes += encoder/random.h
AV1_CX_SRCS-yes += encoder/ratectrl.h
ifeq ($(CONFIG_XIPHRC),yes)
AV1_CX_SRCS-yes += encoder/ratectrl_xiph.h
endif
AV1_CX_SRCS-yes += encoder/rd.h
AV1_CX_SRCS-yes += encoder/rdopt.h
AV1_CX_SRCS-yes += encoder/tokenize.h
......@@ -89,9 +86,6 @@ AV1_CX_SRCS-yes += encoder/picklpf.h
AV1_CX_SRCS-$(CONFIG_LOOP_RESTORATION) += encoder/pickrst.c
AV1_CX_SRCS-$(CONFIG_LOOP_RESTORATION) += encoder/pickrst.h
AV1_CX_SRCS-yes += encoder/ratectrl.c
ifeq ($(CONFIG_XIPHRC),yes)
AV1_CX_SRCS-yes += encoder/ratectrl_xiph.c
endif
AV1_CX_SRCS-yes += encoder/rd.c
AV1_CX_SRCS-yes += encoder/rdopt.c
AV1_CX_SRCS-yes += encoder/segmentation.c
......
......@@ -152,7 +152,7 @@ static struct av1_extracfg default_extra_cfg = {
#if CONFIG_EXT_DELTA_Q
NO_DELTA_Q, // deltaq_mode
#endif
CONFIG_XIPHRC, // frame_periodic_delta_q
0, // frame_periodic_delta_q
AOM_BITS_8, // Bit depth
AOM_CONTENT_DEFAULT, // content
#if CONFIG_CICP
......@@ -369,16 +369,13 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
ERROR("Option --tune=ssim is not currently supported in AV1.");
if (cfg->g_pass == AOM_RC_LAST_PASS) {
#if !CONFIG_XIPHRC
const size_t packet_sz = sizeof(FIRSTPASS_STATS);
const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
const FIRSTPASS_STATS *stats;
#endif
if (cfg->rc_twopass_stats_in.buf == NULL)
ERROR("rc_twopass_stats_in.buf not set.");
#if !CONFIG_XIPHRC
if (cfg->rc_twopass_stats_in.sz % packet_sz)
ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
......@@ -390,7 +387,6 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
if ((int)(stats->count + 0.5) != n_packets - 1)
ERROR("rc_twopass_stats_in missing EOS stats packet");
#endif
}
if (cfg->g_profile <= (unsigned int)PROFILE_1 &&
......
......@@ -448,9 +448,7 @@ void av1_initialize_enc(void) {
aom_scale_rtcd();
av1_init_intra_predictors();
av1_init_me_luts();
#if !CONFIG_XIPHRC
av1_rc_init_minq_luts();
#endif
av1_init_wedge_masks();
init_done = 1;
}
......@@ -819,13 +817,7 @@ static void alloc_compressor_data(AV1_COMP *cpi) {
void av1_new_framerate(AV1_COMP *cpi, double framerate) {
cpi->framerate = framerate < 0.1 ? 30 : framerate;
#if CONFIG_XIPHRC
if (!cpi->od_rc.cur_frame) return;
cpi->od_rc.framerate = cpi->framerate;
od_enc_rc_resize(&cpi->od_rc);
#else
av1_rc_update_framerate(cpi, cpi->common.width, cpi->common.height);
#endif
}
#if CONFIG_MAX_TILE
......@@ -3240,26 +3232,7 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
cpi->common.buffer_pool = pool;
init_config(cpi, oxcf);
#if CONFIG_XIPHRC
cpi->od_rc.framerate = cpi->framerate;
cpi->od_rc.frame_width = cm->render_width;
cpi->od_rc.frame_height = cm->render_height;
cpi->od_rc.keyframe_rate = oxcf->key_freq;
cpi->od_rc.goldenframe_rate = FIXED_GF_INTERVAL;
cpi->od_rc.altref_rate = 25;
cpi->od_rc.firstpass_quant = 1;
cpi->od_rc.bit_depth = cm->bit_depth;
cpi->od_rc.minq = oxcf->best_allowed_q;
cpi->od_rc.maxq = oxcf->worst_allowed_q;
if (cpi->oxcf.rc_mode == AOM_CQ) cpi->od_rc.minq = cpi->od_rc.quality;
cpi->od_rc.quality = cpi->oxcf.rc_mode == AOM_Q ? oxcf->cq_level : -1;
cpi->od_rc.periodic_boosts = oxcf->frame_periodic_boost;
od_enc_rc_init(&cpi->od_rc,
cpi->oxcf.rc_mode == AOM_Q ? -1 : oxcf->target_bandwidth,
oxcf->maximum_buffer_size_ms);
#else
av1_rc_init(&cpi->oxcf, oxcf->pass, &cpi->rc);
#endif
cm->current_video_frame = 0;
cpi->partition_search_skippable_frame = 0;
......@@ -3354,12 +3327,6 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
kf_list = fopen("kf_list.stt", "w");
#endif
#if CONFIG_XIPHRC
if (oxcf->pass == 2) {
cpi->od_rc.twopass_allframes_buf = oxcf->two_pass_stats_in.buf;
cpi->od_rc.twopass_allframes_buf_size = oxcf->two_pass_stats_in.sz;
}
#else
if (oxcf->pass == 1) {
av1_init_first_pass(cpi);
} else if (oxcf->pass == 2) {
......@@ -3385,7 +3352,6 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
av1_init_second_pass(cpi);
}
#endif
int buf_scaler = 2;
CHECK_MEM_ERROR(
......@@ -4066,7 +4032,6 @@ void aom_write_yuv_frame_420(YV12_BUFFER_CONFIG *s, FILE *f) {
}
#endif
#if !CONFIG_XIPHRC
#if USE_GF16_MULTI_LAYER
static void check_show_existing_frame_gf16(AV1_COMP *cpi) {
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
......@@ -4143,7 +4108,6 @@ static void check_show_existing_frame(AV1_COMP *cpi) {
}
cpi->rc.is_src_frame_ext_arf = 0;
}
#endif // !CONFIG_XIPHRC
#ifdef OUTPUT_YUV_REC
void aom_write_one_yuv_frame(AV1_COMMON *cm, YV12_BUFFER_CONFIG *s) {
......@@ -4779,16 +4743,9 @@ static void set_size_dependent_vars(AV1_COMP *cpi, int *q, int *bottom_index,
// Setup variables that depend on the dimensions of the frame.
av1_set_speed_features_framesize_dependent(cpi);
// Decide q and q bounds.
#if CONFIG_XIPHRC
int frame_type = cm->frame_type == KEY_FRAME ? OD_I_FRAME : OD_P_FRAME;
*q = od_enc_rc_select_quantizers_and_lambdas(
&cpi->od_rc, cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
frame_type, bottom_index, top_index);
#else
// Decide q and q bounds.
*q = av1_rc_pick_q_and_bounds(cpi, cm->width, cm->height, bottom_index,
top_index);
#endif
if (!frame_is_intra_only(cm)) {
#if CONFIG_AMVR
......@@ -4918,11 +4875,9 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
set_mv_search_params(cpi);
}
#if !CONFIG_XIPHRC
if (cpi->oxcf.pass == 2) {
av1_set_target_rate(cpi, cm->width, cm->height);
}
#endif
alloc_frame_mvs(cm, cm->new_fb_idx);
......@@ -5375,10 +5330,8 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
int loop_count = 0;
int loop_at_this_size = 0;
int loop = 0;
#if !CONFIG_XIPHRC
int overshoot_seen = 0;
int undershoot_seen = 0;
#endif
int frame_over_shoot_limit;
int frame_under_shoot_limit;
int q = 0, q_low = 0, q_high = 0;
......@@ -5398,11 +5351,9 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
// TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
set_mv_search_params(cpi);
#if !CONFIG_XIPHRC
// Reset the loop state for new frame size.
overshoot_seen = 0;
undershoot_seen = 0;
#endif
q_low = bottom_index;
q_high = top_index;
......@@ -5526,7 +5477,6 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
// Is the projected frame size out of range and are we allowed
// to attempt to recode.
int last_q = q;
#if !CONFIG_XIPHRC
int retries = 0;
// Frame size out of permitted range:
......@@ -5592,7 +5542,6 @@ static void encode_with_recode_loop(AV1_COMP *cpi, size_t *size,
undershoot_seen = 1;
}
#endif
// Clamp Q to upper and lower limits:
q = clamp(q, q_low, q_high);
......@@ -5912,10 +5861,6 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
aom_malloc(num_bwd_ctxs * sizeof(&cpi->tile_data[0].tctx));
aom_cdf_prob **cdf_ptrs = aom_malloc(
num_bwd_ctxs * sizeof(&cpi->tile_data[0].tctx.partition_cdf[0][0]));
#if CONFIG_XIPHRC
int frame_type;
int drop_this_frame = 0;
#endif // CONFIG_XIPHRC
set_ext_overrides(cpi);
aom_clear_system_state();
......@@ -6012,14 +5957,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
// to do post-encoding update accordingly.
if (cpi->rc.is_src_frame_alt_ref) {
av1_set_target_rate(cpi, cm->width, cm->height);
#if CONFIG_XIPHRC
frame_type = cm->frame_type == INTER_FRAME ? OD_P_FRAME : OD_I_FRAME;
drop_this_frame = od_enc_rc_update_state(
&cpi->od_rc, *size << 3, cpi->refresh_golden_frame,
cpi->refresh_alt_ref_frame, frame_type, cpi->droppable);
#else
av1_rc_postencode_update(cpi, *size);
#endif
}
++cm->current_video_frame;
......@@ -6086,15 +6024,6 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
cm->seq_params.monochrome = oxcf->monochrome;
#endif // CONFIG_MONO_VIDEO
#if CONFIG_XIPHRC
if (drop_this_frame) {
av1_rc_postencode_update_drop_frame(cpi);
++cm->current_video_frame;
aom_free(tile_ctxs);
aom_free(cdf_ptrs);
return;
}
#else
// For 1 pass CBR, check if we are dropping this frame.
// Never drop on key frame.
if (oxcf->pass == 0 && oxcf->rc_mode == AOM_CBR &&
......@@ -6107,7 +6036,6 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
return;
}
}
#endif
aom_clear_system_state();
......@@ -6298,22 +6226,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
cm->last_frame_type = cm->frame_type;
#if CONFIG_XIPHRC
frame_type = cm->frame_type == KEY_FRAME ? OD_I_FRAME : OD_P_FRAME;
drop_this_frame =
od_enc_rc_update_state(&cpi->od_rc, *size << 3, cpi->refresh_golden_frame,
cpi->refresh_alt_ref_frame, frame_type, 0);
if (drop_this_frame) {
av1_rc_postencode_update_drop_frame(cpi);
++cm->current_video_frame;
aom_free(tile_ctxs);
aom_free(cdf_ptrs);
return;
}
#else // !CONFIG_XIPHRC
av1_rc_postencode_update(cpi, *size);
#endif // CONFIG_XIPHRC
#if 0
output_frame_level_debug_stats(cpi);
......@@ -6358,42 +6271,14 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
static void Pass0Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
int skip_adapt, unsigned int *frame_flags) {
#if CONFIG_XIPHRC
int64_t ip_count;
int frame_type, is_golden, is_altref;
/* Not updated during init so update it here */
if (cpi->oxcf.rc_mode == AOM_Q) cpi->od_rc.quality = cpi->oxcf.cq_level;
frame_type = od_frame_type(&cpi->od_rc, cpi->od_rc.cur_frame, &is_golden,
&is_altref, &ip_count);
if (frame_type == OD_I_FRAME) {
frame_type = KEY_FRAME;
cpi->frame_flags &= FRAMEFLAGS_KEY;
} else if (frame_type == OD_P_FRAME) {
frame_type = INTER_FRAME;
}
if (is_altref) {
cpi->refresh_alt_ref_frame = 1;
cpi->rc.source_alt_ref_active = 1;
}
cpi->refresh_golden_frame = is_golden;
cpi->common.frame_type = frame_type;
if (is_golden) cpi->frame_flags &= FRAMEFLAGS_GOLDEN;
#else
if (cpi->oxcf.rc_mode == AOM_CBR) {
av1_rc_get_one_pass_cbr_params(cpi);
} else {
av1_rc_get_one_pass_vbr_params(cpi);
}
#endif
encode_frame_to_data_rate(cpi, size, dest, skip_adapt, frame_flags);
}
#if !CONFIG_XIPHRC
static void Pass2Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
unsigned int *frame_flags) {
#if CONFIG_MISMATCH_DEBUG
......@@ -6423,7 +6308,6 @@ static void Pass2Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
}
check_show_existing_frame(cpi);
}
#endif
int av1_receive_raw_frame(AV1_COMP *cpi, aom_enc_frame_flags_t frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
......@@ -6843,10 +6727,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
int brf_src_index;
int i;
#if CONFIG_XIPHRC
cpi->od_rc.end_of_input = flush;
#endif
#if CONFIG_BITSTREAM_DEBUG
assert(cpi->oxcf.max_threads == 0 &&
"bitstream debug tool does not support multithreading");
......@@ -6902,7 +6782,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
cm->reset_decoder_state = 0;
#endif // CONFIG_FWD_KF
#if !CONFIG_XIPHRC
if (oxcf->pass == 2 && cm->show_existing_frame) {
// Manage the source buffer and flush out the source frame that has been
// coded already; Also get prepared for PSNR calculation if needed.
......@@ -6951,7 +6830,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
cm->show_existing_frame = 0;
return 0;
}
#endif // !CONFIG_XIPHRC
// Should we encode an arf frame.
arf_src_index = get_arf_src_index(cpi);
......@@ -7097,11 +6975,7 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
} else {
*size = 0;
if (flush && oxcf->pass == 1 && !cpi->twopass.first_pass_done) {
#if CONFIG_XIPHRC
od_enc_rc_2pass_out(&cpi->od_rc, cpi->output_pkt_list, 1);
#else
av1_end_first_pass(cpi); /* get last stats packet */
#endif
cpi->twopass.first_pass_done = 1;
}
return -1;
......@@ -7142,15 +7016,10 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
cpi->frame_flags = *frame_flags;
if (oxcf->pass == 2) {
#if CONFIG_XIPHRC
if (od_enc_rc_2pass_in(&cpi->od_rc) < 0) return -1;
}
#else
av1_rc_get_second_pass_params(cpi);
} else if (oxcf->pass == 1) {
setup_frame_size(cpi);
}
#endif
if (cpi->oxcf.pass != 0 || frame_is_intra_only(cm) == 1) {
for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i)
......@@ -7186,23 +7055,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
}
#endif
#if CONFIG_XIPHRC
if (oxcf->pass == 1) {
size_t tmp;
if (cpi->od_rc.cur_frame == 0) Pass0Encode(cpi, &tmp, dest, 1, frame_flags);
cpi->od_rc.firstpass_quant = cpi->od_rc.target_quantizer;
Pass0Encode(cpi, &tmp, dest, 0, frame_flags);
od_enc_rc_2pass_out(&cpi->od_rc, cpi->output_pkt_list, 0);
} else if (oxcf->pass == 2) {
Pass0Encode(cpi, size, dest, 0, frame_flags);
} else {
if (cpi->od_rc.cur_frame == 0) {
size_t tmp;
Pass0Encode(cpi, &tmp, dest, 1, frame_flags);
}
Pass0Encode(cpi, size, dest, 0, frame_flags);
}
#else
if (oxcf->pass == 1) {
cpi->td.mb.e_mbd.lossless[0] = is_lossless_requested(oxcf);
av1_first_pass(cpi, source);
......@@ -7212,7 +7064,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
// One pass encode
Pass0Encode(cpi, size, dest, 0, frame_flags);
}
#endif
#if CONFIG_HASH_ME
if (oxcf->pass != 1 && cpi->common.allow_screen_content_tools) {
#if CONFIG_AMVR
......@@ -7285,10 +7136,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
}
#endif // CONFIG_INTERNAL_STATS
#if CONFIG_XIPHRC
cpi->od_rc.cur_frame++;
#endif
aom_clear_system_state();
return 0;
......
......@@ -34,9 +34,6 @@
#include "av1/encoder/rd.h"
#include "av1/encoder/speed_features.h"
#include "av1/encoder/tokenize.h"
#if CONFIG_XIPHRC
#include "av1/encoder/ratectrl_xiph.h"
#endif
#if CONFIG_INTERNAL_STATS
#include "aom_dsp/ssim.h"
......@@ -468,9 +465,6 @@ typedef struct AV1_COMP {
int64_t first_time_stamp_ever;
RATE_CONTROL rc;
#if CONFIG_XIPHRC
od_rc_state od_rc;
#endif
double framerate;
// NOTE(zoeliu): Any inter frame allows maximum of REF_FRAMES inter
......
This diff is collapsed.
/*
* Copyright (c) 2001-2017, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#if !defined(_ratectrl_xiph_H)
#define _ratectrl_xiph_H (1)
#include "av1/encoder/ratectrl.h"
#include "aom/internal/aom_codec_internal.h"
/*Frame types.*/
#define OD_I_FRAME (0)
#define OD_P_FRAME (1)
#define OD_GOLDEN_P_FRAME (2)
#define OD_ALTREF_P_FRAME (3)
#define OD_FRAME_NSUBTYPES (OD_ALTREF_P_FRAME + 1)
/* Periodic boost (in between golden frames) strength - lower is more */
#define OD_PERIODIC_BOOST_DIV (10)
/* Constants for frame QP modulation <- tweak these
* Adjusts how the rate control system decides the quantizers per frame
* (sub)type */
#define OD_MQP_I (0.98)
#define OD_MQP_P (1.06)
#define OD_MQP_GP (0.99)
#define OD_MQP_AP (0.92)
#define OD_DQP_I (-2)
#define OD_DQP_P (0)
#define OD_DQP_GP (-2)
#define OD_DQP_AP (-2)
/*Fractional_coded_quantizer ~=
log2(quantizer / (1 << OD_COEFF_SHIFT))*6.307 + 6.235*/
/*Base/scale factor for linear quantizer to fractional coded quantizer
conversion (6.307 * 2^12) */
#define OD_LOG_QUANTIZER_BASE_Q12 (0x0064EB)
/*Inverse of above scale factor.*/
#define OD_LOG_QUANTIZER_EXP_Q12 (0x000289)
/*Offset for linear quantizer to fractional coded quantizer
conversion (6.235 * 2^45) */
#define OD_LOG_QUANTIZER_OFFSET_Q45 (0x0000C7851EB851ECLL)
#define OD_RC_2PASS_MAGIC (0x53015641) /* [A, V, 1, S] in little endian */
#define OD_RC_2PASS_SUMMARY_SZ (4 + 1 + (4 + 4 + 8) * OD_FRAME_NSUBTYPES)
#define OD_RC_2PASS_PACKET_SZ (1 + 4)
#define OD_RC_2PASS_MIN (OD_RC_2PASS_PACKET_SZ + OD_RC_2PASS_SUMMARY_SZ)
#define OD_RC_2PASS_VERSION (1)
/*A 2nd order low-pass Bessel follower.
We use this for rate control because it has fast reaction time, but is
critically damped.*/
typedef struct od_iir_bessel2 {
int32_t c[2];
int64_t g;
int32_t x[2];
int32_t y[2];
} od_iir_bessel2;
/* The 2-pass metrics associated with a single frame. */
typedef struct od_frame_metrics {
/*The log base 2 of the scale factor for this frame in Q24 format.*/
int64_t log_scale;
/*The frame type from pass 1.*/
unsigned frame_type : 1;
} od_frame_metrics;
/*Rate control setup and working state information.*/
typedef struct od_rc_state {
/* Image format */
int frame_width;
int frame_height;
int bit_depth;
/* Framerate */
double framerate;
/* Keyframe rate */
int keyframe_rate;
/* Golden frame period */
int goldenframe_rate;
/* Altref frame period */
int altref_rate;
/*The target bit-rate in bits per second.*/
int64_t target_bitrate;
/* Quality level for non-bitrate-targeting */
int quality;
/* Copied from oxcf->frame_periodic_boost */
int periodic_boosts;
/* Max Q */
int maxq;
/* Min Q */
int minq;
/* Quantizer to use for the first pass */
int firstpass_quant;
/* 2-pass metrics */
od_frame_metrics cur_metrics;
/* 2-pass state */
int64_t scale_sum[OD_FRAME_NSUBTYPES];
int nframes[OD_FRAME_NSUBTYPES];
/* 2-pass bytestream reader/writer context */
uint8_t *twopass_buffer;
int twopass_buffer_bytes;
/* Pass 1 stats packet storage */
uint8_t firstpass_buffer[OD_RC_2PASS_SUMMARY_SZ];
/* Every state packet from the first pass in a single buffer */
uint8_t *twopass_allframes_buf;
size_t twopass_allframes_buf_size;
/* Actual returned quantizer */
int target_quantizer;
/*The full-precision, unmodulated quantizer upon which
our modulated quantizers are based.*/
int base_quantizer;
/* Increments by 1 for each frame. */
int64_t cur_frame;
/* End of input flag */
int end_of_input;
/* Closed GOP flag */
int closed_gop;
/*The number of frames over which to distribute the reservoir usage.*/
int reservoir_frame_delay;
/*Will we drop frames to meet bitrate target?*/
unsigned char drop_frames;
/*Do we respect the maximum reservoir fullness?*/
unsigned char cap_overflow;
/*Can the reservoir go negative?*/
unsigned char cap_underflow;
/*Two-pass mode state.
0 => 1-pass encoding.
1 => 1st pass of 2-pass encoding.
2 => 2nd pass of 2-pass encoding.*/
int twopass_state;
/*The log of the number of pixels in a frame in Q57 format.*/
int64_t log_npixels;
/*The target average bits per frame.*/
int64_t bits_per_frame;
/*The current bit reservoir fullness (bits available to be used).*/
int64_t reservoir_fullness;
/*The target buffer fullness.
This is where we'd like to be by the last keyframe the appears in the next
buf_delay frames.*/
int64_t reservoir_target;
/*The maximum buffer fullness (total size of the buffer).*/
int64_t reservoir_max;
/*The log of estimated scale factor for the rate model in Q57 format.*/
int64_t log_scale[OD_FRAME_NSUBTYPES];
/*The exponent used in the rate model in Q8 format.*/
unsigned exp[OD_FRAME_NSUBTYPES];
/*The log of an estimated scale factor used to obtain the real framerate, for
VFR sources or, e.g., 12 fps content doubled to 24 fps, etc.*/
int64_t log_drop_scale[OD_FRAME_NSUBTYPES];
/*The total drop count from the previous frame.*/
uint32_t prev_drop_count[OD_FRAME_NSUBTYPES];
/*Second-order lowpass filters to track scale and VFR/drops.*/
od_iir_bessel2 scalefilter[OD_FRAME_NSUBTYPES];
od_iir_bessel2 vfrfilter[OD_FRAME_NSUBTYPES];
int frame_count[OD_FRAME_NSUBTYPES];
int inter_p_delay;
int inter_delay_target;
/*The total accumulated estimation bias.*/
int64_t rate_bias;