[FFmpeg-devel] [Fwd: Summer of code small task patch]

Michael Niedermayer michaelni
Wed Mar 25 21:22:15 CET 2009


On Wed, Mar 25, 2009 at 05:43:05PM +0200, Dylan Yudaken wrote:
>
> Kostya wrote:
[...]
> /**
>  * Initialise the Double Precision Discrete Cosine Transform
>  * functions fdct & idct
>  *
>  */
> void ref_dct_init(void)

av_cold and non static functions needs a ff prefix


> {
>     unsigned int i, j;
>     double c0;
> 
>     c0 = sqrt(0.125);
>     for (i = 0; i < 8; ++i) {
>         for (j = 0; j < 8; ++j) {
>             coefficients[i * 8 + j] = c0 * cos(i * (M_PI / 8.0) * (j + 0.5));

id multiply i and j+0.5 together first, as this can be done without
rounding errors and then mutiply the rest, not that this would make any
real difference ...

also the c0 variable is not really needed



>         }
>         /* c0 = sqrt(0.125) only for i=0 (first iteration) else c0 = 0.5 */
>         c0 = 0.5;
>     }
> }
> 
> /**
>  * Transform 8x8 block of data with a double precision forward DCT <br>
>  * This is a reference implementation.
>  *
>  * @param block Pointer to 8x8 block of data to transform
>  */
> void ref_fdct(short *block)
> {
> 
>     /* This implements the equation block = A*block*A' */
> 
>     unsigned int i, j, k;
>     double tmp;
>     double out[8 * 8];
> 
>     /* out = coefficients*block */
>     for (i = 0; i < 8; ++i) {
>         for (j = 0; j < 8; ++j) {

>             tmp = 0;

declaration and init can be merged


>             for (k = 0; k < 8; ++k) {
>                 tmp += coefficients[i * 8 + k] * block[8 * k + j];
>             }
>             out[8 * i + j] = tmp;
>         }
>     }
>     /* block = out*(coefficients') */
>     for (i = 0; i < 8; ++i) {
>         for (j = 0; j < 8; ++j) {
>             tmp = 0;
>             for (k = 0; k < 8; ++k) {
>                 tmp += out[8 * i + k] * coefficients[j * 8 + k];
>             }
>             block[8 * i + j] = (short) floor(8.0 * tmp + 0.499999999);
>         }
>     }

the *8 is avoidable

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090325/feb20bb8/attachment.pgp>



More information about the ffmpeg-devel mailing list