65 |
#include "../quant/quant_h263.h" |
#include "../quant/quant_h263.h" |
66 |
#include "../encoder.h" |
#include "../encoder.h" |
67 |
|
|
68 |
|
MBFIELDTEST_PTR MBFieldTest; |
69 |
|
|
70 |
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
#define MIN(X, Y) ((X)<(Y)?(X):(Y)) |
71 |
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
#define MAX(X, Y) ((X)>(Y)?(X):(Y)) |
72 |
|
|
73 |
#define TOOSMALL_LIMIT 3 /* skip blocks having a coefficient sum below this value */ |
#define TOOSMALL_LIMIT 1 /* skip blocks having a coefficient sum below this value */ |
|
|
|
|
/* this isnt pretty, but its better than 20 ifdefs */ |
|
74 |
|
|
75 |
void |
void |
76 |
MBTransQuantIntra(const MBParam * pParam, |
MBTransQuantIntra(const MBParam * pParam, |
105 |
|
|
106 |
start_timer(); |
start_timer(); |
107 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
108 |
if ((frame->global_flags & XVID_INTERLACING)) { |
if ((frame->global_flags & XVID_INTERLACING) && |
109 |
|
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
110 |
|
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
111 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
112 |
} |
} |
113 |
stop_interlacing_timer(); |
stop_interlacing_timer(); |
185 |
|
|
186 |
start_timer(); |
start_timer(); |
187 |
pMB->field_dct = 0; |
pMB->field_dct = 0; |
188 |
if ((frame->global_flags & XVID_INTERLACING)) { |
if ((frame->global_flags & XVID_INTERLACING) && |
189 |
|
(x_pos>0) && (x_pos<pParam->mb_width-1) && |
190 |
|
(y_pos>0) && (y_pos<pParam->mb_height-1)) { |
191 |
pMB->field_dct = MBDecideFieldDCT(data); |
pMB->field_dct = MBDecideFieldDCT(data); |
192 |
} |
} |
193 |
stop_interlacing_timer(); |
stop_interlacing_timer(); |
194 |
|
|
195 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
196 |
|
uint32_t increase_limit = (iQuant == 1) ? 1 : 0; |
197 |
|
|
198 |
/* |
/* |
199 |
* no need to transfer 8->16-bit |
* no need to transfer 8->16-bit |
200 |
* (this is performed already in motion compensation) |
* (this is performed already in motion compensation) |
213 |
stop_quant_timer(); |
stop_quant_timer(); |
214 |
} |
} |
215 |
|
|
216 |
if ((sum >= TOOSMALL_LIMIT) || (qcoeff[i*64] != 0) || |
if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) || |
217 |
(qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { |
(qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) { |
218 |
|
|
219 |
if (pParam->m_quant_type == H263_QUANT) { |
if (pParam->m_quant_type == H263_QUANT) { |
302 |
MBTransQuantInterBVOP(const MBParam * pParam, |
MBTransQuantInterBVOP(const MBParam * pParam, |
303 |
FRAMEINFO * frame, |
FRAMEINFO * frame, |
304 |
MACROBLOCK * pMB, |
MACROBLOCK * pMB, |
|
const uint32_t x_pos, |
|
|
const uint32_t y_pos, |
|
305 |
int16_t data[6 * 64], |
int16_t data[6 * 64], |
306 |
int16_t qcoeff[6 * 64]) |
int16_t qcoeff[6 * 64]) |
307 |
{ |
{ |
578 |
|
|
579 |
|
|
580 |
|
|
581 |
/* if sum(diff between field lines) < sum(diff between frame lines), use field dct */ |
/* permute block and return field dct choice */ |
582 |
|
|
583 |
|
|
584 |
uint32_t |
uint32_t |
585 |
MBDecideFieldDCT(int16_t data[6 * 64]) |
MBDecideFieldDCT(int16_t data[6 * 64]) |
586 |
{ |
{ |
587 |
|
uint32_t field = MBFieldTest(data); |
588 |
|
|
589 |
|
if (field) { |
590 |
|
MBFrameToField(data); |
591 |
|
} |
592 |
|
|
593 |
|
return field; |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
|
/* if sum(diff between field lines) < sum(diff between frame lines), use field dct */ |
598 |
|
|
599 |
|
uint32_t |
600 |
|
MBFieldTest_c(int16_t data[6 * 64]) |
601 |
|
{ |
602 |
const uint8_t blocks[] = |
const uint8_t blocks[] = |
603 |
{ 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 }; |
{ 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 }; |
604 |
const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 }; |
const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 }; |
632 |
} |
} |
633 |
} |
} |
634 |
|
|
635 |
if (frame > field) { |
return (frame >= (field + 350)); |
|
MBFrameToField(data); |
|
|
} |
|
|
|
|
|
return (frame > field); |
|
636 |
} |
} |
637 |
|
|
638 |
|
|