tests: migrate gtest suite to the ffmpeg_bridge API and add bridge coverage
- Replace direct FFmpeg usage in the test suite (channel layout masks, pixel/sample format constants, AVFrame field access, sws_scale) with the bridge equivalents and the olive::AVFrame adapter - Drop CoreRational.ToAVRational (API removed with core's FFmpeg dependency) and the GetSwsColorspaceFromAVColorSpace tests (helper moved inside the bridge) - New ffmpeg_bridge_test.cpp exercises the C API directly: constants vs core, error strings, pixel format utilities, frames/packets, scaler, resampler, audio graph tempo processing, probe/decoder round-trip on tests/demo.mp4 (including hw-frame transfer), SRT subtitle reading, and encoder end-to-end tests (PNG video and PCM audio probed back)
This commit is contained in:
@@ -14,10 +14,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/frame.h>
|
||||
}
|
||||
|
||||
#include "common/ffmpegutils.h"
|
||||
#include "node/value.h"
|
||||
#include "pluginSupport/OliveHost.h"
|
||||
@@ -45,24 +41,24 @@ template <typename T>
|
||||
TexturePtr CreateSolidTextureT(const VideoParams ¶ms, T fill_value)
|
||||
{
|
||||
AVFramePtr frame = CreateAVFramePtr();
|
||||
frame->format = FFmpegUtils::GetFFmpegPixelFormat(params.format(),
|
||||
params.channel_count());
|
||||
frame->width = params.width();
|
||||
frame->height = params.height();
|
||||
if (frame->format == AV_PIX_FMT_NONE) {
|
||||
frame->set_format(FFmpegUtils::GetFFmpegPixelFormat(params.format(),
|
||||
params.channel_count()));
|
||||
frame->set_width(params.width());
|
||||
frame->set_height(params.height());
|
||||
if (frame->format() == FB_PIX_FMT_NONE) {
|
||||
return nullptr;
|
||||
}
|
||||
if (av_frame_get_buffer(frame.get(), 0) < 0) {
|
||||
if (frame->get_buffer(0) < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (av_frame_make_writable(frame.get()) < 0) {
|
||||
if (frame->make_writable() < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int linesize = frame->linesize[0];
|
||||
for (int y = 0; y < frame->height; ++y) {
|
||||
T *row = reinterpret_cast<T *>(frame->data[0] + y * linesize);
|
||||
for (int x = 0; x < frame->width * params.channel_count(); ++x) {
|
||||
const int linesize = frame->linesize(0);
|
||||
for (int y = 0; y < frame->height(); ++y) {
|
||||
T *row = reinterpret_cast<T *>(frame->data(0) + y * linesize);
|
||||
for (int x = 0; x < frame->width() * params.channel_count(); ++x) {
|
||||
row[x] = fill_value;
|
||||
}
|
||||
}
|
||||
@@ -99,25 +95,25 @@ template <typename T>
|
||||
TexturePtr CreateGradientTextureT(const VideoParams ¶ms, float scale)
|
||||
{
|
||||
AVFramePtr frame = CreateAVFramePtr();
|
||||
frame->format = FFmpegUtils::GetFFmpegPixelFormat(params.format(),
|
||||
params.channel_count());
|
||||
frame->width = params.width();
|
||||
frame->height = params.height();
|
||||
if (frame->format == AV_PIX_FMT_NONE) {
|
||||
frame->set_format(FFmpegUtils::GetFFmpegPixelFormat(params.format(),
|
||||
params.channel_count()));
|
||||
frame->set_width(params.width());
|
||||
frame->set_height(params.height());
|
||||
if (frame->format() == FB_PIX_FMT_NONE) {
|
||||
return nullptr;
|
||||
}
|
||||
if (av_frame_get_buffer(frame.get(), 0) < 0) {
|
||||
if (frame->get_buffer(0) < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (av_frame_make_writable(frame.get()) < 0) {
|
||||
if (frame->make_writable() < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int linesize = frame->linesize[0];
|
||||
for (int y = 0; y < frame->height; ++y) {
|
||||
T *row = reinterpret_cast<T *>(frame->data[0] + y * linesize);
|
||||
T value = static_cast<T>((y * scale) / frame->height);
|
||||
for (int x = 0; x < frame->width * params.channel_count(); ++x) {
|
||||
const int linesize = frame->linesize(0);
|
||||
for (int y = 0; y < frame->height(); ++y) {
|
||||
T *row = reinterpret_cast<T *>(frame->data(0) + y * linesize);
|
||||
T value = static_cast<T>((y * scale) / frame->height());
|
||||
for (int x = 0; x < frame->width() * params.channel_count(); ++x) {
|
||||
row[x] = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user