21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: encoder.c,v 1.102 2004-03-22 22:36:23 edgomez Exp $ |
* $Id: encoder.c,v 1.103 2004-03-30 12:31:52 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
123 |
if (create->width%2 || create->height%2) |
if (create->width%2 || create->height%2) |
124 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
125 |
|
|
126 |
|
if (create->width<=0 || create->height<=0) |
127 |
|
return XVID_ERR_FAIL; |
128 |
|
|
129 |
/* allocate encoder struct */ |
/* allocate encoder struct */ |
130 |
|
|
131 |
pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE); |
pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE); |
1089 |
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", |
1090 |
pEnc->bframenum_head, pEnc->bframenum_tail, |
pEnc->bframenum_head, pEnc->bframenum_tail, |
1091 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
1092 |
|
pEnc->mbParam.frame_drop_ratio = -1; /* it must be a coded vop */ |
1093 |
|
|
1094 |
FrameCodeP(pEnc, &bs, 1, 0); |
FrameCodeP(pEnc, &bs, 1, 0); |
1095 |
|
|
1343 |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
pEnc->mbParam.edged_width, pEnc->mbParam.height); |
1344 |
} |
} |
1345 |
|
|
1346 |
FrameCodeP(pEnc, &bs, 1, 0); |
if ( FrameCodeP(pEnc, &bs, 1, 0) == 0 ) { |
1347 |
|
/* N-VOP, we mustn't code b-frames yet */ |
1348 |
|
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
1349 |
|
goto done; |
1350 |
|
} |
1351 |
} |
} |
1352 |
|
|
1353 |
|
|
1544 |
MBParam * const pParam = &pEnc->mbParam; |
MBParam * const pParam = &pEnc->mbParam; |
1545 |
int mb_width = pParam->mb_width; |
int mb_width = pParam->mb_width; |
1546 |
int mb_height = pParam->mb_height; |
int mb_height = pParam->mb_height; |
1547 |
|
int coded = 1; |
1548 |
|
|
1549 |
|
|
1550 |
/* IMAGE *pCurrent = ¤t->image; */ |
/* IMAGE *pCurrent = ¤t->image; */ |
1872 |
#if 0 |
#if 0 |
1873 |
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); |
1874 |
#endif |
#endif |
1875 |
if (current->sStat.kblks + current->sStat.mblks < |
if (current->sStat.kblks + current->sStat.mblks <= |
1876 |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100) |
(pParam->frame_drop_ratio * mb_width * mb_height) / 100) |
1877 |
{ |
{ |
1878 |
current->sStat.kblks = current->sStat.mblks = 0; |
current->sStat.kblks = current->sStat.mblks = 0; |
1889 |
current->rounding_type = reference->rounding_type; |
current->rounding_type = reference->rounding_type; |
1890 |
current->fcode = reference->fcode; |
current->fcode = reference->fcode; |
1891 |
current->bcode = reference->bcode; |
current->bcode = reference->bcode; |
1892 |
|
current->stamp = reference->stamp; |
1893 |
image_copy(¤t->image, &reference->image, pParam->edged_width, pParam->height); |
image_copy(¤t->image, &reference->image, pParam->edged_width, pParam->height); |
1894 |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
memcpy(current->mbs, reference->mbs, sizeof(MACROBLOCK) * mb_width * mb_height); |
1895 |
} |
coded = 0; |
1896 |
|
|
1897 |
|
} else { |
1898 |
|
|
1899 |
pEnc->current->is_edged = 0; /* not edged */ |
pEnc->current->is_edged = 0; /* not edged */ |
1900 |
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
pEnc->current->is_interpolated = -1; /* not interpolated (fake rounding -1) */ |
1905 |
image_swap(&pEnc->vInterH, &pEnc->f_refh); |
image_swap(&pEnc->vInterH, &pEnc->f_refh); |
1906 |
image_swap(&pEnc->vInterV, &pEnc->f_refv); |
image_swap(&pEnc->vInterV, &pEnc->f_refv); |
1907 |
image_swap(&pEnc->vInterHV, &pEnc->f_refhv); |
image_swap(&pEnc->vInterHV, &pEnc->f_refhv); |
1908 |
|
} |
1909 |
|
|
1910 |
/* XXX: debug |
/* XXX: debug |
1911 |
{ |
{ |
1926 |
|
|
1927 |
current->length = (BitstreamPos(bs) - bits) / 8; |
current->length = (BitstreamPos(bs) - bits) / 8; |
1928 |
|
|
1929 |
return 0; /* inter */ |
return coded; |
1930 |
} |
} |
1931 |
|
|
1932 |
|
|