⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dcttestc.c

📁 arm ads1.2 with crack.rar
💻 C
📖 第 1 页 / 共 3 页
字号:
	printf( "Both these options can be turned on or off, independently and by default they are on.\n\n" ) ;
	
	while( 1 ) {
		if( ( option = NextTask( DCT_OPTIONS, &Menu ) ) == 0 ) {
			break ;
		}
		
		PerformOption( option ) ;
	}
	
	/* redirection based on trying to open files that don't exist do using defaults */
	if( stdio & ( 1 << STDINID ) ) {
		ResetStdIO( stdin ) ;
	}
	if( stdio & ( 1 << STDOUTID ) ) {
		ResetStdIO( stdout ) ;
	}
	if( stdio & ( 1 << STDERRID ) ) {
		ResetStdIO( stderr ) ;
	}
	 
	return 0 ;
}

/**** FDCTFast **********************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * given a set of blocks for forward DCT'ing, construct the structures necessary
 * for the ARM forward DCT, including tranfering the data to the appropriate type,
 * forward DCT the data using the ARM routines and retrieve the data afterwards
 * placing it in the array given
 *
 * Inputs
 * ------
 *   in
 *   - an array of DCTArray entities, each of which contains a block to be DCT'd
 *   out
 *   - an initialised array of DCTArray entries to hold the result of the DCT'ing
 *     the number of entries in the array must be at least the number of entries
 *     referenced by the array in
 *   numberBlocks
 *   - the number of DCTArray entries in the array in and the number of blocks returned
 *     after the function call in out
 * Return Values
 * ------ ------
 *     TRUE  - the coding operation was successful
 *     FALSE - some error occurred (memory allocation?)
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static Boolean FDCTFast( DCTArray in[ ], DCTArray out[ ], unsigned int numberBlocks )
{   
	int				*dctBlockPtr ;
	int				*dctBlock ;
	unsigned int 	x, y ;
 	SCALETABLE		**fdctSTableArrayPtrs ;
 	unsigned int	bCounter ;
 	
 	if( ( !in ) || ( !out ) ) {
		fprintf( stderr, "[FDCTFast] Error in arguments, aborting.\n\n" ) ;
		/* function name given since intended as internal error for programmer */
 		return FALSE ;
 	}

	CREATEFDCTSTABLEARRAY( fdctSTableArrayPtrs, numberBlocks ) ;
	
	if( !fdctSTableArrayPtrs ) {
		return FALSE ;
	}
	
	CREATEDCTBLOCK( dctBlockPtr, dctBlock, numberBlocks ) ;

	if( !dctBlock ) {
		free( ( void * ) fdctSTableArrayPtrs ) ;
		return FALSE ;
	}

  	for( bCounter = 0 ; bCounter < numberBlocks ; bCounter += 1 ) {
		for( y = 0; y < 8; y += 1 ) {
	    	for( x = 0; x < 8; x += 1 ) {
	    		PREFDCT( dctBlock, in[ bCounter ][ y ][ x ], x, y, bCounter ) ;
			}
		}
	}
	
	fdct_fast( dctBlock, numberBlocks, fdctSTableArrayPtrs ) ;
        
  	for( bCounter = 0 ; bCounter < numberBlocks ; bCounter += 1 ) {
		for( y = 0; y < 8; y += 1 ) {
	    	for( x = 0; x < 8; x += 1 ) {
	    		POSTFDCT( dctBlock, out[ bCounter ][ y ][ x ], x, y, bCounter ) ;
			}
		}
	}

	free( ( void * ) dctBlockPtr ) ;
	free( ( void * ) fdctSTableArrayPtrs ) ;
    
	return TRUE ;           
}

