Example #1
0
        /// <summary> This function finds the new truncation points indices for a packet. It
        /// does so by including the data from the code-blocks in the component,
        /// resolution level and tile, associated with a R-D slope which is larger
        /// than or equal to 'fthresh'.
        /// 
        /// </summary>
        /// <param name="layerIdx">The index of the current layer
        /// 
        /// </param>
        /// <param name="compIdx">The index of the current component
        /// 
        /// </param>
        /// <param name="lvlIdx">The index of the current resolution level
        /// 
        /// </param>
        /// <param name="tileIdx">The index of the current tile
        /// 
        /// </param>
        /// <param name="subb">The LL subband in the resolution level lvlIdx, which is
        /// parent of all the subbands in the packet. Except for resolution level 0
        /// this subband is always a node.
        /// 
        /// </param>
        /// <param name="fthresh">The value of the rate-distortion threshold
        /// 
        /// </param>
        private void findTruncIndices(int layerIdx, int compIdx, int lvlIdx, int tileIdx, SubbandAn subb, float fthresh, int precinctIdx)
        {
            int minsbi, maxsbi, b, n; // bIdx removed
            //Coord ncblks = null;
            SubbandAn sb;
            CBlkRateDistStats cur_cblk;
            PrecInfo prec = pktEnc.getPrecInfo(tileIdx, compIdx, lvlIdx, precinctIdx);
            Coord cbCoord;

            sb = subb;
            while (sb.subb_HH != null)
            {
                sb = sb.subb_HH;
            }
            minsbi = (lvlIdx == 0)?0:1;
            maxsbi = (lvlIdx == 0)?1:4;

            int yend, xend;

            sb = (SubbandAn) subb.getSubbandByIdx(lvlIdx, minsbi);
            for (int s = minsbi; s < maxsbi; s++)
            {
                //loop on subbands
                yend = (prec.cblk[s] != null)?prec.cblk[s].Length:0;
                for (int y = 0; y < yend; y++)
                {
                    xend = (prec.cblk[s][y] != null)?prec.cblk[s][y].Length:0;
                    for (int x = 0; x < xend; x++)
                    {
                        cbCoord = prec.cblk[s][y][x].idx;
                        b = cbCoord.x + cbCoord.y * sb.numCb.x;

                        //Get the current code-block
                        cur_cblk = cblks[tileIdx][compIdx][lvlIdx][s][b];
                        for (n = 0; n < cur_cblk.nVldTrunc; n++)
                        {
                            if (cur_cblk.truncSlopes[n] < fthresh)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        // Store the index in the code-block truncIdxs that gives
                        // the real truncation index.
                        truncIdxs[tileIdx][layerIdx][compIdx][lvlIdx][s][b] = n - 1;
                    } // End loop on horizontal code-blocks
                } // End loop on vertical code-blocks
                sb = (SubbandAn) sb.nextSubband();
            } // End loop on subbands
        }