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.6 2003-10-03 16:57:55 edgomez Exp $ |
* $Id: estimation_rd_based.c,v 1.1.2.7 2003-10-07 13:02:35 edgomez Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
40 |
#include "motion.h" |
#include "motion.h" |
41 |
#include "sad.h" |
#include "sad.h" |
42 |
#include "../bitstream/zigzag.h" |
#include "../bitstream/zigzag.h" |
43 |
#include "../quant/quant_mpeg4.h" |
#include "../quant/quant.h" |
|
#include "../quant/quant_h263.h" |
|
44 |
#include "../bitstream/vlc_codes.h" |
#include "../bitstream/vlc_codes.h" |
45 |
#include "../dct/fdct.h" |
#include "../dct/fdct.h" |
46 |
#include "motion_inlines.h" |
#include "motion_inlines.h" |
64 |
|
|
65 |
fdct(data); |
fdct(data); |
66 |
|
|
67 |
if (quant_type) sum = quant_inter(coeff, data, quant); |
if (quant_type) sum = quant_h263_inter(coeff, data, quant); |
68 |
else sum = quant4_inter(coeff, data, quant); |
else sum = quant_mpeg_inter(coeff, data, quant); |
69 |
|
|
70 |
if (sum > 0) { |
if (sum > 0) { |
71 |
*cbp |= 1 << (5 - block); |
*cbp |= 1 << (5 - block); |
72 |
bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_table); |
bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_table); |
73 |
|
|
74 |
if (quant_type) dequant_inter(dqcoeff, coeff, quant); |
if (quant_type) dequant_h263_inter(dqcoeff, coeff, quant); |
75 |
else dequant4_inter(dqcoeff, coeff, quant); |
else dequant_mpeg_inter(dqcoeff, coeff, quant); |
76 |
|
|
77 |
for (i = 0; i < 64; i++) |
for (i = 0; i < 64; i++) |
78 |
distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); |
distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); |
104 |
fdct(data); |
fdct(data); |
105 |
data[0] -= 1024; |
data[0] -= 1024; |
106 |
|
|
107 |
if (quant_type) quant_intra(coeff, data, quant, iDcScaler); |
if (quant_type) quant_h263_intra(coeff, data, quant, iDcScaler); |
108 |
else quant4_intra(coeff, data, quant, iDcScaler); |
else quant_mpeg_intra(coeff, data, quant, iDcScaler); |
109 |
|
|
110 |
b_dc = coeff[0]; |
b_dc = coeff[0]; |
111 |
if (block < 4) { |
if (block < 4) { |
120 |
else bits += BITS_MULT*dcc_tab[coeff[0] + 255].len; |
else bits += BITS_MULT*dcc_tab[coeff[0] + 255].len; |
121 |
|
|
122 |
coeff[0] = b_dc; |
coeff[0] = b_dc; |
123 |
if (quant_type) dequant_intra(dqcoeff, coeff, quant, iDcScaler); |
if (quant_type) dequant_h263_intra(dqcoeff, coeff, quant, iDcScaler); |
124 |
else dequant4_intra(dqcoeff, coeff, quant, iDcScaler); |
else dequant_mpeg_intra(dqcoeff, coeff, quant, iDcScaler); |
125 |
|
|
126 |
for (i = 0; i < 64; i++) |
for (i = 0; i < 64; i++) |
127 |
distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); |
distortion += (data[i] - dqcoeff[i])*(data[i] - dqcoeff[i]); |