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.119 2005-08-01 10:53:46 Isibaar Exp $ |
* $Id: encoder.c,v 1.120 2005-11-22 10:23:01 suxen_drol Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
203 |
|
|
204 |
memset(&pinfo, 0, sizeof(xvid_plg_info_t)); |
memset(&pinfo, 0, sizeof(xvid_plg_info_t)); |
205 |
pinfo.version = XVID_VERSION; |
pinfo.version = XVID_VERSION; |
206 |
if (create->plugins[n].func(0, XVID_PLG_INFO, &pinfo, 0) >= 0) { |
if (create->plugins[n].func(NULL, XVID_PLG_INFO, &pinfo, NULL) >= 0) { |
207 |
pEnc->mbParam.plugin_flags |= pinfo.flags; |
pEnc->mbParam.plugin_flags |= pinfo.flags; |
208 |
} |
} |
209 |
|
|
220 |
pcreate.param = create->plugins[n].param; |
pcreate.param = create->plugins[n].param; |
221 |
|
|
222 |
pEnc->plugins[n].func = NULL; /* disable plugins that fail */ |
pEnc->plugins[n].func = NULL; /* disable plugins that fail */ |
223 |
if (create->plugins[n].func(0, XVID_PLG_CREATE, &pcreate, &pEnc->plugins[n].param) >= 0) { |
if (create->plugins[n].func(NULL, XVID_PLG_CREATE, &pcreate, &pEnc->plugins[n].param) >= 0) { |
224 |
pEnc->plugins[n].func = create->plugins[n].func; |
pEnc->plugins[n].func = create->plugins[n].func; |
225 |
} |
} |
226 |
} |
} |
522 |
xvid_err_memory0: |
xvid_err_memory0: |
523 |
for (n=0; n<pEnc->num_plugins;n++) { |
for (n=0; n<pEnc->num_plugins;n++) { |
524 |
if (pEnc->plugins[n].func) { |
if (pEnc->plugins[n].func) { |
525 |
pEnc->plugins[n].func(pEnc->plugins[n].param, XVID_PLG_DESTROY, 0, 0); |
pEnc->plugins[n].func(pEnc->plugins[n].param, XVID_PLG_DESTROY, NULL, NULL); |
526 |
} |
} |
527 |
} |
} |
528 |
xvid_free(pEnc->plugins); |
xvid_free(pEnc->plugins); |
627 |
|
|
628 |
for (i=0; i<pEnc->num_plugins;i++) { |
for (i=0; i<pEnc->num_plugins;i++) { |
629 |
if (pEnc->plugins[i].func) { |
if (pEnc->plugins[i].func) { |
630 |
pEnc->plugins[i].func(pEnc->plugins[i].param, XVID_PLG_DESTROY, &pdestroy, 0); |
pEnc->plugins[i].func(pEnc->plugins[i].param, XVID_PLG_DESTROY, &pdestroy, NULL); |
631 |
} |
} |
632 |
} |
} |
633 |
xvid_free(pEnc->plugins); |
xvid_free(pEnc->plugins); |
787 |
for (i=0; i<(unsigned int)pEnc->num_plugins;i++) { |
for (i=0; i<(unsigned int)pEnc->num_plugins;i++) { |
788 |
emms(); |
emms(); |
789 |
if (pEnc->plugins[i].func) { |
if (pEnc->plugins[i].func) { |
790 |
if (pEnc->plugins[i].func(pEnc->plugins[i].param, opt, &data, 0) < 0) { |
if (pEnc->plugins[i].func(pEnc->plugins[i].param, opt, &data, NULL) < 0) { |
791 |
continue; |
continue; |
792 |
} |
} |
793 |
} |
} |
1010 |
} |
} |
1011 |
|
|
1012 |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs); |
FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs); |
1013 |
call_plugins(pEnc, pEnc->bframes[pEnc->bframenum_head], &pEnc->sOriginal2, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->bframes[pEnc->bframenum_head], &pEnc->sOriginal2, XVID_PLG_AFTER, NULL, NULL, stats); |
1014 |
pEnc->bframenum_head++; |
pEnc->bframenum_head++; |
1015 |
|
|
1016 |
goto done; |
goto done; |
1042 |
|
|
1043 |
/* add the not-coded length to the reference frame size */ |
/* add the not-coded length to the reference frame size */ |
1044 |
pEnc->current->length += (BitstreamPos(&bs) - bits) / 8; |
pEnc->current->length += (BitstreamPos(&bs) - bits) / 8; |
1045 |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1046 |
|
|
1047 |
/* flush complete: reset counters */ |
/* flush complete: reset counters */ |
1048 |
pEnc->flush_bframes = 0; |
pEnc->flush_bframes = 0; |
1070 |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size); |
1071 |
|
|
1072 |
if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->mbParam.max_bframes > 0) { |
if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->mbParam.max_bframes > 0) { |
1073 |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1074 |
} |
} |
1075 |
|
|
1076 |
/* if the very last frame is to be b-vop, we must change it to a p-vop */ |
/* if the very last frame is to be b-vop, we must change it to a p-vop */ |
1099 |
|
|
1100 |
|
|
1101 |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) { |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail==0) { |
1102 |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1103 |
}else{ |
}else{ |
1104 |
pEnc->flush_bframes = 1; |
pEnc->flush_bframes = 1; |
1105 |
goto done; |
goto done; |
1223 |
if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->mbParam.max_bframes > 0) |
if (!(pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) && pEnc->mbParam.max_bframes > 0) |
1224 |
{ |
{ |
1225 |
if (pEnc->current->stamp > 0) { |
if (pEnc->current->stamp > 0) { |
1226 |
call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1227 |
} |
} |
1228 |
else |
else |
1229 |
stats->type = XVID_TYPE_NOTHING; |
stats->type = XVID_TYPE_NOTHING; |
1346 |
|
|
1347 |
if ( FrameCodeP(pEnc, &bs) == 0 ) { |
if ( FrameCodeP(pEnc, &bs) == 0 ) { |
1348 |
/* N-VOP, we mustn't code b-frames yet */ |
/* N-VOP, we mustn't code b-frames yet */ |
1349 |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1350 |
goto done; |
goto done; |
1351 |
} |
} |
1352 |
} |
} |
1367 |
|
|
1368 |
/* packed or no-bframes or no-bframes-queued: output stats */ |
/* packed or no-bframes or no-bframes-queued: output stats */ |
1369 |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) || pEnc->mbParam.max_bframes == 0 ) { |
if ((pEnc->mbParam.global_flags & XVID_GLOBAL_PACKED) || pEnc->mbParam.max_bframes == 0 ) { |
1370 |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats); |
call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, NULL, NULL, stats); |
1371 |
} |
} |
1372 |
|
|
1373 |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |