#include "third_party/googletest/src/include/gtest/gtest.h"
namespace libvpx_test {
-void Encoder::EncodeFrame(VideoSource *video, unsigned long flags) {
+void Encoder::EncodeFrame(VideoSource *video, const unsigned long frame_flags) {
if (video->img())
- EncodeFrameInternal(*video, flags);
+ EncodeFrameInternal(*video, frame_flags);
else
Flush();
}
void Encoder::EncodeFrameInternal(const VideoSource &video,
- unsigned long flags) {
+ const unsigned long frame_flags) {
vpx_codec_err_t res;
const vpx_image_t *img = video.img();
cfg_.g_h = img->d_h;
cfg_.g_timebase = video.timebase();
cfg_.rc_twopass_stats_in = stats_->buf();
- res = vpx_codec_enc_init(&encoder_, &vpx_codec_vp8_cx_algo, &cfg_, 0);
+ res = vpx_codec_enc_init(&encoder_, &vpx_codec_vp8_cx_algo, &cfg_,
+ init_flags_);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
// Encode the frame
res = vpx_codec_encode(&encoder_,
video.img(), video.pts(), video.duration(),
- flags, deadline_);
+ frame_flags, deadline_);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
cfg_.g_pass = VPX_RC_LAST_PASS;
BeginPassHook(pass);
- Encoder encoder(cfg_, deadline_, &stats_);
+ Encoder encoder(cfg_, deadline_, init_flags_, &stats_);
#if CONFIG_VP8_DECODER
Decoder decoder(dec_cfg);
bool has_cxdata = false;
PreEncodeFrameHook(video);
PreEncodeFrameHook(video, &encoder);
- encoder.EncodeFrame(video, flags_);
+ encoder.EncodeFrame(video, frame_flags_);
CxDataIterator iter = encoder.GetCxData();
class Encoder {
public:
Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
- TwopassStatsStore *stats)
- : cfg_(cfg), deadline_(deadline), stats_(stats) {
+ const unsigned long init_flags, TwopassStatsStore *stats)
+ : cfg_(cfg), deadline_(deadline), init_flags_(init_flags), stats_(stats) {
memset(&encoder_, 0, sizeof(encoder_));
}
}
// This is a thin wrapper around vpx_codec_encode(), so refer to
// vpx_encoder.h for its semantics.
- void EncodeFrame(VideoSource *video, unsigned long flags);
+ void EncodeFrame(VideoSource *video, const unsigned long frame_flags);
// Convenience wrapper for EncodeFrame()
void EncodeFrame(VideoSource *video) {
}
// Encode an image
- void EncodeFrameInternal(const VideoSource &video, unsigned long flags);
+ void EncodeFrameInternal(const VideoSource &video,
+ const unsigned long frame_flags);
// Flush the encoder on EOS
void Flush();
vpx_codec_ctx_t encoder_;
vpx_codec_enc_cfg_t cfg_;
unsigned long deadline_;
+ unsigned long init_flags_;
TwopassStatsStore *stats_;
};
// classes directly, so that tests can be parameterized differently.
class EncoderTest {
protected:
- EncoderTest() : abort_(false), flags_(0), last_pts_(0) {}
+ EncoderTest() : abort_(false), init_flags_(0), frame_flags_(0),
+ last_pts_(0) {}
virtual ~EncoderTest() {}
unsigned int passes_;
unsigned long deadline_;
TwopassStatsStore stats_;
- unsigned long flags_;
+ unsigned long init_flags_;
+ unsigned long frame_flags_;
vpx_codec_pts_t last_pts_;
};
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (kf_do_force_kf_)
- flags_ = (video->frame() % 3) ? 0 : VPX_EFLAG_FORCE_KF;
+ frame_flags_ = (video->frame() % 3) ? 0 : VPX_EFLAG_FORCE_KF;
if (set_cpu_used_ && video->frame() == 1)
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
}