[vlc-commits] avcodec: avoid forward declaration
Rémi Denis-Courmont
git at videolan.org
Thu Aug 8 20:23:58 CEST 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 25 19:57:48 2013 +0300| [56655ea84524e641b411c6606639129a12843c16] | committer: Rémi Denis-Courmont
avcodec: avoid forward declaration
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=56655ea84524e641b411c6606639129a12843c16
---
modules/codec/avcodec/audio.c | 91 ++++++++++++++++++++---------------------
1 file changed, 45 insertions(+), 46 deletions(-)
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 8511751..412152a 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -69,7 +69,6 @@ struct decoder_sys_t
#define BLOCK_FLAG_PRIVATE_REALLOCATED (1 << BLOCK_FLAG_PRIVATE_SHIFT)
static void SetupOutputFormat( decoder_t *p_dec, bool b_trust );
-static int GetAudioBuf( struct AVCodecContext *, AVFrame * );
static void InitDecoderConfig( decoder_t *p_dec, AVCodecContext *p_context )
{
@@ -116,6 +115,51 @@ static void InitDecoderConfig( decoder_t *p_dec, AVCodecContext *p_context )
}
}
+/**
+ * Allocates decoded audio buffer for libavcodec to use.
+ */
+static int GetAudioBuf( AVCodecContext *ctx, AVFrame *buf )
+{
+ block_t *block;
+ bool planar = av_sample_fmt_is_planar( ctx->sample_fmt );
+ unsigned channels = planar ? 1 : ctx->channels;
+ unsigned planes = planar ? ctx->channels : 1;
+
+ int bytes = av_samples_get_buffer_size( &buf->linesize[0], channels,
+ buf->nb_samples, ctx->sample_fmt,
+ 16 );
+ assert( bytes >= 0 );
+ block = block_Alloc( bytes * planes );
+ if( unlikely(block == NULL) )
+ return AVERROR(ENOMEM);
+
+ block->i_nb_samples = buf->nb_samples;
+ buf->opaque = block;
+
+ if( planes > AV_NUM_DATA_POINTERS )
+ {
+ uint8_t **ext = malloc( sizeof( *ext ) * planes );
+ if( unlikely(ext == NULL) )
+ {
+ block_Release( block );
+ return AVERROR(ENOMEM);
+ }
+ buf->extended_data = ext;
+ }
+ else
+ buf->extended_data = buf->data;
+
+ uint8_t *buffer = block->p_buffer;
+ for( unsigned i = 0; i < planes; i++ )
+ {
+ buf->linesize[i] = buf->linesize[0];
+ buf->extended_data[i] = buffer;
+ buffer += bytes;
+ }
+
+ return 0;
+}
+
/*****************************************************************************
* InitAudioDec: initialize audio decoder
*****************************************************************************
@@ -173,51 +217,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
return VLC_SUCCESS;
}
-/**
- * Allocates decoded audio buffer for libavcodec to use.
- */
-static int GetAudioBuf( AVCodecContext *ctx, AVFrame *buf )
-{
- block_t *block;
- bool planar = av_sample_fmt_is_planar( ctx->sample_fmt );
- unsigned channels = planar ? 1 : ctx->channels;
- unsigned planes = planar ? ctx->channels : 1;
-
- int bytes = av_samples_get_buffer_size( &buf->linesize[0], channels,
- buf->nb_samples, ctx->sample_fmt,
- 16 );
- assert( bytes >= 0 );
- block = block_Alloc( bytes * planes );
- if( unlikely(block == NULL) )
- return AVERROR(ENOMEM);
-
- block->i_nb_samples = buf->nb_samples;
- buf->opaque = block;
-
- if( planes > AV_NUM_DATA_POINTERS )
- {
- uint8_t **ext = malloc( sizeof( *ext ) * planes );
- if( unlikely(ext == NULL) )
- {
- block_Release( block );
- return AVERROR(ENOMEM);
- }
- buf->extended_data = ext;
- }
- else
- buf->extended_data = buf->data;
-
- uint8_t *buffer = block->p_buffer;
- for( unsigned i = 0; i < planes; i++ )
- {
- buf->linesize[i] = buf->linesize[0];
- buf->extended_data[i] = buffer;
- buffer += bytes;
- }
-
- return 0;
-}
-
/*****************************************************************************
* DecodeAudio: Called to decode one frame
*****************************************************************************/
More information about the vlc-commits
mailing list