Skip to content

Commit

Permalink
AviSynth: throw error if wrong format is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Dec 14, 2023
1 parent 5d61a8f commit d365e8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion AviSynth/libavsmash_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,13 @@ AVSValue __cdecl CreateLSMASHVideoSource( AVSValue args, void *user_data, IScrip
int direct_rendering = args[5].AsBool( false ) ? 1 : 0;
int fps_num = args[6].AsInt( 0 );
int fps_den = args[7].AsInt( 1 );
enum AVPixelFormat pixel_format = get_av_output_pixel_format( args[8].AsString( nullptr ) );
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 *preferred_decoder_names = args[9].AsString( nullptr );
int prefer_hw_decoder = args[10].AsInt( 0 );
int ff_loglevel = args[11].AsInt( 0 );
Expand Down
8 changes: 7 additions & 1 deletion AviSynth/lwlibav_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,13 @@ AVSValue __cdecl CreateLWLibavVideoSource( AVSValue args, void *user_data, IScri
return 2;
}();
int field_dominance = args[11].AsInt( 0 );
enum AVPixelFormat pixel_format = get_av_output_pixel_format( args[12].AsString( nullptr ) );
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 *preferred_decoder_names = args[13].AsString( nullptr );
int prefer_hw_decoder = args[14].AsInt( 0 );
int ff_loglevel = args[15].AsInt( 0 );
Expand Down

0 comments on commit d365e8b

Please sign in to comment.