from_lavc_vid_conv: make iternal state opaque

Return just a pointer (that needs to be detroyed after that).

This is perhaps more convenient way and also it will allow eg. utlizing
GPU for the conversions.
This commit is contained in:
Martin Pulec
2024-03-01 08:54:30 +01:00
parent 1825e6a0da
commit dcf882cc61
5 changed files with 111 additions and 88 deletions

View File

@@ -66,14 +66,15 @@ int ff_codec_conversions_test_yuv444pXXle_from_to_r10k()
struct to_lavc_vid_conv *from_conv = to_lavc_vid_conv_init(R10k, width, height, avfmt, 1);
auto to_conv = get_av_to_uv_conversion(avfmt, R10k);
assert(to_conv.valid && from_conv != nullptr);
assert(to_conv != nullptr && from_conv != nullptr);
TIMER(t0);
AVFrame *converted = to_lavc_vid_conv(from_conv, (char *) r10k_buf.data());
TIMER(t1);
av_to_uv_convert(&to_conv, reinterpret_cast<char*>(r10k_buf.data()), converted, width, height, vc_get_linesize(width, R10k), nullptr);
av_to_uv_convert(to_conv, reinterpret_cast<char*>(r10k_buf.data()), converted, width, height, vc_get_linesize(width, R10k), nullptr);
TIMER(t2);
to_lavc_vid_conv_destroy(&from_conv);
av_to_uv_conversion_destroy(&to_conv);
if (getenv("PERF") != nullptr) {
cout << "test_yuv444p16le_from_to_r10k: duration - enc " << tv_diff(t1, t0) << ", dec " <<tv_diff(t2, t1) << "\n";
@@ -133,13 +134,14 @@ int ff_codec_conversions_test_yuv444pXXle_from_to_r12l()
struct to_lavc_vid_conv *from_conv = to_lavc_vid_conv_init(R12L, width, height, avfmt, 1);
auto to_conv = get_av_to_uv_conversion(avfmt, R12L);
assert(to_conv.valid && from_conv != nullptr);
assert(to_conv != nullptr && from_conv != nullptr);
TIMER(t0);
struct AVFrame *converted = to_lavc_vid_conv(from_conv, (char *) r12l_buf.data());
TIMER(t1);
av_to_uv_convert(&to_conv, reinterpret_cast<char*>(r12l_buf.data()), converted, width, height, vc_get_linesize(width, R12L), nullptr);
av_to_uv_convert(to_conv, reinterpret_cast<char*>(r12l_buf.data()), converted, width, height, vc_get_linesize(width, R12L), nullptr);
TIMER(t2);
av_to_uv_conversion_destroy(&to_conv);
to_lavc_vid_conv_destroy(&from_conv);
if (getenv("PERF") != nullptr) {
@@ -189,13 +191,14 @@ static void yuv444p16le_rg48_encode_decode(int width, int height, char *in, char
struct to_lavc_vid_conv *from_conv = to_lavc_vid_conv_init(RG48, width, height, avfmt, 1);
auto to_conv = get_av_to_uv_conversion(avfmt, RG48);
assert(to_conv.valid && from_conv != nullptr);
assert(to_conv && from_conv != nullptr);
TIMER(t0);
struct AVFrame *converted = to_lavc_vid_conv(from_conv, in);
TIMER(t1);
av_to_uv_convert(&to_conv, reinterpret_cast<char*>(out), converted, width, height, vc_get_linesize(width, RG48), nullptr);
av_to_uv_convert(to_conv, reinterpret_cast<char*>(out), converted, width, height, vc_get_linesize(width, RG48), nullptr);
TIMER(t2);
av_to_uv_conversion_destroy(&to_conv);
to_lavc_vid_conv_destroy(&from_conv);
if (getenv("PERF") != nullptr) {
@@ -366,10 +369,11 @@ int ff_codec_conversions_test_pX10_from_to_v210()
struct to_lavc_vid_conv *from_conv = to_lavc_vid_conv_init(codec, width, height, c, 1);
auto to_conv = get_av_to_uv_conversion(c, codec);
assert(from_conv != nullptr);
assert(to_conv.valid);
assert(to_conv != nullptr);
struct AVFrame *converted = to_lavc_vid_conv(from_conv, (char *) in.data());
av_to_uv_convert(&to_conv, reinterpret_cast<char *>(out.data()), converted, width, height, vc_get_linesize(width, codec), nullptr);
av_to_uv_convert(to_conv, reinterpret_cast<char *>(out.data()), converted, width, height, vc_get_linesize(width, codec), nullptr);
av_to_uv_conversion_destroy(&to_conv);
to_lavc_vid_conv_destroy(&from_conv);
if (getenv("DEBUG_DUMP") != nullptr) {