History

Rename frame_stats by first_pass_stats

This is in simple_encode.cc

angiebird committed 7 years ago

Commit 7dd26ae1 parent 422445a1 file · +17 −15Browse files

Unified · Split

vp9/simple_encode.cc+17−15
@@ -48,7 +48,7 @@ class SimpleEncode::impl { · 47 unmodified lines
4848 VP9_COMP *cpi;
4949 vpx_img_fmt_t img_fmt;
5050 vpx_image_t tmp_img;
51− std::vector<FIRSTPASS_STATS> frame_stats;
51+ std::vector<FIRSTPASS_STATS> first_pass_stats;
5252 };
5353
5454 static VP9_COMP *init_encoder(const VP9EncoderConfig *oxcf,
@@ -102,7 +102,7 @@ void SimpleEncode::ComputeFirstPassStats() { · 47 unmodified lines
102102 vpx_image_t img;
103103 vpx_img_alloc(&img, pimpl->img_fmt, frame_width, frame_height, 1);
104104 rewind(file);
105− pimpl->frame_stats.clear();
105+ pimpl->first_pass_stats.clear();
106106 for (i = 0; i < num_frames; ++i) {
107107 assert(!vp9_lookahead_full(lookahead));
108108 if (img_read(&img, file)) {
@@ -127,12 +127,12 @@ void SimpleEncode::ComputeFirstPassStats() { · 18 unmodified lines
127127 // compresses data
128128 assert(size == 0);
129129 }
130− pimpl->frame_stats.push_back(vp9_get_frame_stats(&cpi->twopass));
130+ pimpl->first_pass_stats.push_back(vp9_get_frame_stats(&cpi->twopass));
131131 }
132132 }
133133 vp9_end_first_pass(cpi);
134− // TODO(angiebird): Store the total_stats apart form frame_stats
135− pimpl->frame_stats.push_back(vp9_get_total_stats(&cpi->twopass));
134+ // TODO(angiebird): Store the total_stats apart form first_pass_stats
135+ pimpl->first_pass_stats.push_back(vp9_get_total_stats(&cpi->twopass));
136136 free_encoder(cpi);
137137 rewind(file);
138138 vpx_img_free(&img);
@@ -142,15 +142,16 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() { · 3 unmodified lines
142142 std::vector<std::vector<double>> output_stats;
143143 // TODO(angiebird): This function make several assumptions of
144144 // FIRSTPASS_STATS. 1) All elements in FIRSTPASS_STATS are double except the
145− // last one. 2) The last entry of frame_stats is the total_stats.
145+ // last one. 2) The last entry of first_pass_stats is the total_stats.
146146 // Change the code structure, so that we don't have to make these assumptions
147147
148− // Note the last entry of frame_stats is the total_stats, we don't need it.
149− for (size_t i = 0; i < pimpl->frame_stats.size() - 1; ++i) {
150− double *buf_start = reinterpret_cast<double *>(&pimpl->frame_stats[i]);
148+ // Note the last entry of first_pass_stats is the total_stats, we don't need
149+ // it.
150+ for (size_t i = 0; i < pimpl->first_pass_stats.size() - 1; ++i) {
151+ double *buf_start = reinterpret_cast<double *>(&pimpl->first_pass_stats[i]);
151152 // We use - 1 here because the last member in FIRSTPASS_STATS is not double
152153 double *buf_end =
153− buf_start + sizeof(pimpl->frame_stats[i]) / sizeof(*buf_end) - 1;
154+ buf_start + sizeof(pimpl->first_pass_stats[i]) / sizeof(*buf_end) - 1;
154155 std::vector<double> this_stats(buf_start, buf_end);
155156 output_stats.push_back(this_stats);
156157 }
@@ -158,13 +159,14 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() { · 1 unmodified line
158159 }
159160
160161 void SimpleEncode::StartEncode() {
161− assert(pimpl->frame_stats.size() > 0);
162+ assert(pimpl->first_pass_stats.size() > 0);
162163 vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num, frame_rate_den);
163164 VP9EncoderConfig oxcf = vp9_get_encoder_config(
164165 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
165166 vpx_fixed_buf_t stats;
166− stats.buf = pimpl->frame_stats.data();
167− stats.sz = sizeof(pimpl->frame_stats[0]) * pimpl->frame_stats.size();
167+ stats.buf = pimpl->first_pass_stats.data();
168+ stats.sz =
169+ sizeof(pimpl->first_pass_stats[0]) * pimpl->first_pass_stats.size();
168170
169171 vp9_set_first_pass_stats(&oxcf, &stats);
170172 assert(pimpl->cpi == NULL);
@@ -224,7 +226,7 @@ void SimpleEncode::EncodeFrame(char *cx_data, size_t *size, size_t max_size) { · 53 unmodified lines
224226 }
225227
226228 int SimpleEncode::GetCodingFrameNum() {
227− assert(pimpl->frame_stats.size() - 1 > 0);
229+ assert(pimpl->first_pass_stats.size() - 1 > 0);
228230 // These are the default settings for now.
229231 const int multi_layer_arf = 0;
230232 const int allow_alt_ref = 1;
@@ -233,7 +235,7 @@ int SimpleEncode::GetCodingFrameNum() { · 2 unmodified lines
233235 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
234236 FRAME_INFO frame_info = vp9_get_frame_info(&oxcf);
235237 FIRST_PASS_INFO first_pass_info;
236− fps_init_first_pass_info(&first_pass_info, pimpl->frame_stats.data(),
238+ fps_init_first_pass_info(&first_pass_info, pimpl->first_pass_stats.data(),
237239 num_frames);
238240 return vp9_get_coding_frame_num(&oxcf, &frame_info, &first_pass_info,
239241 multi_layer_arf, allow_alt_ref);

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