}
#if CONFIG_VP9_ENCODER
+TEST(EncodeAPI, ConfigLargeTargetBitrateVp9) {
+ constexpr int kWidth = 16383;
+ constexpr int kHeight = 16383;
+ constexpr auto *iface = &vpx_codec_vp9_cx_algo;
+ SCOPED_TRACE(vpx_codec_iface_name(iface));
+ vpx_codec_enc_cfg_t cfg = {};
+ struct Encoder {
+ ~Encoder() { EXPECT_EQ(vpx_codec_destroy(&ctx), VPX_CODEC_OK); }
+ vpx_codec_ctx_t ctx = {};
+ } enc;
+
+ ASSERT_EQ(vpx_codec_enc_config_default(iface, &cfg, 0), VPX_CODEC_OK);
+ // The following setting will cause avg_frame_bandwidth in rate control to be
+ // larger than INT_MAX
+ cfg.rc_target_bitrate = INT_MAX;
+ cfg.g_timebase.den = 1;
+ cfg.g_timebase.num = 10;
+ EXPECT_NO_FATAL_FAILURE(InitCodec(*iface, kWidth, kHeight, &enc.ctx, &cfg));
+ EXPECT_NO_FATAL_FAILURE(EncodeWithConfig(cfg, &enc.ctx))
+ << "target bitrate: " << cfg.rc_target_bitrate << " framerate: "
+ << static_cast<double>(cfg.g_timebase.den) / cfg.g_timebase.num;
+}
+
class EncodeApiGetTplStatsTest
: public ::libvpx_test::EncoderTest,
public ::testing::TestWithParam<const libvpx_test::CodecFactory *> {
RATE_CONTROL *const rc = &cpi->rc;
int vbr_max_bits;
- rc->avg_frame_bandwidth = (int)(oxcf->target_bandwidth / cpi->framerate);
+ rc->avg_frame_bandwidth =
+ (int)VPXMIN(oxcf->target_bandwidth / cpi->framerate, INT_MAX);
rc->min_frame_bandwidth =
(int)(rc->avg_frame_bandwidth * oxcf->two_pass_vbrmin_section / 100);
VPXMIN(lrc->bits_off_target, lrc->maximum_buffer_size);
lrc->buffer_level = VPXMIN(lrc->buffer_level, lrc->maximum_buffer_size);
lc->framerate = cpi->framerate / oxcf->ts_rate_decimator[tl];
- lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
+ lrc->avg_frame_bandwidth =
+ (int)VPXMIN(lc->target_bandwidth / lc->framerate, INT_MAX);
lrc->max_frame_bandwidth = rc->max_frame_bandwidth;
lrc->worst_quality = rc->worst_quality;
lrc->best_quality = rc->best_quality;
} else {
lc->framerate = cpi->framerate;
}
- lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
+ lrc->avg_frame_bandwidth =
+ (int)VPXMIN(lc->target_bandwidth / lc->framerate, INT_MAX);
lrc->max_frame_bandwidth = rc->max_frame_bandwidth;
// Update qp-related quantities.
lrc->worst_quality = rc->worst_quality;
const int tl = svc->temporal_layer_id;
lc->framerate = cpi->framerate / oxcf->ts_rate_decimator[tl];
- lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
+ lrc->avg_frame_bandwidth =
+ (int)VPXMIN(lc->target_bandwidth / lc->framerate, INT_MAX);
lrc->max_frame_bandwidth = cpi->rc.max_frame_bandwidth;
// Update the average layer frame size (non-cumulative per-frame-bw).
if (tl == 0) {
RATE_CONTROL *const lrc = &lc->rc;
lc->framerate = framerate;
- lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
+ lrc->avg_frame_bandwidth =
+ (int)VPXMIN(lc->target_bandwidth / lc->framerate, INT_MAX);
lrc->min_frame_bandwidth =
(int)(lrc->avg_frame_bandwidth * oxcf->two_pass_vbrmin_section / 100);
lrc->max_frame_bandwidth = (int)(((int64_t)lrc->avg_frame_bandwidth *