ref: 3afd6e8270d8cb5f03b620c653ff5bfe7157ce64
parent: cd686f727ab7b3a6a30758a13d4bb77eb44afb3f
author: angiebird <[email protected]>
date: Mon Nov 18 05:41:52 EST 2019
Rename pimpl by impl_ptr in SimpleEncode Change-Id: I0071216b710544731a6f8e8c7a63c7a28f25bbac
--- a/vp9/simple_encode.cc
+++ b/vp9/simple_encode.cc
@@ -103,7 +103,7 @@
int frame_rate_num, int frame_rate_den,
int target_bitrate, int num_frames,
const char *infile_path) {
- this->pimpl = std::unique_ptr<impl>(new impl());
+ this->impl_ptr = std::unique_ptr<impl>(new impl());
this->frame_width = frame_width;
this->frame_height = frame_height;
this->frame_rate_num = frame_rate_num;
@@ -112,8 +112,8 @@
this->num_frames = num_frames;
// 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;
+ impl_ptr->cpi = NULL;
+ impl_ptr->img_fmt = VPX_IMG_FMT_I420;
}
void SimpleEncode::ComputeFirstPassStats() {
@@ -120,7 +120,7 @@
vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num, frame_rate_den);
const VP9EncoderConfig oxcf = vp9_get_encoder_config(
frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_FIRST_PASS);
- VP9_COMP *cpi = init_encoder(&oxcf, pimpl->img_fmt);
+ VP9_COMP *cpi = init_encoder(&oxcf, impl_ptr->img_fmt);
struct lookahead_ctx *lookahead = cpi->lookahead;
int i;
int use_highbitdepth = 0;
@@ -128,9 +128,9 @@
use_highbitdepth = cpi->common.use_highbitdepth;
#endif
vpx_image_t img;
- vpx_img_alloc(&img, pimpl->img_fmt, frame_width, frame_height, 1);
+ vpx_img_alloc(&img, impl_ptr->img_fmt, frame_width, frame_height, 1);
rewind(file);
- pimpl->first_pass_stats.clear();
+ impl_ptr->first_pass_stats.clear();
for (i = 0; i < num_frames; ++i) {
assert(!vp9_lookahead_full(lookahead));
if (img_read(&img, file)) {
@@ -156,12 +156,12 @@
// compresses data
assert(size == 0);
}
- pimpl->first_pass_stats.push_back(vp9_get_frame_stats(&cpi->twopass));
+ impl_ptr->first_pass_stats.push_back(vp9_get_frame_stats(&cpi->twopass));
}
}
vp9_end_first_pass(cpi);
// TODO(angiebird): Store the total_stats apart form first_pass_stats
- pimpl->first_pass_stats.push_back(vp9_get_total_stats(&cpi->twopass));
+ impl_ptr->first_pass_stats.push_back(vp9_get_total_stats(&cpi->twopass));
free_encoder(cpi);
rewind(file);
vpx_img_free(&img);
@@ -176,11 +176,13 @@
// Note the last entry of first_pass_stats is the total_stats, we don't need
// it.
- for (size_t i = 0; i < pimpl->first_pass_stats.size() - 1; ++i) {
- double *buf_start = reinterpret_cast<double *>(&pimpl->first_pass_stats[i]);
+ for (size_t i = 0; i < impl_ptr->first_pass_stats.size() - 1; ++i) {
+ double *buf_start =
+ reinterpret_cast<double *>(&impl_ptr->first_pass_stats[i]);
// We use - 1 here because the last member in FIRSTPASS_STATS is not double
- double *buf_end =
- buf_start + sizeof(pimpl->first_pass_stats[i]) / sizeof(*buf_end) - 1;
+ double *buf_end = buf_start +
+ sizeof(impl_ptr->first_pass_stats[i]) / sizeof(*buf_end) -
+ 1;
std::vector<double> this_stats(buf_start, buf_end);
output_stats.push_back(this_stats);
}
@@ -188,31 +190,32 @@
}
void SimpleEncode::StartEncode() {
- assert(pimpl->first_pass_stats.size() > 0);
+ assert(impl_ptr->first_pass_stats.size() > 0);
vpx_rational_t frame_rate = make_vpx_rational(frame_rate_num, frame_rate_den);
VP9EncoderConfig oxcf = vp9_get_encoder_config(
frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
vpx_fixed_buf_t stats;
- stats.buf = pimpl->first_pass_stats.data();
+ stats.buf = impl_ptr->first_pass_stats.data();
stats.sz =
- sizeof(pimpl->first_pass_stats[0]) * pimpl->first_pass_stats.size();
+ sizeof(impl_ptr->first_pass_stats[0]) * impl_ptr->first_pass_stats.size();
vp9_set_first_pass_stats(&oxcf, &stats);
- assert(pimpl->cpi == NULL);
- pimpl->cpi = init_encoder(&oxcf, pimpl->img_fmt);
- vpx_img_alloc(&pimpl->tmp_img, pimpl->img_fmt, frame_width, frame_height, 1);
+ assert(impl_ptr->cpi == NULL);
+ impl_ptr->cpi = init_encoder(&oxcf, impl_ptr->img_fmt);
+ vpx_img_alloc(&impl_ptr->tmp_img, impl_ptr->img_fmt, frame_width,
+ frame_height, 1);
rewind(file);
}
void SimpleEncode::EndEncode() {
- free_encoder(pimpl->cpi);
- pimpl->cpi = nullptr;
- vpx_img_free(&pimpl->tmp_img);
+ free_encoder(impl_ptr->cpi);
+ impl_ptr->cpi = nullptr;
+ vpx_img_free(&impl_ptr->tmp_img);
rewind(file);
}
void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) {
- VP9_COMP *cpi = pimpl->cpi;
+ VP9_COMP *cpi = impl_ptr->cpi;
struct lookahead_ctx *lookahead = cpi->lookahead;
int use_highbitdepth = 0;
#if CONFIG_VP9_HIGHBITDEPTH
@@ -226,7 +229,7 @@
while (!vp9_lookahead_full(lookahead)) {
// TODO(angiebird): Check whether we can move this file read logics to
// lookahead
- if (img_read(&pimpl->tmp_img, file)) {
+ if (img_read(&impl_ptr->tmp_img, file)) {
int next_show_idx = vp9_lookahead_next_show_idx(lookahead);
int64_t ts_start =
timebase_units_to_ticks(&cpi->oxcf.g_timebase_in_ts, next_show_idx);
@@ -233,7 +236,7 @@
int64_t ts_end = timebase_units_to_ticks(&cpi->oxcf.g_timebase_in_ts,
next_show_idx + 1);
YV12_BUFFER_CONFIG sd;
- image2yuvconfig(&pimpl->tmp_img, &sd);
+ image2yuvconfig(&impl_ptr->tmp_img, &sd);
vp9_lookahead_push(lookahead, &sd, ts_start, ts_end, use_highbitdepth, 0);
} else {
break;
@@ -263,14 +266,14 @@
void SimpleEncode::EncodeFrameWithQuantizeIndex(
EncodeFrameResult *encode_frame_result, int quantize_index) {
- encode_command_set_external_quantize_index(&pimpl->cpi->encode_command,
+ encode_command_set_external_quantize_index(&impl_ptr->cpi->encode_command,
quantize_index);
EncodeFrame(encode_frame_result);
- encode_command_reset_external_quantize_index(&pimpl->cpi->encode_command);
+ encode_command_reset_external_quantize_index(&impl_ptr->cpi->encode_command);
}
int SimpleEncode::GetCodingFrameNum() {
- assert(pimpl->first_pass_stats.size() - 1 > 0);
+ assert(impl_ptr->first_pass_stats.size() - 1 > 0);
// These are the default settings for now.
const int multi_layer_arf = 0;
const int allow_alt_ref = 1;
@@ -279,7 +282,7 @@
frame_width, frame_height, frame_rate, target_bitrate, VPX_RC_LAST_PASS);
FRAME_INFO frame_info = vp9_get_frame_info(&oxcf);
FIRST_PASS_INFO first_pass_info;
- fps_init_first_pass_info(&first_pass_info, pimpl->first_pass_stats.data(),
+ fps_init_first_pass_info(&first_pass_info, impl_ptr->first_pass_stats.data(),
num_frames);
return vp9_get_coding_frame_num(&oxcf, &frame_info, &first_pass_info,
multi_layer_arf, allow_alt_ref);
--- a/vp9/simple_encode.h
+++ b/vp9/simple_encode.h
@@ -81,7 +81,7 @@
int target_bitrate;
int num_frames;
FILE *file;
- std::unique_ptr<impl> pimpl;
+ std::unique_ptr<impl> impl_ptr;
};
} // namespace vp9