]> git.sesse.net Git - vlc/blobdiff - modules/codec/avcodec/encoder.c
avcodec: p_buffer_out was unused
[vlc] / modules / codec / avcodec / encoder.c
index f4055fa7872a747b09b9f231b1a63f85630b66c9..fbc185118810705685030cc4bac17c5c79c76081 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * encoder.c: video and audio encoder using the ffmpeg library
+ * encoder.c: video and audio encoder using the libavcodec library
  *****************************************************************************
  * Copyright (C) 1999-2004 the VideoLAN team
  * $Id$
@@ -7,7 +7,7 @@
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
- * Part of the file Copyright (C) FFMPEG Project Developers
+ * Part of the file Copyright (C) FFmpeg Project Developers
  * (mpeg4_default matrixes)
  *
  * This program is free software; you can redistribute it and/or modify
@@ -40,7 +40,6 @@
 #include <vlc_avcodec.h>
 #include <vlc_cpu.h>
 
-/* ffmpeg header */
 #define HAVE_MMX 1
 #include <libavcodec/avcodec.h>
 
@@ -84,12 +83,12 @@ struct thread_context_t
 };
 
 /*****************************************************************************
- * encoder_sys_t : ffmpeg encoder descriptor
+ * encoder_sys_t : libavcodec encoder descriptor
  *****************************************************************************/
 struct encoder_sys_t
 {
     /*
-     * Ffmpeg properties
+     * libavcodec properties
      */
     AVCodec         *p_codec;
     AVCodecContext  *p_context;
@@ -98,7 +97,6 @@ struct encoder_sys_t
      * Common properties
      */
     char *p_buffer;
-    uint8_t *p_buffer_out;
     size_t i_buffer_out;
 
     /*
@@ -276,8 +274,8 @@ int OpenEncoder( vlc_object_t *p_this )
     if( !p_codec )
     {
         msg_Err( p_enc, "cannot find encoder %s\n"
-"*** Your FFMPEG installation is crippled.   ***\n"
-"*** Please check with your FFMPEG packager. ***\n"
+"*** Your Libav/FFmpeg installation is crippled.   ***\n"
+"*** Please check with your Libav/FFmpeg packager. ***\n"
 "*** This is NOT a VLC media player issue.   ***", psz_namecodec );
 
         dialog_Fatal( p_enc, _("Streaming / Transcoding failed"), _(
@@ -285,7 +283,7 @@ int OpenEncoder( vlc_object_t *p_this )
  * Downstream packager, you had better not patch this out, or I will be really
  * annoyed. Think about it - you don't want to fork the VLC translation files,
  * do you? -- Courmisch, 2008-10-22 */
-"It seems your FFMPEG (libavcodec) installation lacks the following encoder:\n"
+"It seems your Libav/FFmpeg (libavcodec) installation lacks the following encoder:\n"
 "%s.\n"
 "If you don't know how to fix this, ask for support from your distribution.\n"
 "\n"
@@ -305,7 +303,6 @@ int OpenEncoder( vlc_object_t *p_this )
     p_enc->pf_encode_audio = EncodeAudio;
 
     p_sys->p_buffer = NULL;
-    p_sys->p_buffer_out = NULL;
     p_sys->i_buffer_out = 0;
 
 #if LIBAVCODEC_VERSION_MAJOR < 54
@@ -317,7 +314,13 @@ int OpenEncoder( vlc_object_t *p_this )
     p_sys->p_context->codec_id = p_sys->p_codec->id;
     p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" );
     p_context->opaque = (void *)p_this;
-    p_context->dsp_mask = GetVlcDspMask(); /* set CPU capabilities */
+
+    /* set CPU capabilities */
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 51, 25, 0 )
+    av_set_cpu_flags_mask( INT_MAX & ~GetVlcDspMask() );
+#else
+    p_context->dsp_mask = GetVlcDspMask();
+#endif
 
     p_sys->i_key_int = var_GetInteger( p_enc, ENC_CFG_PREFIX "keyint" );
     p_sys->i_b_frames = var_GetInteger( p_enc, ENC_CFG_PREFIX "bframes" );
@@ -374,7 +377,7 @@ int OpenEncoder( vlc_object_t *p_this )
     p_sys->i_chroma_elim = var_GetInteger( p_enc, ENC_CFG_PREFIX "chroma-elim-threshold" );
 
     psz_val = var_GetString( p_enc, ENC_CFG_PREFIX "aac-profile" );
-    /* ffmpeg uses faac encoder atm, and it has issues with
+    /* libavcodec uses faac encoder atm, and it has issues with
      * other than low-complexity profile, so default to that */
     p_sys->i_aac_profile = FF_PROFILE_AAC_LOW;
     if( psz_val && *psz_val )
@@ -390,7 +393,7 @@ int OpenEncoder( vlc_object_t *p_this )
         else if( !strncmp( psz_val, "ltp", 3 ) )
             p_sys->i_aac_profile = FF_PROFILE_AAC_LTP;
 #if LIBAVCODEC_VERSION_CHECK( 54, 19, 0, 35, 100 )
-/* These require ffmpeg with libfdk-aac */
+/* These require libavcodec with libfdk-aac */
         else if( !strncmp( psz_val, "hev2", 4 ) )
             p_sys->i_aac_profile = FF_PROFILE_AAC_HE_V2;
         else if( !strncmp( psz_val, "hev1", 4 ) )
@@ -458,15 +461,11 @@ int OpenEncoder( vlc_object_t *p_this )
                p_enc->fmt_out.i_codec == VLC_CODEC_MP2V ) )
             p_context->flags |= CODEC_FLAG_LOW_DELAY;
 
-        if( p_enc->fmt_out.i_codec == VLC_CODEC_MP2V )
-            p_context->idct_algo = FF_IDCT_LIBMPEG2MMX;
-
         av_reduce( &p_context->sample_aspect_ratio.num,
                    &p_context->sample_aspect_ratio.den,
                    p_enc->fmt_in.video.i_sar_num,
                    p_enc->fmt_in.video.i_sar_den, 1 << 30 );
 
-        p_sys->p_buffer_out = NULL;
 
         p_enc->fmt_in.i_codec = VLC_CODEC_I420;
         p_enc->fmt_in.video.i_chroma = p_enc->fmt_in.i_codec;
@@ -627,10 +626,10 @@ int OpenEncoder( vlc_object_t *p_this )
         if( !var_GetInteger( p_enc, ENC_CFG_PREFIX "keyint" ) )
             p_context->gop_size = 120;
         /* Don't set rc-values atm, they were from time before
-           libvpx was officially in ffmpeg */
+           libvpx was officially in FFmpeg */
         //p_context->rc_max_rate = 24 * 1000 * 1000; //24M
         //p_context->rc_min_rate = 40 * 1000; // 40k
-        /* seems that ffmpeg presets have 720p as divider for buffers */
+        /* seems that FFmpeg presets have 720p as divider for buffers */
         if( p_enc->fmt_out.video.i_height >= 720 )
         {
             /* Check that we don't overrun users qmin/qmax values */
@@ -830,11 +829,6 @@ int OpenEncoder( vlc_object_t *p_this )
             p_sys->i_buffer_out = 8 * AVCODEC_MAX_AUDIO_FRAME_SIZE;
         else
             p_sys->i_buffer_out = p_sys->i_frame_size * p_sys->i_sample_bytes;
-        p_sys->p_buffer_out = malloc( p_sys->i_buffer_out );
-        if ( p_sys->p_buffer_out == NULL )
-        {
-            goto error;
-        }
     }
 
     msg_Dbg( p_enc, "found encoder %s", psz_namecodec );
@@ -843,7 +837,6 @@ int OpenEncoder( vlc_object_t *p_this )
 error:
     free( p_enc->fmt_out.p_extra );
     free( p_sys->p_buffer );
-    free( p_sys->p_buffer_out );
     free( p_sys );
     return VLC_ENOMEM;
 }
@@ -874,7 +867,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
             frame.linesize[i_plane] = p_pict->p[i_plane].i_pitch;
         }
 
-        /* Let ffmpeg select the frame type */
+        /* Let libavcodec select the frame type */
         frame.pict_type = 0;
 
         frame.repeat_pict = p_pict->i_nb_fields - 2;
@@ -1059,6 +1052,9 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
 
     block_t *p_block, *p_chain = NULL;
 
+    /*FIXME: change to use  avcodec_encode_audio2 to be able to flush*/
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     uint8_t *p_buffer = p_aout_buf->p_buffer;
     int i_samples = p_aout_buf->i_nb_samples;
     int i_samples_delay = p_sys->i_samples_delay;
@@ -1136,7 +1132,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
 }
 
 /*****************************************************************************
- * CloseEncoder: ffmpeg encoder destruction
+ * CloseEncoder: libavcodec encoder destruction
  *****************************************************************************/
 void CloseEncoder( vlc_object_t *p_this )
 {
@@ -1149,7 +1145,6 @@ void CloseEncoder( vlc_object_t *p_this )
     av_free( p_sys->p_context );
 
     free( p_sys->p_buffer );
-    free( p_sys->p_buffer_out );
 
     free( p_sys );
 }