69 |
|
|
70 |
MBFIELDTEST_PTR MBFieldTest; |
MBFIELDTEST_PTR MBFieldTest; |
71 |
|
|
|
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
|
|
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
|
|
|
|
72 |
#define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ |
#define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ |
73 |
|
|
74 |
void |
void |
83 |
|
|
84 |
uint32_t stride = pParam->edged_width; |
uint32_t stride = pParam->edged_width; |
85 |
uint32_t stride2 = stride / 2; |
uint32_t stride2 = stride / 2; |
86 |
uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); |
uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8); |
87 |
uint32_t i; |
uint32_t i; |
88 |
uint32_t iQuant = frame->quant; |
const uint32_t iQuant = pMB->quant; |
89 |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
90 |
IMAGE *pCurrent = &frame->image; |
IMAGE *pCurrent = &frame->image; |
91 |
|
|
92 |
start_timer(); |
start_timer(); |
93 |
if ((frame->global_flags & XVID_REDUCED)) |
if ((frame->vop_flags & XVID_REDUCED)) |
94 |
{ |
{ |
95 |
pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); |
pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); |
96 |
pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); |
pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); |
119 |
/* XXX: rrv+interlacing is buggy */ |
/* XXX: rrv+interlacing is buggy */ |
120 |
start_timer(); |
start_timer(); |
121 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
122 |
if ((frame->global_flags & XVID_INTERLACING) && |
if ((frame->vol_flags & XVID_INTERLACING) && |
123 |
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
124 |
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
125 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
133 |
fdct(&data[i * 64]); |
fdct(&data[i * 64]); |
134 |
stop_dct_timer(); |
stop_dct_timer(); |
135 |
|
|
136 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
137 |
start_timer(); |
start_timer(); |
138 |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
139 |
stop_quant_timer(); |
stop_quant_timer(); |
146 |
/* speedup: dont decode when encoding only ivops */ |
/* speedup: dont decode when encoding only ivops */ |
147 |
if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0) |
if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0) |
148 |
{ |
{ |
149 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
150 |
start_timer(); |
start_timer(); |
151 |
dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
152 |
stop_iquant_timer(); |
stop_iquant_timer(); |
172 |
} |
} |
173 |
|
|
174 |
start_timer(); |
start_timer(); |
175 |
if ((frame->global_flags & XVID_REDUCED)) |
if ((frame->vop_flags & XVID_REDUCED)) |
176 |
{ |
{ |
177 |
copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
178 |
copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride); |
207 |
|
|
208 |
uint32_t stride = pParam->edged_width; |
uint32_t stride = pParam->edged_width; |
209 |
uint32_t stride2 = stride / 2; |
uint32_t stride2 = stride / 2; |
210 |
uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8); |
uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8); |
211 |
uint32_t i; |
uint32_t i; |
212 |
uint32_t iQuant = frame->quant; |
const uint32_t iQuant = pMB->quant; |
213 |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
uint8_t *pY_Cur, *pU_Cur, *pV_Cur; |
214 |
uint8_t cbp = 0; |
uint8_t cbp = 0; |
215 |
uint32_t sum; |
uint32_t sum; |
216 |
IMAGE *pCurrent = &frame->image; |
IMAGE *pCurrent = &frame->image; |
217 |
|
|
218 |
if ((frame->global_flags & XVID_REDUCED)) |
if ((frame->vop_flags & XVID_REDUCED)) |
219 |
{ |
{ |
220 |
pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); |
pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5); |
221 |
pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); |
pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4); |
228 |
|
|
229 |
start_timer(); |
start_timer(); |
230 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
231 |
if ((frame->global_flags & XVID_INTERLACING) && |
if ((frame->vol_flags & XVID_INTERLACING) && |
232 |
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
233 |
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
234 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
246 |
fdct(&data[i * 64]); |
fdct(&data[i * 64]); |
247 |
stop_dct_timer(); |
stop_dct_timer(); |
248 |
|
|
249 |
if (pParam->m_quant_type == 0) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
250 |
start_timer(); |
start_timer(); |
251 |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); |
252 |
stop_quant_timer(); |
stop_quant_timer(); |
259 |
if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) || |
if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) || |
260 |
(qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { |
(qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { |
261 |
|
|
262 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
263 |
start_timer(); |
start_timer(); |
264 |
dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
265 |
stop_iquant_timer(); |
stop_iquant_timer(); |
283 |
} |
} |
284 |
|
|
285 |
start_timer(); |
start_timer(); |
286 |
if ((frame->global_flags & XVID_REDUCED)) |
if ((frame->vop_flags & XVID_REDUCED)) |
287 |
{ |
{ |
288 |
if (cbp & 32) |
if (cbp & 32) |
289 |
add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride); |
329 |
MBTrans(pParam,frame,pMB,x_pos,y_pos,data); |
MBTrans(pParam,frame,pMB,x_pos,y_pos,data); |
330 |
MBfDCT(pParam,frame,pMB,data); |
MBfDCT(pParam,frame,pMB,data); |
331 |
MBQuantIntra(pParam,frame,pMB,data,qcoeff); |
MBQuantIntra(pParam,frame,pMB,data,qcoeff); |
332 |
MBDeQuantIntra(pParam,frame->quant,data,qcoeff); |
MBDeQuantIntra(pParam,pMB->quant,data,qcoeff); |
333 |
MBiDCT(data,0x3F); |
MBiDCT(data,0x3F); |
334 |
MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,0x3F); |
MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,0x3F); |
335 |
} |
} |
349 |
/* there is no MBTrans for Inter block, that's done in motion compensation already */ |
/* there is no MBTrans for Inter block, that's done in motion compensation already */ |
350 |
|
|
351 |
MBfDCT(pParam,frame,pMB,data); |
MBfDCT(pParam,frame,pMB,data); |
352 |
cbp = MBQuantInter(pParam,frame->quant,data,qcoeff); |
cbp = MBQuantInter(pParam,pMB->quant,data,qcoeff); |
353 |
MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp); |
MBDeQuantInter(pParam,pMB->quant,data,qcoeff,cbp); |
354 |
MBiDCT(data,cbp); |
MBiDCT(data,cbp); |
355 |
MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp); |
MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp); |
356 |
|
|
361 |
MBTransQuantInterBVOP(const MBParam * pParam, |
MBTransQuantInterBVOP(const MBParam * pParam, |
362 |
FRAMEINFO * frame, |
FRAMEINFO * frame, |
363 |
MACROBLOCK * pMB, |
MACROBLOCK * pMB, |
364 |
|
const uint32_t x_pos, |
365 |
|
const uint32_t y_pos, |
366 |
int16_t data[6 * 64], |
int16_t data[6 * 64], |
367 |
int16_t qcoeff[6 * 64]) |
int16_t qcoeff[6 * 64]) |
368 |
{ |
{ |
371 |
/* there is no MBTrans for Inter block, that's done in motion compensation already */ |
/* there is no MBTrans for Inter block, that's done in motion compensation already */ |
372 |
|
|
373 |
MBfDCT(pParam,frame,pMB,data); |
MBfDCT(pParam,frame,pMB,data); |
374 |
cbp = MBQuantInter(pParam,frame->quant,data,qcoeff); |
cbp = MBQuantInter(pParam,pMB->quant,data,qcoeff); |
375 |
|
|
376 |
|
/* |
377 |
|
* History comment: |
378 |
|
* we don't have to DeQuant, iDCT and Transfer back data for B-frames |
379 |
|
*/ |
380 |
|
|
381 |
/* we don't have to DeQuant, iDCT and Transfer back data for B-frames */ |
/* |
382 |
|
* As an exception to the previous rule, if we are willing to have extra |
383 |
|
* stats then we have to DeQuant, iDCT and Transfer back the data :-) |
384 |
|
*/ |
385 |
|
if((pParam->plugin_flags & XVID_REQORIGINAL)) { |
386 |
|
MBDeQuantInter(pParam,pMB->quant,data,qcoeff,cbp); |
387 |
|
MBiDCT(data,cbp); |
388 |
|
MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp); |
389 |
|
} |
390 |
|
|
391 |
return cbp; |
return cbp; |
392 |
} |
} |
402 |
|
|
403 |
start_timer(); |
start_timer(); |
404 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
405 |
if ((frame->global_flags & XVID_INTERLACING)) { |
if ((frame->vol_flags & XVID_INTERLACING)) { |
406 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
407 |
} |
} |
408 |
stop_interlacing_timer(); |
stop_interlacing_timer(); |
422 |
int16_t data[6*64]) |
int16_t data[6*64]) |
423 |
{ |
{ |
424 |
int i; |
int i; |
425 |
int iQuant = frame->quant; |
int iQuant = pMB->quant; |
426 |
|
|
427 |
start_timer(); |
start_timer(); |
428 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
429 |
if ((frame->global_flags & XVID_INTERLACING)) { |
if ((frame->vol_flags & XVID_INTERLACING)) { |
430 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
431 |
} |
} |
432 |
stop_interlacing_timer(); |
stop_interlacing_timer(); |
434 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
435 |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
436 |
|
|
437 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
438 |
start_timer(); |
start_timer(); |
439 |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
440 |
stop_quant_timer(); |
stop_quant_timer(); |
462 |
int16_t data[6*64]) |
int16_t data[6*64]) |
463 |
{ |
{ |
464 |
int i; |
int i; |
465 |
int iQuant = frame->quant; |
int iQuant = pMB->quant; |
466 |
|
|
467 |
start_timer(); |
start_timer(); |
468 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
469 |
if ((frame->global_flags & XVID_INTERLACING)) { |
if ((frame->vol_flags & XVID_INTERLACING)) { |
470 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
471 |
} |
} |
472 |
stop_interlacing_timer(); |
stop_interlacing_timer(); |
474 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
475 |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
476 |
|
|
477 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
478 |
start_timer(); |
start_timer(); |
479 |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler); |
480 |
stop_quant_timer(); |
stop_quant_timer(); |
497 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
498 |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4); |
499 |
|
|
500 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
501 |
start_timer(); |
start_timer(); |
502 |
dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler); |
503 |
stop_iquant_timer(); |
stop_iquant_timer(); |
522 |
|
|
523 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
524 |
|
|
525 |
if (pParam->m_quant_type == 0) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
526 |
start_timer(); |
start_timer(); |
527 |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); |
sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant); |
528 |
stop_quant_timer(); |
stop_quant_timer(); |
551 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
552 |
if (cbp & (1 << (5 - i))) |
if (cbp & (1 << (5 - i))) |
553 |
{ |
{ |
554 |
if (pParam->m_quant_type == H263_QUANT) { |
if (!(pParam->vol_flags & XVID_MPEGQUANT)) { |
555 |
start_timer(); |
start_timer(); |
556 |
dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant); |
557 |
stop_iquant_timer(); |
stop_iquant_timer(); |