History

Pass in infile_path to SimpleEncode()

angiebird committed 7 years ago

Commit 21e93eb1 parent c4f1fe43 files · +17 −39Browse files

Unified · Split

3 files
  1. test/simple_encode_test.cc +12 −36
  2. vp9/simple_encode.cc +4 −2
  3. vp9/simple_encode.h +1 −1
test/simple_encode_test.cc+12−36
@@ -4,18 +4,18 @@ · 3 unmodified lines
44 #include "vp9/simple_encode.h"
55
66 namespace {
7+const int w = 352;
8+const int h = 288;
9+const int frame_rate_num = 30;
10+const int frame_rate_den = 1;
11+const int target_bitrate = 1000;
12+const int num_frames = 17;
13+// TODO(angiebird): Figure out how to upload test video to our codebase
14+const char infile_path[] = "bus_352x288_420_f20_b8.yuv";
715
816 TEST(SimpleEncode, ComputeFirstPassStats) {
9− int w = 352;
10− int h = 288;
11− int frame_rate_num = 30;
12− int frame_rate_den = 1;
13− int target_bitrate = 200;
14− int num_frames = 17;
15− // TODO(angiebird): Figure out how to upload test video to our codebase
16− FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r");
1717 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
18− target_bitrate, num_frames, file);
18+ target_bitrate, num_frames, infile_path);
1919 simple_encode.ComputeFirstPassStats();
2020 std::vector<std::vector<double>> frame_stats =
2121 simple_encode.ObserveFirstPassStats();
@@ -34,32 +34,16 @@ TEST(SimpleEncode, ComputeFirstPassStats) { · 12 unmodified lines
3434 }
3535
3636 TEST(SimpleEncode, GetCodingFrameNum) {
37− int w = 352;
38− int h = 288;
39− int frame_rate_num = 30;
40− int frame_rate_den = 1;
41− int target_bitrate = 200;
42− int num_frames = 17;
43− // TODO(angiebird): Figure out how to upload test video to our codebase
44− FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r");
4537 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
46− target_bitrate, num_frames, file);
38+ target_bitrate, num_frames, infile_path);
4739 simple_encode.ComputeFirstPassStats();
4840 int num_coding_frames = simple_encode.GetCodingFrameNum();
4941 EXPECT_EQ(num_coding_frames, 19);
5042 }
5143
5244 TEST(SimpleEncode, EncodeFrame) {
53− int w = 352;
54− int h = 288;
55− int frame_rate_num = 30;
56− int frame_rate_den = 1;
57− int target_bitrate = 1000;
58− int num_frames = 17;
59− // TODO(angiebird): Figure out how to upload test video to our codebase
60− FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r");
6145 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
62− target_bitrate, num_frames, file);
46+ target_bitrate, num_frames, infile_path);
6347 simple_encode.ComputeFirstPassStats();
6448 int num_coding_frames = simple_encode.GetCodingFrameNum();
6549 EXPECT_GE(num_coding_frames, num_frames);
@@ -94,16 +78,8 @@ TEST(SimpleEncode, EncodeFrame) { · 28 unmodified lines
9478 }
9579
9680 TEST(SimpleEncode, EncodeFrameWithQuantizeIndex) {
97− int w = 352;
98− int h = 288;
99− int frame_rate_num = 30;
100− int frame_rate_den = 1;
101− int target_bitrate = 1000;
102− int num_frames = 17;
103− // TODO(angiebird): Figure out how to upload test video to our codebase
104− FILE *file = fopen("bus_352x288_420_f20_b8.yuv", "r");
10581 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
106− target_bitrate, num_frames, file);
82+ target_bitrate, num_frames, infile_path);
10783 simple_encode.ComputeFirstPassStats();
10884 int num_coding_frames = simple_encode.GetCodingFrameNum();
10985 simple_encode.StartEncode();
vp9/simple_encode.cc+4−2
@@ -97,7 +97,8 @@ static void update_encode_frame_result( · 96 unmodified lines
9797
9898 SimpleEncode::SimpleEncode(int frame_width, int frame_height,
9999 int frame_rate_num, int frame_rate_den,
100− int target_bitrate, int num_frames, FILE *file)
100+ int target_bitrate, int num_frames,
101+ const char *infile_path)
101102 : pimpl{ std::unique_ptr<impl>(new impl()) } {
102103 this->frame_width = frame_width;
103104 this->frame_height = frame_height;
@@ -105,7 +106,8 @@ SimpleEncode::SimpleEncode(int frame_width, int frame_height, · 1 unmodified line
105106 this->frame_rate_den = frame_rate_den;
106107 this->target_bitrate = target_bitrate;
107108 this->num_frames = num_frames;
108− this->file = file;
109+ // TODO(angirbid): Should we keep a file pointer here or keep the file_path?
110+ this->file = fopen(infile_path, "r");
109111 pimpl->cpi = NULL;
110112 pimpl->img_fmt = VPX_IMG_FMT_I420;
111113 }
vp9/simple_encode.h+1−1
@@ -23,7 +23,7 @@ class SimpleEncode { · 22 unmodified lines
2323 public:
2424 SimpleEncode(int frame_width, int frame_height, int frame_rate_num,
2525 int frame_rate_den, int target_bitrate, int num_frames,
26− FILE *file);
26+ const char *infile_path);
2727 ~SimpleEncode();
2828 SimpleEncode(SimpleEncode &&) = delete;
2929 SimpleEncode &operator=(SimpleEncode &&) = delete;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t