Skip to content

Commit f4b447e

Browse files
committed
Improve error message
1 parent 214c6e6 commit f4b447e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

AviSynth/lwlibav_source.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,6 @@ LWLibavVideoSource::LWLibavVideoSource(lwlibav_option_t* opt, int seek_mode, uin
138138
prepare_video_decoding(vdhp, vohp, direct_rendering, pixel_format, env);
139139
has_at_least_v8 = env->FunctionExists("propShow");
140140
av_frame = lwlibav_video_get_frame_buffer(vdhp);
141-
if (!av_frame->data[0] && prefer_hw)
142-
env->ThrowError("LWLibavVideoSource: the GPU driver doesn't support this hardware decoding.");
143-
int num = av_frame->sample_aspect_ratio.num;
144-
int den = av_frame->sample_aspect_ratio.den;
145-
env->SetVar(env->Sprintf("%s", "FFSAR_NUM"), num);
146-
env->SetVar(env->Sprintf("%s", "FFSAR_DEN"), den);
147-
if (num > 0 && den > 0)
148-
env->SetVar(env->Sprintf("%s", "FFSAR"), num / static_cast<double>(den));
149141
const char* used_decoder = [&]() {
150142
switch (prefer_hw) {
151143
case 4:
@@ -158,6 +150,14 @@ LWLibavVideoSource::LWLibavVideoSource(lwlibav_option_t* opt, int seek_mode, uin
158150
return "HWAccel: VULKAN";
159151
}
160152
}();
153+
if (!av_frame->data[0] && prefer_hw)
154+
env->ThrowError("LWLibavVideoSource: the GPU driver doesn't support this hardware decoding (%s).", used_decoder);
155+
int num = av_frame->sample_aspect_ratio.num;
156+
int den = av_frame->sample_aspect_ratio.den;
157+
env->SetVar(env->Sprintf("%s", "FFSAR_NUM"), num);
158+
env->SetVar(env->Sprintf("%s", "FFSAR_DEN"), den);
159+
if (num > 0 && den > 0)
160+
env->SetVar(env->Sprintf("%s", "FFSAR"), num / static_cast<double>(den));
161161
env->SetVar(env->Sprintf("%s", "LWLDECODER"), (vdhp->ctx->hw_device_ctx) ? used_decoder : vdhp->ctx->codec->name);
162162
}
163163

@@ -179,7 +179,7 @@ PVideoFrame __stdcall LWLibavVideoSource::GetFrame(int n, IScriptEnvironment* en
179179
return env->NewVideoFrame(vi);
180180
PVideoFrame as_frame;
181181
if (make_frame(vohp, av_frame, as_frame, env) < 0)
182-
env->ThrowError("LWLibavVideoSource: failed to make a frame.");
182+
env->ThrowError("LWLibavVideoSource: failed to make a frame (%s).", env->GetVar("LWLDECODER"));
183183
if (has_at_least_v8) {
184184
const int top = [&]() {
185185
if (vohp->repeat_control && vohp->repeat_requested)

0 commit comments

Comments
 (0)