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
48 VP9_COMP *cpi;48 VP9_COMP *cpi;
49 vpx_img_fmt_t img_fmt;49 vpx_img_fmt_t img_fmt;
50 vpx_image_t tmp_img;50 vpx_image_t tmp_img;
51 std::vector<FIRSTPASS_STATS> frame_stats;51 std::vector<FIRSTPASS_STATS> first_pass_stats;
52};52};
53 53
54static VP9_COMP *init_encoder(const VP9EncoderConfig *oxcf,54static VP9_COMP *init_encoder(const VP9EncoderConfig *oxcf,
@@ -102,7 +102,7 @@ void SimpleEncode::ComputeFirstPassStats() { · 47 unmodified lines
102 vpx_image_t img;102 vpx_image_t img;
103 vpx_img_alloc(&img, pimpl->img_fmt, frame_width, frame_height, 1);103 vpx_img_alloc(&img, pimpl->img_fmt, frame_width, frame_height, 1);
104 rewind(file);104 rewind(file);
105 pimpl->frame_stats.clear();105 pimpl->first_pass_stats.clear();
106 for (i = 0; i < num_frames; ++i) {106 for (i = 0; i < num_frames; ++i) {
107 assert(!vp9_lookahead_full(lookahead));107 assert(!vp9_lookahead_full(lookahead));
108 if (img_read(&img, file)) {108 if (img_read(&img, file)) {
@@ -127,12 +127,12 @@ void SimpleEncode::ComputeFirstPassStats() { · 18 unmodified lines
127 // compresses data127 // compresses data
128 assert(size == 0);128 assert(size == 0);
129 }129 }
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));
131 }131 }
132 }132 }
133 vp9_end_first_pass(cpi);133 vp9_end_first_pass(cpi);
134 // TODO(angiebird): Store the total_stats apart form frame_stats134 // TODO(angiebird): Store the total_stats apart form first_pass_stats
135 pimpl->frame_stats.push_back(vp9_get_total_stats(&cpi->twopass));135 pimpl->first_pass_stats.push_back(vp9_get_total_stats(&cpi->twopass));
136 free_encoder(cpi);136 free_encoder(cpi);
137 rewind(file);137 rewind(file);
138 vpx_img_free(&img);138 vpx_img_free(&img);
@@ -142,15 +142,16 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() { · 3 unmodified lines
142 std::vector<std::vector<double>> output_stats;142 std::vector<std::vector<double>> output_stats;
143 // TODO(angiebird): This function make several assumptions of143 // TODO(angiebird): This function make several assumptions of
144 // FIRSTPASS_STATS. 1) All elements in FIRSTPASS_STATS are double except the144 // 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.
146 // Change the code structure, so that we don't have to make these assumptions146 // Change the code structure, so that we don't have to make these assumptions
147 147
148 // Note the last entry of frame_stats is the total_stats, we don't need it.148 // Note the last entry of first_pass_stats is the total_stats, we don't need
149 for (size_t i = 0; i < pimpl->frame_stats.size() - 1; ++i) {149 // it.
150 double *buf_start = reinterpret_cast<double *>(&pimpl->frame_stats[i]);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]);
151 // We use - 1 here because the last member in FIRSTPASS_STATS is not double152 // We use - 1 here because the last member in FIRSTPASS_STATS is not double
152 double *buf_end =153 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;
154 std::vector<double> this_stats(buf_start, buf_end);155 std::vector<double> this_stats(buf_start, buf_end);
155 output_stats.push_back(this_stats);156 output_stats.push_back(this_stats);
156 }157 }
@@ -158,13 +159,14 @@ std::vector<std::vector<double>> SimpleEncode::ObserveFirstPassStats() { · 1 unmodified line
158}159}
159 160
160void SimpleEncode::StartEncode() {161void SimpleEncode::StartEncode() {
161 assert(pimpl->frame_stats.size() > 0);162 assert(pimpl->first_pass_stats.size() > 0);
162 vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num, frame_rate_den);163 vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num, frame_rate_den);
163 VP9EncoderConfig oxcf = vp9_get_encoder_config(164 VP9EncoderConfig oxcf = vp9_get_encoder_config(
164 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);165 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
165 vpx_fixed_buf_t stats;166 vpx_fixed_buf_t stats;
166 stats.buf = pimpl->frame_stats.data();167 stats.buf = pimpl->first_pass_stats.data();
167 stats.sz = sizeof(pimpl->frame_stats[0]) * pimpl->frame_stats.size();168 stats.sz =
169 sizeof(pimpl->first_pass_stats[0]) * pimpl->first_pass_stats.size();
168 170
169 vp9_set_first_pass_stats(&oxcf, &stats);171 vp9_set_first_pass_stats(&oxcf, &stats);
170 assert(pimpl->cpi == NULL);172 assert(pimpl->cpi == NULL);
@@ -224,7 +226,7 @@ void SimpleEncode::EncodeFrame(char *cx_data, size_t *size, size_t max_size) { · 53 unmodified lines
224}226}
225 227
226int SimpleEncode::GetCodingFrameNum() {228int SimpleEncode::GetCodingFrameNum() {
227 assert(pimpl->frame_stats.size() - 1 > 0);229 assert(pimpl->first_pass_stats.size() - 1 > 0);
228 // These are the default settings for now.230 // These are the default settings for now.
229 const int multi_layer_arf = 0;231 const int multi_layer_arf = 0;
230 const int allow_alt_ref = 1;232 const int allow_alt_ref = 1;
@@ -233,7 +235,7 @@ int SimpleEncode::GetCodingFrameNum() { · 2 unmodified lines
233 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);235 frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
234 FRAME_INFO frame_info = vp9_get_frame_info(&oxcf);236 FRAME_INFO frame_info = vp9_get_frame_info(&oxcf);
235 FIRST_PASS_INFO first_pass_info;237 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(),
237 num_frames);239 num_frames);
238 return vp9_get_coding_frame_num(&oxcf, &frame_info, &first_pass_info,240 return vp9_get_coding_frame_num(&oxcf, &frame_info, &first_pass_info,
239 multi_layer_arf, allow_alt_ref);241 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