Fixed bug in ExtractFrameFromY4mFile API which was not extracting the frames correctly.
Issue: This API was calculating the file_header and frame_header offset only for the first frame which is not the right logic. We need to skip the file and frame header every time we extract a new frame. Also added a unit test case which compares the extracted frame with the frame stored in text file. NOPRESUBMIT=true NOTRY=true BUG=webrtc:6761 Review-Url: https://codereview.webrtc.org/2532963002 Cr-Commit-Position: refs/heads/master@{#15288}
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
// This test doesn't actually verify the output since it's just printed
|
||||
// to stdout by void functions, but it's still useful as it executes the code.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
@ -38,6 +39,32 @@ class VideoQualityAnalysisTest : public ::testing::Test {
|
||||
};
|
||||
FILE* VideoQualityAnalysisTest::logfile_ = NULL;
|
||||
|
||||
TEST_F(VideoQualityAnalysisTest, MatchExtractedY4mFrame) {
|
||||
std::string video_file =
|
||||
webrtc::test::ResourcePath("reference_less_video_test_file", "y4m");
|
||||
|
||||
std::string extracted_frame_from_video_file =
|
||||
webrtc::test::ResourcePath("video_quality_analysis_frame", "txt");
|
||||
|
||||
int frame_height = 720, frame_width = 1280;
|
||||
int frame_number = 2;
|
||||
int size = GetI420FrameSize(frame_width, frame_height);
|
||||
uint8_t* result_frame = new uint8_t[size];
|
||||
uint8_t* expected_frame = new uint8_t[size];
|
||||
|
||||
FILE* input_file = fopen(extracted_frame_from_video_file.c_str(), "rb");
|
||||
fread(expected_frame, 1, size, input_file);
|
||||
|
||||
ExtractFrameFromY4mFile(video_file.c_str(),
|
||||
frame_width, frame_height,
|
||||
frame_number, result_frame);
|
||||
|
||||
EXPECT_EQ(*expected_frame, *result_frame);
|
||||
fclose(input_file);
|
||||
delete[] result_frame;
|
||||
delete[] expected_frame;
|
||||
}
|
||||
|
||||
TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) {
|
||||
ResultsContainer result;
|
||||
PrintAnalysisResults(logfile_, "Empty", &result);
|
||||
|
||||
Reference in New Issue
Block a user