// TODO: make chunks variable
        public static void ProgressiveQuantization(Triplet <short[]> input, ProgressiveQuantizationFactors progQuants, bool UseReduceExtrapolate, out List <Triplet <short[]> > output)
        {
            output = new List <Triplet <short[]> >();
            DwtTile DRS = new DwtTile(input.X, input.Y, input.Z);

            foreach (var quantArray in progQuants.ProgQuants)
            {
                DwtBands yBD  = DwtBands.GetFromLinearizationResult(DRS.Y_DwtQ, UseReduceExtrapolate);
                DwtBands cbBD = DwtBands.GetFromLinearizationResult(DRS.Cb_DwtQ, UseReduceExtrapolate);
                DwtBands crBD = DwtBands.GetFromLinearizationResult(DRS.Cr_DwtQ, UseReduceExtrapolate);

                RFX_PROGRESSIVE_CODEC_QUANT quant = Utility.ConvertProgQuant(quantArray);

                ProgressiveQuantization_Component(yBD, TileComponents.Y, quant);
                ProgressiveQuantization_Component(cbBD, TileComponents.Cb, quant);
                ProgressiveQuantization_Component(crBD, TileComponents.Cr, quant);

                DwtBands yDTS  = DwtBands.GetFromLinearizationResult(DRS.Y_DwtQ, UseReduceExtrapolate);
                DwtBands cbDTS = DwtBands.GetFromLinearizationResult(DRS.Cb_DwtQ, UseReduceExtrapolate);
                DwtBands crDTS = DwtBands.GetFromLinearizationResult(DRS.Cr_DwtQ, UseReduceExtrapolate);

                DTS_Component(yDTS, TileComponents.Y, quant);
                DTS_Component(cbDTS, TileComponents.Cb, quant);
                DTS_Component(crDTS, TileComponents.Cr, quant);
                DwtTile dwtDts = new DwtTile(yDTS.GetLinearizationData(), cbDTS.GetLinearizationData(), crDTS.GetLinearizationData());
                DRS.Sub(dwtDts);

                var triplet = new Triplet <short[]>(yBD.GetLinearizationData(), cbBD.GetLinearizationData(), crBD.GetLinearizationData());
                output.Add(triplet);
            }
        }
示例#2
0
        public static QuantizationFactorsArray GetProgQuantizationFactorsForChunk(ProgressiveChunk chunk)
        {
            RFX_PROGRESSIVE_CODEC_QUANT quant   = RdpegfxTileUtils.GetProgCodecQuant((ProgressiveChunk_Values)chunk);
            QuantizationFactorsArray    factors = ConvertProgQuant(quant);

            return(factors);
        }
        public static void ProgressiveDequantization(Triplet <short[]> input, QuantizationFactorsArray quant, bool useReduceExtrapolate, out Triplet <short[]> output)
        {
            output   = new Triplet <short[]>();
            output.X = (short[])input.X.Clone();
            output.Y = (short[])input.Y.Clone();
            output.Z = (short[])input.Z.Clone();

            RFX_PROGRESSIVE_CODEC_QUANT codecQuant = Utility.ConvertProgQuant(quant);

            ProgressiveDeQuantization_Component(output.X, codecQuant.yQuantValues, useReduceExtrapolate);
            ProgressiveDeQuantization_Component(output.Y, codecQuant.cbQuantValues, useReduceExtrapolate);
            ProgressiveDeQuantization_Component(output.Z, codecQuant.crQuantValues, useReduceExtrapolate);
        }
