[FFmpeg-devel] [Fwd: Summer of code small task patch]
Michael Niedermayer
michaelni
Sun Mar 29 22:37:47 CEST 2009
On Sun, Mar 29, 2009 at 05:19:43PM +0200, Dylan Yudaken wrote:
> Michael Niedermayer wrote:
>> renaming things should be a seperate patch
>> actually a patch should either do functional changes or non functional not
>> both
>>
>>
> I wasnt sure what exactly to do here or if the conversation reached a
> conclusion. I have included a full patch but if you need it split I guess I
> can go and do that - not 100% sure how though.
for example:
first patch you replace the dct but leave the function names
second patch you rename the functions
[...]
> +#include "libavutil/mathematics.h"
> +
> +#ifndef M_SQRT2
> +#define M_SQRT2 (1.0/M_SQRT1_2)
> +#endif
this wasnt what i meant (especially if it requires the ifdefs),
you can keep sqrt(2), the compiler should optimize it out
> +
> +static double coefficients[8 * 8];
> +
> +/**
> + * Initialize the Double Precision Discrete Cosine Transform
> + * functions fdct & idct.
> + */
> +av_cold void ff_ref_dct_init(void)
> +{
> + unsigned int i, j;
> +
> +
> + for (j = 0; j < 8; ++j) {
> + coefficients[j] = 1;
> + }
> + for (i = 8; i < 64; i+=8) {
> + for (j = 0; j < 8; ++j) {
> + coefficients[i + j] = M_SQRT2 * cos(i * (j+0.5) * (M_PI / 64.0));
> + }
> + }
> +
the loops can be merged
}
> +
> +/**
> + * 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 ff_ref_fdct(short *block)
> +{
> + /* This implements the equation block = A*block*A' */
> +
> + unsigned int i, j, k;
> + double out[8 * 8];
> +
> + /* out = coefficients*block */
> + for (i = 0; i < 64; i+=8) {
> + for (j = 0; j < 8; ++j) {
> + double tmp = 0;
> + for (k = 0; k < 8; ++k) {
> + tmp += coefficients[i + k] * block[k * 8 + j];
> + }
> + out[i + j] = tmp;
> + }
> + }
> +
> + /* block = out*(coefficients') */
> + for (i = 0; i < 64; i+=8) {
> + for (j = 0; j < 8; ++j) {
> + double tmp = 0;
> + for (k = 0; k < 8; ++k) {
> + tmp += out[i + k] * coefficients[j * 8 + k];
> + }
> + block[i + j] = (short) floor(tmp + 0.499999999);
the cast is unneeded
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20090329/c9c481e7/attachment.pgp>
More information about the ffmpeg-devel
mailing list