57 |
Bitstream * bs); |
Bitstream * bs); |
58 |
|
|
59 |
static int FrameCodeP(Encoder * pEnc, |
static int FrameCodeP(Encoder * pEnc, |
60 |
Bitstream * bs, |
Bitstream * bs); |
|
bool force_inter, |
|
|
bool vol_header); |
|
61 |
|
|
62 |
static void FrameCodeB(Encoder * pEnc, |
static void FrameCodeB(Encoder * pEnc, |
63 |
FRAMEINFO * frame, |
FRAMEINFO * frame, |
100 |
i--; |
i--; |
101 |
} |
} |
102 |
|
|
103 |
/* if neccessary, round to 65535 accuracy */ |
if (*base > 65535 || *inc > 65535) { |
104 |
if (*base > 65535) { |
int *biggest; |
105 |
float div = (float) *base / 65535; |
int *other; |
106 |
*base = (int) (*base / div); |
float div; |
107 |
*inc = (int) (*inc / div); |
|
108 |
|
if (*base > *inc) { |
109 |
|
biggest = base; |
110 |
|
other = inc; |
111 |
|
} else { |
112 |
|
biggest = inc; |
113 |
|
other = base; |
114 |
|
} |
115 |
|
|
116 |
|
div = ((float)*biggest)/((float)65535); |
117 |
|
*biggest = (int)(((float)*biggest)/div); |
118 |
|
*other = (int)(((float)*other)/div); |
119 |
} |
} |
120 |
} |
} |
121 |
|
|
132 |
if (create->width%2 || create->height%2) |
if (create->width%2 || create->height%2) |
133 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
134 |
|
|
135 |
|
if (create->width<=0 || create->height<=0) |
136 |
|
return XVID_ERR_FAIL; |
137 |
|
|
138 |
/* allocate encoder struct */ |
/* allocate encoder struct */ |
139 |
|
|
140 |
pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE); |
pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE); |
664 |
data.max_quant[i] = pEnc->mbParam.max_quant[i]; |
data.max_quant[i] = pEnc->mbParam.max_quant[i]; |
665 |
} |
} |
666 |
|
|
667 |
data.reference.csp = XVID_CSP_USER; |
data.reference.csp = XVID_CSP_PLANAR; |
668 |
data.reference.plane[0] = pEnc->reference->image.y; |
data.reference.plane[0] = pEnc->reference->image.y; |
669 |
data.reference.plane[1] = pEnc->reference->image.u; |
data.reference.plane[1] = pEnc->reference->image.u; |
670 |
data.reference.plane[2] = pEnc->reference->image.v; |
data.reference.plane[2] = pEnc->reference->image.v; |
672 |
data.reference.stride[1] = pEnc->mbParam.edged_width/2; |
data.reference.stride[1] = pEnc->mbParam.edged_width/2; |
673 |
data.reference.stride[2] = pEnc->mbParam.edged_width/2; |
data.reference.stride[2] = pEnc->mbParam.edged_width/2; |
674 |
|
|
675 |
data.current.csp = XVID_CSP_USER; |
data.current.csp = XVID_CSP_PLANAR; |
676 |
data.current.plane[0] = frame->image.y; |
data.current.plane[0] = frame->image.y; |
677 |
data.current.plane[1] = frame->image.u; |
data.current.plane[1] = frame->image.u; |
678 |
data.current.plane[2] = frame->image.v; |
data.current.plane[2] = frame->image.v; |
702 |
|
|
703 |
} else { /* XVID_PLG_AFTER */ |
} else { /* XVID_PLG_AFTER */ |
704 |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
705 |
data.original.csp = XVID_CSP_USER; |
data.original.csp = XVID_CSP_PLANAR; |
706 |
data.original.plane[0] = original->y; |
data.original.plane[0] = original->y; |
707 |
data.original.plane[1] = original->u; |
data.original.plane[1] = original->u; |
708 |
data.original.plane[2] = original->v; |
data.original.plane[2] = original->v; |
752 |
data.mblks = frame->sStat.mblks; |
data.mblks = frame->sStat.mblks; |
753 |
data.ublks = frame->sStat.ublks; |
data.ublks = frame->sStat.ublks; |
754 |
|
|
755 |
if (stats) { |
/* New code */ |
756 |
stats->type = coding2type(frame->coding_type); |
data.stats.type = coding2type(frame->coding_type); |
757 |
stats->quant = frame->quant; |
data.stats.quant = frame->quant; |
758 |
stats->vol_flags = frame->vol_flags; |
data.stats.vol_flags = frame->vol_flags; |
759 |
stats->vop_flags = frame->vop_flags; |
data.stats.vop_flags = frame->vop_flags; |
760 |
stats->length = frame->length; |
data.stats.length = frame->length; |
761 |
stats->hlength = frame->length - (frame->sStat.iTextBits / 8); |
data.stats.hlength = frame->length - (frame->sStat.iTextBits / 8); |
762 |
stats->kblks = frame->sStat.kblks; |
data.stats.kblks = frame->sStat.kblks; |
763 |
stats->mblks = frame->sStat.mblks; |
data.stats.mblks = frame->sStat.mblks; |
764 |
stats->ublks = frame->sStat.ublks; |
data.stats.ublks = frame->sStat.ublks; |
765 |
stats->sse_y = data.sse_y; |
data.stats.sse_y = data.sse_y; |
766 |
stats->sse_u = data.sse_u; |
data.stats.sse_u = data.sse_u; |
767 |
stats->sse_v = data.sse_v; |
data.stats.sse_v = data.sse_v; |
768 |
} |
|
769 |
|
if (stats) |
770 |
|
*stats = data.stats; |
771 |
} |
} |
772 |
|
|
773 |
/* call plugins */ |
/* call plugins */ |
862 |
pCur->ticks = (int32_t)pCur->stamp % time_base; |
pCur->ticks = (int32_t)pCur->stamp % time_base; |
863 |
pCur->seconds = ((int32_t)pCur->stamp / time_base) - ((int32_t)pRef->stamp / time_base) ; |
pCur->seconds = ((int32_t)pCur->stamp / time_base) - ((int32_t)pRef->stamp / time_base) ; |
864 |
|
|
865 |
/* HEAVY DEBUG OUTPUT remove when timecodes prove to be stable */ |
#if 0 /* HEAVY DEBUG OUTPUT */ |
866 |
|
fprintf(stderr,"WriteVop: %d - %d \n", |
|
/* fprintf(stderr,"WriteVop: %d - %d \n", |
|
867 |
((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base)); |
((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base)); |
868 |
fprintf(stderr,"set_timecodes: VOP %1d stamp=%lld ref_stamp=%lld base=%d\n", |
fprintf(stderr,"set_timecodes: VOP %1d stamp=%lld ref_stamp=%lld base=%d\n", |
869 |
pCur->coding_type, pCur->stamp, pRef->stamp, time_base); |
pCur->coding_type, pCur->stamp, pRef->stamp, time_base); |
870 |
fprintf(stderr,"set_timecodes: VOP %1d seconds=%d ticks=%d (ref-sec=%d ref-tick=%d)\n", |
fprintf(stderr,"set_timecodes: VOP %1d seconds=%d ticks=%d (ref-sec=%d ref-tick=%d)\n", |
871 |
pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks); |
pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks); |
872 |
|
#endif |
873 |
|
} |
874 |
|
|
875 |
*/ |
static int |
876 |
|
gcd(int a, int b) |
877 |
|
{ |
878 |
|
int r ; |
879 |
|
|
880 |
|
if (b > a) { |
881 |
|
r = a; |
882 |
|
a = b; |
883 |
|
b = r; |
884 |
} |
} |
885 |
|
|
886 |
|
while ((r = a % b)) { |
887 |
|
a = b; |
888 |
|
b = r; |
889 |
|
} |
890 |
|
return b; |
891 |
|
} |
892 |
|
|
893 |
|
static void |
894 |
|
simplify_par(int *par_width, int *par_height) |
895 |
|
{ |
896 |
|
|
897 |
|
int _par_width = (!*par_width) ? 1 : (*par_width<0) ? -*par_width: *par_width; |
898 |
|
int _par_height = (!*par_height) ? 1 : (*par_height<0) ? -*par_height: *par_height; |
899 |
|
int divisor = gcd(_par_width, _par_height); |
900 |
|
|
901 |
|
_par_width /= divisor; |
902 |
|
_par_height /= divisor; |
903 |
|
|
904 |
|
/* 2^8 precision maximum */ |
905 |
|
if (_par_width>255 || _par_height>255) { |
906 |
|
float div; |
907 |
|
emms(); |
908 |
|
if (_par_width>_par_height) |
909 |
|
div = (float)_par_width/255; |
910 |
|
else |
911 |
|
div = (float)_par_height/255; |
912 |
|
|
913 |
|
_par_width = (int)((float)_par_width/div); |
914 |
|
_par_height = (int)((float)_par_height/div); |
915 |
|
} |
916 |
|
|
917 |
|
*par_width = _par_width; |
918 |
|
*par_height = _par_height; |
919 |
|
|
920 |
|
return; |
921 |
|
} |
922 |
|
|
923 |
|
|
924 |
/***************************************************************************** |
/***************************************************************************** |
1098 |
DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i\n", |
DPRINTF(XVID_DEBUG_DEBUG,"*** PFRAME bf: head=%i tail=%i queue: head=%i tail=%i size=%i\n", |
1099 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
1100 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
1101 |
|
pEnc->mbParam.frame_drop_ratio = -1; /* it must be a coded vop */ |
1102 |
|
|
1103 |
FrameCodeP(pEnc, &bs, 1, 0); |
FrameCodeP(pEnc, &bs); |
1104 |
|
|
1105 |
|
|
1106 |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) { |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) { |
1134 |
|
|
1135 |
pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr; |
pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr; |
1136 |
inc_frame_num(pEnc); |
inc_frame_num(pEnc); |
1137 |
pEnc->current->vol_flags = pEnc->mbParam.vol_flags; |
pEnc->current->vol_flags = frame->vol_flags; |
1138 |
pEnc->current->vop_flags = frame->vop_flags; |
pEnc->current->vop_flags = frame->vop_flags; |
1139 |
pEnc->current->motion_flags = frame->motion; |
pEnc->current->motion_flags = frame->motion; |
1140 |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
pEnc->current->fcode = pEnc->mbParam.m_fcode; |
1169 |
} |
} |
1170 |
} |
} |
1171 |
|
|
1172 |
|
if (type != I_VOP) |
1173 |
|
pEnc->current->vol_flags = pEnc->mbParam.vol_flags; /* don't allow VOL changes here */ |
1174 |
|
|
1175 |
/* bframes buffer overflow check */ |
/* bframes buffer overflow check */ |
1176 |
if (type == B_VOP && pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) { |
if (type == B_VOP && pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) { |
1177 |
type = P_VOP; |
type = P_VOP; |
1284 |
pEnc->iFrameNum = 1; |
pEnc->iFrameNum = 1; |
1285 |
|
|
1286 |
/* ---- update vol flags at IVOP ----------- */ |
/* ---- update vol flags at IVOP ----------- */ |
1287 |
pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags; |
pEnc->mbParam.vol_flags = pEnc->current->vol_flags; |
1288 |
|
|
1289 |
|
/* Aspect ratio */ |
1290 |
switch(frame->par) { |
switch(frame->par) { |
1291 |
case XVID_PAR_11_VGA: |
case XVID_PAR_11_VGA: |
1292 |
case XVID_PAR_43_PAL: |
case XVID_PAR_43_PAL: |
1297 |
pEnc->mbParam.par = frame->par; |
pEnc->mbParam.par = frame->par; |
1298 |
break; |
break; |
1299 |
default: |
default: |
1300 |
pEnc->mbParam.par = XVID_PAR_EXT; |
pEnc->mbParam.par = XVID_PAR_11_VGA; |
1301 |
break; |
break; |
1302 |
} |
} |
1303 |
pEnc->mbParam.par_width = (frame->par_width)?frame->par_width:1; |
|
1304 |
pEnc->mbParam.par_height = (frame->par_height)?frame->par_height:1; |
/* For extended PAR only, we try to sanityse/simplify par values */ |
1305 |
|
if (pEnc->mbParam.par == XVID_PAR_EXT) { |
1306 |
|
pEnc->mbParam.par_width = frame->par_width; |
1307 |
|
pEnc->mbParam.par_height = frame->par_height; |
1308 |
|
simplify_par(&pEnc->mbParam.par_width, &pEnc->mbParam.par_height); |
1309 |
|
} |
1310 |
|
|
1311 |
if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) { |
if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) { |
1312 |
if (frame->quant_intra_matrix != NULL) |
if (frame->quant_intra_matrix != NULL) |
1317 |
|
|
1318 |
/* prevent vol/vop misuse */ |
/* prevent vol/vop misuse */ |
1319 |
|
|
|
if (!(pEnc->current->vol_flags & XVID_VOL_REDUCED_ENABLE)) |
|
|
pEnc->current->vop_flags &= ~XVID_VOP_REDUCED; |
|
|
|
|
1320 |
if (!(pEnc->current->vol_flags & XVID_VOL_INTERLACING)) |
if (!(pEnc->current->vol_flags & XVID_VOL_INTERLACING)) |
1321 |
pEnc->current->vop_flags &= ~(XVID_VOP_TOPFIELDFIRST|XVID_VOP_ALTERNATESCAN); |
pEnc->current->vop_flags &= ~(XVID_VOP_TOPFIELDFIRST|XVID_VOP_ALTERNATESCAN); |
1322 |
|
|
1349 |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
1350 |
} |
} |
1351 |
|
|
1352 |
FrameCodeP(pEnc, &bs, 1, 0); |
if ( FrameCodeP(pEnc, &bs) == 0 ) { |
1353 |
|
/* N-VOP, we mustn't code b-frames yet */ |
1354 |
|
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
1355 |
|
goto done; |
1356 |
|
} |
1357 |
} |
} |
1358 |
|
|
1359 |
|
|
1444 |
|
|
1445 |
uint16_t x, y; |
uint16_t x, y; |
1446 |
|
|
|
if ((pEnc->current->vol_flags & XVID_VOL_REDUCED_ENABLE)) |
|
|
{ |
|
|
mb_width = (pEnc->mbParam.width + 31) / 32; |
|
|
mb_height = (pEnc->mbParam.height + 31) / 32; |
|
|
|
|
|
/* 16x16->8x8 downsample requires 1 additional edge pixel*/ |
|
|
/* XXX: setedges is overkill */ |
|
|
start_timer(); |
|
|
image_setedges(&pEnc->current->image, |
|
|
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
|
|
pEnc->mbParam.width, pEnc->mbParam.height); |
|
|
stop_edges_timer(); |
|
|
} |
|
|
|
|
1447 |
pEnc->mbParam.m_rounding_type = 1; |
pEnc->mbParam.m_rounding_type = 1; |
1448 |
pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type; |
pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type; |
1449 |
pEnc->current->coding_type = I_VOP; |
pEnc->current->coding_type = I_VOP; |
1452 |
|
|
1453 |
SetMacroblockQuants(&pEnc->mbParam, pEnc->current); |
SetMacroblockQuants(&pEnc->mbParam, pEnc->current); |
1454 |
|
|
1455 |
BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current); |
1456 |
|
|
1457 |
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
1458 |
|
|
1479 |
stop_prediction_timer(); |
stop_prediction_timer(); |
1480 |
|
|
1481 |
start_timer(); |
start_timer(); |
|
if (pEnc->current->vop_flags & XVID_VOP_GREYSCALE) |
|
|
{ pMB->cbp &= 0x3C; /* keep only bits 5-2 */ |
|
|
qcoeff[4*64+0]=0; /* zero, because for INTRA MBs DC value is saved */ |
|
|
qcoeff[5*64+0]=0; |
|
|
} |
|
1482 |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
1483 |
stop_coding_timer(); |
stop_coding_timer(); |
1484 |
} |
} |
1485 |
|
|
|
if ((pEnc->current->vop_flags & XVID_VOP_REDUCED)) |
|
|
{ |
|
|
image_deblock_rrv(&pEnc->current->image, pEnc->mbParam.edged_width, |
|
|
pEnc->current->mbs, mb_width, mb_height, pEnc->mbParam.mb_width, |
|
|
16, 0); |
|
|
} |
|
1486 |
emms(); |
emms(); |
1487 |
|
|
1488 |
BitstreamPadAlways(bs); /* next_start_code() at the end of VideoObjectPlane() */ |
BitstreamPadAlways(bs); /* next_start_code() at the end of VideoObjectPlane() */ |
1498 |
return 1; /* intra */ |
return 1; /* intra */ |
1499 |
} |
} |
1500 |
|
|
1501 |
|
static __inline void |
1502 |
|
updateFcode(Statistics * sStat, Encoder * pEnc) |
1503 |
|
{ |
1504 |
|
float fSigma; |
1505 |
|
int iSearchRange; |
1506 |
|
|
1507 |
#define INTRA_THRESHOLD 0.5 |
if (sStat->iMvCount == 0) |
1508 |
#define BFRAME_SKIP_THRESHHOLD 30 |
sStat->iMvCount = 1; |
1509 |
|
|
1510 |
|
fSigma = (float) sqrt((float) sStat->iMvSum / sStat->iMvCount); |
1511 |
|
|
1512 |
|
iSearchRange = 16 << pEnc->mbParam.m_fcode; |
1513 |
|
|
1514 |
|
if ((3.0 * fSigma > iSearchRange) && (pEnc->mbParam.m_fcode <= 5) ) |
1515 |
|
pEnc->mbParam.m_fcode++; |
1516 |
|
|
1517 |
|
else if ((5.0 * fSigma < iSearchRange) |
1518 |
|
&& (4.0 * pEnc->fMvPrevSigma < iSearchRange) |
1519 |
|
&& (pEnc->mbParam.m_fcode >= 2) ) |
1520 |
|
pEnc->mbParam.m_fcode--; |
1521 |
|
|
1522 |
|
pEnc->fMvPrevSigma = fSigma; |
1523 |
|
} |
1524 |
|
|
1525 |
|
#define BFRAME_SKIP_THRESHHOLD 30 |
1526 |
|
|
1527 |
/* FrameCodeP also handles S(GMC)-VOPs */ |
/* FrameCodeP also handles S(GMC)-VOPs */ |
1528 |
static int |
static int |
1529 |
FrameCodeP(Encoder * pEnc, |
FrameCodeP(Encoder * pEnc, |
1530 |
Bitstream * bs, |
Bitstream * bs) |
|
bool force_inter, |
|
|
bool vol_header) |
|
1531 |
{ |
{ |
|
float fSigma; |
|
1532 |
int bits = BitstreamPos(bs); |
int bits = BitstreamPos(bs); |
1533 |
|
|
1534 |
DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(dct_codes, 6, 64, int16_t, CACHE_LINE); |
1535 |
DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(qcoeff, 6, 64, int16_t, CACHE_LINE); |
1536 |
|
|
|
int iLimit; |
|
1537 |
int x, y, k; |
int x, y, k; |
|
int iSearchRange; |
|
|
int bIntra=0, skip_possible; |
|
1538 |
FRAMEINFO *const current = pEnc->current; |
FRAMEINFO *const current = pEnc->current; |
1539 |
FRAMEINFO *const reference = pEnc->reference; |
FRAMEINFO *const reference = pEnc->reference; |
1540 |
MBParam * const pParam = &pEnc->mbParam; |
MBParam * const pParam = &pEnc->mbParam; |
1541 |
int mb_width = pParam->mb_width; |
int mb_width = pParam->mb_width; |
1542 |
int mb_height = pParam->mb_height; |
int mb_height = pParam->mb_height; |
1543 |
|
int coded = 1; |
1544 |
|
|
|
|
|
|
/* IMAGE *pCurrent = ¤t->image; */ |
|
1545 |
IMAGE *pRef = &reference->image; |
IMAGE *pRef = &reference->image; |
1546 |
|
|
|
if ((current->vop_flags & XVID_VOP_REDUCED)) |
|
|
{ |
|
|
mb_width = (pParam->width + 31) / 32; |
|
|
mb_height = (pParam->height + 31) / 32; |
|
|
} |
|
|
|
|
|
|
|
1547 |
if (!reference->is_edged) { |
if (!reference->is_edged) { |
1548 |
start_timer(); |
start_timer(); |
1549 |
image_setedges(pRef, pParam->edged_width, pParam->edged_height, |
image_setedges(pRef, pParam->edged_width, pParam->edged_height, |
1550 |
pParam->width, pParam->height); |
pParam->width, pParam->height, 0); |
1551 |
stop_edges_timer(); |
stop_edges_timer(); |
1552 |
reference->is_edged = 1; |
reference->is_edged = 1; |
1553 |
} |
} |
1556 |
current->rounding_type = pParam->m_rounding_type; |
current->rounding_type = pParam->m_rounding_type; |
1557 |
current->fcode = pParam->m_fcode; |
current->fcode = pParam->m_fcode; |
1558 |
|
|
|
if (!force_inter) |
|
|
iLimit = (int)(mb_width * mb_height * INTRA_THRESHOLD); |
|
|
else |
|
|
iLimit = mb_width * mb_height + 1; |
|
|
|
|
1559 |
if ((current->vop_flags & XVID_VOP_HALFPEL)) { |
if ((current->vop_flags & XVID_VOP_HALFPEL)) { |
1560 |
if (reference->is_interpolated != current->rounding_type) { |
if (reference->is_interpolated != current->rounding_type) { |
1561 |
start_timer(); |
start_timer(); |
1569 |
} |
} |
1570 |
} |
} |
1571 |
|
|
1572 |
|
current->sStat.iTextBits = current->sStat.iMvSum = current->sStat.iMvCount = |
1573 |
|
current->sStat.kblks = current->sStat.mblks = current->sStat.ublks = 0; |
1574 |
|
|
1575 |
current->coding_type = P_VOP; |
current->coding_type = P_VOP; |
1576 |
|
|
1577 |
call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_FRAME, NULL, NULL, NULL); |
1629 |
} |
} |
1630 |
} |
} |
1631 |
|
|
|
bIntra = |
|
1632 |
MotionEstimation(&pEnc->mbParam, current, reference, |
MotionEstimation(&pEnc->mbParam, current, reference, |
1633 |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
&pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1634 |
&pEnc->vGMC, iLimit); |
&pEnc->vGMC, 256*4096); |
1635 |
|
|
1636 |
|
|
1637 |
stop_motion_timer(); |
stop_motion_timer(); |
1638 |
|
|
|
if (bIntra == 1) return FrameCodeI(pEnc, bs); |
|
|
|
|
1639 |
set_timecodes(current,reference,pParam->fbase); |
set_timecodes(current,reference,pParam->fbase); |
|
if (vol_header) |
|
|
{ BitstreamWriteVolHeader(bs, &pEnc->mbParam); |
|
|
BitstreamPad(bs); |
|
|
} |
|
1640 |
|
|
1641 |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant); |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, current, 1, current->mbs[0].quant); |
1642 |
|
|
|
current->sStat.iTextBits = current->sStat.iMvSum = current->sStat.iMvCount = |
|
|
current->sStat.kblks = current->sStat.mblks = current->sStat.ublks = 0; |
|
|
|
|
|
|
|
1643 |
for (y = 0; y < mb_height; y++) { |
for (y = 0; y < mb_height; y++) { |
1644 |
for (x = 0; x < mb_width; x++) { |
for (x = 0; x < mb_width; x++) { |
1645 |
MACROBLOCK *pMB = |
MACROBLOCK *pMB = ¤t->mbs[x + y * pParam->mb_width]; |
1646 |
¤t->mbs[x + y * pParam->mb_width]; |
int skip_possible; |
1647 |
|
|
1648 |
bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q); |
if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) { |
|
|
|
|
if (bIntra) { |
|
1649 |
CodeIntraMB(pEnc, pMB); |
CodeIntraMB(pEnc, pMB); |
1650 |
MBTransQuantIntra(&pEnc->mbParam, current, pMB, x, y, |
MBTransQuantIntra(&pEnc->mbParam, current, pMB, x, y, |
1651 |
dct_codes, qcoeff); |
dct_codes, qcoeff); |
1656 |
|
|
1657 |
current->sStat.kblks++; |
current->sStat.kblks++; |
1658 |
|
|
|
if (pEnc->current->vop_flags & XVID_VOP_GREYSCALE) |
|
|
{ pMB->cbp &= 0x3C; /* keep only bits 5-2 */ |
|
|
qcoeff[4*64+0]=0; /* zero, because for INTRA MBs DC value is saved */ |
|
|
qcoeff[5*64+0]=0; |
|
|
} |
|
1659 |
MBCoding(current, pMB, qcoeff, bs, ¤t->sStat); |
MBCoding(current, pMB, qcoeff, bs, ¤t->sStat); |
1660 |
stop_coding_timer(); |
stop_coding_timer(); |
1661 |
continue; |
continue; |
1670 |
pParam->height, |
pParam->height, |
1671 |
pParam->edged_width, |
pParam->edged_width, |
1672 |
(current->vol_flags & XVID_VOL_QUARTERPEL), |
(current->vol_flags & XVID_VOL_QUARTERPEL), |
|
(current->vop_flags & XVID_VOP_REDUCED), |
|
1673 |
current->rounding_type); |
current->rounding_type); |
1674 |
|
|
1675 |
stop_comp_timer(); |
stop_comp_timer(); |
1676 |
|
|
1677 |
pMB->field_pred = 0; |
pMB->field_pred = 0; |
1678 |
|
|
1679 |
if (pMB->mode != MODE_NOT_CODED) |
if (pMB->cbp != 0) { |
1680 |
{ pMB->cbp = |
pMB->cbp = MBTransQuantInter(&pEnc->mbParam, current, pMB, x, y, |
|
MBTransQuantInter(&pEnc->mbParam, current, pMB, x, y, |
|
1681 |
dct_codes, qcoeff); |
dct_codes, qcoeff); |
1682 |
} |
} |
1683 |
|
|
1697 |
|
|
1698 |
/* Finished processing the MB, now check if to CODE or SKIP */ |
/* Finished processing the MB, now check if to CODE or SKIP */ |
1699 |
|
|
1700 |
skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) && |
skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER); |
|
(pMB->dquant == 0); |
|
1701 |
|
|
1702 |
if (current->coding_type == S_VOP) |
if (current->coding_type == S_VOP) |
1703 |
skip_possible &= (pMB->mcsel == 1); |
skip_possible &= (pMB->mcsel == 1); |
1704 |
else if (current->coding_type == P_VOP) { |
else { /* PVOP */ |
1705 |
if ((pParam->vol_flags & XVID_VOL_QUARTERPEL)) |
const VECTOR * const mv = (pParam->vol_flags & XVID_VOL_QUARTERPEL) ? |
1706 |
skip_possible &= ( (pMB->qmvs[0].x == 0) && (pMB->qmvs[0].y == 0) ); |
pMB->qmvs : pMB->mvs; |
1707 |
else |
skip_possible &= ((mv->x|mv->y) == 0); |
|
skip_possible &= ( (pMB->mvs[0].x == 0) && (pMB->mvs[0].y == 0) ); |
|
1708 |
} |
} |
1709 |
|
|
1710 |
if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) { |
if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) { |
|
|
|
1711 |
/* This is a candidate for SKIPping, but for P-VOPs check intermediate B-frames first */ |
/* This is a candidate for SKIPping, but for P-VOPs check intermediate B-frames first */ |
|
|
|
|
if (current->coding_type == P_VOP) /* special rule for P-VOP's SKIP */ |
|
|
{ |
|
1712 |
int bSkip = 1; |
int bSkip = 1; |
1713 |
|
|
1714 |
for (k=pEnc->bframenum_head; k< pEnc->bframenum_tail; k++) |
if (current->coding_type == P_VOP) { /* special rule for P-VOP's SKIP */ |
1715 |
{ |
|
1716 |
|
for (k = pEnc->bframenum_head; k < pEnc->bframenum_tail; k++) { |
1717 |
int iSAD; |
int iSAD; |
1718 |
iSAD = sad16(reference->image.y + 16*y*pParam->edged_width + 16*x, |
iSAD = sad16(reference->image.y + 16*y*pParam->edged_width + 16*x, |
1719 |
pEnc->bframes[k]->image.y + 16*y*pParam->edged_width + 16*x, |
pEnc->bframes[k]->image.y + 16*y*pParam->edged_width + 16*x, |
1720 |
pParam->edged_width,BFRAME_SKIP_THRESHHOLD); |
pParam->edged_width, BFRAME_SKIP_THRESHHOLD * pMB->quant); |
1721 |
if (iSAD >= BFRAME_SKIP_THRESHHOLD * pMB->quant) |
if (iSAD >= BFRAME_SKIP_THRESHHOLD * pMB->quant) { |
1722 |
{ bSkip = 0; |
bSkip = 0; /* could not SKIP */ |
1723 |
break; |
if (pParam->vol_flags & XVID_VOL_QUARTERPEL) { |
|
} |
|
|
} |
|
|
|
|
|
if (!bSkip) { /* no SKIP, but trivial block */ |
|
|
if((pParam->vol_flags & XVID_VOL_QUARTERPEL)) { |
|
1724 |
VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
1725 |
pMB->pmvs[0].x = - predMV.x; |
pMB->pmvs[0].x = - predMV.x; |
1726 |
pMB->pmvs[0].y = - predMV.y; |
pMB->pmvs[0].y = - predMV.y; |
1727 |
} |
} else { |
|
else { |
|
1728 |
VECTOR predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
VECTOR predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
1729 |
pMB->pmvs[0].x = - predMV.x; |
pMB->pmvs[0].x = - predMV.x; |
1730 |
pMB->pmvs[0].y = - predMV.y; |
pMB->pmvs[0].y = - predMV.y; |
1731 |
} |
} |
1732 |
pMB->mode = MODE_INTER; |
pMB->mode = MODE_INTER; |
1733 |
pMB->cbp = 0; |
pMB->cbp = 0; |
1734 |
MBCoding(current, pMB, qcoeff, bs, ¤t->sStat); |
break; |
1735 |
stop_coding_timer(); |
} |
|
|
|
|
continue; /* next MB */ |
|
1736 |
} |
} |
1737 |
} |
} |
|
/* do SKIP */ |
|
1738 |
|
|
1739 |
|
if (bSkip) { |
1740 |
|
/* do SKIP */ |
1741 |
pMB->mode = MODE_NOT_CODED; |
pMB->mode = MODE_NOT_CODED; |
1742 |
MBSkip(bs); |
MBSkip(bs); |
1743 |
stop_coding_timer(); |
stop_coding_timer(); |
1744 |
continue; /* next MB */ |
continue; /* next MB */ |
1745 |
} |
} |
|
/* ordinary case: normal coded INTER/INTER4V block */ |
|
|
|
|
|
if ((current->vop_flags & XVID_VOP_GREYSCALE)) |
|
|
{ pMB->cbp &= 0x3C; /* keep only bits 5-2 */ |
|
|
qcoeff[4*64+0]=0; /* zero, because DC for INTRA MBs DC value is saved */ |
|
|
qcoeff[5*64+0]=0; |
|
|
} |
|
|
|
|
|
if((pParam->vol_flags & XVID_VOL_QUARTERPEL)) { |
|
|
VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
|
|
pMB->pmvs[0].x = pMB->qmvs[0].x - predMV.x; |
|
|
pMB->pmvs[0].y = pMB->qmvs[0].y - predMV.y; |
|
|
DPRINTF(XVID_DEBUG_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)\n", pMB->pmvs[0].x, pMB->pmvs[0].y, predMV.x, predMV.y, pMB->mvs[0].x, pMB->mvs[0].y); |
|
|
} else { |
|
|
VECTOR predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, 0); |
|
|
pMB->pmvs[0].x = pMB->mvs[0].x - predMV.x; |
|
|
pMB->pmvs[0].y = pMB->mvs[0].y - predMV.y; |
|
|
DPRINTF(XVID_DEBUG_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)\n", pMB->pmvs[0].x, pMB->pmvs[0].y, predMV.x, predMV.y, pMB->mvs[0].x, pMB->mvs[0].y); |
|
|
} |
|
|
|
|
|
|
|
|
if (pMB->mode == MODE_INTER4V) |
|
|
{ int k; |
|
|
for (k=1;k<4;k++) |
|
|
{ |
|
|
if((pParam->vol_flags & XVID_VOL_QUARTERPEL)) { |
|
|
VECTOR predMV = get_qpmv2(current->mbs, pParam->mb_width, 0, x, y, k); |
|
|
pMB->pmvs[k].x = pMB->qmvs[k].x - predMV.x; |
|
|
pMB->pmvs[k].y = pMB->qmvs[k].y - predMV.y; |
|
|
DPRINTF(XVID_DEBUG_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)\n", pMB->pmvs[k].x, pMB->pmvs[k].y, predMV.x, predMV.y, pMB->mvs[k].x, pMB->mvs[k].y); |
|
|
} else { |
|
|
VECTOR predMV = get_pmv2(current->mbs, pParam->mb_width, 0, x, y, k); |
|
|
pMB->pmvs[k].x = pMB->mvs[k].x - predMV.x; |
|
|
pMB->pmvs[k].y = pMB->mvs[k].y - predMV.y; |
|
|
DPRINTF(XVID_DEBUG_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)\n", pMB->pmvs[k].x, pMB->pmvs[k].y, predMV.x, predMV.y, pMB->mvs[k].x, pMB->mvs[k].y); |
|
|
} |
|
|
|
|
|
} |
|
1746 |
} |
} |
1747 |
|
|
1748 |
|
/* ordinary case: normal coded INTER/INTER4V block */ |
1749 |
MBCoding(current, pMB, qcoeff, bs, &pEnc->current->sStat); |
MBCoding(current, pMB, qcoeff, bs, &pEnc->current->sStat); |
1750 |
stop_coding_timer(); |
stop_coding_timer(); |
|
|
|
1751 |
} |
} |
1752 |
} |
} |
1753 |
|
|
|
if ((current->vop_flags & XVID_VOP_REDUCED)) |
|
|
{ |
|
|
image_deblock_rrv(¤t->image, pParam->edged_width, |
|
|
current->mbs, mb_width, mb_height, pParam->mb_width, |
|
|
16, 0); |
|
|
} |
|
|
|
|
1754 |
emms(); |
emms(); |
1755 |
|
updateFcode(¤t->sStat, pEnc); |
|
if (current->sStat.iMvCount == 0) |
|
|
current->sStat.iMvCount = 1; |
|
|
|
|
|
fSigma = (float) sqrt((float) current->sStat.iMvSum / current->sStat.iMvCount); |
|
|
|
|
|
iSearchRange = 1 << (3 + pParam->m_fcode); |
|
|
|
|
|
if ((fSigma > iSearchRange / 3) |
|
|
&& (pParam->m_fcode <= (3 + (pParam->vol_flags & XVID_VOL_QUARTERPEL?1:0) ))) /* maximum search range 128 */ |
|
|
{ |
|
|
pParam->m_fcode++; |
|
|
iSearchRange *= 2; |
|
|
} else if ((fSigma < iSearchRange / 6) |
|
|
&& (pEnc->fMvPrevSigma >= 0) |
|
|
&& (pEnc->fMvPrevSigma < iSearchRange / 6) |
|
|
&& (pParam->m_fcode >= (2 + (pParam->vol_flags & XVID_VOL_QUARTERPEL?1:0) ))) /* minimum search range 16 */ |
|
|
{ |
|
|
pParam->m_fcode--; |
|
|
iSearchRange /= 2; |
|
|
} |
|
|
|
|
|
pEnc->fMvPrevSigma = fSigma; |
|
1756 |
|
|
1757 |
/* frame drop code */ |
/* frame drop code */ |
1758 |
#if 0 |
#if 0 |
1759 |
DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks); |
DPRINTF(XVID_DEBUG_DEBUG, "kmu %i %i %i\n", current->sStat.kblks, current->sStat.mblks, current->sStat.ublks); |
1760 |
#endif |
#endif |
1761 |
if (current->sStat.kblks + current->sStat.mblks < |
if (current->sStat.kblks + current->sStat.mblks <= |
1762 |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100) |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100 && |
1763 |
|
( (pEnc->bframenum_head >= pEnc->bframenum_tail) || !(pEnc->mbParam.global_flags & XVID_GLOBAL_CLOSED_GOP)) ) |
1764 |
{ |
{ |
1765 |
current->sStat.kblks = current->sStat.mblks = 0; |
current->sStat.kblks = current->sStat.mblks = 0; |
1766 |
current->sStat.ublks = mb_width * mb_height; |
current->sStat.ublks = mb_width * mb_height; |
1776 |
current->rounding_type = reference->rounding_type; |
current->rounding_type = reference->rounding_type; |
1777 |
current->fcode = reference->fcode; |
current->fcode = reference->fcode; |
1778 |
current->bcode = reference->bcode; |
current->bcode = reference->bcode; |
1779 |
|
current->stamp = reference->stamp; |
1780 |
image_copy(¤t->image, &reference->image, pParam->edged_width, pParam->height); |
image_copy(¤t->image, &reference->image, pParam->edged_width, pParam->height); |
1781 |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
1782 |
} |
coded = 0; |
1783 |
|
|
1784 |
|
} else { |
1785 |
|
|
1786 |
pEnc->current->is_edged = 0; /* not edged */ |
pEnc->current->is_edged = 0; /* not edged */ |
1787 |
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
1792 |
image_swap(&pEnc->vInterH, &pEnc->f_refh); |
image_swap(&pEnc->vInterH, &pEnc->f_refh); |
1793 |
image_swap(&pEnc->vInterV, &pEnc->f_refv); |
image_swap(&pEnc->vInterV, &pEnc->f_refv); |
1794 |
image_swap(&pEnc->vInterHV, &pEnc->f_refhv); |
image_swap(&pEnc->vInterHV, &pEnc->f_refhv); |
1795 |
|
} |
1796 |
|
|
1797 |
/* XXX: debug |
/* XXX: debug |
1798 |
{ |
{ |
1813 |
|
|
1814 |
current->length = (BitstreamPos(bs) - bits) / 8; |
current->length = (BitstreamPos(bs) - bits) / 8; |
1815 |
|
|
1816 |
return 0; /* inter */ |
return coded; |
1817 |
} |
} |
1818 |
|
|
1819 |
|
|
1837 |
fprintf(fp,"Y=%3d X=%3d MB=%2d CBP=%02X\n",y,x,mb->mode,mb->cbp); \ |
fprintf(fp,"Y=%3d X=%3d MB=%2d CBP=%02X\n",y,x,mb->mode,mb->cbp); \ |
1838 |
} |
} |
1839 |
|
|
|
/* XXX: pEnc->current->global_flags &= ~XVID_VOP_REDUCED; reduced resoltion not yet supported */ |
|
|
|
|
1840 |
if (!first){ |
if (!first){ |
1841 |
fp=fopen("C:\\XVIDDBGE.TXT","w"); |
fp=fopen("C:\\XVIDDBGE.TXT","w"); |
1842 |
} |
} |
1846 |
if (!pEnc->reference->is_edged) { |
if (!pEnc->reference->is_edged) { |
1847 |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
1848 |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
1849 |
pEnc->mbParam.height); |
pEnc->mbParam.height, 0); |
1850 |
pEnc->current->is_edged = 1; |
pEnc->current->is_edged = 1; |
1851 |
} |
} |
1852 |
|
|
1863 |
if (!pEnc->current->is_edged) { |
if (!pEnc->current->is_edged) { |
1864 |
image_setedges(b_ref, pEnc->mbParam.edged_width, |
image_setedges(b_ref, pEnc->mbParam.edged_width, |
1865 |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
1866 |
pEnc->mbParam.height); |
pEnc->mbParam.height, 0); |
1867 |
pEnc->current->is_edged = 1; |
pEnc->current->is_edged = 1; |
1868 |
} |
} |
1869 |
|
|
1907 |
if (mb->mode == MODE_NOT_CODED) { |
if (mb->mode == MODE_NOT_CODED) { |
1908 |
if (pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
if (pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
1909 |
MBMotionCompensation(mb, x, y, f_ref, NULL, f_ref, NULL, NULL, &frame->image, |
MBMotionCompensation(mb, x, y, f_ref, NULL, f_ref, NULL, NULL, &frame->image, |
1910 |
NULL, 0, 0, pEnc->mbParam.edged_width, 0, 0, 0); |
NULL, 0, 0, pEnc->mbParam.edged_width, 0, 0); |
1911 |
} |
} |
|
|
|
1912 |
continue; |
continue; |
1913 |
} |
} |
1914 |
|
|
1915 |
if (mb->mode != MODE_DIRECT_NONE_MV || pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
mb->quant = frame->quant; |
1916 |
|
|
1917 |
|
if (mb->cbp != 0 || pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
1918 |
|
/* we have to motion-compensate, transfer etc, |
1919 |
|
because there might be blocks to code */ |
1920 |
|
|
1921 |
MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image, |
MBMotionCompensationBVOP(&pEnc->mbParam, mb, x, y, &frame->image, |
1922 |
f_ref, &pEnc->f_refh, &pEnc->f_refv, |
f_ref, &pEnc->f_refh, &pEnc->f_refv, |
1923 |
&pEnc->f_refhv, b_ref, &pEnc->vInterH, |
&pEnc->f_refhv, b_ref, &pEnc->vInterH, |
1924 |
&pEnc->vInterV, &pEnc->vInterHV, |
&pEnc->vInterV, &pEnc->vInterHV, |
1925 |
dct_codes); |
dct_codes); |
1926 |
|
|
|
if (mb->mode == MODE_DIRECT_NO4V) mb->mode = MODE_DIRECT; |
|
|
mb->quant = frame->quant; |
|
|
|
|
|
if (mb->mode != MODE_DIRECT_NONE_MV) |
|
1927 |
mb->cbp = MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, x, y, dct_codes, qcoeff); |
mb->cbp = MBTransQuantInterBVOP(&pEnc->mbParam, frame, mb, x, y, dct_codes, qcoeff); |
|
|
|
|
if ( (mb->mode == MODE_DIRECT) && (mb->cbp == 0) |
|
|
&& (mb->pmvs[3].x == 0) && (mb->pmvs[3].y == 0) ) { |
|
|
mb->mode = MODE_DIRECT_NONE_MV; /* skipped */ |
|
|
} |
|
1928 |
} |
} |
1929 |
|
|
1930 |
/* keep only bits 5-2 -- Chroma blocks will just be skipped by the |
if (mb->mode == MODE_DIRECT_NO4V) |
1931 |
* coding function for BFrames, that's why we don't zero teh DC |
mb->mode = MODE_DIRECT; |
1932 |
* coeffs */ |
|
1933 |
if ((frame->vop_flags & XVID_VOP_GREYSCALE)) |
if (mb->mode == MODE_DIRECT && (mb->cbp | mb->pmvs[3].x | mb->pmvs[3].y) == 0) |
1934 |
|
mb->mode = MODE_DIRECT_NONE_MV; /* skipped */ |
1935 |
|
else |
1936 |
|
if (frame->vop_flags & XVID_VOP_GREYSCALE) |
1937 |
|
/* keep only bits 5-2 -- Chroma blocks will just be skipped by MBCodingBVOP */ |
1938 |
mb->cbp &= 0x3C; |
mb->cbp &= 0x3C; |
1939 |
|
|
1940 |
start_timer(); |
start_timer(); |
1946 |
|
|
1947 |
emms(); |
emms(); |
1948 |
|
|
|
/* TODO: dynamic fcode/bcode ??? */ |
|
|
|
|
1949 |
BitstreamPadAlways(bs); /* next_start_code() at the end of VideoObjectPlane() */ |
BitstreamPadAlways(bs); /* next_start_code() at the end of VideoObjectPlane() */ |
1950 |
frame->length = (BitstreamPos(bs) - bits) / 8; |
frame->length = (BitstreamPos(bs) - bits) / 8; |
1951 |
|
|