Skip to content

Commit

Permalink
Updating unit tests to ignore older versions of FFmpeg that do not su…
Browse files Browse the repository at this point in the history
…pport AV1 decoding.
  • Loading branch information
jonoomph committed Nov 16, 2022
1 parent 58dc99d commit 2c24d0f
Showing 1 changed file with 61 additions and 56 deletions.
117 changes: 61 additions & 56 deletions tests/FFmpegReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,60 +287,65 @@ TEST_CASE( "DisplayInfo", "[libopenshot][ffmpegreader]" )

TEST_CASE( "Decoding AV1 Video", "[libopenshot][ffmpegreader]" )
{
// Create a reader
std::stringstream path;
path << TEST_MEDIA_PATH << "test_video_sync.mp4";
FFmpegReader r(path.str());
r.Open();

std::shared_ptr<Frame> f = r.GetFrame(1);

// Get the image data
const unsigned char* pixels = f->GetPixels(10);
int pixel_index = 112 * 4;

// Check image properties on scanline 10, pixel 112
CHECK((int)pixels[pixel_index] == Approx(0).margin(5));
CHECK((int)pixels[pixel_index + 1] == Approx(0).margin(5));
CHECK((int)pixels[pixel_index + 2] == Approx(0).margin(5));
CHECK((int)pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(90);

// Get the image data
pixels = f->GetPixels(820);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int)pixels[pixel_index] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(160);

// Get the image data
pixels = f->GetPixels(420);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int)pixels[pixel_index] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(240);

// Get the image data
pixels = f->GetPixels(624);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int)pixels[pixel_index] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int)pixels[pixel_index + 3] == Approx(255).margin(5));

// Close reader
r.Close();
try {
// Create a reader
std::stringstream path;
path << TEST_MEDIA_PATH << "test_video_sync.mp4";
FFmpegReader r(path.str());
r.Open();

std::shared_ptr<Frame> f = r.GetFrame(1);

// Get the image data
const unsigned char *pixels = f->GetPixels(10);
int pixel_index = 112 * 4;

// Check image properties on scanline 10, pixel 112
CHECK((int) pixels[pixel_index] == Approx(0).margin(5));
CHECK((int) pixels[pixel_index + 1] == Approx(0).margin(5));
CHECK((int) pixels[pixel_index + 2] == Approx(0).margin(5));
CHECK((int) pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(90);

// Get the image data
pixels = f->GetPixels(820);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int) pixels[pixel_index] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(160);

// Get the image data
pixels = f->GetPixels(420);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int) pixels[pixel_index] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 3] == Approx(255).margin(5));

f = r.GetFrame(240);

// Get the image data
pixels = f->GetPixels(624);
pixel_index = 930 * 4;

// Check image properties on scanline 820, pixel 930
CHECK((int) pixels[pixel_index] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 1] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 2] == Approx(255).margin(5));
CHECK((int) pixels[pixel_index + 3] == Approx(255).margin(5));

// Close reader
r.Close();

} catch (const InvalidFile & e) {
// Ignore older FFmpeg versions which don't support AV1
}
}

0 comments on commit 2c24d0f

Please sign in to comment.