Merge "Add initialization and per frame flag members"

This commit is contained in:
Adrian Grange 2012-10-04 10:37:38 -07:00 коммит произвёл Gerrit Code Review
Родитель 0e213fb999 4206c6dd01
Коммит 85b27a1271
3 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -16,9 +16,9 @@
#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();
@ -34,7 +34,7 @@ void Encoder::EncodeFrame(VideoSource *video, unsigned long flags) {
}
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();
@ -44,7 +44,8 @@ void Encoder::EncodeFrameInternal(const VideoSource &video,
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();
}
@ -59,7 +60,7 @@ void Encoder::EncodeFrameInternal(const VideoSource &video,
// 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();
}
@ -140,7 +141,7 @@ void EncoderTest::RunLoop(VideoSource *video) {
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;
@ -151,7 +152,7 @@ void EncoderTest::RunLoop(VideoSource *video) {
PreEncodeFrameHook(video);
PreEncodeFrameHook(video, &encoder);
encoder.EncodeFrame(video, flags_);
encoder.EncodeFrame(video, frame_flags_);
CxDataIterator iter = encoder.GetCxData();

Просмотреть файл

@ -82,8 +82,8 @@ class TwopassStatsStore {
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_));
}
@ -100,7 +100,7 @@ class 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) {
@ -123,7 +123,8 @@ class Encoder {
}
// 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();
@ -131,6 +132,7 @@ class Encoder {
vpx_codec_ctx_t encoder_;
vpx_codec_enc_cfg_t cfg_;
unsigned long deadline_;
unsigned long init_flags_;
TwopassStatsStore *stats_;
};
@ -143,7 +145,8 @@ class Encoder {
// 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() {}
@ -181,7 +184,8 @@ class 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_;
};

Просмотреть файл

@ -34,7 +34,7 @@ class KeyframeTest : public ::libvpx_test::EncoderTest,
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_);
}