Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCT with factor 5 introduced #228

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib_dsp/api/dsp_dct.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
*/
void dsp_dct_forward48(int32_t output[48], int32_t input[48]);

/** This function performs a 40 point DCT
*
* The first output is the DC value, subsequent values are the values for
* the basis vectors of half a cosine, a whole cosine, 1.5 cosine, 2
* consines, etc.
*
* \param input input values to the DCT
* \param output DCT values.
*/
void dsp_dct_forward40(int32_t output[40], int32_t input[40]);

/** This function performs a 32 point DCT
*
* The first output is the DC value, subsequent values are the values for
Expand All @@ -43,6 +54,17 @@ void dsp_dct_forward32(int32_t output[32], int32_t input[32]);
*/
void dsp_dct_forward24(int32_t output[24], int32_t input[24]);

/** This function performs a 20 point DCT
*
* The first output is the DC value, subsequent values are the values for
* the basis vectors of half a cosine, a whole cosine, 1.5 cosine, 2
* consines, etc.
*
* \param input input values to the DCT
* \param output DCT values.
*/
void dsp_dct_forward20(int32_t output[20], int32_t input[20]);

/** This function performs a 16 point DCT
*
* The first output is the DC value, subsequent values are the values for
Expand All @@ -65,6 +87,17 @@ void dsp_dct_forward16(int32_t output[16], int32_t input[16]);
*/
void dsp_dct_forward12(int32_t output[12], int32_t input[12]);

/** This function performs a 10 point DCT
*
* The first output is the DC value, subsequent values are the values for
* the basis vectors of half a cosine, a whole cosine, 1.5 cosine, 2
* consines, etc.
*
* \param input input values to the DCT
* \param output DCT values.
*/
void dsp_dct_forward10(int32_t output[10], int32_t input[10]);

/** This function performs a 8 point DCT
*
* The first output is the DC value, subsequent values are the values for
Expand Down
55 changes: 55 additions & 0 deletions lib_dsp/src/dsp_dct.xc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,50 @@ static const int32_t costable48[24] = {
70263695,
};

static const int32_t costable10[5] = {
2121044560,
1913421940,
1518500249,
974937174,
335940455,
};

static const int32_t costable20[10] = {
2140863672,
2088148503,
1984016188,
1831030810,
1632959376,
1394679064,
1122057123,
821806413,
501320101,
168489625,
};

static const int32_t costable40[20] = {
2145828015,
2132598272,
2106220351,
2066856882,
2014750552,
1950222615,
1873670908,
1785567396,
1686455267,
1576945581,
1457713501,
1329494132,
1193077990,
1049306126,
899064940,
743280720,
582913927,
418953276,
252409639,
84309812,
};

static inline int32_t mulcos(int32_t x, int32_t cos) {
long long r = cos * (long long) x;
return r >> 31;
Expand Down Expand Up @@ -139,6 +183,14 @@ void dsp_dct_forward##N(int32_t output[N], int32_t input[N]) { \
} \
}

void dsp_dct_forward5(int32_t output[5], int32_t input[5]) {
output[0] = input[0] + input[1] + input[2] + input[3] + input[4];
output[1] = mulcos(input[0] - input[4], 2042378317) + mulcos(input[1] - input[3], 1262259218);
output[2] = mulcos(input[0] + input[4], 1737350766) + mulcos(input[1] + input[3], -663608941) - input[2];
output[3] = mulcos(input[0] - input[4], 1262259218) + mulcos(input[1] - input[3], -2042378316);
output[4] = mulcos(input[0] + input[4], 663608942) + mulcos(input[1] + input[3], -1737350765) + input[2];
}

void dsp_dct_forward4(int32_t output[4], int32_t input[4]) {
int32_t i03 = input[0] + input[3];
int32_t i12 = input[1] + input[2];
Expand Down Expand Up @@ -171,10 +223,13 @@ void dsp_dct_forward1(int32_t output[1], int32_t input[1]) {

DCT(6,3)
DCT(8,4)
DCT(10,5)
DCT(12,6)
DCT(16,8)
DCT(20,10)
DCT(24,12)
DCT(32,16)
DCT(40,20)
DCT(48,24)

#ifdef INCLUDE_REFERENCE_DCT
Expand Down