2014-10-25 13:19 GMT+02:00 Christophe Gisquet <[email protected]>:
> Patch #3 uses mathematically more correct values, which happens to match
> another dv implementation (cedocida). It does not seem to affect that
> much the decoded output, as there is PSNR variations on the 3rd decimal
> at most. The best I got was, using a resized version of lena.ppm, a PSNR
> going from 49.35dB to 49.36dB. It would be ok not to integrate it, as
> one may argue they were devised with the simple_idct implementation in
> mind (I haven't checked).
>
> Patch #4 fixes the actual issue. As I don't want to bother determining
> how the table was incorrectly mangled, I've preferred regenerating it.
And here's a program to regenerate it (hopefully I haven't mangled too
much when testing other stuff).
--
Christophe
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#define CS(n) cos(n*M_PI/16.0)
#define SCAN_8x8 1
#define USE_ZZ_SCAN 1
int main(void)
{
//double w[8] = { 1.0, CS(4)/(4*CS(7)*CS(2)), CS(4)/(2*CS(6)), 1.0/(2*CS(5)), 7.0/8, CS(4)/CS(3), CS(4)/CS(2), CS(4)/CS(1) };
double w[8] = { 1.00000000, 0.98078528, 0.92387953, 0.89997622, 0.87500000, 0.85043009, 0.76536686, 0.72095982 };
int i, j, order;
# if USE_ZZ_SCAN
const uint8_t dv_zz[64] = {
# if SCAN_8x8
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46,
53, 60, 61, 54, 47, 55, 62, 63
# else
0, 8, 1, 9, 16, 24, 2, 10,
17, 25, 32, 40, 48, 56, 33, 41,
18, 26, 3, 11, 4, 12, 19, 27,
34, 42, 49, 57, 50, 58, 35, 43,
20, 28, 5, 13, 6, 14, 21, 29,
36, 44, 51, 59, 52, 60, 37, 45,
22, 30, 7, 15, 23, 31, 38, 46,
53, 61, 54, 62, 39, 47, 55, 63,
# endif
};
#endif
#if 0
const uint16_t ff_dv_iweight_88[64] = {
32768, 16705, 16705, 17734, 17032, 17734, 18205, 18081,
18081, 18205, 18725, 18562, 19195, 18562, 18725, 19266,
19091, 19705, 19705, 19091, 19266, 21407, 19643, 20267,
20228, 20267, 19643, 21407, 22725, 21826, 20853, 20806,
20806, 20853, 21826, 22725, 23170, 23170, 21407, 21400,
21407, 23170, 23170, 24598, 23786, 22018, 22018, 23786,
24598, 25251, 24465, 22654, 24465, 25251, 25972, 25172,
25172, 25972, 26722, 27969, 26722, 29692, 29692, 31521,
};
static const int dv_weight_88[64] = {
131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
};
double sum = 0;
double sqsum = 0;
for(i=0; i<64; i++)
{
double val = ff_dv_iweight_88[i]*dv_weight_88[i]/(double)(0xFFFFFFFFU);
sum += val;
sqsum += val*val;
}
printf("std dev: %e\n", sum, sqsum, sqrt(sqsum-sum*sum/64.0));
#else
//for(j=0; j<8; j++) { printf(" %1.8f", w[j]); } printf("\n");
for(order = 0, j=0; j<8; j++)
{
for(i=0; i<8; i++, order++)
{
# if USE_ZZ_SCAN
int zz = dv_zz[order];
int v = zz/8, h = zz%8;
# else
int v = j, h = i;
# endif
double coeff;
#if SCAN_8x8 // 8x8
if(!v && !h) coeff=1.0/4.0;
else
{
coeff = w[v];
#else // 2x4x8
if(!v && !h) coeff=1.0/2.0;
else
{
if(v<4) coeff=w[2*v];
else coeff=w[2*v-8];
#endif
coeff *= w[h]/2.0;
}
printf(" %5d,", (int)(8192/coeff+0.5));
}
printf("\n");
}
#endif
return 0;
}
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel