188 |
pcreate.zones = pEnc->zones; |
pcreate.zones = pEnc->zones; |
189 |
pcreate.width = pEnc->mbParam.width; |
pcreate.width = pEnc->mbParam.width; |
190 |
pcreate.height = pEnc->mbParam.height; |
pcreate.height = pEnc->mbParam.height; |
191 |
|
pcreate.mb_width = pEnc->mbParam.mb_width; |
192 |
|
pcreate.mb_height = pEnc->mbParam.mb_height; |
193 |
pcreate.fincr = pEnc->mbParam.fincr; |
pcreate.fincr = pEnc->mbParam.fincr; |
194 |
pcreate.fbase = pEnc->mbParam.fbase; |
pcreate.fbase = pEnc->mbParam.fbase; |
195 |
pcreate.param = create->plugins[n].param; |
pcreate.param = create->plugins[n].param; |
650 |
data.mb_height = pEnc->mbParam.mb_height; |
data.mb_height = pEnc->mbParam.mb_height; |
651 |
data.fincr = frame->fincr; |
data.fincr = frame->fincr; |
652 |
data.fbase = pEnc->mbParam.fbase; |
data.fbase = pEnc->mbParam.fbase; |
653 |
|
data.bquant_ratio = pEnc->mbParam.bquant_ratio; |
654 |
|
data.bquant_offset = pEnc->mbParam.bquant_offset; |
655 |
|
|
656 |
for (i=0; i<3; i++) { |
for (i=0; i<3; i++) { |
657 |
data.min_quant[i] = pEnc->mbParam.min_quant[i]; |
data.min_quant[i] = pEnc->mbParam.min_quant[i]; |
998 |
SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]); |
SWAP(FRAMEINFO*, pEnc->current, pEnc->bframes[pEnc->bframenum_tail]); |
999 |
|
|
1000 |
/* convert B-VOP to P-VOP */ |
/* convert B-VOP to P-VOP */ |
1001 |
pEnc->current->quant = ((pEnc->current->quant*100) - pEnc->mbParam.bquant_offset) / pEnc->mbParam.bquant_ratio; |
pEnc->current->quant = 100*pEnc->current->quant - pEnc->mbParam.bquant_offset; |
1002 |
|
pEnc->current->quant += pEnc->mbParam.bquant_ratio - 1; /* to avoid rouding issues */ |
1003 |
|
pEnc->current->quant /= pEnc->mbParam.bquant_ratio; |
1004 |
|
|
1005 |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) { |
1006 |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
1075 |
}else{ |
}else{ |
1076 |
type = MEanalysis(&pEnc->reference->image, pEnc->current, |
type = MEanalysis(&pEnc->reference->image, pEnc->current, |
1077 |
&pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval, |
&pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval, |
1078 |
pEnc->iFrameNum, pEnc->bframenum_tail, xFrame->bframe_threshold); |
pEnc->iFrameNum, pEnc->bframenum_tail, xFrame->bframe_threshold, |
1079 |
|
(pEnc->bframes) ? pEnc->bframes[pEnc->bframenum_head]->mbs: NULL); |
1080 |
} |
} |
1081 |
} |
} |
1082 |
|
|
1089 |
|
|
1090 |
if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) { |
if ((pEnc->current->vop_flags & XVID_VOP_DEBUG)) { |
1091 |
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5, |
image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5, |
1092 |
"%i st:%i if:%i", pEnc->current->frame_num, pEnc->current->stamp, pEnc->iFrameNum); |
"%d st:%lld if:%d", pEnc->current->frame_num, pEnc->current->stamp, pEnc->iFrameNum); |
1093 |
} |
} |
1094 |
|
|
1095 |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1168 |
} |
} |
1169 |
|
|
1170 |
/* convert B-VOP quant to P-VOP */ |
/* convert B-VOP quant to P-VOP */ |
1171 |
pEnc->current->quant = ((pEnc->current->quant*100) - pEnc->mbParam.bquant_offset) / pEnc->mbParam.bquant_ratio; |
pEnc->current->quant = 100*pEnc->current->quant - pEnc->mbParam.bquant_offset; |
1172 |
|
pEnc->current->quant += pEnc->mbParam.bquant_ratio - 1; /* to avoid rouding issues */ |
1173 |
|
pEnc->current->quant /= pEnc->mbParam.bquant_ratio; |
1174 |
type = P_VOP; |
type = P_VOP; |
1175 |
} |
} |
1176 |
|
|
1415 |
pEnc->fMvPrevSigma = -1; |
pEnc->fMvPrevSigma = -1; |
1416 |
pEnc->mbParam.m_fcode = 2; |
pEnc->mbParam.m_fcode = 2; |
1417 |
|
|
1418 |
|
pEnc->current->is_edged = 0; /* not edged */ |
1419 |
|
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
1420 |
|
|
1421 |
return 1; /* intra */ |
return 1; /* intra */ |
1422 |
} |
} |
1423 |
|
|
1460 |
} |
} |
1461 |
|
|
1462 |
|
|
1463 |
|
if (!reference->is_edged) { |
1464 |
start_timer(); |
start_timer(); |
1465 |
image_setedges(pRef, pParam->edged_width, pParam->edged_height, |
image_setedges(pRef, pParam->edged_width, pParam->edged_height, |
1466 |
pParam->width, pParam->height); |
pParam->width, pParam->height); |
1467 |
stop_edges_timer(); |
stop_edges_timer(); |
1468 |
|
reference->is_edged = 1; |
1469 |
|
} |
1470 |
|
|
1471 |
pParam->m_rounding_type = 1 - pParam->m_rounding_type; |
pParam->m_rounding_type = 1 - pParam->m_rounding_type; |
1472 |
current->rounding_type = pParam->m_rounding_type; |
current->rounding_type = pParam->m_rounding_type; |
1478 |
iLimit = mb_width * mb_height + 1; |
iLimit = mb_width * mb_height + 1; |
1479 |
|
|
1480 |
if ((current->vop_flags & XVID_VOP_HALFPEL)) { |
if ((current->vop_flags & XVID_VOP_HALFPEL)) { |
1481 |
|
if (reference->is_interpolated != current->rounding_type) { |
1482 |
start_timer(); |
start_timer(); |
1483 |
image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV, |
image_interpolate(pRef, &pEnc->vInterH, &pEnc->vInterV, |
1484 |
&pEnc->vInterHV, pParam->edged_width, |
&pEnc->vInterHV, pParam->edged_width, |
1486 |
(pParam->vol_flags & XVID_VOL_QUARTERPEL), |
(pParam->vol_flags & XVID_VOL_QUARTERPEL), |
1487 |
current->rounding_type); |
current->rounding_type); |
1488 |
stop_inter_timer(); |
stop_inter_timer(); |
1489 |
|
reference->is_interpolated = current->rounding_type; |
1490 |
|
} |
1491 |
} |
} |
1492 |
|
|
1493 |
current->coding_type = P_VOP; |
current->coding_type = P_VOP; |
1510 |
&pEnc->vInterH, |
&pEnc->vInterH, |
1511 |
&pEnc->vInterV, |
&pEnc->vInterV, |
1512 |
&pEnc->vInterHV); |
&pEnc->vInterHV); |
1513 |
gmcval += /*current->quant */ 2 * (int)(pParam->mb_width*pParam->mb_height); |
} else { |
|
} |
|
|
|
|
1514 |
gmcval = globalSAD(¤t->warp, pParam, current->mbs, |
gmcval = globalSAD(¤t->warp, pParam, current->mbs, |
1515 |
current, |
current, |
1516 |
&reference->image, |
&reference->image, |
1517 |
¤t->image, |
¤t->image, |
1518 |
pEnc->vGMC.y); |
pEnc->vGMC.y); |
1519 |
|
} |
1520 |
|
|
1521 |
gmcval += /*current->quant*/ 2 * (int)(pParam->mb_width*pParam->mb_height); |
gmcval += /*current->quant*/ 2 * (int)(pParam->mb_width*pParam->mb_height); |
1522 |
|
|
1523 |
/* 1st '3': 3 warpoints, 2nd '3': 16th pel res (2<<3) */ |
/* 1st '3': 3 warpoints, 2nd '3': 16th pel res (2<<3) */ |
1795 |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
1796 |
} |
} |
1797 |
|
|
1798 |
|
pEnc->current->is_edged = 0; /* not edged */ |
1799 |
|
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
1800 |
|
|
1801 |
|
/* what was this frame's interpolated reference will become |
1802 |
|
forward (past) reference in b-frame coding */ |
1803 |
|
|
1804 |
|
image_swap(&pEnc->vInterH, &pEnc->f_refh); |
1805 |
|
image_swap(&pEnc->vInterV, &pEnc->f_refv); |
1806 |
|
image_swap(&pEnc->vInterHV, &pEnc->f_refhv); |
1807 |
|
|
1808 |
|
|
1809 |
/* XXX: debug |
/* XXX: debug |
1810 |
{ |
{ |
1811 |
char s[100]; |
char s[100]; |
1857 |
#endif |
#endif |
1858 |
|
|
1859 |
/* forward */ |
/* forward */ |
1860 |
|
if (!pEnc->reference->is_edged) { |
1861 |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
image_setedges(f_ref, pEnc->mbParam.edged_width, |
1862 |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
1863 |
pEnc->mbParam.height); |
pEnc->mbParam.height); |
1864 |
|
pEnc->current->is_edged = 1; |
1865 |
|
} |
1866 |
|
|
1867 |
|
if (pEnc->reference->is_interpolated != 0) { |
1868 |
start_timer(); |
start_timer(); |
1869 |
image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv, |
image_interpolate(f_ref, &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv, |
1870 |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
1871 |
(pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0); |
(pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0); |
1872 |
stop_inter_timer(); |
stop_inter_timer(); |
1873 |
|
pEnc->reference->is_interpolated = 0; |
1874 |
|
} |
1875 |
|
|
1876 |
/* backward */ |
/* backward */ |
1877 |
|
if (!pEnc->current->is_edged) { |
1878 |
image_setedges(b_ref, pEnc->mbParam.edged_width, |
image_setedges(b_ref, pEnc->mbParam.edged_width, |
1879 |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
pEnc->mbParam.edged_height, pEnc->mbParam.width, |
1880 |
pEnc->mbParam.height); |
pEnc->mbParam.height); |
1881 |
|
pEnc->current->is_edged = 1; |
1882 |
|
} |
1883 |
|
|
1884 |
|
if (pEnc->current->is_interpolated != 0) { |
1885 |
start_timer(); |
start_timer(); |
1886 |
image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
image_interpolate(b_ref, &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV, |
1887 |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_height, |
1888 |
(pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0); |
(pEnc->mbParam.vol_flags & XVID_VOL_QUARTERPEL), 0); |
1889 |
stop_inter_timer(); |
stop_inter_timer(); |
1890 |
|
pEnc->current->is_interpolated = 0; |
1891 |
|
} |
1892 |
|
|
1893 |
start_timer(); |
start_timer(); |
1894 |
MotionEstimationBVOP(&pEnc->mbParam, frame, |
MotionEstimationBVOP(&pEnc->mbParam, frame, |
1918 |
|
|
1919 |
/* decoder ignores mb when refence block is INTER(0,0), CBP=0 */ |
/* decoder ignores mb when refence block is INTER(0,0), CBP=0 */ |
1920 |
if (mb->mode == MODE_NOT_CODED) { |
if (mb->mode == MODE_NOT_CODED) { |
1921 |
/* mb->mvs[0].x = mb->mvs[0].y = mb->cbp = 0; */ |
if (pEnc->mbParam.plugin_flags & XVID_REQORIGINAL) { |
1922 |
|
MBMotionCompensation(mb, x, y, f_ref, NULL, f_ref, NULL, NULL, &frame->image, |
1923 |
|
NULL, 0, 0, pEnc->mbParam.edged_width, 0, 0, 0); |
1924 |
|
} |
1925 |
|
|
1926 |
continue; |
continue; |
1927 |
} |
} |
1928 |
|
|