const int frame_rate_den_ = 1;
const int target_bitrate_ = 1000;
const int num_frames_ = 17;
+ const int target_level_ = LEVEL_UNKNOWN;
const std::string in_file_path_str_ =
libvpx_test::GetDataPath() + "/bus_352x288_420_f20_b8.yuv";
};
TEST_F(SimpleEncodeTest, ComputeFirstPassStats) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
std::vector<std::vector<double>> frame_stats =
TEST_F(SimpleEncodeTest, ObserveFirstPassMotionVectors) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
std::vector<std::vector<MotionVectorInfo>> fps_motion_vectors =
TEST_F(SimpleEncodeTest, GetCodingFrameNum) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
TEST_F(SimpleEncodeTest, EncodeFrame) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
int num_coding_frames = simple_encode.GetCodingFrameNum();
TEST_F(SimpleEncodeTest, ObserveKeyFrameMap) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
std::vector<int> key_frame_map = simple_encode.ObserveKeyFrameMap();
TEST_F(SimpleEncodeTest, EncodeFrameWithTargetFrameBits) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
TEST_F(SimpleEncodeTest, EncodeFrameWithQuantizeIndex) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
// The first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
simple_encode.StartEncode();
// The second encode with quantize index got from the first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
EXPECT_EQ(static_cast<size_t>(num_coding_frames),
const int num_units_4x4 = num_rows_4x4 * num_cols_4x4;
// The first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
// The second encode.
SimpleEncode simple_encode_2(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode_2.ComputeFirstPassStats();
const int num_coding_frames_2 = simple_encode_2.GetCodingFrameNum();
simple_encode_2.StartEncode();
const int num_units_4x4 = num_rows_4x4 * num_cols_4x4;
// The first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
// The second encode.
SimpleEncode simple_encode_2(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode_2.ComputeFirstPassStats();
const int num_coding_frames_2 = simple_encode_2.GetCodingFrameNum();
simple_encode_2.StartEncode();
// The first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
simple_encode.StartEncode();
// The external arfs are the same as the first encode.
SimpleEncode simple_encode(width_, height_, frame_rate_num_,
frame_rate_den_, target_bitrate_, num_frames_,
- in_file_path_str_.c_str());
+ target_level_, in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
simple_encode.SetExternalGroupOfPicturesMap(gop_map.data(), gop_map.size());
const int num_coding_frames = simple_encode.GetCodingFrameNum();
TEST_F(SimpleEncodeTest, SetExternalGroupOfPicturesMap) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
// Makes sure that the encode_frame_info obtained from GetEncodeFrameInfo()
// matches the counterpart in encode_frame_result obtained from EncodeFrame()
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
simple_encode.ComputeFirstPassStats();
const int num_coding_frames = simple_encode.GetCodingFrameNum();
TEST_F(SimpleEncodeTest, GetFramePixelCount) {
SimpleEncode simple_encode(width_, height_, frame_rate_num_, frame_rate_den_,
- target_bitrate_, num_frames_,
+ target_bitrate_, num_frames_, target_level_,
in_file_path_str_.c_str());
EXPECT_EQ(simple_encode.GetFramePixelCount(),
static_cast<uint64_t>(width_ * height_ * 3 / 2));
static VP9EncoderConfig GetEncodeConfig(
int frame_width, int frame_height, vpx_rational_t frame_rate,
- int target_bitrate, int encode_speed, vpx_enc_pass enc_pass,
+ int target_bitrate, int encode_speed, int target_level,
+ vpx_enc_pass enc_pass,
const std::vector<EncodeConfig> &encode_config_list) {
- VP9EncoderConfig oxcf =
- vp9_get_encoder_config(frame_width, frame_height, frame_rate,
- target_bitrate, encode_speed, enc_pass);
+ VP9EncoderConfig oxcf = vp9_get_encoder_config(
+ frame_width, frame_height, frame_rate, target_bitrate, encode_speed,
+ target_level, enc_pass);
for (const auto &config : encode_config_list) {
UpdateEncodeConfig(config, &oxcf);
}
SimpleEncode::SimpleEncode(int frame_width, int frame_height,
int frame_rate_num, int frame_rate_den,
- int target_bitrate, int num_frames,
+ int target_bitrate, int num_frames, int target_level,
const char *infile_path, const char *outfile_path) {
impl_ptr_ = std::unique_ptr<EncodeImpl>(new EncodeImpl());
frame_width_ = frame_width;
target_bitrate_ = target_bitrate;
num_frames_ = num_frames;
encode_speed_ = 0;
+ target_level_ = target_level;
frame_coding_index_ = 0;
show_frame_count_ = 0;
}
const vpx_rational_t frame_rate =
make_vpx_rational(frame_rate_num_, frame_rate_den_);
- const VP9EncoderConfig oxcf =
- GetEncodeConfig(frame_width_, frame_height_, frame_rate, target_bitrate_,
- encode_speed_, enc_pass, impl_ptr_->encode_config_list);
+ const VP9EncoderConfig oxcf = GetEncodeConfig(
+ frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_,
+ target_level_, enc_pass, impl_ptr_->encode_config_list);
vp9_dump_encoder_config(&oxcf, fp);
return StatusOk;
}
make_vpx_rational(frame_rate_num_, frame_rate_den_);
const VP9EncoderConfig oxcf = GetEncodeConfig(
frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_,
- VPX_RC_FIRST_PASS, impl_ptr_->encode_config_list);
+ target_level_, VPX_RC_FIRST_PASS, impl_ptr_->encode_config_list);
impl_ptr_->cpi = init_encoder(&oxcf, impl_ptr_->img_fmt);
struct lookahead_ctx *lookahead = impl_ptr_->cpi->lookahead;
int i;
make_vpx_rational(frame_rate_num_, frame_rate_den_);
VP9EncoderConfig oxcf = GetEncodeConfig(
frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_,
- VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
+ target_level_, VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
vpx_fixed_buf_t stats;
stats.buf = GetVectorData(impl_ptr_->first_pass_stats);
make_vpx_rational(frame_rate_num_, frame_rate_den_);
const VP9EncoderConfig oxcf = GetEncodeConfig(
frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_,
- VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
+ target_level_, VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
FRAME_INFO frame_info = vp9_get_frame_info(&oxcf);
fps_init_first_pass_info(&twopass.first_pass_info,
GetVectorData(impl_ptr_->first_pass_stats),
make_vpx_rational(frame_rate_num_, frame_rate_den_);
const VP9EncoderConfig oxcf = GetEncodeConfig(
frame_width_, frame_height_, frame_rate, target_bitrate_, encode_speed_,
- VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
+ target_level_, VPX_RC_LAST_PASS, impl_ptr_->encode_config_list);
TWO_PASS twopass;
fps_init_first_pass_info(&twopass.first_pass_info,
GetVectorData(impl_ptr_->first_pass_stats),