| 1 |
#define HAVE_SPECK |
| 2 |
|
| 3 |
#include "libQccPack.h" |
| 4 |
#include <stdio.h> |
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
/* This definitions ain't in libQccPack.h ... */ |
| 8 |
typedef struct |
| 9 |
{ |
| 10 |
char type; |
| 11 |
int level; |
| 12 |
int origin_row; |
| 13 |
int origin_col; |
| 14 |
int num_rows; |
| 15 |
int num_cols; |
| 16 |
char significance; |
| 17 |
} QccSPECKSet; |
| 18 |
#define QCCSPECK_SET_S 0 |
| 19 |
#define QCCSPECK_SET_I 1 |
| 20 |
|
| 21 |
static int QccSPECKSetSize(QccSPECKSet *set, |
| 22 |
const QccWAVSubbandPyramid *coefficients, |
| 23 |
int subband) /* specifies which chunk (0, 1, 2, 3), though |
| 24 |
its mechanism seems quite complex. */ |
| 25 |
{ |
| 26 |
if (QccWAVSubbandPyramidSubbandOffsets(coefficients, /* input */ |
| 27 |
subband, /* input */ |
| 28 |
&set->origin_row, /* output */ |
| 29 |
&set->origin_col)) /* output */ |
| 30 |
{ |
| 31 |
QccErrorAddMessage("(QccSPECKSetSize): Error calling QccWAVSubbandPyramidSubbandOffsets()"); |
| 32 |
return(1); |
| 33 |
} |
| 34 |
if (QccWAVSubbandPyramidSubbandSize(coefficients, /* input */ |
| 35 |
subband, /* input */ |
| 36 |
&set->num_rows, /* output */ |
| 37 |
&set->num_cols)) /* output */ |
| 38 |
{ |
| 39 |
QccErrorAddMessage("(QccSPECKSetSize): Error calling QccWAVSubbandPyramidSubbandSize()"); |
| 40 |
return(1); |
| 41 |
} |
| 42 |
|
| 43 |
return(0); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
void print_size( const QccSPECKSet* set ) |
| 49 |
{ |
| 50 |
printf(" start position: %d, %d\n", set->origin_col, set->origin_row ); |
| 51 |
printf(" length : %d, %d\n", set->num_cols, set->num_rows ); |
| 52 |
} |
| 53 |
|
| 54 |
int main( int argc, char* argv[] ) |
| 55 |
{ |
| 56 |
if( argc != 4 ) |
| 57 |
{ |
| 58 |
printf("Usage: ./a.out dim_x, dim_y, num_of_levels\n"); |
| 59 |
return 1; |
| 60 |
} |
| 61 |
|
| 62 |
const long dim_x = atol( argv[1] ); |
| 63 |
const long dim_y = atol( argv[2] ); |
| 64 |
const long num_lev = atol( argv[3] ); |
| 65 |
|
| 66 |
|
| 67 |
/* Create a subband pyramid */ |
| 68 |
QccWAVSubbandPyramid pyramid; |
| 69 |
QccWAVSubbandPyramidInitialize( &pyramid ); |
| 70 |
pyramid.num_levels = num_lev; |
| 71 |
pyramid.num_cols = dim_x; |
| 72 |
pyramid.num_rows = dim_y; |
| 73 |
if (QccWAVSubbandPyramidAlloc( &pyramid )) |
| 74 |
{ |
| 75 |
printf("(QccSPECKEncode): Error calling QccWAVSubbandPyramidAlloc()"); |
| 76 |
return 1; |
| 77 |
} |
| 78 |
|
| 79 |
/* Create a QccSPECKSet */ |
| 80 |
QccSPECKSet set; |
| 81 |
set.type = QCCSPECK_SET_S; |
| 82 |
set.level = num_lev; |
| 83 |
|
| 84 |
for( int i = 0; i < 4; i++ ) |
| 85 |
{ |
| 86 |
QccSPECKSetSize( &set, &pyramid, i ); |
| 87 |
printf("subband = %d\n", i ); |
| 88 |
print_size( &set ); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
QccWAVSubbandPyramidFree( &pyramid ); |
| 93 |
} |