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; |
221 |
|
|
222 |
IMAGE *pCurrent = &(pEnc->sCurrent); |
IMAGE *pCurrent = &(pEnc->sCurrent); |
223 |
|
|
274 |
|
|
275 |
if(pEnc->mbParam.quant_type != quant_type) { |
if(pEnc->mbParam.quant_type != quant_type) { |
276 |
pEnc->mbParam.quant_type = quant_type; |
pEnc->mbParam.quant_type = quant_type; |
277 |
quant_change = 1; |
write_vol_header = 1; |
278 |
} |
} |
279 |
else |
else |
280 |
quant_change = 0; |
write_vol_header = 0; |
281 |
|
|
282 |
|
if ((pEnc->mbParam.global_flags & XVID_CUSTOM_QMATRIX) > 0) |
283 |
|
{ |
284 |
|
int ret1, ret2; |
285 |
|
ret1 = set_intra_matrix(pFrame->quant_intra_matrix); |
286 |
|
ret2 = set_inter_matrix(pFrame->quant_inter_matrix); |
287 |
|
if(write_vol_header == 0) |
288 |
|
write_vol_header = ret1 | ret2; |
289 |
|
} |
290 |
|
|
291 |
if (pFrame->intra < 0) |
if (pFrame->intra < 0) |
292 |
{ |
{ |
295 |
|
|
296 |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
297 |
else |
else |
298 |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, quant_change); |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 0, write_vol_header); |
299 |
} |
} |
300 |
else |
else |
301 |
{ |
{ |
302 |
if (pFrame->intra == 1) |
if (pFrame->intra == 1) |
303 |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
pFrame->intra = FrameCodeI(pEnc, &bs, &bits); |
304 |
else |
else |
305 |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, quant_change); |
pFrame->intra = FrameCodeP(pEnc, &bs, &bits, 1, write_vol_header); |
306 |
} |
} |
307 |
|
|
308 |
BitstreamPutBits(&bs, 0xFFFF, 16); |
BitstreamPutBits(&bs, 0xFFFF, 16); |