Example #1
0
        protected override void Initialize(AVSValue args)
        {
            LimitedRange = LimitedRange && GetVideoInfo().IsPlanar();
            planes       = GetVideoInfo().pixel_type.HasFlag(ColorSpaces.CS_INTERLEAVED)
                ? new[] { default(YUVPlanes) }
                : (Channels ?? "yuv").ToCharArray().Select(p => Enum.Parse(typeof(YUVPlanes), "PLANAR_" + p, true))
            .Cast <YUVPlanes>().ToArray();
            realChannels = GetVideoInfo().IsPlanar()
                ? new[] { 0 }
                : (Channels ?? "rgb").ToLower().ToCharArray().Select(p => "bgr".IndexOf(p)).ToArray();
            if (!OverlayUtils.IsRealPlanar(Child))
            {
                planes = new[] { default(YUVPlanes) }
            }
            ;
            sampleBits    = Sample.GetVideoInfo().pixel_type.GetBitDepth();
            referenceBits = Reference.GetVideoInfo().pixel_type.GetBitDepth();
            var vi = GetVideoInfo();

            vi.pixel_type = vi.pixel_type.ChangeBitDepth(referenceBits);
            SetVideoInfo(ref vi);
            var cacheSize = tr * 2 + 1;
            var cacheKey  = StaticEnv.GetEnv2() == null ? CacheType.CACHE_25_ALL : CacheType.CACHE_GENERIC;

            Child.SetCacheHints(cacheKey, cacheSize);
            Sample.SetCacheHints(cacheKey, cacheSize);
            Reference.SetCacheHints(cacheKey, cacheSize);
            SampleMask?.SetCacheHints(cacheKey, cacheSize);
            ReferenceMask?.SetCacheHints(cacheKey, cacheSize);
            if (Intensity < 1 && sampleBits != referenceBits)
            {
                throw new AvisynthException("Intensity < 1 is not allowed when sample and reference bit depth are not equal");
            }
        }
Example #2
0
        protected override void Initialize(AVSValue args)
        {
            parallelOptions = new ParallelOptions
            {
                MaxDegreeOfParallelism = Threads == 0 ? -1 : Threads
            };
            LimitedRange = LimitedRange && GetVideoInfo().IsPlanar();
            planes       = GetVideoInfo().pixel_type.HasFlag(ColorSpaces.CS_INTERLEAVED)
                ? new[] { default(YUVPlanes) }
                : (Channels ?? "yuv").ToCharArray().Select(p => Enum.Parse(typeof(YUVPlanes), "PLANAR_" + p, true))
            .Cast <YUVPlanes>().ToArray();
            realChannels = GetVideoInfo().IsPlanar()
                ? new[] { 0 }
                : (Channels ?? "rgb").ToLower().ToCharArray().Select(p => "bgr".IndexOf(p)).ToArray();
            if (!Child.IsRealPlanar())
            {
                planes = new[] { default(YUVPlanes) }
            }
            ;
            sampleBits    = Sample.GetVideoInfo().pixel_type.GetBitDepth();
            referenceBits = Reference.GetVideoInfo().pixel_type.GetBitDepth();
            var vi = GetVideoInfo();

            vi.pixel_type = vi.pixel_type.ChangeBitDepth(referenceBits);
            SetVideoInfo(ref vi);
            var cacheSize = AdjacentFramesCount * 2 + 1;
            var cacheKey  = StaticEnv.GetEnv2() == null ? CacheType.CACHE_25_ALL : CacheType.CACHE_GENERIC;

            Child.SetCacheHints(cacheKey, cacheSize);
            Sample.SetCacheHints(cacheKey, cacheSize);
            Reference.SetCacheHints(cacheKey, cacheSize);
            SampleMask?.SetCacheHints(cacheKey, cacheSize);
            ReferenceMask?.SetCacheHints(cacheKey, cacheSize);
            if (Intensity < 1 && sampleBits != referenceBits)
            {
                throw new AvisynthException("Intensity < 1 is not allowed when sample and reference bit depth are not equal");
            }

            histogramCache = !string.IsNullOrEmpty(CacheId)
                ? HistogramCache.Get(CacheId)
                : new HistogramCache(planes, realChannels, SIMD, LimitedRange,
                                     Sample.GetVideoInfo().pixel_type, Reference.GetVideoInfo().pixel_type,
                                     Child.GetVideoInfo().pixel_type, AdjacentFramesCount, GreyMask, parallelOptions);

            if (histogramCache == null)
            {
                throw new AvisynthException($"$Histogram cache with ID: {CacheId} not found");
            }
        }