34 |
#include "../global.h" |
#include "../global.h" |
35 |
#include "mem_transfer.h" |
#include "mem_transfer.h" |
36 |
#include "timer.h" |
#include "timer.h" |
37 |
|
#include "../bitstream/mbcoding.h" |
38 |
#include "../dct/fdct.h" |
#include "../dct/fdct.h" |
39 |
#include "../dct/idct.h" |
#include "../dct/idct.h" |
40 |
#include "../quant/quant_mpeg4.h" |
#include "../quant/quant_mpeg4.h" |
116 |
/* Quantize all blocks -- Intra mode */ |
/* Quantize all blocks -- Intra mode */ |
117 |
static __inline void |
static __inline void |
118 |
MBQuantIntra(const MBParam * pParam, |
MBQuantIntra(const MBParam * pParam, |
119 |
|
const FRAMEINFO * const frame, |
120 |
const MACROBLOCK * pMB, |
const MACROBLOCK * pMB, |
121 |
int16_t qcoeff[6 * 64], |
int16_t qcoeff[6 * 64], |
122 |
int16_t data[6*64]) |
int16_t data[6*64]) |
128 |
|
|
129 |
/* Quantize the block */ |
/* Quantize the block */ |
130 |
start_timer(); |
start_timer(); |
131 |
if (!(pParam->vol_flags & XVID_VOL_MPEGQUANT)) |
if (!(pParam->vol_flags & XVID_VOL_MPEGQUANT)) { |
132 |
quant_intra(&data[i * 64], &qcoeff[i * 64], pMB->quant, iDcScaler); |
quant_intra(&data[i * 64], &qcoeff[i * 64], pMB->quant, iDcScaler); |
133 |
else |
} else { |
134 |
quant4_intra(&data[i * 64], &qcoeff[i * 64], pMB->quant, iDcScaler); |
quant4_intra(&data[i * 64], &qcoeff[i * 64], pMB->quant, iDcScaler); |
135 |
|
} |
136 |
stop_quant_timer(); |
stop_quant_timer(); |
137 |
} |
} |
138 |
} |
} |
161 |
/* Quantize all blocks -- Inter mode */ |
/* Quantize all blocks -- Inter mode */ |
162 |
static __inline uint8_t |
static __inline uint8_t |
163 |
MBQuantInter(const MBParam * pParam, |
MBQuantInter(const MBParam * pParam, |
164 |
|
const FRAMEINFO * const frame, |
165 |
const MACROBLOCK * pMB, |
const MACROBLOCK * pMB, |
166 |
int16_t data[6 * 64], |
int16_t data[6 * 64], |
167 |
int16_t qcoeff[6 * 64], |
int16_t qcoeff[6 * 64], |
178 |
|
|
179 |
/* Quantize the block */ |
/* Quantize the block */ |
180 |
start_timer(); |
start_timer(); |
181 |
if (!(pParam->vol_flags & XVID_VOL_MPEGQUANT)) |
if (!(pParam->vol_flags & XVID_VOL_MPEGQUANT)) { |
182 |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], pMB->quant); |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], pMB->quant); |
183 |
else |
if ( (sum) && (frame->vop_flags & XVID_VOP_TRELLISQUANT) ) { |
184 |
|
sum = dct_quantize_trellis_inter_h263_c (&qcoeff[i*64], &data[i*64], pMB->quant)+1; |
185 |
|
limit = 1; |
186 |
|
} |
187 |
|
} else { |
188 |
sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], pMB->quant); |
sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], pMB->quant); |
189 |
|
// if ( (sum) && (frame->vop_flags & XVID_VOP_TRELLISQUANT) ) |
190 |
|
// sum = dct_quantize_trellis_inter_mpeg_c (&qcoeff[i*64], &data[i*64], pMB->quant)+1; |
191 |
|
} |
192 |
stop_quant_timer(); |
stop_quant_timer(); |
193 |
|
|
194 |
/* |
/* |
213 |
|
|
214 |
/* Set the corresponding cbp bit */ |
/* Set the corresponding cbp bit */ |
215 |
cbp |= code_block << (5 - i); |
cbp |= code_block << (5 - i); |
|
|
|
216 |
} |
} |
217 |
|
|
218 |
return(cbp); |
return(cbp); |
384 |
MBfDCT(pParam, frame, pMB, x_pos, y_pos, data); |
MBfDCT(pParam, frame, pMB, x_pos, y_pos, data); |
385 |
|
|
386 |
/* Quantize the block */ |
/* Quantize the block */ |
387 |
MBQuantIntra(pParam, pMB, data, qcoeff); |
MBQuantIntra(pParam, frame, pMB, data, qcoeff); |
388 |
|
|
389 |
/* DeQuantize the block */ |
/* DeQuantize the block */ |
390 |
MBDeQuantIntra(pParam, pMB->quant, data, qcoeff); |
MBDeQuantIntra(pParam, pMB->quant, data, qcoeff); |
421 |
limit = PVOP_TOOSMALL_LIMIT + ((pMB->quant == 1)? 1 : 0); |
limit = PVOP_TOOSMALL_LIMIT + ((pMB->quant == 1)? 1 : 0); |
422 |
|
|
423 |
/* Quantize the block */ |
/* Quantize the block */ |
424 |
cbp = MBQuantInter(pParam, pMB, data, qcoeff, 0, limit); |
cbp = MBQuantInter(pParam, frame, pMB, data, qcoeff, 0, limit); |
425 |
|
|
426 |
/* DeQuantize the block */ |
/* DeQuantize the block */ |
427 |
MBDeQuantInter(pParam, pMB->quant, data, qcoeff, cbp); |
MBDeQuantInter(pParam, pMB->quant, data, qcoeff, cbp); |
459 |
limit = BVOP_TOOSMALL_LIMIT; |
limit = BVOP_TOOSMALL_LIMIT; |
460 |
|
|
461 |
/* Quantize the block */ |
/* Quantize the block */ |
462 |
cbp = MBQuantInter(pParam, pMB, data, qcoeff, 1, limit); |
cbp = MBQuantInter(pParam, frame, pMB, data, qcoeff, 1, limit); |
463 |
|
|
464 |
/* |
/* |
465 |
* History comment: |
* History comment: |