public override Frame Process(Frame sourceFrame)
        {
            var width = sourceFrame.Width;
            var height = sourceFrame.Height;

            var rSourceIndex = 0;
            var gSourceIndex = rSourceIndex + 1;
            var bSourceIndex = rSourceIndex + 2;

            var destFrame = new YuvFrame(width, height, PixelFormatType.PIX_FMT_YUV444);
            for (int i = 0, k = 0; i < height; i++)
            {
                for (var j = 0; j < width; j++)
                {
                    destFrame[0][k] = (byte)((RGB2_YUV_YR[sourceFrame.Data[rSourceIndex]] + RGB2_YUV_YG[sourceFrame.Data[gSourceIndex]] + RGB2_YUV_YB[sourceFrame.Data[bSourceIndex]] + 1048576) >> 16);
                    destFrame[1][k] = (byte)((-RGB2_YUV_UR[sourceFrame.Data[rSourceIndex]] - RGB2_YUV_UG[sourceFrame.Data[gSourceIndex]] + RGB2_YUV_UBVR[sourceFrame.Data[bSourceIndex]] + 8388608) >> 16);
                    destFrame[2][k] = (byte)((RGB2_YUV_UBVR[sourceFrame.Data[rSourceIndex]] - RGB2_YUV_VG[sourceFrame.Data[gSourceIndex]] - RGB2_YUV_VB[sourceFrame.Data[bSourceIndex]] + 8388608) >> 16);

                    rSourceIndex += 3;
                    gSourceIndex += 3;
                    bSourceIndex += 3;

                    k++;
                }
            }

            return destFrame;
        }
        public override Frame Process(Frame sourceFrame)
        {
            var width = sourceFrame.Width;
            var height = sourceFrame.Height;

            var destIntermediateFrame = base.Process(sourceFrame);

            var destFrame = new YuvFrame(width, height, PixelFormatType.PIX_FMT_YUV420);
            destFrame[0].Copy(destIntermediateFrame[0]);

            // For U
            var uDestinationIndex1 = 0;
            var uDestinationIndex2 = uDestinationIndex1 + 1;
            var uDestinationIndex3 = uDestinationIndex1 + width;
            var uDestinationIndex4 = uDestinationIndex3 + 1;

            // For V
            var vDestinationIndex1 = 0;
            var vDestinationIndex2 = vDestinationIndex1 + 1;
            var vDestinationIndex3 = vDestinationIndex1 + width;
            var vDestinationIndex4 = vDestinationIndex3 + 1;

            for (int i = 0, k = 0; i < height; i += 2)
            {
                for (var j = 0; j < width; j += 2)
                {
                    destFrame[1][k] = (byte)((destIntermediateFrame[1][uDestinationIndex1] +
                                                 destIntermediateFrame[1][uDestinationIndex2] +
                                                 destIntermediateFrame[1][uDestinationIndex3] +
                                                 destIntermediateFrame[1][uDestinationIndex4]) >> 2);
                    destFrame[2][k] = (byte)((destIntermediateFrame[2][vDestinationIndex1] +
                                                 destIntermediateFrame[2][vDestinationIndex2] +
                                                 destIntermediateFrame[2][vDestinationIndex3] +
                                                 destIntermediateFrame[2][vDestinationIndex4]) >> 2);

                    uDestinationIndex1 += 2;
                    uDestinationIndex2 += 2;
                    uDestinationIndex3 += 2;
                    uDestinationIndex4 += 2;

                    vDestinationIndex1 += 2;
                    vDestinationIndex2 += 2;
                    vDestinationIndex3 += 2;
                    vDestinationIndex4 += 2;

                    k++;
                }

                uDestinationIndex1 += width;
                uDestinationIndex2 += width;
                uDestinationIndex3 += width;
                uDestinationIndex4 += width;

                vDestinationIndex1 += width;
                vDestinationIndex2 += width;
                vDestinationIndex3 += width;
                vDestinationIndex4 += width;
            }

            return destFrame;
        }