/**** GetN **************************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * check the width and height given to ensure that they are equal (only square images
 * can be used) and that the dimensions are even numbers and if so return the length
 * of any column or row for N
 *
 * Inputs
 * ------
 *   width
 *   - the width (number of columns) of the image read in
 *   height
 *   - the height (number of rows) of the image read in
 * Return Values
 * ------ ------
 *     unsigned int - the dimension of the image that is both the width and height
 *     0            - the dimensions given are not valid, cannot accept image, abort
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static unsigned int GetN( unsigned int width, unsigned int height )
{
	if( width != height ) {
		fprintf( stderr, "This implementation of the codec only accepts square images.\n\n" ) ;
		return 0 ;
	}
	else if( width%2 != 0 ) { 
		fprintf( stderr, "This implementation of the codec only accepts images with even dimensions.\n\n" ) ;
		return 0 ;
	}
	
	return width ;
}

/**** GetNumberBlocks ***************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * get the user's choice for the number of blocks to perform with each iteration of the
 * ARM DCT routines
 *
 * the returned value will be a multiple of (N*N)/(BLOCKSIZE*BLOCKSIZE) as required
 * by the function Transform
 *
 * Inputs
 * ------
 *   N
 *   - the size of one of the dimensions of the array being worked on (number of rows
 *     or number of columns)
 * Return Values
 * ------ ------
 *     int - the number of blocks given by the user to perform with each iteration of
 *           of the ARM routines
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static unsigned int GetNumberBlocks( unsigned int N )
{
	unsigned int	totalNoBlocks ;
	unsigned int	numberBlocks ;
	
	printf( "The ARM Assembler routines can perform (I)DCT on any number of blocks with each call.\n\n" ) ;
	
	printf( "The number of blocks, by default, is a multiple of 2 since the functions operate on pairs\n" ) ;
	printf( "of blocks.  The number of blocks specified, however, need not be a multiple of 2, but it must\n" ) ;
	printf( "divide exactly into the total number of blocks that make up an image.\n\n" ) ;
	
	printf( "Please give the number of blocks for the ARM Assembler routines to code at a time.\n\n" ) ;
	
	totalNoBlocks = ( N * N )/( BLOCKSIZE * BLOCKSIZE ) ;
	
	printf( "This number must be a divisor of %d.\n\n", totalNoBlocks ) ;
	
	printf( "Number of blocks: " ) ;
	
	while( ( totalNoBlocks%( numberBlocks = ( int )ReadDouble( ) ) ) != 0 ) {
		printf( "The number given, %d, is not a divisor of %d.\n\n", numberBlocks, totalNoBlocks ) ;
		
		printf( "Please give another number: " ) ;
	}
	
	printf( "The ARM Assembler routines will code using %d blocks at a time.\n\n", numberBlocks ) ;
	
	return numberBlocks ;
}

/**** MakeDCTArrayPtr ***************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * create an array of DCTArray's to hold the data for ARM coding
 *
 * Inputs
 * ------
 *   option
 *   - the number of blocks in the DCTArray (number of entries for array) that will
 *     be coded with each call to ARM routines
 * Return Values
 * ------ ------
 *     DCTArray * - the allocated array with numberBlocks entries
 *     NULL       - an error occurred in allocating the memory
 *
 * Memory allocated (not deallocated)
 * ------ ---------  --- -----
 * the returned array of DCTArray's
 * deallocate after use
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static DCTArray *MakeDCTArrayPtr( unsigned int numberBlocks )
{
	return( ( DCTArray * )calloc( numberBlocks, sizeof( DCTArray ) ) ) ;
}

/**** Menu **************************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * print the menu of options to the screen (defined in standard way for NextTask 
 * function and will be called by NextTask)
 *
 * Inputs
 * ------
 *   numberOptions
 *   - the number of menu options that should be printed
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static void Menu( unsigned int numberOptions )
{
	if( numberOptions == DCT_OPTIONS ) {
		printf( " 1. I/DCT transform an image using C functions\n" ) ;
		printf( " 2. I/DCT transform an image using ARM Assembler functions\n" ) ;
		printf( " 3. DCT transform an image using C, IDCT using ARM Assembler\n" ) ;
		printf( " 4. DCT transform an image using ARM Assembler, IDCT using C\n" ) ;
		printf( "\n" ) ;
		printf( " 5. Change 'codec status messages' option\n" ) ;
		printf( " 6. Change 'max block sample output' option\n" ) ;
	}
	else {
		fprintf( stderr, "[Menu] Error in arguments, aborting.\n\n" ) ;
		/* function name given since intended as internal error for programmer */
	}
}

/**** PerformOption *****************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * check the option given and perform the correct task accordingly - either code
 * some set of data or change the status of the one of the global options
 *
 * Inputs
 * ------
 *   option
 *   - the option to be performed chosen by the user (returned by NextTask)
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
static void PerformOption( unsigned int option )
{
    switch( option ) {
    	case 1 :
    		Codec( 1, "perform C (I)DCT on" ) ;
    		break ;
        case 2 :
			Codec( 2, "perform ARM Assembler (I)DCT on" ) ;
			break ;
		case 3 :
			Codec( 3, "perform C DCT, ARM Assembler IDCT on" ) ;
			break ;
		case 4 :
			Codec( 4, "perform ARM Assembler DCT, C IDCT on" ) ;
			break ;
       	case 5 :
       		SetStatus( "status messages option", gStatus, LIMIT ) ;
       		break ;
       	case 6 :
       		SetStatus( "image results option", gResults, LIMIT ) ;
       		break ;
        default :
            fprintf( stderr, "[PerformOption] Some internal error has occured, suggest quitting!\n\n" ) ;
            break ;
    }
}

/**** RDCTFast **********************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * given a set of blocks for inverse DCT'ing, construct the structures necessary
 * for the ARM inverse DCT, including tranfering the data to the appropriate type,
 * inverse DCT the data using the ARM routines and retrieve the data afterwards
 * placing it in the array given
 *
 * Inputs
 * ------
 *   in

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -