]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libxvidff.c
correctly patch syncword for samples rates < 16000, decoder now fully support all...
[ffmpeg] / libavcodec / libxvidff.c
index 506af910beba57d474b806a469773a9ea5b42eaf..acac29b7dd49e8cf0dac7c5c6126026666744681 100644 (file)
@@ -38,9 +38,7 @@
 #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.
@@ -83,7 +81,7 @@ void xvid_correct_framerate(AVCodecContext *avctx);
  * @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;
@@ -169,7 +167,7 @@ int ff_xvid_encode_init(AVCodecContext *avctx)  {
 
 #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
@@ -194,10 +192,11 @@ int ff_xvid_encode_init(AVCodecContext *avctx)  {
     /* 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;
@@ -407,6 +406,17 @@ int ff_xvid_encode_frame(AVCodecContext *avctx,
     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;
@@ -463,7 +473,7 @@ int ff_xvid_encode_frame(AVCodecContext *avctx,
  * @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);
@@ -755,8 +765,8 @@ int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) {
 /**
  * XviD codec definition for libavcodec.
  */
-AVCodec xvid_encoder = {
-    "xvid",
+AVCodec libxvid_encoder = {
+    "libxvid",
     CODEC_TYPE_VIDEO,
     CODEC_ID_XVID,
     sizeof(xvid_context_t),