From 6c2a19ab3d04c4718bbebd0b530a3cd6e13d8aa6 Mon Sep 17 00:00:00 2001 From: Asd-g <65298684+Asd-g@users.noreply.github.com> Date: Sun, 24 Dec 2023 04:14:14 +0200 Subject: [PATCH] AviSynth: allow format="" (#54) --- AviSynth/libavsmash_source.cpp | 10 +++++++--- AviSynth/lwlibav_source.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/AviSynth/libavsmash_source.cpp b/AviSynth/libavsmash_source.cpp index 52b54c9d..5abe5b5d 100644 --- a/AviSynth/libavsmash_source.cpp +++ b/AviSynth/libavsmash_source.cpp @@ -530,9 +530,13 @@ AVSValue __cdecl CreateLSMASHVideoSource( AVSValue args, void *user_data, IScrip enum AVPixelFormat pixel_format = AV_PIX_FMT_NONE; if (args[8].Defined()) { - pixel_format = get_av_output_pixel_format(args[8].AsString(nullptr)); - if (pixel_format == AV_PIX_FMT_NONE) - env->ThrowError("LSMASHVideoSource: wrong format."); + const char* pix_fmt = args[8].AsString(); + if (strcmp(pix_fmt, "")) + { + pixel_format = get_av_output_pixel_format(pix_fmt); + if (pixel_format == AV_PIX_FMT_NONE) + env->ThrowError("LSMASHVideoSource: wrong format."); + } } const char *preferred_decoder_names = args[9].AsString( nullptr ); int prefer_hw_decoder = args[10].AsInt( 0 ); diff --git a/AviSynth/lwlibav_source.cpp b/AviSynth/lwlibav_source.cpp index 1554cec4..915a7ae7 100644 --- a/AviSynth/lwlibav_source.cpp +++ b/AviSynth/lwlibav_source.cpp @@ -415,9 +415,13 @@ AVSValue __cdecl CreateLWLibavVideoSource( AVSValue args, void *user_data, IScri enum AVPixelFormat pixel_format = AV_PIX_FMT_NONE; if (args[12].Defined()) { - pixel_format = get_av_output_pixel_format(args[12].AsString()); - if (pixel_format == AV_PIX_FMT_NONE) - env->ThrowError("LWLibavVideoSource: wrong format."); + const char* pix_fmt = args[12].AsString(); + if (strcmp(pix_fmt, "")) + { + pixel_format = get_av_output_pixel_format(pix_fmt); + if (pixel_format == AV_PIX_FMT_NONE) + env->ThrowError("LWLibavVideoSource: wrong format."); + } } const char *preferred_decoder_names = args[13].AsString( nullptr ); int prefer_hw_decoder = args[14].AsInt( 0 );