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 "libavutil/intreadwrite.h"
00032 #include "libxvid_internal.h"
00033
00037 #define BUFFER_SIZE 1024
00038 #define BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x))
00039 #define BUFFER_CAT(x) (&((x)[strlen(x)]))
00040
00041
00042 int has_altivec(void);
00043
00048 struct xvid_context {
00049 void *encoder_handle;
00050 int xsize, ysize;
00051 int vop_flags;
00052 int vol_flags;
00053 int me_flags;
00054 int qscale;
00055 int quicktime_format;
00056 AVFrame encoded_picture;
00057 char *twopassbuffer;
00058 char *old_twopassbuffer;
00059 char *twopassfile;
00060 unsigned char *intra_matrix;
00061 unsigned char *inter_matrix;
00062 };
00063
00067 struct xvid_ff_pass1 {
00068 int version;
00069 struct xvid_context *context;
00070 };
00071
00072
00073 int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len);
00074 int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2);
00075 void xvid_correct_framerate(AVCodecContext *avctx);
00076
00085 av_cold int ff_xvid_encode_init(AVCodecContext *avctx) {
00086 int xerr, i;
00087 int xvid_flags = avctx->flags;
00088 struct xvid_context *x = avctx->priv_data;
00089 uint16_t *intra, *inter;
00090 int fd;
00091
00092 xvid_plugin_single_t single;
00093 struct xvid_ff_pass1 rc2pass1;
00094 xvid_plugin_2pass2_t rc2pass2;
00095 xvid_gbl_init_t xvid_gbl_init;
00096 xvid_enc_create_t xvid_enc_create;
00097 xvid_enc_plugin_t plugins[7];
00098
00099
00100 x->vop_flags = XVID_VOP_HALFPEL;
00101 if( xvid_flags & CODEC_FLAG_4MV )
00102 x->vop_flags |= XVID_VOP_INTER4V;
00103 if( avctx->trellis
00104 )
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 #if ARCH_PPC
00171
00172 #if HAVE_ALTIVEC
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
00201 xvid_enc_create.num_threads = avctx->thread_count;
00202
00203 xvid_enc_create.plugins = plugins;
00204 xvid_enc_create.num_plugins = 0;
00205
00206
00207 x->twopassbuffer = NULL;
00208 x->old_twopassbuffer = NULL;
00209 x->twopassfile = NULL;
00210
00211 if( xvid_flags & CODEC_FLAG_PASS1 ) {
00212 memset(&rc2pass1, 0, sizeof(struct xvid_ff_pass1));
00213 rc2pass1.version = XVID_VERSION;
00214 rc2pass1.context = x;
00215 x->twopassbuffer = av_malloc(BUFFER_SIZE);
00216 x->old_twopassbuffer = av_malloc(BUFFER_SIZE);
00217 if( x->twopassbuffer == NULL || x->old_twopassbuffer == NULL ) {
00218 av_log(avctx, AV_LOG_ERROR,
00219 "Xvid: Cannot allocate 2-pass log buffers\n");
00220 return -1;
00221 }
00222 x->twopassbuffer[0] = x->old_twopassbuffer[0] = 0;
00223
00224 plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass;
00225 plugins[xvid_enc_create.num_plugins].param = &rc2pass1;
00226 xvid_enc_create.num_plugins++;
00227 } else if( xvid_flags & CODEC_FLAG_PASS2 ) {
00228 memset(&rc2pass2, 0, sizeof(xvid_plugin_2pass2_t));
00229 rc2pass2.version = XVID_VERSION;
00230 rc2pass2.bitrate = avctx->bit_rate;
00231
00232 fd = av_tempfile("xvidff.", &(x->twopassfile));
00233 if( fd == -1 ) {
00234 av_log(avctx, AV_LOG_ERROR,
00235 "Xvid: Cannot write 2-pass pipe\n");
00236 return -1;
00237 }
00238
00239 if( avctx->stats_in == NULL ) {
00240 av_log(avctx, AV_LOG_ERROR,
00241 "Xvid: No 2-pass information loaded for second pass\n");
00242 return -1;
00243 }
00244
00245 if( strlen(avctx->stats_in) >
00246 write(fd, avctx->stats_in, strlen(avctx->stats_in)) ) {
00247 close(fd);
00248 av_log(avctx, AV_LOG_ERROR,
00249 "Xvid: Cannot write to 2-pass pipe\n");
00250 return -1;
00251 }
00252
00253 close(fd);
00254 rc2pass2.filename = x->twopassfile;
00255 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2;
00256 plugins[xvid_enc_create.num_plugins].param = &rc2pass2;
00257 xvid_enc_create.num_plugins++;
00258 } else if( !(xvid_flags & CODEC_FLAG_QSCALE) ) {
00259
00260 memset(&single, 0, sizeof(xvid_plugin_single_t));
00261 single.version = XVID_VERSION;
00262 single.bitrate = avctx->bit_rate;
00263
00264 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single;
00265 plugins[xvid_enc_create.num_plugins].param = &single;
00266 xvid_enc_create.num_plugins++;
00267 }
00268
00269
00270 if( 0.0 != avctx->lumi_masking ) {
00271 plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking;
00272 plugins[xvid_enc_create.num_plugins].param = NULL;
00273 xvid_enc_create.num_plugins++;
00274 }
00275
00276
00277 xvid_correct_framerate(avctx);
00278 xvid_enc_create.fincr = avctx->time_base.num;
00279 xvid_enc_create.fbase = avctx->time_base.den;
00280 if( avctx->gop_size > 0 )
00281 xvid_enc_create.max_key_interval = avctx->gop_size;
00282 else
00283 xvid_enc_create.max_key_interval = 240;
00284
00285
00286 if( xvid_flags & CODEC_FLAG_QSCALE ) x->qscale = 1;
00287 else x->qscale = 0;
00288
00289 xvid_enc_create.min_quant[0] = avctx->qmin;
00290 xvid_enc_create.min_quant[1] = avctx->qmin;
00291 xvid_enc_create.min_quant[2] = avctx->qmin;
00292 xvid_enc_create.max_quant[0] = avctx->qmax;
00293 xvid_enc_create.max_quant[1] = avctx->qmax;
00294 xvid_enc_create.max_quant[2] = avctx->qmax;
00295
00296
00297 x->intra_matrix = x->inter_matrix = NULL;
00298 if( avctx->mpeg_quant )
00299 x->vol_flags |= XVID_VOL_MPEGQUANT;
00300 if( (avctx->intra_matrix || avctx->inter_matrix) ) {
00301 x->vol_flags |= XVID_VOL_MPEGQUANT;
00302
00303 if( avctx->intra_matrix ) {
00304 intra = avctx->intra_matrix;
00305 x->intra_matrix = av_malloc(sizeof(unsigned char) * 64);
00306 } else
00307 intra = NULL;
00308 if( avctx->inter_matrix ) {
00309 inter = avctx->inter_matrix;
00310 x->inter_matrix = av_malloc(sizeof(unsigned char) * 64);
00311 } else
00312 inter = NULL;
00313
00314 for( i = 0; i < 64; i++ ) {
00315 if( intra )
00316 x->intra_matrix[i] = (unsigned char)intra[i];
00317 if( inter )
00318 x->inter_matrix[i] = (unsigned char)inter[i];
00319 }
00320 }
00321
00322
00323 xvid_enc_create.frame_drop_ratio = 0;
00324 xvid_enc_create.global = 0;
00325 if( xvid_flags & CODEC_FLAG_CLOSED_GOP )
00326 xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP;
00327
00328
00329 avctx->extradata = NULL;
00330 avctx->extradata_size = 0;
00331 if( xvid_flags & CODEC_FLAG_GLOBAL_HEADER ) {
00332
00333 x->quicktime_format = 1;
00334 avctx->codec_id = CODEC_ID_MPEG4;
00335 } else {
00336
00337 x->quicktime_format = 0;
00338 if(!avctx->codec_tag)
00339 avctx->codec_tag = AV_RL32("xvid");
00340 }
00341
00342
00343 xvid_enc_create.max_bframes = avctx->max_b_frames;
00344 xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
00345 xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
00346 if( avctx->max_b_frames > 0 && !x->quicktime_format ) xvid_enc_create.global |= XVID_GLOBAL_PACKED;
00347
00348
00349 xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL);
00350 if( xerr ) {
00351 av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
00352 return -1;
00353 }
00354
00355 x->encoder_handle = xvid_enc_create.handle;
00356 avctx->coded_frame = &x->encoded_picture;
00357
00358 return 0;
00359 }
00360
00370 int ff_xvid_encode_frame(AVCodecContext *avctx,
00371 unsigned char *frame, int buf_size, void *data) {
00372 int xerr, i;
00373 char *tmp;
00374 struct xvid_context *x = avctx->priv_data;
00375 AVFrame *picture = data;
00376 AVFrame *p = &(x->encoded_picture);
00377
00378 xvid_enc_frame_t xvid_enc_frame;
00379 xvid_enc_stats_t xvid_enc_stats;
00380
00381
00382 memset(&xvid_enc_frame, 0, sizeof(xvid_enc_frame));
00383 xvid_enc_frame.version = XVID_VERSION;
00384 memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats));
00385 xvid_enc_stats.version = XVID_VERSION;
00386 *p = *picture;
00387
00388
00389 xvid_enc_frame.bitstream = frame;
00390 xvid_enc_frame.length = buf_size;
00391
00392
00393 if( avctx->pix_fmt != PIX_FMT_YUV420P ) {
00394 av_log(avctx, AV_LOG_ERROR, "Xvid: Color spaces other than 420p not supported\n");
00395 return -1;
00396 }
00397
00398 xvid_enc_frame.input.csp = XVID_CSP_PLANAR;
00399
00400 for( i = 0; i < 4; i++ ) {
00401 xvid_enc_frame.input.plane[i] = picture->data[i];
00402 xvid_enc_frame.input.stride[i] = picture->linesize[i];
00403 }
00404
00405
00406 xvid_enc_frame.vop_flags = x->vop_flags;
00407 xvid_enc_frame.vol_flags = x->vol_flags;
00408 xvid_enc_frame.motion = x->me_flags;
00409 xvid_enc_frame.type = XVID_TYPE_AUTO;
00410
00411
00412 if (avctx->sample_aspect_ratio.num < 1 || avctx->sample_aspect_ratio.num > 255 ||
00413 avctx->sample_aspect_ratio.den < 1 || avctx->sample_aspect_ratio.den > 255) {
00414 av_log(avctx, AV_LOG_ERROR, "Invalid pixel aspect ratio %i/%i\n",
00415 avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
00416 return -1;
00417 }
00418 xvid_enc_frame.par = XVID_PAR_EXT;
00419 xvid_enc_frame.par_width = avctx->sample_aspect_ratio.num;
00420 xvid_enc_frame.par_height = avctx->sample_aspect_ratio.den;
00421
00422
00423 if( x->qscale ) xvid_enc_frame.quant = picture->quality / FF_QP2LAMBDA;
00424 else xvid_enc_frame.quant = 0;
00425
00426
00427 xvid_enc_frame.quant_intra_matrix = x->intra_matrix;
00428 xvid_enc_frame.quant_inter_matrix = x->inter_matrix;
00429
00430
00431 xerr = xvid_encore(x->encoder_handle, XVID_ENC_ENCODE,
00432 &xvid_enc_frame, &xvid_enc_stats);
00433
00434
00435 avctx->stats_out = NULL;
00436 if( x->twopassbuffer ) {
00437 tmp = x->old_twopassbuffer;
00438 x->old_twopassbuffer = x->twopassbuffer;
00439 x->twopassbuffer = tmp;
00440 x->twopassbuffer[0] = 0;
00441 if( x->old_twopassbuffer[0] != 0 ) {
00442 avctx->stats_out = x->old_twopassbuffer;
00443 }
00444 }
00445
00446 if( 0 <= xerr ) {
00447 p->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
00448 if( xvid_enc_stats.type == XVID_TYPE_PVOP )
00449 p->pict_type = FF_P_TYPE;
00450 else if( xvid_enc_stats.type == XVID_TYPE_BVOP )
00451 p->pict_type = FF_B_TYPE;
00452 else if( xvid_enc_stats.type == XVID_TYPE_SVOP )
00453 p->pict_type = FF_S_TYPE;
00454 else
00455 p->pict_type = FF_I_TYPE;
00456 if( xvid_enc_frame.out_flags & XVID_KEYFRAME ) {
00457 p->key_frame = 1;
00458 if( x->quicktime_format )
00459 return xvid_strip_vol_header(avctx, frame,
00460 xvid_enc_stats.hlength, xerr);
00461 } else
00462 p->key_frame = 0;
00463
00464 return xerr;
00465 } else {
00466 av_log(avctx, AV_LOG_ERROR, "Xvid: Encoding Error Occurred: %i\n", xerr);
00467 return -1;
00468 }
00469 }
00470
00478 av_cold int ff_xvid_encode_close(AVCodecContext *avctx) {
00479 struct xvid_context *x = avctx->priv_data;
00480
00481 xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
00482
00483 if( avctx->extradata != NULL )
00484 av_free(avctx->extradata);
00485 if( x->twopassbuffer != NULL ) {
00486 av_free(x->twopassbuffer);
00487 av_free(x->old_twopassbuffer);
00488 avctx->stats_out = NULL;
00489 }
00490 if( x->twopassfile != NULL )
00491 av_free(x->twopassfile);
00492 if( x->intra_matrix != NULL )
00493 av_free(x->intra_matrix);
00494 if( x->inter_matrix != NULL )
00495 av_free(x->inter_matrix);
00496
00497 return 0;
00498 }
00499
00513 int xvid_strip_vol_header(AVCodecContext *avctx,
00514 unsigned char *frame,
00515 unsigned int header_len,
00516 unsigned int frame_len) {
00517 int vo_len = 0, i;
00518
00519 for( i = 0; i < header_len - 3; i++ ) {
00520 if( frame[i] == 0x00 &&
00521 frame[i+1] == 0x00 &&
00522 frame[i+2] == 0x01 &&
00523 frame[i+3] == 0xB6 ) {
00524 vo_len = i;
00525 break;
00526 }
00527 }
00528
00529 if( vo_len > 0 ) {
00530
00531 if( avctx->extradata == NULL ) {
00532 avctx->extradata = av_malloc(vo_len);
00533 memcpy(avctx->extradata, frame, vo_len);
00534 avctx->extradata_size = vo_len;
00535 }
00536
00537
00538 memmove(frame, &(frame[vo_len]), frame_len - vo_len);
00539 return frame_len - vo_len;
00540 } else
00541 return frame_len;
00542 }
00543
00553 void xvid_correct_framerate(AVCodecContext *avctx) {
00554 int frate, fbase;
00555 int est_frate, est_fbase;
00556 int gcd;
00557 float est_fps, fps;
00558
00559 frate = avctx->time_base.den;
00560 fbase = avctx->time_base.num;
00561
00562 gcd = av_gcd(frate, fbase);
00563 if( gcd > 1 ) {
00564 frate /= gcd;
00565 fbase /= gcd;
00566 }
00567
00568 if( frate <= 65000 && fbase <= 65000 ) {
00569 avctx->time_base.den = frate;
00570 avctx->time_base.num = fbase;
00571 return;
00572 }
00573
00574 fps = (float)frate / (float)fbase;
00575 est_fps = roundf(fps * 1000.0) / 1000.0;
00576
00577 est_frate = (int)est_fps;
00578 if( est_fps > (int)est_fps ) {
00579 est_frate = (est_frate + 1) * 1000;
00580 est_fbase = (int)roundf((float)est_frate / est_fps);
00581 } else
00582 est_fbase = 1;
00583
00584 gcd = av_gcd(est_frate, est_fbase);
00585 if( gcd > 1 ) {
00586 est_frate /= gcd;
00587 est_fbase /= gcd;
00588 }
00589
00590 if( fbase > est_fbase ) {
00591 avctx->time_base.den = est_frate;
00592 avctx->time_base.num = est_fbase;
00593 av_log(avctx, AV_LOG_DEBUG,
00594 "Xvid: framerate re-estimated: %.2f, %.3f%% correction\n",
00595 est_fps, (((est_fps - fps)/fps) * 100.0));
00596 } else {
00597 avctx->time_base.den = frate;
00598 avctx->time_base.num = fbase;
00599 }
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00619 static int xvid_ff_2pass_create(xvid_plg_create_t * param,
00620 void ** handle) {
00621 struct xvid_ff_pass1 *x = (struct xvid_ff_pass1 *)param->param;
00622 char *log = x->context->twopassbuffer;
00623
00624
00625 if( log == NULL )
00626 return XVID_ERR_FAIL;
00627
00628
00629
00630 log[0] = 0;
00631 snprintf(log, BUFFER_REMAINING(log),
00632 "# ffmpeg 2-pass log file, using xvid codec\n");
00633 snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
00634 "# Do not modify. libxvidcore version: %d.%d.%d\n\n",
00635 XVID_VERSION_MAJOR(XVID_VERSION),
00636 XVID_VERSION_MINOR(XVID_VERSION),
00637 XVID_VERSION_PATCH(XVID_VERSION));
00638
00639 *handle = x->context;
00640 return 0;
00641 }
00642
00650 static int xvid_ff_2pass_destroy(struct xvid_context *ref,
00651 xvid_plg_destroy_t *param) {
00652
00653
00654 if( ref->twopassbuffer != NULL )
00655 ref->twopassbuffer[0] = 0;
00656 return 0;
00657 }
00658
00666 static int xvid_ff_2pass_before(struct xvid_context *ref,
00667 xvid_plg_data_t *param) {
00668 int motion_remove;
00669 int motion_replacements;
00670 int vop_remove;
00671
00672
00673 if( param->zone && param->zone->mode == XVID_ZONE_QUANT )
00674 return 0;
00675
00676
00677 param->quant = 2;
00678
00679
00680 motion_remove = ~XVID_ME_CHROMA_PVOP &
00681 ~XVID_ME_CHROMA_BVOP &
00682 ~XVID_ME_EXTSEARCH16 &
00683 ~XVID_ME_ADVANCEDDIAMOND16;
00684 motion_replacements = XVID_ME_FAST_MODEINTERPOLATE |
00685 XVID_ME_SKIP_DELTASEARCH |
00686 XVID_ME_FASTREFINE16 |
00687 XVID_ME_BFRAME_EARLYSTOP;
00688 vop_remove = ~XVID_VOP_MODEDECISION_RD &
00689 ~XVID_VOP_FAST_MODEDECISION_RD &
00690 ~XVID_VOP_TRELLISQUANT &
00691 ~XVID_VOP_INTER4V &
00692 ~XVID_VOP_HQACPRED;
00693
00694 param->vol_flags &= ~XVID_VOL_GMC;
00695 param->vop_flags &= vop_remove;
00696 param->motion_flags &= motion_remove;
00697 param->motion_flags |= motion_replacements;
00698
00699 return 0;
00700 }
00701
00709 static int xvid_ff_2pass_after(struct xvid_context *ref,
00710 xvid_plg_data_t *param) {
00711 char *log = ref->twopassbuffer;
00712 char *frame_types = " ipbs";
00713 char frame_type;
00714
00715
00716 if( log == NULL )
00717 return XVID_ERR_FAIL;
00718
00719
00720 if( param->type < 5 && param->type > 0 ) {
00721 frame_type = frame_types[param->type];
00722 } else {
00723 return XVID_ERR_FAIL;
00724 }
00725
00726 snprintf(BUFFER_CAT(log), BUFFER_REMAINING(log),
00727 "%c %d %d %d %d %d %d\n",
00728 frame_type, param->stats.quant, param->stats.kblks, param->stats.mblks,
00729 param->stats.ublks, param->stats.length, param->stats.hlength);
00730
00731 return 0;
00732 }
00733
00745 int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) {
00746 switch( cmd ) {
00747 case XVID_PLG_INFO:
00748 case XVID_PLG_FRAME:
00749 return 0;
00750
00751 case XVID_PLG_BEFORE:
00752 return xvid_ff_2pass_before(ref, p1);
00753
00754 case XVID_PLG_CREATE:
00755 return xvid_ff_2pass_create(p1, p2);
00756
00757 case XVID_PLG_AFTER:
00758 return xvid_ff_2pass_after(ref, p1);
00759
00760 case XVID_PLG_DESTROY:
00761 return xvid_ff_2pass_destroy(ref, p1);
00762
00763 default:
00764 return XVID_ERR_FAIL;
00765 }
00766 }
00767
00771 AVCodec libxvid_encoder = {
00772 "libxvid",
00773 CODEC_TYPE_VIDEO,
00774 CODEC_ID_XVID,
00775 sizeof(struct xvid_context),
00776 ff_xvid_encode_init,
00777 ff_xvid_encode_frame,
00778 ff_xvid_encode_close,
00779 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
00780 .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"),
00781 };