1 /*****************************************************************************
3 * - XviD 1.x export module for mplayer/mencoder -
5 * Copyright(C) 2003 Marco Belli <elcabesa@inwind.it>
6 * 2003-2004 Edouard Gomez <ed.gomez@free.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ****************************************************************************/
24 /*****************************************************************************
26 ****************************************************************************/
36 #include "../config.h"
37 #include "../mp_msg.h"
41 #include "codec-cfg.h"
48 #include "img_format.h"
60 #define XVID_FIRST_PASS_FILENAME "xvid-twopass.stats"
64 // Code taken from Libavcodec and ve_lavc.c to handle Aspect Ratio calculation
66 typedef struct xvid_rational_s
{
71 #define MAX(a,b) ((a) > (b) ? (a) : (b))
72 #define ABS(a) ((a) >= 0 ? (a) : (-(a)))
75 static int64_t xvid_gcd(int64_t a
, int64_t b
){
76 if(b
) return xvid_gcd(b
, a
%b
);
80 static int xvid_reduce(int *dst_nom
, int *dst_den
, int64_t nom
, int64_t den
, int64_t max
){
96 gcd
= xvid_gcd(nom
, den
);
100 if(nom
> max
|| den
> max
){
101 XVIDRational a0
={0,1}, a1
={1,0};
105 int64_t x
= nom
/ den
;
106 int64_t a2n
= x
*a1
.num
+ a0
.num
;
107 int64_t a2d
= x
*a1
.den
+ a0
.den
;
109 if(a2n
> max
|| a2d
> max
) break;
114 a1
= (XVIDRational
){a2n
, a2d
};
116 x
= nom
; nom
=den
; den
=x
;
122 assert(xvid_gcd(nom
, den
) == 1);
133 static XVIDRational
xvid_d2q(double d
, int max
){
135 int exponent
= MAX( (int)(log(ABS(d
) + 1e-20)/log(2)), 0);
136 int64_t den
= 1LL << (61 - exponent
);
137 xvid_reduce(&a
.num
, &a
.den
, (int64_t)(d
* den
+ 0.5), den
, max
);
144 /*****************************************************************************
145 * Configuration options
146 ****************************************************************************/
148 static int xvidenc_bitrate
= 0;
149 static int xvidenc_pass
= 0;
150 static float xvidenc_quantizer
= 0;
152 static int xvidenc_packed
= 0;
153 static int xvidenc_closed_gop
= 1;
154 static int xvidenc_interlaced
= 0;
155 static int xvidenc_quarterpel
= 0;
156 static int xvidenc_gmc
= 0;
157 static int xvidenc_trellis
= 0;
158 static int xvidenc_cartoon
= 0;
159 static int xvidenc_hqacpred
= 1;
160 static int xvidenc_chromame
= 0;
161 static int xvidenc_chroma_opt
= 0;
162 static int xvidenc_vhq
= 0;
163 static int xvidenc_bvhq
= 0;
164 static int xvidenc_motion
= 6;
165 static int xvidenc_turbo
= 0;
166 static int xvidenc_stats
= 0;
167 static int xvidenc_max_key_interval
= 0; /* Let xvidcore set a 10s interval by default */
168 static int xvidenc_frame_drop_ratio
= 0;
169 static int xvidenc_greyscale
= 0;
170 static int xvidenc_debug
= 0;
171 static int xvidenc_psnr
= 0;
173 static int xvidenc_max_bframes
= 2;
174 static int xvidenc_bquant_ratio
= 150;
175 static int xvidenc_bquant_offset
= 100;
176 static int xvidenc_bframe_threshold
= 0;
178 static int xvidenc_min_quant
[3] = {2, 2, 2};
179 static int xvidenc_max_quant
[3] = {31, 31, 31};
180 static char *xvidenc_intra_matrix_file
= NULL
;
181 static char *xvidenc_inter_matrix_file
= NULL
;
182 static char *xvidenc_quant_method
= NULL
;
184 static int xvidenc_cbr_reaction_delay_factor
= 0;
185 static int xvidenc_cbr_averaging_period
= 0;
186 static int xvidenc_cbr_buffer
= 0;
188 static int xvidenc_vbr_keyframe_boost
= 0;
189 static int xvidenc_vbr_overflow_control_strength
= 5;
190 static int xvidenc_vbr_curve_compression_high
= 0;
191 static int xvidenc_vbr_curve_compression_low
= 0;
192 static int xvidenc_vbr_max_overflow_improvement
= 5;
193 static int xvidenc_vbr_max_overflow_degradation
= 5;
194 static int xvidenc_vbr_kfreduction
= 0;
195 static int xvidenc_vbr_kfthreshold
= 0;
196 static int xvidenc_vbr_container_frame_overhead
= 24; /* mencoder uses AVI container */
198 static char *xvidenc_par
= NULL
;
199 static int xvidenc_par_width
= 0;
200 static int xvidenc_par_height
= 0;
201 static float xvidenc_dar_aspect
= 0.0f
;
202 static int xvidenc_autoaspect
= 0;
204 m_option_t xvidencopts_conf
[] =
206 /* Standard things mencoder should be able to treat directly */
207 {"bitrate", &xvidenc_bitrate
, CONF_TYPE_INT
, 0, 0, 0, NULL
},
208 {"pass", &xvidenc_pass
, CONF_TYPE_INT
, CONF_RANGE
, 1, 2, NULL
},
209 {"fixed_quant", &xvidenc_quantizer
, CONF_TYPE_FLOAT
, CONF_RANGE
, 1, 31, NULL
},
212 {"quant_type", &xvidenc_quant_method
, CONF_TYPE_STRING
, 0, 0, 0, NULL
},
213 {"me_quality", &xvidenc_motion
, CONF_TYPE_INT
, CONF_RANGE
, 0, 6, NULL
},
214 {"chroma_me", &xvidenc_chromame
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
215 {"chroma_opt", &xvidenc_chroma_opt
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
216 {"vhq", &xvidenc_vhq
, CONF_TYPE_INT
, CONF_RANGE
, 0, 4, NULL
},
217 {"bvhq", &xvidenc_bvhq
, CONF_TYPE_INT
, CONF_RANGE
, 0, 1, NULL
},
218 {"max_bframes", &xvidenc_max_bframes
, CONF_TYPE_INT
, CONF_RANGE
, 0, 20, NULL
},
219 {"bquant_ratio", &xvidenc_bquant_ratio
, CONF_TYPE_INT
, CONF_RANGE
, 0, 200, NULL
},
220 {"bquant_offset", &xvidenc_bquant_offset
, CONF_TYPE_INT
, CONF_RANGE
, 0, 200, NULL
},
221 {"bf_threshold", &xvidenc_bframe_threshold
, CONF_TYPE_INT
, CONF_RANGE
, -255, 255, NULL
},
222 {"qpel", &xvidenc_quarterpel
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
223 {"gmc", &xvidenc_gmc
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
224 {"trellis", &xvidenc_trellis
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
225 {"packed", &xvidenc_packed
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
226 {"closed_gop", &xvidenc_closed_gop
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
227 {"interlacing", &xvidenc_interlaced
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
228 {"cartoon", &xvidenc_cartoon
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
229 {"hq_ac", &xvidenc_hqacpred
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
230 {"frame_drop_ratio", &xvidenc_frame_drop_ratio
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
231 {"max_key_interval", &xvidenc_max_key_interval
, CONF_TYPE_INT
, CONF_MIN
, 0, 0, NULL
},
232 {"greyscale", &xvidenc_greyscale
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
233 {"turbo", &xvidenc_turbo
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
234 {"debug", &xvidenc_debug
, CONF_TYPE_INT
, 0 ,0,-1,NULL
},
235 {"stats", &xvidenc_stats
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
236 {"psnr", &xvidenc_psnr
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
239 /* section [quantizer] */
240 {"min_iquant", &xvidenc_min_quant
[0], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
241 {"max_iquant", &xvidenc_max_quant
[0], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
242 {"min_pquant", &xvidenc_min_quant
[1], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
243 {"max_pquant", &xvidenc_max_quant
[1], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
244 {"min_bquant", &xvidenc_min_quant
[2], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
245 {"max_bquant", &xvidenc_max_quant
[2], CONF_TYPE_INT
, CONF_RANGE
, 1, 31, NULL
},
246 {"quant_intra_matrix", &xvidenc_intra_matrix_file
, CONF_TYPE_STRING
, 0, 0, 100, NULL
},
247 {"quant_inter_matrix", &xvidenc_inter_matrix_file
, CONF_TYPE_STRING
, 0, 0, 100, NULL
},
250 {"rc_reaction_delay_factor", &xvidenc_cbr_reaction_delay_factor
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
251 {"rc_averaging_period", &xvidenc_cbr_averaging_period
, CONF_TYPE_INT
, CONF_MIN
, 0, 0, NULL
},
252 {"rc_buffer", &xvidenc_cbr_buffer
, CONF_TYPE_INT
, CONF_MIN
, 0, 0, NULL
},
255 {"keyframe_boost", &xvidenc_vbr_keyframe_boost
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
256 {"curve_compression_high", &xvidenc_vbr_curve_compression_high
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
257 {"curve_compression_low", &xvidenc_vbr_curve_compression_low
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
258 {"overflow_control_strength", &xvidenc_vbr_overflow_control_strength
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
259 {"max_overflow_improvement", &xvidenc_vbr_max_overflow_improvement
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
260 {"max_overflow_degradation", &xvidenc_vbr_max_overflow_degradation
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
261 {"kfreduction", &xvidenc_vbr_kfreduction
, CONF_TYPE_INT
, CONF_RANGE
, 0, 100, NULL
},
262 {"kfthreshold", &xvidenc_vbr_kfthreshold
, CONF_TYPE_INT
, CONF_MIN
, 0, 0, NULL
},
263 {"container_frame_overhead", &xvidenc_vbr_container_frame_overhead
, CONF_TYPE_INT
, CONF_MIN
, 0, 0, NULL
},
265 /* Section Aspect Ratio */
266 {"par", &xvidenc_par
, CONF_TYPE_STRING
, 0, 0, 0, NULL
},
267 {"par_width", &xvidenc_par_width
, CONF_TYPE_INT
, CONF_RANGE
, 0, 255, NULL
},
268 {"par_height", &xvidenc_par_height
, CONF_TYPE_INT
, CONF_RANGE
, 0, 255, NULL
},
269 {"aspect", &xvidenc_dar_aspect
, CONF_TYPE_FLOAT
, CONF_RANGE
, 0.1, 9.99, NULL
},
270 {"autoaspect", &xvidenc_autoaspect
, CONF_TYPE_FLAG
, 0, 0, 1, NULL
},
272 /* End of the config array */
273 {NULL
, 0, 0, 0, 0, 0, NULL
}
276 /*****************************************************************************
277 * Module private data
278 ****************************************************************************/
280 typedef struct _xvid_mplayer_module_t
282 /* Instance related global vars */
284 xvid_gbl_init_t init
;
285 xvid_enc_create_t create
;
286 xvid_enc_frame_t frame
;
287 xvid_plugin_single_t onepass
;
288 xvid_plugin_2pass1_t pass1
;
289 xvid_plugin_2pass2_t pass2
;
291 /* This data must survive local block scope, so here it is */
292 xvid_enc_plugin_t plugins
[7];
293 xvid_enc_zone_t zones
[1];
295 /* MPEG4 stream buffer */
298 /* Stats accumulators */
316 /* DAR/PAR and all that thingies */
320 } xvid_mplayer_module_t
;
322 static void dispatch_settings(xvid_mplayer_module_t
*mod
);
323 static int set_create_struct(xvid_mplayer_module_t
*mod
);
324 static int set_frame_struct(xvid_mplayer_module_t
*mod
, mp_image_t
*mpi
);
325 static void update_stats(xvid_mplayer_module_t
*mod
, xvid_enc_stats_t
*stats
);
326 static void print_stats(xvid_mplayer_module_t
*mod
);
327 static void flush_internal_buffers(xvid_mplayer_module_t
*mod
);
328 static const char *par_string(int parcode
);
329 static const char *errorstring(int err
);
331 /*****************************************************************************
332 * Video Filter API function definitions
333 ****************************************************************************/
335 /*============================================================================
337 *==========================================================================*/
340 config(struct vf_instance_s
* vf
,
341 int width
, int height
, int d_width
, int d_height
,
342 unsigned int flags
, unsigned int outfmt
)
345 xvid_mplayer_module_t
*mod
= (xvid_mplayer_module_t
*)vf
->priv
;
347 /* Complete the muxer initialization */
348 mod
->mux
->bih
->biWidth
= width
;
349 mod
->mux
->bih
->biHeight
= height
;
350 mod
->mux
->bih
->biSizeImage
=
351 mod
->mux
->bih
->biWidth
* mod
->mux
->bih
->biHeight
* 3 / 2;
352 mod
->mux
->aspect
= (float)d_width
/d_height
;
354 /* Message the FourCC type */
355 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
356 "videocodec: XviD (%dx%d fourcc=%x [%.4s])\n",
357 width
, height
, mod
->mux
->bih
->biCompression
,
358 (char *)&mod
->mux
->bih
->biCompression
);
360 /* Total number of pixels per frame required for PSNR */
361 mod
->pixels
= mod
->mux
->bih
->biWidth
*mod
->mux
->bih
->biHeight
;
363 /*--------------------------------------------------------------------
364 * Dispatch all module settings to XviD structures
365 *------------------------------------------------------------------*/
367 mod
->d_width
= d_width
;
368 mod
->d_height
= d_height
;
370 dispatch_settings(mod
);
372 /*--------------------------------------------------------------------
373 * Set remaining information in the xvid_enc_create_t structure
374 *------------------------------------------------------------------*/
376 if(set_create_struct(mod
) == BAD
)
379 /*--------------------------------------------------------------------
380 * Encoder instance creation
381 *------------------------------------------------------------------*/
383 err
= xvid_encore(NULL
, XVID_ENC_CREATE
, &mod
->create
, NULL
);
386 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
387 "xvid: xvidcore returned a '%s' error\n", errorstring(err
));
391 /* Store the encoder instance into the private data */
392 mod
->instance
= mod
->create
.handle
;
397 /*============================================================================
399 *==========================================================================*/
402 uninit(struct vf_instance_s
* vf
)
405 xvid_mplayer_module_t
*mod
= (xvid_mplayer_module_t
*)vf
->priv
;
407 /* Destroy xvid instance */
408 xvid_encore(mod
->instance
, XVID_ENC_DESTROY
, NULL
, NULL
);
410 /* Display stats (if any) */
413 /* Close PSNR file if ever opened */
415 fclose(mod
->fvstats
);
419 /* Free allocated memory */
420 if(mod
->frame
.quant_intra_matrix
)
421 free(mod
->frame
.quant_intra_matrix
);
423 if(mod
->frame
.quant_inter_matrix
)
424 free(mod
->frame
.quant_inter_matrix
);
435 /*============================================================================
437 *==========================================================================*/
440 control(struct vf_instance_s
* vf
, int request
, void* data
)
442 xvid_mplayer_module_t
*mod
= (xvid_mplayer_module_t
*)vf
->priv
;
445 case VFCTRL_FLUSH_FRAMES
:
447 flush_internal_buffers(mod
);
450 return(CONTROL_UNKNOWN
);
453 /*============================================================================
455 *==========================================================================*/
458 query_format(struct vf_instance_s
* vf
, unsigned int fmt
)
464 return(VFCAP_CSP_SUPPORTED
| VFCAP_CSP_SUPPORTED_BY_HW
);
467 return(VFCAP_CSP_SUPPORTED
);
472 /*============================================================================
474 *==========================================================================*/
477 put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
)
480 xvid_enc_stats_t stats
;
481 xvid_mplayer_module_t
*mod
= (xvid_mplayer_module_t
*)vf
->priv
;
483 /* Prepare the stats */
484 memset(&stats
,0,sizeof( xvid_enc_stats_t
));
485 stats
.version
= XVID_VERSION
;
487 /* -------------------------------------------------------------------
488 * Set remaining information in the xvid_enc_frame_t structure
489 * NB: all the other struct members were initialized by
491 * -----------------------------------------------------------------*/
493 if(set_frame_struct(mod
, mpi
) == BAD
)
496 /* -------------------------------------------------------------------
498 * ---------------------------------------------------------------- */
500 size
= xvid_encore(mod
->instance
, XVID_ENC_ENCODE
, &mod
->frame
, &stats
);
502 /* Analyse the returned value */
504 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
505 "xvid: xvidcore returned a '%s' error\n", errorstring(size
));
509 /* If size is == 0, we're done with that frame */
510 if(size
== 0) return(FINE
);
512 /* xvidcore returns stats about encoded frame in an asynchronous way
513 * accumulate these stats */
514 update_stats(mod
, &stats
);
516 /* xvidcore outputed bitstream -- mux it */
517 muxer_write_chunk(mod
->mux
,
519 (mod
->frame
.out_flags
& XVID_KEYFRAME
)?0x10:0);
524 /*============================================================================
526 *==========================================================================*/
529 vf_open(vf_instance_t
*vf
, char* args
)
531 xvid_mplayer_module_t
*mod
;
532 xvid_gbl_init_t xvid_gbl_init
;
533 xvid_gbl_info_t xvid_gbl_info
;
535 /* Setting libmpcodec module API pointers */
537 vf
->control
= control
;
539 vf
->query_format
= query_format
;
540 vf
->put_image
= put_image
;
542 /* Allocate the private part of the codec module */
543 vf
->priv
= malloc(sizeof(xvid_mplayer_module_t
));
544 mod
= (xvid_mplayer_module_t
*)vf
->priv
;
547 mp_msg(MSGT_MENCODER
,MSGL_ERR
,
548 "xvid: memory allocation failure (private data)\n");
552 /* Initialize the module to zeros */
553 memset(mod
, 0, sizeof(xvid_mplayer_module_t
));
554 mod
->min_sse_y
= mod
->min_sse_u
= mod
->min_sse_v
= INT_MAX
;
555 mod
->max_sse_y
= mod
->max_sse_u
= mod
->max_sse_v
= INT_MIN
;
558 mod
->mux
= (muxer_stream_t
*)args
;
560 /* Initialize muxer BITMAP header */
561 mod
->mux
->bih
= malloc(sizeof(BITMAPINFOHEADER
));
563 if(mod
->mux
->bih
== NULL
) {
564 mp_msg(MSGT_MENCODER
,MSGL_ERR
,
565 "xvid: memory allocation failure (BITMAP header)\n");
569 mod
->mux
->bih
->biSize
= sizeof(BITMAPINFOHEADER
);
570 mod
->mux
->bih
->biWidth
= 0;
571 mod
->mux
->bih
->biHeight
= 0;
572 mod
->mux
->bih
->biPlanes
= 1;
573 mod
->mux
->bih
->biBitCount
= 12;
574 mod
->mux
->bih
->biCompression
= mmioFOURCC('X','V','I','D');
576 /* Retrieve information about the host XviD library */
577 memset(&xvid_gbl_info
, 0, sizeof(xvid_gbl_info_t
));
578 xvid_gbl_info
.version
= XVID_VERSION
;
580 if (xvid_global(NULL
, XVID_GBL_INFO
, &xvid_gbl_info
, NULL
) < 0) {
581 mp_msg(MSGT_MENCODER
,MSGL_WARN
, "xvid: could not get information about the library\n");
583 mp_msg(MSGT_MENCODER
,MSGL_INFO
, "xvid: using library version %d.%d.%d (build %s)\n",
584 XVID_VERSION_MAJOR(xvid_gbl_info
.actual_version
),
585 XVID_VERSION_MINOR(xvid_gbl_info
.actual_version
),
586 XVID_VERSION_PATCH(xvid_gbl_info
.actual_version
),
587 xvid_gbl_info
.build
);
590 /* Initialize the xvid_gbl_init structure */
591 memset(&xvid_gbl_init
, 0, sizeof(xvid_gbl_init_t
));
592 xvid_gbl_init
.version
= XVID_VERSION
;
593 xvid_gbl_init
.debug
= xvidenc_debug
;
595 /* Initialize the xvidcore library */
596 if (xvid_global(NULL
, XVID_GBL_INIT
, &xvid_gbl_init
, NULL
) < 0) {
597 mp_msg(MSGT_MENCODER
,MSGL_ERR
, "xvid: initialisation failure\n");
604 /*****************************************************************************
606 ****************************************************************************/
608 static void *read_matrix(unsigned char *filename
);
610 static void dispatch_settings(xvid_mplayer_module_t
*mod
)
612 xvid_enc_create_t
*create
= &mod
->create
;
613 xvid_enc_frame_t
*frame
= &mod
->frame
;
614 xvid_plugin_single_t
*onepass
= &mod
->onepass
;
615 xvid_plugin_2pass2_t
*pass2
= &mod
->pass2
;
618 const int motion_presets
[7] =
624 XVID_ME_HALFPELREFINE16
,
625 XVID_ME_HALFPELREFINE16
| XVID_ME_ADVANCEDDIAMOND16
,
626 XVID_ME_HALFPELREFINE16
| XVID_ME_EXTSEARCH16
|
627 XVID_ME_HALFPELREFINE8
| XVID_ME_USESQUARES16
631 /* -------------------------------------------------------------------
632 * Dispatch all settings having an impact on the "create" structure
633 * This includes plugins as they are passed to encore through the
635 * -----------------------------------------------------------------*/
637 /* -------------------------------------------------------------------
638 * The create structure
639 * ---------------------------------------------------------------- */
644 create
->global
|= XVID_GLOBAL_PACKED
;
646 if(xvidenc_closed_gop
)
647 create
->global
|= XVID_GLOBAL_CLOSED_GOP
;
653 create
->global
|= XVID_GLOBAL_EXTRASTATS_ENABLE
;
655 create
->num_zones
= 0;
656 create
->zones
= NULL
;
657 create
->num_plugins
= 0;
658 create
->plugins
= NULL
;
659 create
->num_threads
= 0;
660 create
->max_bframes
= xvidenc_max_bframes
;
661 create
->bquant_ratio
= xvidenc_bquant_ratio
;
662 create
->bquant_offset
= xvidenc_bquant_offset
;
663 create
->max_key_interval
= xvidenc_max_key_interval
;
664 create
->frame_drop_ratio
= xvidenc_frame_drop_ratio
;
665 create
->min_quant
[0] = xvidenc_min_quant
[0];
666 create
->min_quant
[1] = xvidenc_min_quant
[1];
667 create
->min_quant
[2] = xvidenc_min_quant
[2];
668 create
->max_quant
[0] = xvidenc_max_quant
[0];
669 create
->max_quant
[1] = xvidenc_max_quant
[1];
670 create
->max_quant
[2] = xvidenc_max_quant
[2];
673 /* -------------------------------------------------------------------
674 * The single pass plugin
675 * ---------------------------------------------------------------- */
677 if (xvidenc_bitrate
> 16000) onepass
->bitrate
= xvidenc_bitrate
;
678 else onepass
->bitrate
= xvidenc_bitrate
*1000;
679 onepass
->reaction_delay_factor
= xvidenc_cbr_reaction_delay_factor
;
680 onepass
->averaging_period
= xvidenc_cbr_averaging_period
;
681 onepass
->buffer
= xvidenc_cbr_buffer
;
683 /* -------------------------------------------------------------------
685 * ---------------------------------------------------------------- */
687 pass2
->keyframe_boost
= xvidenc_vbr_keyframe_boost
;
688 pass2
->overflow_control_strength
= xvidenc_vbr_overflow_control_strength
;
689 pass2
->curve_compression_high
= xvidenc_vbr_curve_compression_high
;
690 pass2
->curve_compression_low
= xvidenc_vbr_curve_compression_low
;
691 pass2
->max_overflow_improvement
= xvidenc_vbr_max_overflow_improvement
;
692 pass2
->max_overflow_degradation
= xvidenc_vbr_max_overflow_degradation
;
693 pass2
->kfreduction
= xvidenc_vbr_kfreduction
;
694 pass2
->kfthreshold
= xvidenc_vbr_kfthreshold
;
695 pass2
->container_frame_overhead
= xvidenc_vbr_container_frame_overhead
;
697 /* -------------------------------------------------------------------
698 * The frame structure
699 * ---------------------------------------------------------------- */
700 frame
->vol_flags
= 0;
701 frame
->vop_flags
= 0;
704 frame
->vop_flags
|= XVID_VOP_HALFPEL
;
705 frame
->motion
|= motion_presets
[xvidenc_motion
];
708 frame
->vol_flags
|= XVID_VOL_EXTRASTATS
;
710 if(xvidenc_greyscale
)
711 frame
->vop_flags
|= XVID_VOP_GREYSCALE
;
713 if(xvidenc_cartoon
) {
714 frame
->vop_flags
|= XVID_VOP_CARTOON
;
715 frame
->motion
|= XVID_ME_DETECT_STATIC_MOTION
;
718 if(xvidenc_intra_matrix_file
!= NULL
) {
719 frame
->quant_intra_matrix
= (unsigned char*)read_matrix(xvidenc_intra_matrix_file
);
720 if(frame
->quant_intra_matrix
!= NULL
) {
721 mp_msg(MSGT_MENCODER
, MSGL_INFO
, "xvid: Loaded Intra matrix (switching to mpeg quantization type)\n");
722 if(xvidenc_quant_method
) free(xvidenc_quant_method
);
723 xvidenc_quant_method
= strdup("mpeg");
726 if(xvidenc_inter_matrix_file
!= NULL
) {
727 frame
->quant_inter_matrix
= read_matrix(xvidenc_inter_matrix_file
);
728 if(frame
->quant_inter_matrix
) {
729 mp_msg(MSGT_MENCODER
, MSGL_INFO
, "\nxvid: Loaded Inter matrix (switching to mpeg quantization type)\n");
730 if(xvidenc_quant_method
) free(xvidenc_quant_method
);
731 xvidenc_quant_method
= strdup("mpeg");
734 if(xvidenc_quant_method
!= NULL
&& !strcasecmp(xvidenc_quant_method
, "mpeg")) {
735 frame
->vol_flags
|= XVID_VOL_MPEGQUANT
;
737 if(xvidenc_quarterpel
) {
738 frame
->vol_flags
|= XVID_VOL_QUARTERPEL
;
739 frame
->motion
|= XVID_ME_QUARTERPELREFINE16
;
740 frame
->motion
|= XVID_ME_QUARTERPELREFINE8
;
743 frame
->vol_flags
|= XVID_VOL_GMC
;
744 frame
->motion
|= XVID_ME_GME_REFINE
;
746 if(xvidenc_interlaced
) {
747 frame
->vol_flags
|= XVID_VOL_INTERLACING
;
749 if(xvidenc_trellis
) {
750 frame
->vop_flags
|= XVID_VOP_TRELLISQUANT
;
752 if(xvidenc_hqacpred
) {
753 frame
->vop_flags
|= XVID_VOP_HQACPRED
;
755 if(xvidenc_chroma_opt
) {
756 frame
->vop_flags
|= XVID_VOP_CHROMAOPT
;
758 if(xvidenc_motion
> 4) {
759 frame
->vop_flags
|= XVID_VOP_INTER4V
;
761 if(xvidenc_chromame
) {
762 frame
->motion
|= XVID_ME_CHROMA_PVOP
;
763 frame
->motion
|= XVID_ME_CHROMA_BVOP
;
765 if(xvidenc_vhq
>= 1) {
766 frame
->vop_flags
|= XVID_VOP_MODEDECISION_RD
;
768 if(xvidenc_vhq
>= 2) {
769 frame
->motion
|= XVID_ME_HALFPELREFINE16_RD
;
770 frame
->motion
|= XVID_ME_QUARTERPELREFINE16_RD
;
772 if(xvidenc_vhq
>= 3) {
773 frame
->motion
|= XVID_ME_HALFPELREFINE8_RD
;
774 frame
->motion
|= XVID_ME_QUARTERPELREFINE8_RD
;
775 frame
->motion
|= XVID_ME_CHECKPREDICTION_RD
;
777 if(xvidenc_vhq
>= 4) {
778 frame
->motion
|= XVID_ME_EXTSEARCH_RD
;
780 if(xvidenc_bvhq
>= 1) {
781 #if XVID_API >= XVID_MAKE_API(4,1)
782 frame
->vop_flags
|= XVID_VOP_RD_BVOP
;
786 frame
->motion
|= XVID_ME_FASTREFINE16
;
787 frame
->motion
|= XVID_ME_FASTREFINE8
;
788 frame
->motion
|= XVID_ME_SKIP_DELTASEARCH
;
789 frame
->motion
|= XVID_ME_FAST_MODEINTERPOLATE
;
790 frame
->motion
|= XVID_ME_BFRAME_EARLYSTOP
;
793 /* motion level == 0 means no motion search which is equivalent to
794 * intra coding only */
795 if(xvidenc_motion
== 0) {
796 frame
->type
= XVID_TYPE_IVOP
;
798 frame
->type
= XVID_TYPE_AUTO
;
801 frame
->bframe_threshold
= xvidenc_bframe_threshold
;
803 /* PAR related initialization */
804 frame
->par
= XVID_PAR_11_VGA
; /* Default */
806 if(xvidenc_dar_aspect
> 0)
807 ar
= xvid_d2q(xvidenc_dar_aspect
* mod
->mux
->bih
->biHeight
/ mod
->mux
->bih
->biWidth
, 255);
808 else if(xvidenc_autoaspect
)
809 ar
= xvid_d2q((float)mod
->d_width
/ mod
->d_height
* mod
->mux
->bih
->biHeight
/ mod
->mux
->bih
->biWidth
, 255);
810 else ar
.num
= ar
.den
= 0;
813 if(ar
.num
== 12 && ar
.den
== 11)
814 frame
->par
= XVID_PAR_43_PAL
;
815 else if(ar
.num
== 10 && ar
.den
== 11)
816 frame
->par
= XVID_PAR_43_NTSC
;
817 else if(ar
.num
== 16 && ar
.den
== 11)
818 frame
->par
= XVID_PAR_169_PAL
;
819 else if(ar
.num
== 40 && ar
.den
== 33)
820 frame
->par
= XVID_PAR_169_NTSC
;
823 frame
->par
= XVID_PAR_EXT
;
824 frame
->par_width
= ar
.num
;
825 frame
->par_height
= ar
.den
;
828 } else if(xvidenc_par
!= NULL
) {
829 if(strcasecmp(xvidenc_par
, "pal43") == 0)
830 frame
->par
= XVID_PAR_43_PAL
;
831 else if(strcasecmp(xvidenc_par
, "pal169") == 0)
832 frame
->par
= XVID_PAR_169_PAL
;
833 else if(strcasecmp(xvidenc_par
, "ntsc43") == 0)
834 frame
->par
= XVID_PAR_43_NTSC
;
835 else if(strcasecmp(xvidenc_par
, "ntsc169") == 0)
836 frame
->par
= XVID_PAR_169_NTSC
;
837 else if(strcasecmp(xvidenc_par
, "ext") == 0)
838 frame
->par
= XVID_PAR_EXT
;
840 if(frame
->par
== XVID_PAR_EXT
) {
841 if(xvidenc_par_width
)
842 frame
->par_width
= xvidenc_par_width
;
844 frame
->par_width
= 1;
846 if(xvidenc_par_height
)
847 frame
->par_height
= xvidenc_par_height
;
849 frame
->par_height
= 1;
853 /* Display par information */
854 mp_msg(MSGT_MENCODER
, MSGL_INFO
, "xvid: par=%d/%d (%s), displayed=%dx%d, sampled=%dx%d\n",
855 ar
.num
, ar
.den
, par_string(frame
->par
),
856 mod
->d_width
, mod
->d_height
, mod
->mux
->bih
->biWidth
, mod
->mux
->bih
->biHeight
);
860 static int set_create_struct(xvid_mplayer_module_t
*mod
)
863 xvid_enc_create_t
*create
= &mod
->create
;
865 /* Most of the structure is initialized by dispatch settings, only a
866 * few things are missing */
867 create
->version
= XVID_VERSION
;
869 /* Width and Height */
870 create
->width
= mod
->mux
->bih
->biWidth
;
871 create
->height
= mod
->mux
->bih
->biHeight
;
874 create
->fincr
= mod
->mux
->h
.dwScale
;
875 create
->fbase
= mod
->mux
->h
.dwRate
;
877 /* Encodings zones */
878 memset(mod
->zones
, 0, sizeof(mod
->zones
));
879 create
->zones
= mod
->zones
;
880 create
->num_zones
= 0;
883 memset(mod
->plugins
, 0, sizeof(mod
->plugins
));
884 create
->plugins
= mod
->plugins
;
885 create
->num_plugins
= 0;
887 /* -------------------------------------------------------------------
888 * Initialize and bind the right rate controller plugin
889 * ---------------------------------------------------------------- */
891 /* First we try to sort out configuration conflicts */
892 if(xvidenc_quantizer
!= 0 && (xvidenc_bitrate
|| xvidenc_pass
)) {
893 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
894 "xvid: you can't mix Fixed Quantizer Rate Control"
895 " with other Rate Control mechanisms\n");
899 if(xvidenc_bitrate
!= 0 && xvidenc_pass
== 1) {
900 mp_msg(MSGT_MENCODER
, MSGL_WARN
,
901 "xvid: bitrate setting is ignored during first pass\n");
904 /* Sort out which sort of pass we are supposed to do
906 * pass == 1<<1 Two pass first pass
907 * pass == 1<<2 Two pass second pass
908 * pass == 1<<3 Constant quantizer
910 #define MODE_CBR (1<<0)
911 #define MODE_2PASS1 (1<<1)
912 #define MODE_2PASS2 (1<<2)
913 #define MODE_QUANT (1<<3)
917 if(xvidenc_bitrate
!= 0 && xvidenc_pass
== 0)
920 if(xvidenc_pass
== 1)
923 if(xvidenc_bitrate
!= 0 && xvidenc_pass
== 2)
926 if(xvidenc_quantizer
!= 0 && xvidenc_pass
== 0)
929 /* We must be in at least one RC mode */
931 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
932 "xvid: you must specify one or a valid combination of "
933 "'bitrate', 'pass', 'quantizer' settings\n");
937 /* Sanity checking */
938 if(pass
!= MODE_CBR
&& pass
!= MODE_QUANT
&&
939 pass
!= MODE_2PASS1
&& pass
!= MODE_2PASS2
) {
940 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
941 "xvid: this code should not be reached - fill a bug "
946 /* This is a single pass encoding: either a CBR pass or a constant
948 if(pass
== MODE_CBR
|| pass
== MODE_QUANT
) {
949 xvid_plugin_single_t
*onepass
= &mod
->onepass
;
951 /* There is not much left to initialize after dispatch settings */
952 onepass
->version
= XVID_VERSION
;
953 if (xvidenc_bitrate
> 16000) onepass
->bitrate
= xvidenc_bitrate
;
954 else onepass
->bitrate
= xvidenc_bitrate
*1000;
956 /* Quantizer mode uses the same plugin, we have only to define
957 * a constant quantizer zone beginning at frame 0 */
958 if(pass
== MODE_QUANT
) {
960 squant
= xvid_d2q(xvidenc_quantizer
,128);
962 create
->zones
[create
->num_zones
].mode
= XVID_ZONE_QUANT
;
963 create
->zones
[create
->num_zones
].frame
= 0;
964 create
->zones
[create
->num_zones
].increment
= squant
.num
;
965 create
->zones
[create
->num_zones
].base
= squant
.den
;
968 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
969 "xvid: Fixed Quant Rate Control -- quantizer=%d/%d=%2.2f\n",
972 (float)(squant
.num
)/(float)(squant
.den
));
975 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
976 "xvid: CBR Rate Control -- bitrate=%dkbit/s\n",
977 xvidenc_bitrate
>16000?xvidenc_bitrate
/1000:xvidenc_bitrate
);
980 create
->plugins
[create
->num_plugins
].func
= xvid_plugin_single
;
981 create
->plugins
[create
->num_plugins
].param
= onepass
;
982 create
->num_plugins
++;
985 /* This is the first pass of a Two pass process */
986 if(pass
== MODE_2PASS1
) {
987 xvid_plugin_2pass1_t
*pass1
= &mod
->pass1
;
989 /* There is not much to initialize for this plugin */
990 pass1
->version
= XVID_VERSION
;
991 pass1
->filename
= XVID_FIRST_PASS_FILENAME
;
993 create
->plugins
[create
->num_plugins
].func
= xvid_plugin_2pass1
;
994 create
->plugins
[create
->num_plugins
].param
= pass1
;
995 create
->num_plugins
++;
997 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
998 "xvid: 2Pass Rate Control -- 1st pass\n");
1001 /* This is the second pass of a Two pass process */
1002 if(pass
== MODE_2PASS2
) {
1003 xvid_plugin_2pass2_t
*pass2
= &mod
->pass2
;
1005 /* There is not much left to initialize after dispatch settings */
1006 pass2
->version
= XVID_VERSION
;
1007 pass2
->filename
= XVID_FIRST_PASS_FILENAME
;
1009 /* Positive bitrate values are bitrates as usual but if the
1010 * value is negative it is considered as being a total size
1011 * to reach (in kilobytes) */
1012 if(xvidenc_bitrate
> 0) {
1013 if(xvidenc_bitrate
> 16000) pass2
->bitrate
= xvidenc_bitrate
;
1014 else pass2
->bitrate
= xvidenc_bitrate
*1000;
1015 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1016 "xvid: 2Pass Rate Control -- 2nd pass -- bitrate=%dkbit/s\n",
1017 xvidenc_bitrate
>16000?xvidenc_bitrate
/1000:xvidenc_bitrate
);
1019 pass2
->bitrate
= xvidenc_bitrate
;
1020 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1021 "xvid: 2Pass Rate Control -- 2nd pass -- total size=%dkB\n",
1025 create
->plugins
[create
->num_plugins
].func
= xvid_plugin_2pass2
;
1026 create
->plugins
[create
->num_plugins
].param
= pass2
;
1027 create
->num_plugins
++;
1033 static int set_frame_struct(xvid_mplayer_module_t
*mod
, mp_image_t
*mpi
)
1035 xvid_enc_frame_t
*frame
= &mod
->frame
;
1037 /* Most of the initialization is done during dispatch_settings */
1038 frame
->version
= XVID_VERSION
;
1040 /* Bind output buffer */
1041 frame
->bitstream
= mod
->mux
->buffer
;
1045 switch(mpi
->imgfmt
) {
1049 frame
->input
.csp
= XVID_CSP_USER
;
1052 frame
->input
.csp
= XVID_CSP_YUY2
;
1055 frame
->input
.csp
= XVID_CSP_UYVY
;
1058 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
1059 "xvid: unsupported picture format (%s)!\n",
1060 vo_format_name(mpi
->imgfmt
));
1064 /* Bind source frame */
1065 frame
->input
.plane
[0] = mpi
->planes
[0];
1066 frame
->input
.plane
[1] = mpi
->planes
[1];
1067 frame
->input
.plane
[2] = mpi
->planes
[2];
1068 frame
->input
.stride
[0] = mpi
->stride
[0];
1069 frame
->input
.stride
[1] = mpi
->stride
[1];
1070 frame
->input
.stride
[2] = mpi
->stride
[2];
1072 /* Force the right quantizer -- It is internally managed by RC
1080 flush_internal_buffers(xvid_mplayer_module_t
*mod
)
1083 xvid_enc_frame_t
*frame
= &mod
->frame
;
1085 if (mod
->instance
== NULL
)
1086 return;/*encoder not inited*/
1088 /* Init a fake frame to force flushing */
1089 frame
->version
= XVID_VERSION
;
1090 frame
->bitstream
= mod
->mux
->buffer
;
1092 frame
->input
.csp
= XVID_CSP_NULL
;
1093 frame
->input
.plane
[0] = NULL
;
1094 frame
->input
.plane
[1] = NULL
;
1095 frame
->input
.plane
[2] = NULL
;
1096 frame
->input
.stride
[0] = 0;
1097 frame
->input
.stride
[1] = 0;
1098 frame
->input
.stride
[2] = 0;
1101 /* Flush encoder buffers caused by bframes usage */
1103 xvid_enc_stats_t stats
;
1104 memset(&stats
, 0, sizeof(xvid_enc_stats_t
));
1105 stats
.version
= XVID_VERSION
;
1107 /* Encode internal buffer */
1108 size
= xvid_encore(mod
->instance
, XVID_ENC_ENCODE
, &mod
->frame
, &stats
);
1112 update_stats(mod
, &stats
);
1114 /* xvidcore outputed bitstream -- mux it */
1115 muxer_write_chunk(mod
->mux
, size
,
1116 (mod
->frame
.out_flags
& XVID_KEYFRAME
)?0x10:0);
1121 #define SSE2PSNR(sse, nbpixels) \
1122 ((!(sse)) ? 99.99f : 48.131f - 10*(double)log10((double)(sse)/(double)((nbpixels))))
1124 update_stats(xvid_mplayer_module_t
*mod
, xvid_enc_stats_t
*stats
)
1126 if(xvidenc_stats
&& stats
->type
> 0) {
1127 mod
->sse_y
+= stats
->sse_y
;
1128 mod
->sse_u
+= stats
->sse_u
;
1129 mod
->sse_v
+= stats
->sse_v
;
1131 if(mod
->min_sse_y
> stats
->sse_y
) {
1132 mod
->min_sse_y
= stats
->sse_y
;
1133 mod
->min_sse_u
= stats
->sse_u
;
1134 mod
->min_sse_v
= stats
->sse_v
;
1135 mod
->min_framenum
= mod
->frames
;
1138 if(mod
->max_sse_y
< stats
->sse_y
) {
1139 mod
->max_sse_y
= stats
->sse_y
;
1140 mod
->max_sse_u
= stats
->sse_u
;
1141 mod
->max_sse_v
= stats
->sse_v
;
1142 mod
->max_framenum
= mod
->frames
;
1146 if (!mod
->fvstats
) {
1150 today2
= time (NULL
);
1151 today
= localtime (&today2
);
1152 sprintf (filename
, "psnr_%02d%02d%02d.log", today
->tm_hour
, today
->tm_min
, today
->tm_sec
);
1153 mod
->fvstats
= fopen (filename
,"w");
1154 if (!mod
->fvstats
) {
1156 /* Disable PSNR file output so we don't get here again */
1160 fprintf (mod
->fvstats
, "%6d, %2d, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n",
1164 SSE2PSNR (stats
->sse_y
, mod
->pixels
),
1165 SSE2PSNR (stats
->sse_u
, mod
->pixels
/ 4),
1166 SSE2PSNR (stats
->sse_v
, mod
->pixels
/ 4),
1167 SSE2PSNR (stats
->sse_y
+ stats
->sse_u
+ stats
->sse_v
,(double)mod
->pixels
* 1.5),
1168 stats
->type
==1?'I':stats
->type
==2?'P':stats
->type
==3?'B':stats
->type
?'S':'?'
1176 print_stats(xvid_mplayer_module_t
*mod
)
1179 mod
->sse_y
/= mod
->frames
;
1180 mod
->sse_u
/= mod
->frames
;
1181 mod
->sse_v
/= mod
->frames
;
1183 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1184 "The value 99.99dB is a special value and represents "
1185 "the upper range limit\n");
1186 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1187 "xvid: Min PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, in frame %d\n",
1188 SSE2PSNR(mod
->max_sse_y
, mod
->pixels
),
1189 SSE2PSNR(mod
->max_sse_u
, mod
->pixels
/4),
1190 SSE2PSNR(mod
->max_sse_v
, mod
->pixels
/4),
1192 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1193 "xvid: Average PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, for %d frames\n",
1194 SSE2PSNR(mod
->sse_y
, mod
->pixels
),
1195 SSE2PSNR(mod
->sse_u
, mod
->pixels
/4),
1196 SSE2PSNR(mod
->sse_v
, mod
->pixels
/4),
1198 mp_msg(MSGT_MENCODER
, MSGL_INFO
,
1199 "xvid: Max PSNR y : %.2f dB, u : %.2f dB, v : %.2f dB, in frame %d\n",
1200 SSE2PSNR(mod
->min_sse_y
, mod
->pixels
),
1201 SSE2PSNR(mod
->min_sse_u
, mod
->pixels
/4),
1202 SSE2PSNR(mod
->min_sse_v
, mod
->pixels
/4),
1208 static void *read_matrix(unsigned char *filename
)
1211 unsigned char *matrix
;
1214 /* Allocate matrix space */
1215 if((matrix
= malloc(64*sizeof(unsigned char))) == NULL
)
1218 /* Open the matrix file */
1219 if((input
= fopen(filename
, "rb")) == NULL
) {
1220 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
1221 "xvid: Error opening the matrix file %s\n",
1227 /* Read the matrix */
1228 for(i
=0; i
<64; i
++) {
1232 /* If fscanf fails then get out of the loop */
1233 if(fscanf(input
, "%d", &value
) != 1) {
1234 mp_msg(MSGT_MENCODER
, MSGL_ERR
,
1235 "xvid: Error reading the matrix file %s\n",
1242 /* Clamp the value to safe range */
1243 value
= (value
< 1)?1 :value
;
1244 value
= (value
>255)?255:value
;
1248 /* Fills the rest with 1 */
1249 while(i
<64) matrix
[i
++] = 1;
1260 par_string(int parcode
)
1262 const char *par_string
;
1264 case XVID_PAR_11_VGA
:
1265 par_string
= "vga11";
1267 case XVID_PAR_43_PAL
:
1268 par_string
= "pal43";
1270 case XVID_PAR_43_NTSC
:
1271 par_string
= "ntsc43";
1273 case XVID_PAR_169_PAL
:
1274 par_string
= "pal169";
1276 case XVID_PAR_169_NTSC
:
1277 par_string
= "ntsc69";
1283 par_string
= "unknown";
1286 return (par_string
);
1289 static const char *errorstring(int err
)
1294 error
= "General fault";
1296 case XVID_ERR_MEMORY
:
1297 error
= "Memory allocation error";
1299 case XVID_ERR_FORMAT
:
1300 error
= "File format error";
1302 case XVID_ERR_VERSION
:
1303 error
= "Structure version not supported";
1306 error
= "End of stream reached";
1315 /*****************************************************************************
1316 * Module structure definition
1317 ****************************************************************************/
1319 vf_info_t ve_info_xvid
= {
1322 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>",
1328 #endif /* HAVE_XVID4 */
1330 /* Please do not change that tag comment.
1331 * arch-tag: 42ccc257-0548-4a3e-9617-2876c4e8ac88 mplayer xvid encoder module */