예제 #1
0
        public override VideoFrame GetFrame(int n, ScriptEnvironment env)
        {
            if (noRotate)
            {
                return(base.GetFrame(n, env));
            }
            var res = NewVideoFrame(env);

            using (var frame = Child.GetFrame(n, env))
            {
                var vi = Child.GetVideoInfo();
                Parallel.ForEach(planes, plane =>
                {
                    var zero = plane == YUVPlanes.PLANAR_U || plane == YUVPlanes.PLANAR_V ? 128 : 0;
                    OverlayUtils.MemSet(res.GetWritePtr(plane), zero, res.GetPitch(plane) * res.GetHeight(plane));

                    // get source image size
                    var height    = frame.GetHeight(plane);
                    var width     = vi.width / (vi.height / height);
                    var pixelSize = frame.GetRowSize(plane) / width;

                    NativeUtils.BilinearRotate(
                        frame.GetReadPtr(plane), frame.GetRowSize(plane) / pixelSize, frame.GetHeight(plane),
                        frame.GetPitch(plane),
                        res.GetWritePtr(plane), res.GetRowSize(plane) / pixelSize, res.GetHeight(plane),
                        res.GetPitch(plane),
                        angle, pixelSize);
                });
            }

            return(res);
        }