00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include <xvid.h>
00029 #include <unistd.h>
00030 #include "avcodec.h"
00031 #include "libxvid_internal.h"
00032
00036 #define BUFFER_SIZE 1024
00037 #define BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x))
00038 #define BUFFER_CAT(x) (&((x)[strlen(x)]))
00039
00040
00041 #if HAVE_ALTIVEC==1
00042 extern int has_altivec(void);
00043 #endif
00044
00049 typedef struct xvid_context {
00050 void *encoder_handle;
00051 int xsize, ysize;
00052 int vop_flags;
00053 int vol_flags;
00054 int me_flags;
00055 int qscale;
00056 int quicktime_format;
00057 AVFrame encoded_picture;
00058 char *twopassbuffer;
00059 char *old_twopassbuffer;
00060 char *twopassfile;
00061 unsigned char *intra_matrix;
00062 unsigned char *inter_matrix;
00063 } xvid_context_t;
00064
00068 typedef struct xvid_ff_pass1 {
00069 int version;
00070 xvid_context_t *context;
00071 } xvid_ff_pass1_t;
00072
00073
00074 int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len);
00075 int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2);
00076 void xvid_correct_framerate(AVCodecContext *avctx);
00077
00086 int ff_xvid_encode_init(AVCodecContext *avctx) {
00087 int xerr, i;
00088 int xvid_flags = avctx->flags;
00089 xvid_context_t *x = avctx->priv_data;
00090 uint16_t *intra, *inter;
00091 int fd;
00092
00093 xvid_plugin_single_t single;
00094 xvid_ff_pass1_t rc2pass1;
00095 xvid_plugin_2pass2_t rc2pass2;
00096 xvid_gbl_init_t xvid_gbl_init;
00097 xvid_enc_create_t xvid_enc_create;
00098 xvid_enc_plugin_t plugins[7];
00099
00100
00101 x->vop_flags = XVID_VOP_HALFPEL;
00102 if( xvid_flags & CODEC_FLAG_4MV )
00103 x->vop_flags |= XVID_VOP_INTER4V;
00104 if( xvid_flags & CODEC_FLAG_TRELLIS_QUANT)
00105 x->vop_flags |= XVID_VOP_TRELLISQUANT;
00106 if( xvid_flags & CODEC_FLAG_AC_PRED )
00107 x->vop_flags |= XVID_VOP_HQACPRED;
00108 if( xvid_flags & CODEC_FLAG_GRAY )
00109 x->vop_flags |= XVID_VOP_GREYSCALE;
00110
00111
00112 x->me_flags = 0;
00113 switch( avctx->me_method ) {
00114 case ME_FULL:
00115 x->me_flags |= XVID_ME_EXTSEARCH16
00116 | XVID_ME_EXTSEARCH8;
00117
00118 case ME_EPZS:
00119 x->me_flags |= XVID_ME_ADVANCEDDIAMOND8
00120 | XVID_ME_HALFPELREFINE8
00121 | XVID_ME_CHROMA_PVOP
00122 | XVID_ME_CHROMA_BVOP;
00123
00124 case ME_LOG:
00125 case ME_PHODS:
00126 case ME_X1:
00127 x->me_flags |= XVID_ME_ADVANCEDDIAMOND16
00128 | XVID_ME_HALFPELREFINE16;
00129
00130 case ME_ZERO:
00131 default:
00132 break;
00133 }
00134
00135
00136 switch( avctx->mb_decision ) {
00137 case 2:
00138 x->vop_flags |= XVID_VOP_MODEDECISION_RD;
00139 x->me_flags |= XVID_ME_HALFPELREFINE8_RD
00140 | XVID_ME_QUARTERPELREFINE8_RD
00141 | XVID_ME_EXTSEARCH_RD
00142 | XVID_ME_CHECKPREDICTION_RD;
00143 case 1:
00144 if( !(x->vop_flags & XVID_VOP_MODEDECISION_RD) )
00145 x->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD;
00146 x->me_flags |= XVID_ME_HALFPELREFINE16_RD
00147 | XVID_ME_QUARTERPELREFINE16_RD;
00148
00149 default:
00150 break;
00151 }
00152
00153
00154 x->vol_flags = 0;
00155 if( xvid_flags & CODEC_FLAG_GMC ) {
00156 x->vol_flags |= XVID_VOL_GMC;
00157 x->me_flags |= XVID_ME_GME_REFINE;
00158 }
00159 if( xvid_flags & CODEC_FLAG_QPEL ) {
00160 x->vol_flags |= XVID_VOL_QUARTERPEL;
00161 x->me_flags |= XVID_ME_QUARTERPELREFINE16;
00162 if( x->vop_flags & XVID_VOP_INTER4V )
00163 x->me_flags |= XVID_ME_QUARTERPELREFINE8;
00164 }
00165
00166 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init));
00167 xvid_gbl_init.version = XVID_VERSION;
00168 xvid_gbl_init.debug = 0;
00169
00170 #ifdef ARCH_POWERPC
00171
00172 #if HAVE_ALTIVEC==1
00173 if( has_altivec() ) {
00174 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC;
00175 } else
00176 #endif
00177 xvid_gbl_init.cpu_flags = XVID_CPU_FORCE;
00178 #else
00179
00180 xvid_gbl_init.cpu_flags = 0;
00181 #endif
00182
00183
00184 xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL);
00185
00186
00187 memset(&xvid_enc_create, 0, sizeof(xvid_enc_create));
00188 xvid_enc_create.version = XVID_VERSION;
00189
00190
00191 xvid_enc_create.width = x->xsize = avctx->width;
00192 xvid_enc_create.height = x->ysize = avctx->height;
00193
00194
00195
00196
00197
00198 xvid_enc_create.zones = NULL;
00199 xvid_enc_create.num_zones = 0;
00200 xvid_enc_create.num_threads = 0;
00201
00202 xvid_enc_create.plugins = plugins;
00203 xvid_enc_create.num_plugins = 0;
00204
00205
00206 x->twopassbuffer = NULL;
00207 x->old_twopassbuffer = NULL;
00208 x->twopassfile = NULL;
00209
00210 if( xvid_flags & CODEC_FLAG_PASS1 ) {
00211 memset(&rc2pass1, 0, sizeof(xvid_ff_pass1_t));
00212 rc2pass1.version = XVID_VERSION;
00213 rc2pass1.context = x;
00214 x->twopassbuffer = av_malloc(BUFFER_SIZE);
00215 x->old_twopassbuffer = av_malloc(BUFFER_SIZE);
00216 if( x->twopassbuffer == NULL || x->old_twopassbuffer == NULL ) {
00217 av_log(avctx, AV_LOG_ERROR,
00218 "XviD: Cannot allocate 2-pass log buffers\n");
00219 return -1;
00220 }
00221 x->twopassbuffer[0] = x->old_twopassbuffer[0] = 0;
00222
00223 plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;
00224 plugins[xvid_enc_create.num_plugins].param = &rc2pass1;
00225 xvid_enc_create.num_plugins++;
00226 } else if( xvid_flags & CODEC_FLAG_PASS2 ) {
00227 memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));
00228 rc2pass2.version = XVID_VERSION;
00229 rc2pass2.bitrate = avctx->bit_rate;
00230
00231 fd = av_tempfile("xvidff.", &(x->twopassfile));
00232 if( fd == -1 ) {
00233 av_log(avctx, AV_LOG_ERROR,
00234 "XviD: Cannot write 2-pass pipe\n");
00235 return -1;
00236 }
00237
00238 if( avctx->stats_in == NULL ) {
00239 av_log(avctx, AV_LOG_ERROR,
00240 "XviD: No 2-pass information loaded for second pass\n");
00241 return -1;
00242 }
00243
00244 if( strlen(avctx->stats_in) >
00245 write(fd, avctx->stats_in, strlen(avctx->stats_in)) ) {
00246 close(fd);
00247 av_log(avctx, AV_LOG_ERROR,
00248 "XviD: Cannot write to 2-pass pipe\n");
00249 return -1;
00250 }
00251
00252 close(fd);
00253 rc2pass2.filename = x->twopassfile;
00254 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
00255 plugins[xvid_enc_create.num_plugins].param = &rc2pass2;
00256 xvid_enc_create.num_plugins++;
00257 } else if( !(xvid_flags & CODEC_FLAG_QSCALE) ) {
00258
00259 memset(&single, 0, sizeof(xvid_plugin_single_t));
00260 single.version = XVID_VERSION;
00261 single.bitrate = avctx->bit_rate;
00262
00263 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;
00264 plugins[xvid_enc_create.num_plugins].param = &single;
00265 xvid_enc_create.num_plugins++;
00266 }
00267
00268
00269 if( 0.0 != avctx->lumi_masking ) {
00270 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
00271 plugins[xvid_enc_create.num_plugins].param = NULL;
00272 xvid_enc_create.num_plugins++;
00273 }
00274
00275
00276 xvid_correct_framerate(avctx);
00277 xvid_enc_create.fincr = avctx->time_base.num;
00278 xvid_enc_create.fbase = avctx->time_base.den;
00279 if( avctx->gop_size > 0 )
00280 xvid_enc_create.max_key_interval = avctx->gop_size;
00281 else
00282 xvid_enc_create.max_key_interval = 240;
00283
00284
00285 if( xvid_flags & CODEC_FLAG_QSCALE ) x->qscale = 1;
00286 else x->qscale = 0;
00287
00288 xvid_enc_create.min_quant[0] = avctx->qmin;
00289 xvid_enc_create.min_quant[1] = avctx->qmin;
00290 xvid_enc_create.min_quant[2] = avctx->qmin;
00291 xvid_enc_create.max_quant[0] = avctx->qmax;
00292 xvid_enc_create.max_quant[1] = avctx->qmax;
00293 xvid_enc_create.max_quant[2] = avctx->qmax;
00294
00295
00296 x->intra_matrix = x->inter_matrix = NULL;
00297 if( avctx->mpeg_quant )
00298 x->vol_flags |= XVID_VOL_MPEGQUANT;
00299 if( (avctx->intra_matrix || avctx->inter_matrix) ) {
00300 x->vol_flags |= XVID_VOL_MPEGQUANT;
00301
00302 if( avctx->intra_matrix ) {
00303 intra = avctx->intra_matrix;
00304 x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
00305 } else
00306 intra = NULL;
00307 if( avctx->inter_matrix ) {
00308 inter = avctx->inter_matrix;
00309 x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
00310 } else
00311 inter = NULL;
00312
00313 for( i = 0; i < 64; i++ ) {
00314 if( intra )
00315 x->intra_matrix[i] = (unsigned char)intra[i];
00316 if( inter )
00317 x->inter_matrix[i] = (unsigned char)inter[i];
00318 }
00319 }
00320
00321
00322 xvid_enc_create.frame_drop_ratio = 0;
00323 xvid_enc_create.global = 0;
00324 if( xvid_flags & CODEC_FLAG_CLOSED_GOP )
00325 xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;
00326
00327
00328 avctx->extradata = NULL;
00329 avctx->extradata_size = 0;
00330 if( xvid_flags & CODEC_FLAG_GLOBAL_HEADER ) {
00331
00332 x->quicktime_format = 1;
00333 avctx->codec_id = CODEC_ID_MPEG4;
00334 } else {
00335
00336 x->quicktime_format = 0;
00337 if(!avctx->codec_tag)
00338 avctx->codec_tag = ff_get_fourcc("xvid");
00339 }
00340
00341
00342 xvid_enc_create.max_bframes = avctx->max_b_frames;
00343 xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
00344 xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
00345 if( avctx->max_b_frames > 0 && !x->quicktime_format ) xvid_enc_create.global |= XVID_GLOBAL_PACKED;
00346
00347
00348 xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
00349 if( xerr ) {
00350 av_log(avctx, AV_LOG_ERROR, "XviD: Could not create encoder reference\n");
00351 return -1;
00352 }
00353
00354 x->encoder_handle = xvid_enc_create.handle;
00355 avctx->coded_frame = &x->encoded_picture;
00356
00357 return 0;
00358 }
00359
00369 int ff_xvid_encode_frame(AVCodecContext *avctx,
00370 unsigned char *frame, int buf_size, void *data) {
00371 int xerr, i;
00372 char *tmp;
00373 xvid_context_t *x = avctx->priv_data;
00374 AVFrame *picture = data;
00375 AVFrame *p = &(x->encoded_picture);
00376
00377 xvid_enc_frame_t xvid_enc_frame;
00378 xvid_enc_stats_t xvid_enc_stats;
00379
00380
00381 memset(&xvid_enc_frame, 0, sizeof(xvid_enc_frame));
00382 xvid_enc_frame.version = XVID_VERSION;
00383 memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats));
00384 xvid_enc_stats.version = XVID_VERSION;
00385 *p = *picture;
00386
00387
00388 xvid_enc_frame.bitstream = frame;
00389 xvid_enc_frame.length = buf_size;
00390
00391
00392 if( avctx->pix_fmt != PIX_FMT_YUV420P ) {
00393 av_log(avctx, AV_LOG_ERROR, "XviD: Color spaces other than 420p not supported\n");
00394 return -1;
00395 }
00396
00397 xvid_enc_frame.input.csp = XVID_CSP_PLANAR;
00398
00399 for( i = 0; i < 4; i++ ) {
00400 xvid_enc_frame.input.plane[i] = picture->data[i];
00401 xvid_enc_frame.input.stride[i] = picture->linesize[i];
00402 }
00403
00404
00405 xvid_enc_frame.vop_flags = x->vop_flags;
00406 xvid_enc_frame.vol_flags = x->vol_flags;
00407 xvid_enc_frame.motion = x->me_flags;
00408 xvid_enc_frame.type = XVID_TYPE_AUTO;
00409
00410
00411 if( x->qscale ) xvid_enc_frame.quant = picture->quality / FF_QP2LAMBDA;
00412 else xvid_enc_frame.quant = 0;
00413
00414
00415 xvid_enc_frame.quant_intra_matrix = x->intra_matrix;
00416 xvid_enc_frame.quant_inter_matrix = x->inter_matrix;
00417
00418
00419 xerr = xvid_encore(x->encoder_handle, XVID_ENC_ENCODE,
00420 &xvid_enc_frame, &xvid_enc_stats);
00421
00422
00423 avctx->stats_out = NULL;
00424 if( x->twopassbuffer ) {
00425 tmp = x->old_twopassbuffer;
00426 x->old_twopassbuffer = x->twopassbuffer;
00427 x->twopassbuffer = tmp;
00428 x->twopassbuffer[0] = 0;
00429 if( x->old_twopassbuffer[0] != 0 ) {
00430 avctx->stats_out = x->old_twopassbuffer;
00431 }
00432 }
00433
00434 if( 0 <= xerr ) {
00435 p->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
00436 if( xvid_enc_stats.type == XVID_TYPE_PVOP )
00437 p->pict_type = FF_P_TYPE;
00438 else if( xvid_enc_stats.type == XVID_TYPE_BVOP )
00439 p->pict_type = FF_B_TYPE;
00440 else if( xvid_enc_stats.type == XVID_TYPE_SVOP )
00441 p->pict_type = FF_S_TYPE;
00442 else
00443 p->pict_type = FF_I_TYPE;
00444 if( xvid_enc_frame.out_flags & XVID_KEYFRAME ) {
00445 p->key_frame = 1;
00446 if( x->quicktime_format )
00447 return xvid_strip_vol_header(avctx, frame,
00448 xvid_enc_stats.hlength, xerr);
00449 } else
00450 p->key_frame = 0;
00451
00452 return xerr;
00453 } else {
00454 av_log(avctx, AV_LOG_ERROR, "XviD: Encoding Error Occurred: %i\n", xerr);
00455 return -1;
00456 }
00457 }
00458
00466 int ff_xvid_encode_close(AVCodecContext *avctx) {
00467 xvid_context_t *x = avctx->priv_data;
00468
00469 xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
00470
00471 if( avctx->extradata != NULL )
00472 av_free(avctx->extradata);
00473 if( x->twopassbuffer != NULL ) {
00474 av_free(x->twopassbuffer);
00475 av_free(x->old_twopassbuffer);
00476 }
00477 if( x->twopassfile != NULL )
00478 av_free(x->twopassfile);
00479 if( x->intra_matrix != NULL )
00480 av_free(x->intra_matrix);
00481 if( x->inter_matrix != NULL )
00482 av_free(x->inter_matrix);
00483
00484 return 0;
00485 }
00486
00500 int xvid_strip_vol_header(AVCodecContext *avctx,
00501 unsigned char *frame,
00502 unsigned int header_len,
00503 unsigned int frame_len) {
00504 int vo_len = 0, i;
00505
00506 for( i = 0; i < header_len - 3; i++ ) {
00507 if( frame[i] == 0x00 &&
00508 frame[i+1] == 0x00 &&
00509 frame[i+2] == 0x01 &&
00510 frame[i+3] == 0xB6 ) {
00511 vo_len = i;
00512 break;
00513 }
00514 }
00515
00516 if( vo_len > 0 ) {
00517
00518 if( avctx->extradata == NULL ) {
00519 avctx->extradata = av_malloc(vo_len);
00520 memcpy(avctx->extradata, frame, vo_len);
00521 avctx->extradata_size = vo_len;
00522 }
00523
00524
00525 memmove(frame, &(frame[vo_len]), frame_len - vo_len);
00526 return frame_len - vo_len;
00527 } else
00528 return frame_len;
00529 }
00530
00540 void xvid_correct_framerate(AVCodecContext *avctx) {
00541 int frate, fbase;
00542 int est_frate, est_fbase;
00543 int gcd;
00544 float est_fps, fps;
00545
00546 frate = avctx->time_base.den;
00547 fbase = avctx->time_base.num;
00548
00549 gcd = ff_gcd(frate, fbase);
00550 if( gcd > 1 ) {
00551 frate /= gcd;
00552 fbase /= gcd;
00553 }
00554
00555 if( frate <= 65000 && fbase <= 65000 ) {
00556 avctx->time_base.den = frate;
00557 avctx->time_base.num = fbase;
00558 return;
00559 }
00560
00561 fps = (float)frate / (float)fbase;
00562 est_fps = roundf(fps * 1000.0) / 1000.0;
00563
00564 est_frate = (int)est_fps;
00565 if( est_fps > (int)est_fps ) {
00566 est_frate = (est_frate + 1) * 1000;
00567 est_fbase = (int)roundf((float)est_frate / est_fps);
00568 } else
00569 est_fbase = 1;
00570
00571 gcd = ff_gcd(est_frate, est_fbase);
00572 if( gcd > 1 ) {
00573 est_frate /= gcd;
00574 est_fbase /= gcd;
00575 }
00576
00577 if( fbase > est_fbase ) {
00578 avctx->time_base.den = est_frate;
00579 avctx->time_base.num = est_fbase;
00580 av_log(avctx, AV_LOG_DEBUG,
00581 "XviD: framerate re-estimated: %.2f, %.3f%% correction\n",
00582 est_fps, (((est_fps - fps)/fps) * 100.0));
00583 } else {
00584 avctx->time_base.den = frate;
00585 avctx->time_base.num = fbase;
00586 }
00587 }
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00606 static int xvid_ff_2pass_create(xvid_plg_create_t * param,
00607 void ** handle) {
00608 xvid_ff_pass1_t *x = (xvid_ff_pass1_t *)param->param;
00609 char *log = x->context->twopassbuffer;
00610
00611
00612 if( log == NULL )
00613 return XVID_ERR_FAIL;
00614
00615
00616
00617 log[0] = 0;
00618 snprintf(log, BUFFER_REMAINING(log),
00619 "# ffmpeg 2-pass log file, using xvid codec\n");
00620 snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
00621 "# Do not modify. libxvidcore version: %d.%d.%d\n\n",
00622 XVID_VERSION_MAJOR(XVID_VERSION),
00623 XVID_VERSION_MINOR(XVID_VERSION),
00624 XVID_VERSION_PATCH(XVID_VERSION));
00625
00626 *handle = x->context;
00627 return 0;
00628 }
00629
00637 static int xvid_ff_2pass_destroy(xvid_context_t *ref,
00638 xvid_plg_destroy_t *param) {
00639
00640
00641 if( ref->twopassbuffer != NULL )
00642 ref->twopassbuffer[0] = 0;
00643 return 0;
00644 }
00645
00653 static int xvid_ff_2pass_before(xvid_context_t *ref,
00654 xvid_plg_data_t *param) {
00655 int motion_remove;
00656 int motion_replacements;
00657 int vop_remove;
00658
00659
00660 if( param->zone && param->zone->mode == XVID_ZONE_QUANT )
00661 return 0;
00662
00663
00664 param->quant = 2;
00665
00666
00667 motion_remove = ~XVID_ME_CHROMA_PVOP &
00668 ~XVID_ME_CHROMA_BVOP &
00669 ~XVID_ME_EXTSEARCH16 &
00670 ~XVID_ME_ADVANCEDDIAMOND16;
00671 motion_replacements = XVID_ME_FAST_MODEINTERPOLATE |
00672 XVID_ME_SKIP_DELTASEARCH |
00673 XVID_ME_FASTREFINE16 |
00674 XVID_ME_BFRAME_EARLYSTOP;
00675 vop_remove = ~XVID_VOP_MODEDECISION_RD &
00676 ~XVID_VOP_FAST_MODEDECISION_RD &
00677 ~XVID_VOP_TRELLISQUANT &
00678 ~XVID_VOP_INTER4V &
00679 ~XVID_VOP_HQACPRED;
00680
00681 param->vol_flags &= ~XVID_VOL_GMC;
00682 param->vop_flags &= vop_remove;
00683 param->motion_flags &= motion_remove;
00684 param->motion_flags |= motion_replacements;
00685
00686 return 0;
00687 }
00688
00696 static int xvid_ff_2pass_after(xvid_context_t *ref,
00697 xvid_plg_data_t *param) {
00698 char *log = ref->twopassbuffer;
00699 char *frame_types = " ipbs";
00700 char frame_type;
00701
00702
00703 if( log == NULL )
00704 return XVID_ERR_FAIL;
00705
00706
00707 if( param->type < 5 && param->type > 0 ) {
00708 frame_type = frame_types[param->type];
00709 } else {
00710 return XVID_ERR_FAIL;
00711 }
00712
00713 snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
00714 "%c %d %d %d %d %d %d\n",
00715 frame_type, param->stats.quant, param->stats.kblks, param->stats.mblks,
00716 param->stats.ublks, param->stats.length, param->stats.hlength);
00717
00718 return 0;
00719 }
00720
00732 int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) {
00733 switch( cmd ) {
00734 case XVID_PLG_INFO:
00735 case XVID_PLG_FRAME:
00736 return 0;
00737
00738 case XVID_PLG_BEFORE:
00739 return xvid_ff_2pass_before(ref, p1);
00740
00741 case XVID_PLG_CREATE:
00742 return xvid_ff_2pass_create(p1, p2);
00743
00744 case XVID_PLG_AFTER:
00745 return xvid_ff_2pass_after(ref, p1);
00746
00747 case XVID_PLG_DESTROY:
00748 return xvid_ff_2pass_destroy(ref, p1);
00749
00750 default:
00751 return XVID_ERR_FAIL;
00752 }
00753 }
00754
00758 AVCodec libxvid_encoder = {
00759 "libxvid",
00760 CODEC_TYPE_VIDEO,
00761 CODEC_ID_XVID,
00762 sizeof(xvid_context_t),
00763 ff_xvid_encode_init,
00764 ff_xvid_encode_frame,
00765 ff_xvid_encode_close,
00766 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
00767 };