xp_comm_proj/rd_dicom/Papyrus3/JpegDir/JpgLless/huffcoptimisebug.c
/*
 *--------------------------------------------------------------
 *
 * EncodeFirstRow --
 *
 *     Encode the first raster line of samples at the start of
 *     the scan and at the beginning of each restart interval.  
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */
EncodeFirstRow
Encode the first raster line of samples at the start of
the scan and at the beginning of each restart interval.

None.

Side effects:
None.
EncodeFirstRow Encode the first raster line of samples at the start of the scan and at the beginning of each restart interval . None . Side effects : None .
void
EncodeFirstRow(CompressInfo *cPtr, PapyUShort *ImageIn)
{
    register short curComp,ci;
    register int col,compsInScan,numCOL;
    register JpegComponentInfo *compptr;
    int Pr,Pt,diff;
    PapyUChar *ImageIn8b;
    Pr=cPtr->dataPrecision;
    Pt=cPtr->Pt;
    compsInScan=cPtr->compsInScan;
    numCOL=cPtr->imageWidth;
    if (cPtr->dataPrecision == 8) ImageIn8b = (Uchar *) ImageIn;
    if (cPtr->dataPrecision == 8) {
    	for (curComp = 0; curComp < compsInScan; curComp++) {
      		 ci = cPtr->MCUmembership[curComp];
       		 compptr = cPtr->curCompInfo[ci];
       		 diff = ImageIn8b[0] - (1<<(Pr-Pt-1));
       		 EncodeOneDiff(diff,cPtr->dcHuffTblPtrs[compptr->dcTblNo]);
   		 }
    	for (col=1; col<numCOL; col++) {
       		 for (curComp = 0; curComp < compsInScan; curComp++) {
        	    ci = cPtr->MCUmembership[curComp];
        	    compptr = cPtr->curCompInfo[ci];
       		     diff = ImageIn8b[col]-ImageIn8b[col-1];
         		 EncodeOneDiff (diff, cPtr->dcHuffTblPtrs[compptr->dcTblNo]);
       		 }
 	     }
    	if (cPtr->restartInRows) {
       cPtr->restartRowsToGo--;
   	 	}
    }
    else { 
    	for (curComp = 0; curComp < compsInScan; curComp++) {
        ci = cPtr->MCUmembership[curComp];
        compptr = cPtr->curCompInfo[ci];
        diff = ImageIn[0] - (1<<(Pr-Pt-1));
        EncodeOneDiff(diff,cPtr->dcHuffTblPtrs[compptr->dcTblNo]);
    }
    for (col=1; col<numCOL; col++) {
        for (curComp = 0; curComp < compsInScan; curComp++) {
            ci = cPtr->MCUmembership[curComp];
            compptr = cPtr->curCompInfo[ci];
            diff = ImageIn[col]-ImageIn[col-1];
            EncodeOneDiff (diff, cPtr->dcHuffTblPtrs[compptr->dcTblNo]);
        }
    }
    if (cPtr->restartInRows) {
       cPtr->restartRowsToGo--;
    }
    }
}
void EncodeFirstRow ( CompressInfo * cPtr , PapyUShort * ImageIn ) { register short curComp , ci ; register int col , compsInScan , numCOL ; register JpegComponentInfo * compptr ; int Pr , Pt , diff ; PapyUChar * ImageIn8b ; Pr = cPtr -> dataPrecision ; Pt = cPtr -> Pt ; compsInScan = cPtr -> compsInScan ; numCOL = cPtr -> imageWidth ; if ( cPtr -> dataPrecision == 8 ) ImageIn8b = ( Uchar * ) ImageIn ; if ( cPtr -> dataPrecision == 8 ) { for ( curComp = 0 ; curComp < compsInScan ; curComp ++ ) { ci = cPtr -> MCUmembership [ curComp ] ; compptr = cPtr -> curCompInfo [ ci ] ; diff = ImageIn8b [ 0 ] - ( 1 << ( Pr - Pt - 1 ) ) ; EncodeOneDiff ( diff , cPtr -> dcHuffTblPtrs [ compptr -> dcTblNo ] ) ; } for ( col = 1 ; col < numCOL ; col ++ ) { for ( curComp = 0 ; curComp < compsInScan ; curComp ++ ) { ci = cPtr -> MCUmembership [ curComp ] ; compptr = cPtr -> curCompInfo [ ci ] ; diff = ImageIn8b [ col ] - ImageIn8b [ col - 1 ] ; EncodeOneDiff ( diff , cPtr -> dcHuffTblPtrs [ compptr -> dcTblNo ] ) ; } } if ( cPtr -> restartInRows ) { cPtr -> restartRowsToGo -- ; } } else { for ( curComp = 0 ; curComp < compsInScan ; curComp ++ ) { ci = cPtr -> MCUmembership [ curComp ] ; compptr = cPtr -> curCompInfo [ ci ] ; diff = ImageIn [ 0 ] - ( 1 << ( Pr - Pt - 1 ) ) ; EncodeOneDiff ( diff , cPtr -> dcHuffTblPtrs [ compptr -> dcTblNo ] ) ; } for ( col = 1 ; col < numCOL ; col ++ ) { for ( curComp = 0 ; curComp < compsInScan ; curComp ++ ) { ci = cPtr -> MCUmembership [ curComp ] ; compptr = cPtr -> curCompInfo [ ci ] ; diff = ImageIn [ col ] - ImageIn [ col - 1 ] ; EncodeOneDiff ( diff , cPtr -> dcHuffTblPtrs [ compptr -> dcTblNo ] ) ; } } if ( cPtr -> restartInRows ) { cPtr -> restartRowsToGo -- ; } } }
EncodeFirstRow
     Encode the first raster line of samples at the start of
     the scan and at the beginning of each restart interval.
EncodeFirstRow Encode the first raster line of samples at the start of the scan and at the beginning of each restart interval .
/*
     * At the start of the scan or at the beginning of restart interval,
     * 1<<(Pr-Pt-1) is the predictor.
     */ /*
     * In rest of the first row, left neighboring pixel is the predictor. 
     */ /* 16 bits */ /*
     * In rest of the first row, left neighboring pixel is the predictor. 
     */