Skip to content
This repository was archived by the owner on Sep 14, 2024. It is now read-only.

Commit 53fdf0a

Browse files
committed
Speed up frame grain level measure by denoising a fraction of the frame
1 parent 859e92c commit 53fdf0a

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

Av1ador/Form1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial class Form1 : Form
2525
[DllImport("user32.dll")]
2626
static extern bool GetCursorPos(ref Point point);
2727

28-
private readonly string title = "Av1ador 1.4.1";
28+
private readonly string title = "Av1ador 1.4.2";
2929
private readonly Regex formatos = new Regex(".+(mkv|mp4|avi|webm|ivf|m2ts|wmv|mpg|mov|3gp|ts|mpeg|y4m|vob|m2v|m4v|flv|asf|png)$", RegexOptions.IgnoreCase);
3030
private Player mpv;
3131
private Video primer_video, segundo_video;
@@ -328,7 +328,7 @@ private void Get_res(string entry_res = "")
328328
}
329329
}
330330
}
331-
if (uh / primer_video.Sar > int.Parse(resComboBox.Items[0].ToString().Replace("p", "")))
331+
if (resComboBox.Items.Count == 0 || uh / primer_video.Sar > int.Parse(resComboBox.Items[0].ToString().Replace("p", "")))
332332
{
333333
resComboBox.Items.Insert(0, uh / primer_video.Sar + "p");
334334
resComboBox.Text = resComboBox.Items[0].ToString();

Av1ador/Video.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,22 +469,25 @@ internal void Grain_detect(NumericUpDown gsupdown, Label status, int maxgs, Labe
469469
Process ffmpeg = new Process();
470470
Func.Setinicial(ffmpeg, 3);
471471
int ss = (int)(Duration * i / (loop + 2));
472-
string cmd = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -ss " + ss + " -i \"" + File + "\" -an -sn -frames:v 1 -vf \"" + crop + "thumbnail=n=" + frames + ",scale=w=1920:h=1080:force_original_aspect_ratio=decrease:force_divisible_by=2";
472+
string cmd = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -ss " + ss + " -i \"" + File + "\" -an -sn -frames:v 1 -vf \"" + crop + "crop='min(386,iw):min(386,ih)':exact=1,thumbnail=n=" + frames;
473473
if (Hdr == 1)
474474
cmd += ",format=p010,hwupload,tonemap_opencl=tonemap=hable:r=tv:p=bt709:t=bt709:m=bt709:format=nv12,hwdownload,format=nv12";
475475
else if (Hdr == 2 && Encoder.Libplacebo)
476476
{
477477
cmd = cmd.Replace("opencl:" + Encoder.OCL_Device, "vulkan:" + Encoder.Vkn_Device);
478478
cmd += ",format=yuv420p10le,hwupload,libplacebo=tonemapping=reinhard:range=tv:color_primaries=bt709:color_trc=bt709:colorspace=bt709:format=yuv420p,hwdownload,format=yuv420p";
479479
}
480-
cmd += "\" -lossless 1 -compression_level 1 -y \"" + name + "_th.webp\"";
480+
cmd += "\" -y \"" + name + "_ss.png\"";
481481
ffmpeg.StartInfo.Arguments = cmd;
482482
ffmpeg.Start();
483483
ffmpeg.WaitForExit(-1);
484-
ffmpeg.StartInfo.Arguments = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -i \"" + name + "_th.webp\" -frames:v 1 -vf pad=(iw+16):(ih+16):8:8,format=pix_fmts=yuv420p,hwupload,nlmeans_opencl=s=1.8:p=7:r=9,hwdownload,format=pix_fmts=yuv420p,crop=(iw-16):(ih-16):8:8 -lossless 1 -compression_level 1 -y \"" + name + "_th_dns.webp\"";
484+
ffmpeg.StartInfo.Arguments = " -loglevel panic -i \"" + name + "_ss.png\" -vf crop='min(270,iw):min(270,ih)' -lossless 1 -compression_level 1 -y \"" + name + "_th.webp\"";
485485
ffmpeg.Start();
486486
ffmpeg.WaitForExit(-1);
487-
ffmpeg.StartInfo.Arguments = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -i \"" + name + "_th.webp\" -frames:v 1 -vf pad=(iw+12):(ih+12):6:6,format=pix_fmts=yuv420p,hwupload,nlmeans_opencl=s=4:p=5:r=15,hwdownload,format=pix_fmts=yuv420p,crop=(iw-10):(ih-12):6:6 -lossless 1 -compression_level 1 -y \"" + name + "_th_dnb.webp\"";
487+
ffmpeg.StartInfo.Arguments = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -i \"" + name + "_ss.png\" -frames:v 1 -vf format=pix_fmts=yuv420p,hwupload,nlmeans_opencl=s=1.8:p=7:r=9,hwdownload,format=pix_fmts=yuv420p,crop='min(270,iw):min(270,ih)':exact=1 -lossless 1 -compression_level 1 -y \"" + name + "_th_dns.webp\"";
488+
ffmpeg.Start();
489+
ffmpeg.WaitForExit(-1);
490+
ffmpeg.StartInfo.Arguments = " -loglevel panic -init_hw_device opencl:" + Encoder.OCL_Device + " -i \"" + name + "_ss.png\" -frames:v 1 -vf format=pix_fmts=yuv420p,hwupload,nlmeans_opencl=s=4:p=5:r=15,hwdownload,format=pix_fmts=yuv420p,crop='min(270,iw):min(270,ih)':exact=1 -lossless 1 -compression_level 1 -y \"" + name + "_th_dnb.webp\"";
488491
ffmpeg.Start();
489492
ffmpeg.WaitForExit(-1);
490493
double s1 = new FileInfo(name + "_th.webp").Length;
@@ -537,6 +540,8 @@ public void Clear_tmp()
537540
string name = Path.GetFileNameWithoutExtension(File);
538541
try
539542
{
543+
if (System.IO.File.Exists(name + "_ss.png"))
544+
System.IO.File.Delete(name + "_ss.png");
540545
if (System.IO.File.Exists(name + "_th.webp"))
541546
System.IO.File.Delete(name + "_th.webp");
542547
if (System.IO.File.Exists(name + "_th_dns.webp"))

0 commit comments

Comments
 (0)