20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: estimation_rd_based.c,v 1.1.2.8 2003-10-11 16:36:10 syskin Exp $ |
* $Id: estimation_rd_based.c,v 1.1.2.9 2003-11-13 23:11:24 edgomez Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
60 |
int sum; |
int sum; |
61 |
int bits; |
int bits; |
62 |
int distortion = 0; |
int distortion = 0; |
|
int i; |
|
63 |
|
|
64 |
fdct(data); |
fdct(data); |
65 |
|
|
73 |
if (quant_type) dequant_h263_inter(dqcoeff, coeff, quant); |
if (quant_type) dequant_h263_inter(dqcoeff, coeff, quant); |
74 |
else dequant_mpeg_inter(dqcoeff, coeff, quant); |
else dequant_mpeg_inter(dqcoeff, coeff, quant); |
75 |
|
|
76 |
for (i = 0; i < 64; i++) |
distortion = sse8_16bit(data, dqcoeff, 8*sizeof(int16_t)); |
|
distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); |
|
|
|
|
77 |
} else { |
} else { |
78 |
|
const static int16_t zero_block[64] = |
79 |
|
{ |
80 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
81 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
82 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
83 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
84 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
85 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
86 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
87 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
88 |
|
}; |
89 |
bits = 0; |
bits = 0; |
90 |
for (i = 0; i < 64; i++) |
distortion = sse8_16bit(data, zero_block, 8*sizeof(int16_t)); |
|
distortion += data[i]*data[i]; |
|
91 |
} |
} |
92 |
|
|
93 |
|
|
94 |
return bits + (LAMBDA*distortion)/(quant*quant); |
return bits + (LAMBDA*distortion)/(quant*quant); |
95 |
} |
} |
96 |
|
|
164 |
bits[1] += coded = CodeCoeffIntra_CalcBits(qcoeff, scan_tables[direction]); |
bits[1] += coded = CodeCoeffIntra_CalcBits(qcoeff, scan_tables[direction]); |
165 |
if (coded > 0) cbp[1] |= 1 << (5 - block); |
if (coded > 0) cbp[1] |= 1 << (5 - block); |
166 |
|
|
167 |
for (i = 0; i < 64; i++) |
distortion = sse8_16bit(coeff, dqcoeff, 8*sizeof(int16_t)); |
|
distortion += (coeff[i] - dqcoeff[i])*(coeff[i] - dqcoeff[i]); |
|
|
|
|
168 |
|
|
169 |
return (LAMBDA*distortion)/(quant*quant); |
return (LAMBDA*distortion)/(quant*quant); |
|
|
|
170 |
} |
} |
171 |
|
|
172 |
|
|