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]); |