15 |
#include "utils/emms.h" |
#include "utils/emms.h" |
16 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
17 |
#include "quant/adapt_quant.h" |
#include "quant/adapt_quant.h" |
18 |
|
#include "quant/quant_matrix.h" |
19 |
|
|
20 |
#define ENC_CHECK(X) if(!(X)) return XVID_ERR_FORMAT |
#define ENC_CHECK(X) if(!(X)) return XVID_ERR_FORMAT |
21 |
|
|
217 |
Bitstream bs; |
Bitstream bs; |
218 |
uint32_t bits; |
uint32_t bits; |
219 |
uint16_t quant_type = 0; |
uint16_t quant_type = 0; |
220 |
uint16_t quant_change = 0; |
uint16_t write_vol_header = 0; |
|
|
|
|
IMAGE *pCurrent = &(pEnc->sCurrent); |
|
221 |
|
|
222 |
start_global_timer(); |
start_global_timer(); |
223 |
|
|
272 |
|
|
273 |
if(pEnc->mbParam.quant_type != quant_type) { |
if(pEnc->mbParam.quant_type != quant_type) { |
274 |
pEnc->mbParam.quant_type = quant_type; |
pEnc->mbParam.quant_type = quant_type; |
275 |
quant_change = 1; |
write_vol_header = 1; |
276 |
} |
} |
277 |
else |
else |
278 |
quant_change = 0; |
write_vol_header = 0; |
279 |
|
|
280 |
|
if ((pEnc->mbParam.global_flags & XVID_CUSTOM_QMATRIX) > 0) |
281 |
|
{ |
282 |
|
int ret1, ret2; |
283 |
|
ret1 = set_intra_matrix(pFrame->quant_intra_matrix); |
284 |
|
ret2 = set_inter_matrix(pFrame->quant_inter_matrix); |
285 |
|
if(write_vol_header == 0) |
286 |
|
write_vol_header = ret1 | ret2; |
287 |
|
} |
288 |
|
|
289 |
if (pFrame->intra < 0) |
if (pFrame->intra < 0) |
290 |
{ |
{ |
293 |
|
|
294 |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
295 |
else |
else |
296 |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, quant_change); |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, write_vol_header); |
297 |
} |
} |
298 |
else |
else |
299 |
{ |
{ |
300 |
if (pFrame->intra == 1) |
if (pFrame->intra == 1) |
301 |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
302 |
else |
else |
303 |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, quant_change); |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, write_vol_header); |
304 |
} |
} |
305 |
|
|
306 |
BitstreamPutBits(&bs, 0xFFFF, 16); |
BitstreamPutBits(&bs, 0xFFFF, 16); |
356 |
int16_t dct_codes[6][64]; |
int16_t dct_codes[6][64]; |
357 |
int16_t qcoeff[6][64]; |
int16_t qcoeff[6][64]; |
358 |
uint16_t x, y; |
uint16_t x, y; |
|
IMAGE *pCurrent = &pEnc->sCurrent; |
|
359 |
|
|
360 |
pEnc->iFrameNum = 0; |
pEnc->iFrameNum = 0; |
361 |
pEnc->mbParam.rounding_type = 1; |
pEnc->mbParam.rounding_type = 1; |
379 |
|
|
380 |
CodeIntraMB(pEnc, pMB); |
CodeIntraMB(pEnc, pMB); |
381 |
|
|
382 |
MBTransQuantIntra(&pEnc->mbParam, x, y, dct_codes, qcoeff, pCurrent); |
MBTransQuantIntra(&pEnc->mbParam, x, y, dct_codes, qcoeff, &pEnc->sCurrent); |
383 |
|
|
384 |
start_timer(); |
start_timer(); |
385 |
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |
MBPrediction(&pEnc->mbParam, x, y, pEnc->mbParam.mb_width, qcoeff, pEnc->pMBs); |