/*****************************************************************************
- * 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$
* 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
#include <vlc_avcodec.h>
#include <vlc_cpu.h>
-/* ffmpeg header */
#define HAVE_MMX 1
#include <libavcodec/avcodec.h>
};
/*****************************************************************************
- * 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;
* Common properties
*/
char *p_buffer;
- uint8_t *p_buffer_out;
size_t i_buffer_out;
/*
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"), _(
* 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"
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
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" );
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 )
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 ) )
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;
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 */
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 );
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;
}
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;
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;
}
/*****************************************************************************
- * CloseEncoder: ffmpeg encoder destruction
+ * CloseEncoder: libavcodec encoder destruction
*****************************************************************************/
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 );
}