*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
-#include <vlc/decoder.h>
+#include <vlc_aout.h>
+#include <vlc_codec.h>
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVCODEC_H
/* Common part between video and audio decoder */
int i_cat;
int i_codec_id;
- char *psz_namecodec;
+ const char *psz_namecodec;
AVCodecContext *p_context;
AVCodec *p_codec;
* The ffmpeg codec will be opened, some memory allocated.
*****************************************************************************/
int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
- AVCodec *p_codec, int i_codec_id, char *psz_namecodec )
+ AVCodec *p_codec, int i_codec_id, const char *psz_namecodec )
{
decoder_sys_t *p_sys;
vlc_value_t lockval;
- var_Get( p_dec->p_libvlc, "avcodec", &lockval );
+ var_Get( p_dec->p_libvlc_global, "avcodec", &lockval );
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys =
msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );
- p_sys->p_output = malloc( 3 * AVCODEC_MAX_AUDIO_FRAME_SIZE );
+ p_sys->p_output = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
p_sys->p_samples = NULL;
p_sys->i_samples = 0;
* SplitBuffer: Needed because aout really doesn't like big audio chunk and
* wma produces easily > 30000 samples...
*****************************************************************************/
-aout_buffer_t *SplitBuffer( decoder_t *p_dec )
+static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_samples = __MIN( p_sys->i_samples, 4096 );
return NULL;
}
- if( p_block->i_buffer <= 0 || ( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) )
+ if( p_block->i_buffer <= 0 ||
+ (p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) )
{
block_Release( p_block );
return NULL;
}
+ if( p_block->i_buffer > AVCODEC_MAX_AUDIO_FRAME_SIZE )
+ {
+ /* Grow output buffer if necessary (eg. for PCM data) */
+ p_sys->p_output = realloc(p_sys->p_output, p_block->i_buffer);
+ }
+
i_used = avcodec_decode_audio( p_sys->p_context,
(int16_t*)p_sys->p_output, &i_output,
p_block->p_buffer, p_block->i_buffer );