diff options
author | angiebird <angiebird@google.com> | 2019-11-11 12:32:10 -0800 |
---|---|---|
committer | angiebird <angiebird@google.com> | 2019-11-18 11:37:24 -0800 |
commit | 6956e393c710fab99833500a57062862e97096b6 (patch) | |
tree | c899c9fe8ebb5d74e9b2e812007e1c88b4ba006e /vp9/simple_encode.cc | |
parent | f975d02d6dc095c97c6950a2b8c3768f29644fe5 (diff) | |
download | libvpx-6956e393c710fab99833500a57062862e97096b6.tar libvpx-6956e393c710fab99833500a57062862e97096b6.tar.gz libvpx-6956e393c710fab99833500a57062862e97096b6.tar.bz2 libvpx-6956e393c710fab99833500a57062862e97096b6.zip |
Add frame_type and show_idx to EncodeFrameResult
Let vp9_get_compressed_data update ENCODE_FRAME_RESULT, a C
version of EncodeFrameResult.
Let unit test to test frame_type and show_idx properly.
Change-Id: Id810c26c826254fd82249f19ab855ea3b440d99c
Diffstat (limited to 'vp9/simple_encode.cc')
-rw-r--r-- | vp9/simple_encode.cc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/vp9/simple_encode.cc b/vp9/simple_encode.cc index 020ea9fe8..9319a7f9f 100644 --- a/vp9/simple_encode.cc +++ b/vp9/simple_encode.cc @@ -73,6 +73,25 @@ static INLINE vpx_rational_t make_vpx_rational(int num, int den) { return v; } +static INLINE FrameType +get_frame_type_from_update_type(FRAME_UPDATE_TYPE update_type) { + // TODO(angiebird): Figure out if we need frame type other than key frame, + // alternate reference and inter frame + switch (update_type) { + case KF_UPDATE: return kKeyFrame; break; + case ARF_UPDATE: return kAlternateReference; break; + default: return kInterFrame; break; + } +} + +static void update_encode_frame_result( + EncodeFrameResult *encode_frame_result, + const ENCODE_FRAME_RESULT *encode_frame_info) { + encode_frame_result->show_idx = encode_frame_info->show_idx; + encode_frame_result->frame_type = + get_frame_type_from_update_type(encode_frame_info->update_type); +} + SimpleEncode::SimpleEncode(int frame_width, int frame_height, int frame_rate_num, int frame_rate_den, int target_bitrate, int num_frames, FILE *file) @@ -120,9 +139,10 @@ void SimpleEncode::ComputeFirstPassStats() { int flush = 1; // Make vp9_get_compressed_data process a frame size_t size; unsigned int frame_flags = 0; + ENCODE_FRAME_RESULT encode_frame_info; // TODO(angiebird): Call vp9_first_pass directly vp9_get_compressed_data(cpi, &frame_flags, &size, NULL, &time_stamp, - &time_end, flush); + &time_end, flush, &encode_frame_info); // vp9_get_compressed_data only generates first pass stats not // compresses data assert(size == 0); @@ -218,13 +238,17 @@ void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) { int64_t time_end; int flush = 1; // Make vp9_get_compressed_data encode a frame unsigned int frame_flags = 0; - vp9_get_compressed_data( - cpi, &frame_flags, &encode_frame_result->coding_data_size, - encode_frame_result->coding_data.get(), &time_stamp, &time_end, flush); + ENCODE_FRAME_RESULT encode_frame_info; + vp9_get_compressed_data(cpi, &frame_flags, + &encode_frame_result->coding_data_size, + encode_frame_result->coding_data.get(), &time_stamp, + &time_end, flush, &encode_frame_info); // vp9_get_compressed_data is expected to encode a frame every time, so the // data size should be greater than zero. assert(encode_frame_result->coding_data_size > 0); assert(encode_frame_result->coding_data_size < max_coding_data_size); + + update_encode_frame_result(encode_frame_result, &encode_frame_info); } int SimpleEncode::GetCodingFrameNum() { |