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
4#include "vp9/simple_encode.h"4#include "vp9/simple_encode.h"
5 5
6namespace {6namespace {
7const int w = 352;
8const int h = 288;
9const int frame_rate_num = 30;
10const int frame_rate_den = 1;
11const int target_bitrate = 1000;
12const int num_frames = 17;
13// TODO(angiebird): Figure out how to upload test video to our codebase
14const char infile_path[] = "bus_352x288_420_f20_b8.yuv";
7 15
8TEST(SimpleEncode, ComputeFirstPassStats) {16TEST(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");
17 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,17 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
18 target_bitrate, num_frames, file);18 target_bitrate, num_frames, infile_path);
19 simple_encode.ComputeFirstPassStats();19 simple_encode.ComputeFirstPassStats();
20 std::vector<std::vector<double>> frame_stats =20 std::vector<std::vector<double>> frame_stats =
21 simple_encode.ObserveFirstPassStats();21 simple_encode.ObserveFirstPassStats();
@@ -34,32 +34,16 @@ TEST(SimpleEncode, ComputeFirstPassStats) { · 12 unmodified lines
34}34}
35 35
36TEST(SimpleEncode, GetCodingFrameNum) {36TEST(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");
45 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,37 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
46 target_bitrate, num_frames, file);38 target_bitrate, num_frames, infile_path);
47 simple_encode.ComputeFirstPassStats();39 simple_encode.ComputeFirstPassStats();
48 int num_coding_frames = simple_encode.GetCodingFrameNum();40 int num_coding_frames = simple_encode.GetCodingFrameNum();
49 EXPECT_EQ(num_coding_frames, 19);41 EXPECT_EQ(num_coding_frames, 19);
50}42}
51 43
52TEST(SimpleEncode, EncodeFrame) {44TEST(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");
61 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,45 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
62 target_bitrate, num_frames, file);46 target_bitrate, num_frames, infile_path);
63 simple_encode.ComputeFirstPassStats();47 simple_encode.ComputeFirstPassStats();
64 int num_coding_frames = simple_encode.GetCodingFrameNum();48 int num_coding_frames = simple_encode.GetCodingFrameNum();
65 EXPECT_GE(num_coding_frames, num_frames);49 EXPECT_GE(num_coding_frames, num_frames);
@@ -94,16 +78,8 @@ TEST(SimpleEncode, EncodeFrame) { · 28 unmodified lines
94}78}
95 79
96TEST(SimpleEncode, EncodeFrameWithQuantizeIndex) {80TEST(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");
105 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,81 SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
106 target_bitrate, num_frames, file);82 target_bitrate, num_frames, infile_path);
107 simple_encode.ComputeFirstPassStats();83 simple_encode.ComputeFirstPassStats();
108 int num_coding_frames = simple_encode.GetCodingFrameNum();84 int num_coding_frames = simple_encode.GetCodingFrameNum();
109 simple_encode.StartEncode();85 simple_encode.StartEncode();
vp9/simple_encode.cc+4−2
@@ -97,7 +97,8 @@ static void update_encode_frame_result( · 96 unmodified lines
97 97
98SimpleEncode::SimpleEncode(int frame_width, int frame_height,98SimpleEncode::SimpleEncode(int frame_width, int frame_height,
99 int frame_rate_num, int frame_rate_den,99 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)
101 : pimpl{ std::unique_ptr<impl>(new impl()) } {102 : pimpl{ std::unique_ptr<impl>(new impl()) } {
102 this->frame_width = frame_width;103 this->frame_width = frame_width;
103 this->frame_height = frame_height;104 this->frame_height = frame_height;
@@ -105,7 +106,8 @@ SimpleEncode::SimpleEncode(int frame_width, int frame_height, · 1 unmodified line
105 this->frame_rate_den = frame_rate_den;106 this->frame_rate_den = frame_rate_den;
106 this->target_bitrate = target_bitrate;107 this->target_bitrate = target_bitrate;
107 this->num_frames = num_frames;108 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");
109 pimpl->cpi = NULL;111 pimpl->cpi = NULL;
110 pimpl->img_fmt = VPX_IMG_FMT_I420;112 pimpl->img_fmt = VPX_IMG_FMT_I420;
111}113}
vp9/simple_encode.h+1−1
@@ -23,7 +23,7 @@ class SimpleEncode { · 22 unmodified lines
23 public:23 public:
24 SimpleEncode(int frame_width, int frame_height, int frame_rate_num,24 SimpleEncode(int frame_width, int frame_height, int frame_rate_num,
25 int frame_rate_den, int target_bitrate, int num_frames,25 int frame_rate_den, int target_bitrate, int num_frames,
26 FILE *file);26 const char *infile_path);
27 ~SimpleEncode();27 ~SimpleEncode();
28 SimpleEncode(SimpleEncode &&) = delete;28 SimpleEncode(SimpleEncode &&) = delete;
29 SimpleEncode &operator=(SimpleEncode &&) = delete;29 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