229 |
|
|
230 |
pEnc->bitrate = pParam->rc_bitrate; |
pEnc->bitrate = pParam->rc_bitrate; |
231 |
|
|
232 |
pEnc->iFrameNum = 0; |
pEnc->iFrameNum = -1; |
233 |
pEnc->mbParam.iMaxKeyInterval = pParam->max_key_interval; |
pEnc->mbParam.iMaxKeyInterval = pParam->max_key_interval; |
234 |
|
|
235 |
/* try to allocate frame memory */ |
/* try to allocate frame memory */ |
254 |
|
|
255 |
/* try to allocate image memory */ |
/* try to allocate image memory */ |
256 |
|
|
257 |
#ifdef _DEBUG_PSNR |
if (pParam->global & XVID_GLOBAL_EXTRASTATS) |
258 |
image_null(&pEnc->sOriginal); |
image_null(&pEnc->sOriginal); |
|
#endif |
|
259 |
|
|
260 |
image_null(&pEnc->f_refh); |
image_null(&pEnc->f_refh); |
261 |
image_null(&pEnc->f_refv); |
image_null(&pEnc->f_refv); |
269 |
image_null(&pEnc->vInterHV); |
image_null(&pEnc->vInterHV); |
270 |
image_null(&pEnc->vInterHVf); |
image_null(&pEnc->vInterHVf); |
271 |
|
|
272 |
#ifdef _DEBUG_PSNR |
if (pParam->global & XVID_GLOBAL_EXTRASTATS) |
273 |
if (image_create |
{ if (image_create |
274 |
(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
275 |
pEnc->mbParam.edged_height) < 0) |
pEnc->mbParam.edged_height) < 0) |
276 |
goto xvid_err_memory3; |
goto xvid_err_memory3; |
277 |
#endif |
} |
278 |
|
|
279 |
if (image_create |
if (image_create |
280 |
(&pEnc->f_refh, pEnc->mbParam.edged_width, |
(&pEnc->f_refh, pEnc->mbParam.edged_width, |
325 |
goto xvid_err_memory3; |
goto xvid_err_memory3; |
326 |
|
|
327 |
|
|
|
/* B Frames specific init */ |
|
328 |
|
|
329 |
pEnc->mbParam.global = pParam->global; |
pEnc->mbParam.global = pParam->global; |
330 |
|
|
331 |
|
/* B Frames specific init */ |
332 |
pEnc->mbParam.max_bframes = pParam->max_bframes; |
pEnc->mbParam.max_bframes = pParam->max_bframes; |
333 |
pEnc->mbParam.bquant_ratio = pParam->bquant_ratio; |
pEnc->mbParam.bquant_ratio = pParam->bquant_ratio; |
334 |
pEnc->mbParam.bquant_offset = pParam->bquant_offset; |
pEnc->mbParam.bquant_offset = pParam->bquant_offset; |
464 |
} |
} |
465 |
|
|
466 |
xvid_err_memory3: |
xvid_err_memory3: |
467 |
#ifdef _DEBUG_PSNR |
|
468 |
image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
if (pEnc->mbParam.global & XVID_GLOBAL_EXTRASTATS) |
469 |
|
{ image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
470 |
pEnc->mbParam.edged_height); |
pEnc->mbParam.edged_height); |
471 |
#endif |
} |
472 |
|
|
473 |
image_destroy(&pEnc->f_refh, pEnc->mbParam.edged_width, |
image_destroy(&pEnc->f_refh, pEnc->mbParam.edged_width, |
474 |
pEnc->mbParam.edged_height); |
pEnc->mbParam.edged_height); |
584 |
image_destroy(&pEnc->f_refhv, pEnc->mbParam.edged_width, |
image_destroy(&pEnc->f_refhv, pEnc->mbParam.edged_width, |
585 |
pEnc->mbParam.edged_height); |
pEnc->mbParam.edged_height); |
586 |
|
|
587 |
#ifdef _DEBUG_PSNR |
if (pEnc->mbParam.global & XVID_GLOBAL_EXTRASTATS) |
588 |
image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
{ image_destroy(&pEnc->sOriginal, pEnc->mbParam.edged_width, |
589 |
pEnc->mbParam.edged_height); |
pEnc->mbParam.edged_height); |
590 |
#endif |
} |
591 |
|
|
592 |
/* Encoder structure */ |
/* Encoder structure */ |
593 |
|
|
690 |
int input_valid = 1; |
int input_valid = 1; |
691 |
int bframes_count = 0; |
int bframes_count = 0; |
692 |
|
|
|
#ifdef _DEBUG_PSNR |
|
693 |
float psnr; |
float psnr; |
694 |
char temp[128]; |
char temp[128]; |
|
#endif |
|
695 |
|
|
696 |
ENC_CHECK(pEnc); |
ENC_CHECK(pEnc); |
697 |
ENC_CHECK(pFrame); |
ENC_CHECK(pFrame); |
729 |
FrameCodeP(pEnc, &bs, &bits, 1, 0); |
FrameCodeP(pEnc, &bs, &bits, 1, 0); |
730 |
bframes_count = 0; |
bframes_count = 0; |
731 |
|
|
732 |
BitstreamPad(&bs); |
BitstreamPadAlways(&bs); |
733 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
734 |
pFrame->intra = 0; |
pFrame->intra = 0; |
735 |
|
|
736 |
|
|
737 |
emms(); |
emms(); |
738 |
|
|
739 |
|
if (pResult) { |
740 |
|
pResult->quant = pEnc->current->quant; |
741 |
|
pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8); |
742 |
|
pResult->kblks = pEnc->current->sStat.kblks; |
743 |
|
pResult->mblks = pEnc->current->sStat.mblks; |
744 |
|
pResult->ublks = pEnc->current->sStat.ublks; |
745 |
|
} |
746 |
|
|
747 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
748 |
} |
} |
749 |
|
|
755 |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs, &bits); |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs, &bits); |
756 |
pEnc->bframenum_head++; |
pEnc->bframenum_head++; |
757 |
|
|
758 |
BitstreamPad(&bs); |
BitstreamPadAlways(&bs); |
759 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
760 |
pFrame->intra = 2; |
pFrame->intra = 2; |
761 |
|
|
762 |
|
if (pResult) { |
763 |
|
pResult->quant = pEnc->current->quant; |
764 |
|
pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8); |
765 |
|
pResult->kblks = pEnc->current->sStat.kblks; |
766 |
|
pResult->mblks = pEnc->current->sStat.mblks; |
767 |
|
pResult->ublks = pEnc->current->sStat.ublks; |
768 |
|
} |
769 |
|
|
770 |
if (input_valid) |
if (input_valid) |
771 |
queue_image(pEnc, pFrame); |
queue_image(pEnc, pFrame); |
772 |
|
|
792 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
793 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
794 |
|
|
|
BitstreamPad(&bs); |
|
795 |
|
|
796 |
tmp = pEnc->current->seconds; |
tmp = pEnc->current->seconds; |
797 |
pEnc->current->seconds = 0; /* force time_base = 0 */ |
pEnc->current->seconds = 0; /* force time_base = 0 */ |
798 |
|
|
799 |
BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); |
BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0); |
800 |
pEnc->current->seconds = tmp; |
pEnc->current->seconds = tmp; |
801 |
|
|
802 |
|
BitstreamPadAlways(&bs); |
803 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
804 |
pFrame->intra = 4; |
pFrame->intra = 4; |
805 |
|
|
806 |
|
if (pResult) { |
807 |
|
pResult->quant = pEnc->current->quant; |
808 |
|
pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8); |
809 |
|
pResult->kblks = pEnc->current->sStat.kblks; |
810 |
|
pResult->mblks = pEnc->current->sStat.mblks; |
811 |
|
pResult->ublks = pEnc->current->sStat.ublks; |
812 |
|
} |
813 |
|
|
814 |
if (input_valid) |
if (input_valid) |
815 |
queue_image(pEnc, pFrame); |
queue_image(pEnc, pFrame); |
816 |
|
|
884 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
885 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
886 |
|
|
887 |
BitstreamPutBits(&bs, 0x7f, 8); |
// BitstreamPutBits(&bs, 0x7f, 8); |
888 |
pFrame->intra = 5; |
pFrame->intra = 5; |
889 |
|
|
890 |
|
if (pResult) { |
891 |
|
/* |
892 |
|
* We must decide what to put there because i know some apps |
893 |
|
* are storing statistics about quantizers and just do |
894 |
|
* stats[quant]++ or stats[quant-1]++ |
895 |
|
* transcode is one of these app with its 2pass module |
896 |
|
*/ |
897 |
|
|
898 |
|
/* |
899 |
|
* For now i prefer 31 than 0 that could lead to a segfault |
900 |
|
* in transcode |
901 |
|
*/ |
902 |
|
pResult->quant = 31; |
903 |
|
|
904 |
|
pResult->hlength = 0; |
905 |
|
pResult->kblks = 0; |
906 |
|
pResult->mblks = 0; |
907 |
|
pResult->ublks = 0; |
908 |
|
} |
909 |
|
|
910 |
|
} else { |
911 |
|
|
912 |
|
if (pResult) { |
913 |
|
pResult->quant = pEnc->current->quant; |
914 |
|
pResult->hlength = pFrame->length - (pEnc->current->sStat.iTextBits / 8); |
915 |
|
pResult->kblks = pEnc->current->sStat.kblks; |
916 |
|
pResult->mblks = pEnc->current->sStat.mblks; |
917 |
|
pResult->ublks = pEnc->current->sStat.ublks; |
918 |
|
} |
919 |
|
|
920 |
} |
} |
921 |
|
|
922 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
923 |
|
|
924 |
emms(); |
emms(); |
925 |
|
|
926 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
927 |
} |
} |
928 |
|
|
954 |
|
|
955 |
inc_frame_num(pEnc); |
inc_frame_num(pEnc); |
956 |
|
|
957 |
#ifdef _DEBUG_PSNR |
if (pFrame->general & XVID_EXTRASTATS) |
958 |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
{ image_copy(&pEnc->sOriginal, &pEnc->current->image, |
959 |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
960 |
#endif |
} |
961 |
|
|
962 |
emms(); |
emms(); |
963 |
|
|
1059 |
} |
} |
1060 |
FrameCodeP(pEnc, &bs, &bits, 1, 0); |
FrameCodeP(pEnc, &bs, &bits, 1, 0); |
1061 |
bframes_count = 0; |
bframes_count = 0; |
|
|
|
1062 |
pFrame->intra = 0; |
pFrame->intra = 0; |
1063 |
|
|
1064 |
} else { |
} else { |
1082 |
* NB : sequences like "IIBB" decode fine with msfdam but, |
* NB : sequences like "IIBB" decode fine with msfdam but, |
1083 |
* go screwy with divx 5.00 |
* go screwy with divx 5.00 |
1084 |
*/ |
*/ |
1085 |
} else if (mode == P_VOP || pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) { |
} else if (mode == P_VOP || mode == S_VOP || pEnc->bframenum_tail >= pEnc->mbParam.max_bframes) { |
1086 |
/* |
/* |
1087 |
* This will be coded as a Predicted Frame |
* This will be coded as a Predicted Frame |
1088 |
*/ |
*/ |
1146 |
goto bvop_loop; |
goto bvop_loop; |
1147 |
} |
} |
1148 |
|
|
1149 |
BitstreamPad(&bs); |
BitstreamPadAlways(&bs); |
1150 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
1151 |
|
|
1152 |
if (pResult) { |
if (pResult) { |
1155 |
pResult->kblks = pEnc->current->sStat.kblks; |
pResult->kblks = pEnc->current->sStat.kblks; |
1156 |
pResult->mblks = pEnc->current->sStat.mblks; |
pResult->mblks = pEnc->current->sStat.mblks; |
1157 |
pResult->ublks = pEnc->current->sStat.ublks; |
pResult->ublks = pEnc->current->sStat.ublks; |
|
} |
|
|
|
|
|
emms(); |
|
1158 |
|
|
1159 |
#ifdef _DEBUG_PSNR |
if (pFrame->general & XVID_EXTRASTATS) |
1160 |
psnr = |
{ pResult->sse_y = |
1161 |
image_psnr(&pEnc->sOriginal, &pEnc->current->image, |
plane_sse( pEnc->sOriginal.y, pEnc->current->image.y, |
1162 |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
1163 |
pEnc->mbParam.height); |
pEnc->mbParam.height); |
1164 |
|
|
1165 |
printf("PSNR: %f\n", psnr); |
pResult->sse_u = |
1166 |
// DEBUG(temp); |
plane_sse( pEnc->sOriginal.u, pEnc->current->image.u, |
1167 |
#endif |
pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2, |
1168 |
|
pEnc->mbParam.height/2); |
1169 |
|
|
1170 |
|
pResult->sse_v = |
1171 |
|
plane_sse( pEnc->sOriginal.v, pEnc->current->image.v, |
1172 |
|
pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2, |
1173 |
|
pEnc->mbParam.height/2); |
1174 |
|
} |
1175 |
|
} |
1176 |
|
|
1177 |
|
emms(); |
1178 |
|
|
1179 |
if (pFrame->quant == 0) { |
if (pFrame->quant == 0) { |
1180 |
RateControlUpdate(&pEnc->rate_control, pEnc->current->quant, |
RateControlUpdate(&pEnc->rate_control, pEnc->current->quant, |
1209 |
uint32_t bits; |
uint32_t bits; |
1210 |
uint16_t write_vol_header = 0; |
uint16_t write_vol_header = 0; |
1211 |
|
|
|
#ifdef _DEBUG_PSNR |
|
1212 |
float psnr; |
float psnr; |
1213 |
uint8_t temp[128]; |
uint8_t temp[128]; |
|
#endif |
|
1214 |
|
|
1215 |
start_global_timer(); |
start_global_timer(); |
1216 |
|
|
1241 |
return XVID_ERR_FORMAT; |
return XVID_ERR_FORMAT; |
1242 |
stop_conv_timer(); |
stop_conv_timer(); |
1243 |
|
|
1244 |
#ifdef _DEBUG_PSNR |
if (pFrame->general & XVID_EXTRASTATS) |
1245 |
image_copy(&pEnc->sOriginal, &pEnc->current->image, |
{ image_copy(&pEnc->sOriginal, &pEnc->current->image, |
1246 |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
1247 |
#endif |
} |
1248 |
|
|
1249 |
emms(); |
emms(); |
1250 |
|
|
1337 |
|
|
1338 |
} |
} |
1339 |
|
|
1340 |
BitstreamPutBits(&bs, 0xFFFF, 16); |
// BitstreamPutBits(&bs, 0xFFFF, 16); |
1341 |
BitstreamPutBits(&bs, 0xFFFF, 16); |
// BitstreamPutBits(&bs, 0xFFFF, 16); |
1342 |
BitstreamPad(&bs); |
BitstreamPadAlways(&bs); |
1343 |
pFrame->length = BitstreamLength(&bs); |
pFrame->length = BitstreamLength(&bs); |
1344 |
|
|
1345 |
if (pResult) { |
if (pResult) { |
1356 |
RateControlUpdate(&pEnc->rate_control, pEnc->current->quant, |
RateControlUpdate(&pEnc->rate_control, pEnc->current->quant, |
1357 |
pFrame->length, pFrame->intra); |
pFrame->length, pFrame->intra); |
1358 |
} |
} |
1359 |
#ifdef _DEBUG_PSNR |
if (pFrame->general & XVID_EXTRASTATS) |
1360 |
|
{ |
1361 |
psnr = |
psnr = |
1362 |
image_psnr(&pEnc->sOriginal, &pEnc->current->image, |
image_psnr(&pEnc->sOriginal, &pEnc->current->image, |
1363 |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
pEnc->mbParam.edged_width, pEnc->mbParam.width, |
1364 |
pEnc->mbParam.height); |
pEnc->mbParam.height); |
1365 |
|
|
1366 |
snprintf(temp, 127, "PSNR: %f\n", psnr); |
snprintf(temp, 127, "PSNR: %f\n", psnr); |
1367 |
// DEBUG(temp); |
} |
|
#endif |
|
1368 |
|
|
1369 |
pEnc->iFrameNum++; |
pEnc->iFrameNum++; |
1370 |
|
|
1530 |
|
|
1531 |
if (intra) { |
if (intra) { |
1532 |
if (!hint->rawhints) { |
if (!hint->rawhints) { |
1533 |
BitstreamPad(&bs); |
BitstreamPadAlways(&bs); |
1534 |
hint->hintlength = BitstreamLength(&bs); |
hint->hintlength = BitstreamLength(&bs); |
1535 |
} |
} |
1536 |
return; |
return; |
1636 |
BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current); |
BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current); |
1637 |
|
|
1638 |
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
1639 |
|
|
1640 |
|
BitstreamPadAlways(bs); |
1641 |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1); |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1); |
1642 |
|
|
1643 |
*pBits = BitstreamPos(bs); |
*pBits = BitstreamPos(bs); |
1777 |
generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image, |
generate_GMCimage(&pEnc->current->gmc_data, &pEnc->reference->image, |
1778 |
pEnc->mbParam.mb_width, pEnc->mbParam.mb_height, |
pEnc->mbParam.mb_width, pEnc->mbParam.mb_height, |
1779 |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2, |
pEnc->mbParam.edged_width, pEnc->mbParam.edged_width/2, |
1780 |
pEnc->mbParam.m_fcode, 0, 0, |
pEnc->mbParam.m_fcode, pEnc->mbParam.m_quarterpel, 0, |
1781 |
pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC); |
pEnc->current->rounding_type, pEnc->current->mbs, &pEnc->vGMC); |
1782 |
|
|
1783 |
} |
} |
1784 |
|
|
1785 |
|
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
1786 |
if (vol_header) |
if (vol_header) |
1787 |
BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current); |
{ BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current); |
1788 |
|
BitstreamPadAlways(bs); |
1789 |
|
} |
1790 |
|
|
|
set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase); |
|
1791 |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1); |
BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1); |
1792 |
|
|
1793 |
*pBits = BitstreamPos(bs); |
*pBits = BitstreamPos(bs); |
1804 |
/* Mode decision: Check, if the block should be INTRA / INTER or GMC-coded */ |
/* Mode decision: Check, if the block should be INTRA / INTER or GMC-coded */ |
1805 |
/* For a start, leave INTRA decision as is, only choose only between INTER/GMC - gruel, 9.1.2002 */ |
/* For a start, leave INTRA decision as is, only choose only between INTER/GMC - gruel, 9.1.2002 */ |
1806 |
|
|
|
|
|
1807 |
bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q); |
bIntra = (pMB->mode == MODE_INTRA) || (pMB->mode == MODE_INTRA_Q); |
1808 |
|
|
1809 |
if (bIntra) { |
if (bIntra) { |
1818 |
pEnc->current->sStat.kblks++; |
pEnc->current->sStat.kblks++; |
1819 |
|
|
1820 |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
1821 |
|
stop_coding_timer(); |
1822 |
continue; |
continue; |
1823 |
} |
} |
1824 |
|
|
1828 |
pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x, |
pEnc->vGMC.y + 16*y*pEnc->mbParam.edged_width + 16*x, |
1829 |
pEnc->mbParam.edged_width,65536); |
pEnc->mbParam.edged_width,65536); |
1830 |
|
|
1831 |
|
if (pEnc->current->motion_flags & PMV_CHROMA16) { |
1832 |
|
iSAD += sad8(pEnc->current->image.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, |
1833 |
|
pEnc->vGMC.u + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2); |
1834 |
|
|
1835 |
|
iSAD += sad8(pEnc->current->image.v + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, |
1836 |
|
pEnc->vGMC.v + 8*y*(pEnc->mbParam.edged_width/2) + 8*x, pEnc->mbParam.edged_width/2); |
1837 |
|
} |
1838 |
|
|
1839 |
if (iSAD <= pMB->sad16) { /* mode decision GMC */ |
if (iSAD <= pMB->sad16) { /* mode decision GMC */ |
1840 |
|
|
1841 |
if (pEnc->mbParam.m_quarterpel) |
if (pEnc->mbParam.m_quarterpel) |
1842 |
pMB->qmvs[0] = pMB->qmvs[1] =pMB->qmvs[2] =pMB->qmvs[3] = pMB->amv; |
pMB->qmvs[0] = pMB->qmvs[1] =pMB->qmvs[2] =pMB->qmvs[3] = pMB->amv; |
1843 |
else |
else |
1849 |
} else { |
} else { |
1850 |
pMB->mcsel = 0; |
pMB->mcsel = 0; |
1851 |
} |
} |
1852 |
} else |
} else { |
|
{ |
|
1853 |
pMB->mcsel = 0; /* just a precaution */ |
pMB->mcsel = 0; /* just a precaution */ |
1854 |
} |
} |
1855 |
|
|
1887 |
dct_codes, qcoeff); |
dct_codes, qcoeff); |
1888 |
} |
} |
1889 |
|
|
|
|
|
1890 |
if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y || |
if (pMB->cbp || pMB->mvs[0].x || pMB->mvs[0].y || |
1891 |
pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x || |
pMB->mvs[1].x || pMB->mvs[1].y || pMB->mvs[2].x || |
1892 |
pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) { |
pMB->mvs[2].y || pMB->mvs[3].x || pMB->mvs[3].y) { |
1899 |
|
|
1900 |
/* Finished processing the MB, now check if to CODE or SKIP */ |
/* Finished processing the MB, now check if to CODE or SKIP */ |
1901 |
|
|
1902 |
skip_possible = (pMB->cbp == 0) & (pMB->mode == MODE_INTER) & |
skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) && |
1903 |
(pMB->dquant == NO_CHANGE); |
(pMB->dquant == NO_CHANGE); |
1904 |
|
|
1905 |
if (pEnc->current->coding_type == S_VOP) |
if (pEnc->current->coding_type == S_VOP) |
1906 |
skip_possible &= (pMB->mcsel == 1); |
skip_possible &= (pMB->mcsel == 1); |
1907 |
else if (pEnc->current->coding_type == P_VOP) { |
else if (pEnc->current->coding_type == P_VOP) { |
1908 |
if (pEnc->mbParam.m_quarterpel) |
if (pEnc->mbParam.m_quarterpel) |
1909 |
skip_possible &= (pMB->qmvs[0].x == 0) & (pMB->qmvs[0].y == 0); |
skip_possible &= ( (pMB->qmvs[0].x == 0) && (pMB->qmvs[0].y == 0) ); |
1910 |
else |
else |
1911 |
skip_possible &= (pMB->mvs[0].x == 0) & (pMB->mvs[0].y == 0); |
skip_possible &= ( (pMB->mvs[0].x == 0) && (pMB->mvs[0].y == 0) ); |
1912 |
} |
} |
1913 |
|
|
1914 |
if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) { |
if ( (pMB->mode == MODE_NOT_CODED) || (skip_possible)) { |
1946 |
pMB->cbp = 0; |
pMB->cbp = 0; |
1947 |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
1948 |
stop_coding_timer(); |
stop_coding_timer(); |
1949 |
|
|
1950 |
continue; /* next MB */ |
continue; /* next MB */ |
1951 |
} |
} |
1952 |
} |
} |
1996 |
|
|
1997 |
} |
} |
1998 |
} |
} |
1999 |
|
|
2000 |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
MBCoding(pEnc->current, pMB, qcoeff, bs, &pEnc->current->sStat); |
2001 |
stop_coding_timer(); |
stop_coding_timer(); |
2002 |
|
|
2003 |
} |
} |
2004 |
} |
} |
2005 |
|
|