xp_comm_proj/rd_dicom/Papyrus3/JpegDir/JpgLless/huffcoptimisebug.c
/*
 *--------------------------------------------------------------
 *
 * StdPickSelValue --
 *
 *	Select the best PSV from the psvSet. Default Huffman
 *	tables and frequency counting tables are used in the
 *	selection procedure.
 *
 * Results:
 *	Chosen selection value is stored in cPtr->Ss
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */
StdPickSelValue
Select the best PSV from the psvSet. Default Huffman
tables and frequency counting tables are used in the
selection procedure.

Chosen selection value is stored in cPtr->Ss

Side effects:
None.
StdPickSelValue Select the best PSV from the psvSet . Default Huffman tables and frequency counting tables are used in the selection procedure . Chosen selection value is stored in cPtr - > Ss Side effects : None .
void
StdPickSelValue(CompressInfo *cPtr, long *bestTotalBits)
{
    int tbl,i;
    long curTotalBits;
    int curCountTblNo;
    FreqCountInit(cPtr);
    if (numSelValue>3) { 
       FreqCountAllSelValue(cPtr);
       }
    else {
       FreqCountSelValueSet(cPtr);
    }
    curCountTblNo=psvSet[0]-1;
    *bestTotalBits=EmitBitsSum(curCountTblNo,cPtr->dcHuffTblPtrs);
    cPtr->Ss=psvSet[0];
    for (i=1; i<numSelValue; i++) {
        curCountTblNo=psvSet[i]-1;
        curTotalBits=EmitBitsSum(curCountTblNo,cPtr->dcHuffTblPtrs);
        if (curTotalBits<*bestTotalBits) {
           *bestTotalBits=curTotalBits;
           cPtr->Ss=psvSet[i];
        }
    }
    for (tbl = 0; tbl < NUM_HUFF_TBLS; tbl++) {
        for (i=0;i<7;i++) {
            if (freqCountPtrs[i][tbl] != NULL) {
               efree3((void **) &freqCountPtrs[i][tbl]);
            }
        }
    }
}
void StdPickSelValue ( CompressInfo * cPtr , long * bestTotalBits ) { int tbl , i ; long curTotalBits ; int curCountTblNo ; FreqCountInit ( cPtr ) ; if ( numSelValue > 3 ) { FreqCountAllSelValue ( cPtr ) ; } else { FreqCountSelValueSet ( cPtr ) ; } curCountTblNo = psvSet [ 0 ] - 1 ; * bestTotalBits = EmitBitsSum ( curCountTblNo , cPtr -> dcHuffTblPtrs ) ; cPtr -> Ss = psvSet [ 0 ] ; for ( i = 1 ; i < numSelValue ; i ++ ) { curCountTblNo = psvSet [ i ] - 1 ; curTotalBits = EmitBitsSum ( curCountTblNo , cPtr -> dcHuffTblPtrs ) ; if ( curTotalBits < * bestTotalBits ) { * bestTotalBits = curTotalBits ; cPtr -> Ss = psvSet [ i ] ; } } for ( tbl = 0 ; tbl < NUM_HUFF_TBLS ; tbl ++ ) { for ( i = 0 ; i < 7 ; i ++ ) { if ( freqCountPtrs [ i ] [ tbl ] != NULL ) { efree3 ( ( void * * ) & freqCountPtrs [ i ] [ tbl ] ) ; } } } }
StdPickSelValue
      Select the best PSV from the psvSet.
StdPickSelValue Select the best PSV from the psvSet .
/*long curFreqCount[257];*/ /*
     * Collect the frequency count in freqCountPtrs for each PSV.
     * Experiment data shows that when numSelValue > 4,
     * FreqCountAllSelValue does a better job than FreqCountSelValueSet.
     */ /* 
     * Loop through each PSV in the psvSet, and store the PSV
     * which generates the least output bits in cPtr->Ss.
     */ /*
     * Release frequency counting tables.
     */