@@ -132,7 +132,8 @@ static void VS_CC CreateBestVideoSource(const VSMap *In, VSMap *Out, void *, VSC
132132
133133 int err;
134134 std::filesystem::path Source = CreateProbablyUTF8Path (vsapi->mapGetData (In, " source" , 0 , nullptr ));
135- const char *CachePath = vsapi->mapGetData (In, " cachepath" , 0 , &err);
135+ const char *RawCachePath = vsapi->mapGetData (In, " cachepath" , 0 , &err);
136+ std::filesystem::path CachePath = CreateProbablyUTF8Path (RawCachePath ? RawCachePath : " " );
136137 const char *HWDevice = vsapi->mapGetData (In, " hwdevice" , 0 , &err);
137138 const char *Timecodes = vsapi->mapGetData (In, " timecodes" , 0 , &err);
138139 int Track = vsapi->mapGetIntSaturated (In, " track" , 0 , &err);
@@ -208,21 +209,21 @@ static void VS_CC CreateBestVideoSource(const VSMap *In, VSMap *Out, void *, VSC
208209 return true ;
209210 };
210211 try {
211- D->V .reset (new BestVideoSource (Source, HWDevice ? HWDevice : " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath ? CachePath : " " , &Opts, ProgressCB));
212+ D->V .reset (new BestVideoSource (Source, HWDevice ? HWDevice : " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath, &Opts, ProgressCB));
212213 } catch (BestSourceHWDecoderException &) {
213214 if (HWFallback) {
214- D->V .reset (new BestVideoSource (Source, " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath ? CachePath : " " , &Opts, ProgressCB));
215+ D->V .reset (new BestVideoSource (Source, " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath, &Opts, ProgressCB));
215216 } else {
216217 vsapi->logMessage (mtInformation, (" VideoSource track #" + std::to_string (Track) + " using CPU decoding fallback" ).c_str (), Core);
217218 throw ;
218219 }
219220 }
220221 } else {
221222 try {
222- D->V .reset (new BestVideoSource (Source, HWDevice ? HWDevice : " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath ? CachePath : " " , &Opts));
223+ D->V .reset (new BestVideoSource (Source, HWDevice ? HWDevice : " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath, &Opts));
223224 } catch (BestSourceHWDecoderException &) {
224225 if (HWFallback) {
225- D->V .reset (new BestVideoSource (Source, " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath ? CachePath : " " , &Opts));
226+ D->V .reset (new BestVideoSource (Source, " " , ExtraHWFrames, Track, ViewID, Threads, CacheMode, CachePath, &Opts));
226227 } else {
227228 vsapi->logMessage (mtInformation, (" VideoSource track #" + std::to_string (Track) + " using CPU decoding fallback" ).c_str (), Core);
228229 throw ;
@@ -333,7 +334,8 @@ static void VS_CC CreateBestAudioSource(const VSMap *In, VSMap *Out, void *, VSC
333334
334335 int err;
335336 std::filesystem::path Source = CreateProbablyUTF8Path (vsapi->mapGetData (In, " source" , 0 , nullptr ));
336- const char *CachePath = vsapi->mapGetData (In, " cachepath" , 0 , &err);
337+ const char *RawCachePath = vsapi->mapGetData (In, " cachepath" , 0 , &err);
338+ std::filesystem::path CachePath = CreateProbablyUTF8Path (RawCachePath ? RawCachePath : " " );
337339 int Track = vsapi->mapGetIntSaturated (In, " track" , 0 , &err);
338340 if (err)
339341 Track = -1 ;
@@ -361,7 +363,7 @@ static void VS_CC CreateBestAudioSource(const VSMap *In, VSMap *Out, void *, VSC
361363 if (ShowProgress) {
362364 auto NextUpdate = std::chrono::high_resolution_clock::now ();
363365 int LastValue = -1 ;
364- D->A .reset (new BestAudioSource (Source, Track, AdjustDelay, Threads, CacheMode, CachePath ? CachePath : " " , &Opts, DrcScale,
366+ D->A .reset (new BestAudioSource (Source, Track, AdjustDelay, Threads, CacheMode, CachePath, &Opts, DrcScale,
365367 [vsapi, Core, &NextUpdate, &LastValue](int Track, int64_t Cur, int64_t Total) {
366368 if (NextUpdate < std::chrono::high_resolution_clock::now ()) {
367369 if (Total == INT64_MAX && Cur == Total) {
@@ -379,7 +381,7 @@ static void VS_CC CreateBestAudioSource(const VSMap *In, VSMap *Out, void *, VSC
379381 }));
380382
381383 } else {
382- D->A .reset (new BestAudioSource (Source, Track, AdjustDelay, Threads, CacheMode, CachePath ? CachePath : " " , &Opts, DrcScale));
384+ D->A .reset (new BestAudioSource (Source, Track, AdjustDelay, Threads, CacheMode, CachePath, &Opts, DrcScale));
383385 }
384386
385387 D->A ->SetMaxDecoderInstances (MaxDecoders);
0 commit comments