示例#4
0
        public static QuantizationFactorsArray ConvertProgQuant(RFX_PROGRESSIVE_CODEC_QUANT quant)
        {
            var fators = new QuantizationFactorsArray();

            fators.quants = new QuantizationFactors[3];

            fators.quants[0]     = new QuantizationFactors();
            fators.quants[0].LL3 = (byte)(quant.yQuantValues.LL3_HL3 & 0x0F);
            fators.quants[0].HL3 = (byte)(quant.yQuantValues.LL3_HL3 >> 4);
            fators.quants[0].LH3 = (byte)(quant.yQuantValues.LH3_HH3 & 0x0F);
            fators.quants[0].HH3 = (byte)(quant.yQuantValues.LH3_HH3 >> 4);
            fators.quants[0].HL2 = (byte)(quant.yQuantValues.HL2_LH2 & 0x0F);
            fators.quants[0].LH2 = (byte)(quant.yQuantValues.HL2_LH2 >> 4);
            fators.quants[0].HH2 = (byte)(quant.yQuantValues.HH2_HL1 & 0x0F);
            fators.quants[0].HL1 = (byte)(quant.yQuantValues.HH2_HL1 >> 4);
            fators.quants[0].LH1 = (byte)(quant.yQuantValues.LH1_HH1 & 0x0F);
            fators.quants[0].HH1 = (byte)(quant.yQuantValues.LH1_HH1 >> 4);

            fators.quants[1]     = new QuantizationFactors();
            fators.quants[1].LL3 = (byte)(quant.cbQuantValues.LL3_HL3 & 0x0F);
            fators.quants[1].HL3 = (byte)(quant.cbQuantValues.LL3_HL3 >> 4);
            fators.quants[1].LH3 = (byte)(quant.cbQuantValues.LH3_HH3 & 0x0F);
            fators.quants[1].HH3 = (byte)(quant.cbQuantValues.LH3_HH3 >> 4);
            fators.quants[1].HL2 = (byte)(quant.cbQuantValues.HL2_LH2 & 0x0F);
            fators.quants[1].LH2 = (byte)(quant.cbQuantValues.HL2_LH2 >> 4);
            fators.quants[1].HH2 = (byte)(quant.cbQuantValues.HH2_HL1 & 0x0F);
            fators.quants[1].HL1 = (byte)(quant.cbQuantValues.HH2_HL1 >> 4);
            fators.quants[1].LH1 = (byte)(quant.cbQuantValues.LH1_HH1 & 0x0F);
            fators.quants[1].HH1 = (byte)(quant.cbQuantValues.LH1_HH1 >> 4);

            fators.quants[2]     = new QuantizationFactors();
            fators.quants[2].LL3 = (byte)(quant.crQuantValues.LL3_HL3 & 0x0F);
            fators.quants[2].HL3 = (byte)(quant.crQuantValues.LL3_HL3 >> 4);
            fators.quants[2].LH3 = (byte)(quant.crQuantValues.LH3_HH3 & 0x0F);
            fators.quants[2].HH3 = (byte)(quant.crQuantValues.LH3_HH3 >> 4);
            fators.quants[2].HL2 = (byte)(quant.crQuantValues.HL2_LH2 & 0x0F);
            fators.quants[2].LH2 = (byte)(quant.crQuantValues.HL2_LH2 >> 4);
            fators.quants[2].HH2 = (byte)(quant.crQuantValues.HH2_HL1 & 0x0F);
            fators.quants[2].HL1 = (byte)(quant.crQuantValues.HH2_HL1 >> 4);
            fators.quants[2].LH1 = (byte)(quant.crQuantValues.LH1_HH1 & 0x0F);
            fators.quants[2].HH1 = (byte)(quant.crQuantValues.LH1_HH1 >> 4);

            return(fators);
        }
示例#5
0
        public static RFX_PROGRESSIVE_CODEC_QUANT ConvertProgQuant(QuantizationFactorsArray quants)
        {
            var RFXQuants = new RFX_PROGRESSIVE_CODEC_QUANT();
            var quantList = new List <RFX_COMPONMENT_CODEC_QUANT>();

            foreach (var quant in quants.quants)
            {
                var rfxQuant = new RFX_COMPONMENT_CODEC_QUANT
                {
                    LL3_HL3 = (byte)((quant.HL3 << 4) | quant.LL3),
                    LH3_HH3 = (byte)((quant.HH3 << 4) | quant.LH3),
                    HL2_LH2 = (byte)((quant.LH2 << 4) | quant.HL2),
                    HH2_HL1 = (byte)((quant.HL1 << 4) | quant.HH2),
                    LH1_HH1 = (byte)((quant.HH1 << 4) | quant.LH1)
                };
                quantList.Add(rfxQuant);
            }
            RFXQuants.yQuantValues  = quantList[0];
            RFXQuants.cbQuantValues = quantList[1];
            RFXQuants.crQuantValues = quantList[2];

            return(RFXQuants);
        }
        public static void SRLDecode(
            Triplet <byte[]> decodedData,
            Triplet <byte[]> rawData,
            QuantizationFactorsArray quant,
            Triplet <short[]> DAS,
            QuantizationFactorsArray preQuant,
            bool useReduceExtrapolate,
            out Triplet <short[]> output)
        {
            RFX_PROGRESSIVE_CODEC_QUANT progCodecQuant = Utility.ConvertProgQuant(quant);
            RFX_PROGRESSIVE_CODEC_QUANT preCodecQuant  = Utility.ConvertProgQuant(preQuant);
            // construct the fake parameter to invoke RfxProgressiveDecoder.SRLDecode
            var codecContext = new RfxProgressiveCodecContext(new[] { RdpegfxTileUtils.GetCodecQuant(ImageQuality_Values.Midium) }, 0, 0, 0, useReduceExtrapolate);
            var encodeTile   = new EncodedTile
            {
                YEncodedData         = decodedData.X,
                CbEncodedData        = decodedData.Y,
                CrEncodedData        = decodedData.Z,
                YRawData             = rawData.X,
                CbRawData            = rawData.Y,
                CrRawData            = rawData.Z,
                ProgCodecQuant       = progCodecQuant,
                UseReduceExtrapolate = useReduceExtrapolate // Important
            };
            var sentTile = new DwtTile(DAS.X, DAS.Y, DAS.Z);

            sentTile.ProgCodecQuant = preCodecQuant;
            var frame = new SurfaceFrame(0, RdpegfxTileUtils.TileSize, RdpegfxTileUtils.TileSize);

            frame.UpdateTileDwtQ(new TileIndex(0, 0, RdpegfxTileUtils.TileSize, RdpegfxTileUtils.TileSize), sentTile);
            frame.UpdateTriState(new TileIndex(0, 0, RdpegfxTileUtils.TileSize, RdpegfxTileUtils.TileSize), sentTile);
            var tileState = new TileState(frame, new TileIndex(0, 0, RdpegfxTileUtils.TileSize, RdpegfxTileUtils.TileSize));

            SRLDecode(codecContext, encodeTile, tileState);
            output = new Triplet <short[]>(codecContext.YComponent, codecContext.CbComponent, codecContext.CrComponent);
        }