diff options
-rw-r--r-- | test/simple_encode_test.cc | 48 | ||||
-rw-r--r-- | vp9/simple_encode.cc | 6 | ||||
-rw-r--r-- | vp9/simple_encode.h | 2 |
3 files changed, 17 insertions, 39 deletions
diff --git a/test/simple_encode_test.cc b/test/simple_encode_test.cc index 15d13b18b..b4be21cdf 100644 --- a/test/simple_encode_test.cc +++ b/test/simple_encode_test.cc @@ -4,18 +4,18 @@ #include "vp9/simple_encode.h" namespace { +const int w = 352; +const int h = 288; +const int frame_rate_num = 30; +const int frame_rate_den = 1; +const int target_bitrate = 1000; +const int num_frames = 17; +// TODO(angiebird): Figure out how to upload test video to our codebase +const char infile_path[] = "bus_352x288_420_f20_b8.yuv"; TEST(SimpleEncode, ComputeFirstPassStats) { - int w = 352; - int h = 288; - int frame_rate_num = 30; - int frame_rate_den = 1; - int target_bitrate = 200; - int num_frames = 17; - // TODO(angiebird): Figure out how to upload test video to our codebase - FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r"); SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den, - target_bitrate, num_frames, file); + target_bitrate, num_frames, infile_path); simple_encode.ComputeFirstPassStats(); std::vector<std::vector<double>> frame_stats = simple_encode.ObserveFirstPassStats(); @@ -34,32 +34,16 @@ TEST(SimpleEncode, ComputeFirstPassStats) { } TEST(SimpleEncode, GetCodingFrameNum) { - int w = 352; - int h = 288; - int frame_rate_num = 30; - int frame_rate_den = 1; - int target_bitrate = 200; - int num_frames = 17; - // TODO(angiebird): Figure out how to upload test video to our codebase - FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r"); SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den, - target_bitrate, num_frames, file); + target_bitrate, num_frames, infile_path); simple_encode.ComputeFirstPassStats(); int num_coding_frames = simple_encode.GetCodingFrameNum(); EXPECT_EQ(num_coding_frames, 19); } TEST(SimpleEncode, EncodeFrame) { - int w = 352; - int h = 288; - int frame_rate_num = 30; - int frame_rate_den = 1; - int target_bitrate = 1000; - int num_frames = 17; - // TODO(angiebird): Figure out how to upload test video to our codebase - FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r"); SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den, - target_bitrate, num_frames, file); + target_bitrate, num_frames, infile_path); simple_encode.ComputeFirstPassStats(); int num_coding_frames = simple_encode.GetCodingFrameNum(); EXPECT_GE(num_coding_frames, num_frames); @@ -94,16 +78,8 @@ TEST(SimpleEncode, EncodeFrame) { } TEST(SimpleEncode, EncodeFrameWithQuantizeIndex) { - int w = 352; - int h = 288; - int frame_rate_num = 30; - int frame_rate_den = 1; - int target_bitrate = 1000; - int num_frames = 17; - // TODO(angiebird): Figure out how to upload test video to our codebase - FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r"); SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den, - target_bitrate, num_frames, file); + target_bitrate, num_frames, infile_path); simple_encode.ComputeFirstPassStats(); int num_coding_frames = simple_encode.GetCodingFrameNum(); simple_encode.StartEncode(); diff --git a/vp9/simple_encode.cc b/vp9/simple_encode.cc index 38f87fc3a..54358c681 100644 --- a/vp9/simple_encode.cc +++ b/vp9/simple_encode.cc @@ -97,7 +97,8 @@ static void update_encode_frame_result( SimpleEncode::SimpleEncode(int frame_width, int frame_height, int frame_rate_num, int frame_rate_den, - int target_bitrate, int num_frames, FILE *file) + int target_bitrate, int num_frames, + const char *infile_path) : pimpl{ std::unique_ptr<impl>(new impl()) } { this->frame_width = frame_width; this->frame_height = frame_height; @@ -105,7 +106,8 @@ SimpleEncode::SimpleEncode(int frame_width, int frame_height, this->frame_rate_den = frame_rate_den; this->target_bitrate = target_bitrate; this->num_frames = num_frames; - this->file = file; + // TODO(angirbid): Should we keep a file pointer here or keep the file_path? + this->file = fopen(infile_path, "r"); pimpl->cpi = NULL; pimpl->img_fmt = VPX_IMG_FMT_I420; } diff --git a/vp9/simple_encode.h b/vp9/simple_encode.h index e359f0553..adcc0fd58 100644 --- a/vp9/simple_encode.h +++ b/vp9/simple_encode.h @@ -23,7 +23,7 @@ class SimpleEncode { public: SimpleEncode(int frame_width, int frame_height, int frame_rate_num, int frame_rate_den, int target_bitrate, int num_frames, - FILE *file); + const char *infile_path); ~SimpleEncode(); SimpleEncode(SimpleEncode &&) = delete; SimpleEncode &operator=(SimpleEncode &&) = delete; |