protected override VideoFrame GetFrame(int n) { OverlayInfo info; lock (Child) using (var infoFrame = Child.GetFrame(n, StaticEnv)) info = OverlayInfo.FromFrame(infoFrame).First(); var crop = info.GetCrop(); var hybrid = DynamicEnv.Invoke(Function, Engine, Source, Overlay, info.X, info.Y, info.Angle / 100.0, info.Width, info.Height, crop.Left, crop.Top, crop.Right, crop.Bottom, info.Diff); if (Debug) { hybrid = hybrid.Subtitle(info.ToString().Replace("\n", "\\n"), lsp: 0); } var res = NewVideoFrame(StaticEnv); using (VideoFrame frame = hybrid[n]) { Parallel.ForEach(new[] { YUVPlanes.PLANAR_Y, YUVPlanes.PLANAR_U, YUVPlanes.PLANAR_V }, plane => { for (var y = 0; y < frame.GetHeight(plane); y++) { OverlayUtils.CopyMemory(res.GetWritePtr(plane) + y * res.GetPitch(plane), frame.GetReadPtr(plane) + y * frame.GetPitch(plane), res.GetRowSize(plane)); } }); } return(res); }
private VideoFrame GetFrameWithSmooth(int n) { if (GetVideoInfo().pixel_type.IsRealPlanar()) { dynamic ProcessPlane(YUVPlanes plane, dynamic srcClip, dynamic overClip) => planes.Contains(plane) ? DynamicEnv.Invoke(nameof(ComplexityOverlay), srcClip, overClip, mask: Mask, steps: Steps, smooth: Smooth, preference: Preference) : Mask?srcClip.BlankClip(color_yuv : 0x00800000) : srcClip; var y = ProcessPlane(YUVPlanes.PLANAR_Y, Source.Dynamic().ExtractY(), Overlay.Dynamic().ExtractY()); var u = ProcessPlane(YUVPlanes.PLANAR_U, Source.Dynamic().ExtractU(), Overlay.Dynamic().ExtractU()); var v = ProcessPlane(YUVPlanes.PLANAR_V, Source.Dynamic().ExtractV(), Overlay.Dynamic().ExtractV()); return(DynamicEnv.CombinePlanes(y, u, v, planes: "YUV", sample_clip: Source)[n]); } var mask = DynamicEnv.Invoke(nameof(ComplexityOverlay), Source, Overlay, mask: true, steps: Steps, preference: Preference).Blur(Smooth); return(Mask ? mask[n] : Source.Dynamic().Overlay(Overlay, mask: mask)[n]); }