New helper function test::ReadI420Buffer, refactor FrameReader to use it.

This change reduces the number of places where we first fread a I420
frame into a uint8_t buffer, followed by a copy into a frame buffer
object.

BUG=None

Review-Url: https://codereview.webrtc.org/2362683002
Cr-Commit-Position: refs/heads/master@{#14456}
This commit is contained in:
nisse
2016-09-30 04:14:07 -07:00
committed by Commit bot
parent 6f112cc136
commit 115bd153c7
19 changed files with 182 additions and 229 deletions

View File

@ -125,6 +125,8 @@ TEST_F(VideoProcessingTest, MbDenoise) {
EXPECT_EQ(COPY_BLOCK, decision);
}
// TODO(nisse): Refactor to not use test fixture. Can use some static
// helper method to open the input file.
TEST_F(VideoProcessingTest, Denoiser) {
// Used in swap buffer.
int denoised_frame_toggle = 0;
@ -137,14 +139,11 @@ TEST_F(VideoProcessingTest, Denoiser) {
rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon;
rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon;
std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
frame_length_) {
// Using ConvertToI420 to add stride to the image.
rtc::scoped_refptr<webrtc::I420Buffer> input_buffer =
I420Buffer::Create(width_, height_, width_, half_width_, half_width_);
EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
0, kVideoRotation_0, input_buffer.get()));
for (;;) {
rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer(
test::ReadI420Buffer(width_, height_, source_file_));
if (!video_frame_buffer)
break;
rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c;
rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c;
@ -159,9 +158,11 @@ TEST_F(VideoProcessingTest, Denoiser) {
p_denoised_sse_neon = &denoised_frame_prev_sse_neon;
p_denoised_prev_sse_neon = &denoised_frame_sse_neon;
}
denoiser_c.DenoiseFrame(input_buffer, p_denoised_c, p_denoised_prev_c,
denoiser_c.DenoiseFrame(video_frame_buffer,
p_denoised_c, p_denoised_prev_c,
false);
denoiser_sse_neon.DenoiseFrame(input_buffer, p_denoised_sse_neon,
denoiser_sse_neon.DenoiseFrame(video_frame_buffer,
p_denoised_sse_neon,
p_denoised_prev_sse_neon, false);
// Invert the flag.
denoised_frame_toggle ^= 1;