#define BUFFER_CAT(x) (&((x)[strlen(x)]))
/* For PPC Use */
-#if HAVE_ALTIVEC==1
extern int has_altivec(void);
-#endif
/**
* Structure for the private XviD context.
* @param avctx AVCodecContext pointer to context
* @return Returns 0 on success, -1 on failure
*/
-int ff_xvid_encode_init(AVCodecContext *avctx) {
+av_cold int ff_xvid_encode_init(AVCodecContext *avctx) {
int xerr, i;
int xvid_flags = avctx->flags;
xvid_context_t *x = avctx->priv_data;
#ifdef ARCH_POWERPC
/* XviD's PPC support is borked, use libavcodec to detect */
-#if HAVE_ALTIVEC==1
+#ifdef HAVE_ALTIVEC
if( has_altivec() ) {
xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC;
} else
/* XviD can determine the proper profile to use */
/* xvid_enc_create.profile = XVID_PROFILE_S_L3; */
- /* We don't use zones or threads */
+ /* We don't use zones */
xvid_enc_create.zones = NULL;
xvid_enc_create.num_zones = 0;
- xvid_enc_create.num_threads = 0;
+
+ xvid_enc_create.num_threads = avctx->thread_count;
xvid_enc_create.plugins = plugins;
xvid_enc_create.num_plugins = 0;
xvid_enc_frame.motion = x->me_flags;
xvid_enc_frame.type = XVID_TYPE_AUTO;
+ /* Pixel aspect ratio setting */
+ if (avctx->sample_aspect_ratio.num < 1 || avctx->sample_aspect_ratio.num > 255 ||
+ avctx->sample_aspect_ratio.den < 1 || avctx->sample_aspect_ratio.den > 255) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid pixel aspect ratio %i/%i\n",
+ avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
+ return -1;
+ }
+ xvid_enc_frame.par = XVID_PAR_EXT;
+ xvid_enc_frame.par_width = avctx->sample_aspect_ratio.num;
+ xvid_enc_frame.par_height = avctx->sample_aspect_ratio.den;
+
/* Quant Setting */
if( x->qscale ) xvid_enc_frame.quant = picture->quality / FF_QP2LAMBDA;
else xvid_enc_frame.quant = 0;
* @param avctx AVCodecContext pointer to context
* @return Returns 0, success guaranteed
*/
-int ff_xvid_encode_close(AVCodecContext *avctx) {
+av_cold int ff_xvid_encode_close(AVCodecContext *avctx) {
xvid_context_t *x = avctx->priv_data;
xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL);
/**
* XviD codec definition for libavcodec.
*/
-AVCodec xvid_encoder = {
- "xvid",
+AVCodec libxvid_encoder = {
+ "libxvid",
CODEC_TYPE_VIDEO,
CODEC_ID_XVID,
sizeof(xvid_context_t),