[FFmpeg-cvslog] adxenc: alloc/free coded_frame instead of keeping it in the ADXContext
Justin Ruggles
git at videolan.org
Wed Feb 13 11:44:22 CET 2013
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sun Dec 23 16:51:41 2012 -0500| [bae4f47938bbc63b7ab567edce9a5e778a37a3bf] | committer: Justin Ruggles
adxenc: alloc/free coded_frame instead of keeping it in the ADXContext
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bae4f47938bbc63b7ab567edce9a5e778a37a3bf
---
libavcodec/adx.h | 1 -
libavcodec/adxenc.c | 15 +++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libavcodec/adx.h b/libavcodec/adx.h
index 47d9f24..ff4c2d6 100644
--- a/libavcodec/adx.h
+++ b/libavcodec/adx.h
@@ -40,7 +40,6 @@ typedef struct ADXChannelState {
} ADXChannelState;
typedef struct ADXContext {
- AVFrame frame;
int channels;
ADXChannelState prev[2];
int header_parsed;
diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index 8a50539..7a9c06a 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -107,6 +107,14 @@ static int adx_encode_header(AVCodecContext *avctx, uint8_t *buf, int bufsize)
return HEADER_SIZE;
}
+#if FF_API_OLD_ENCODE_AUDIO
+static av_cold int adx_encode_close(AVCodecContext *avctx)
+{
+ av_freep(&avctx->coded_frame);
+ return 0;
+}
+#endif
+
static av_cold int adx_encode_init(AVCodecContext *avctx)
{
ADXContext *c = avctx->priv_data;
@@ -118,8 +126,8 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
avctx->frame_size = BLOCK_SAMPLES;
#if FF_API_OLD_ENCODE_AUDIO
- avcodec_get_frame_defaults(&c->frame);
- avctx->coded_frame = &c->frame;
+ if (!(avctx->coded_frame = avcodec_alloc_frame()))
+ return AVERROR(ENOMEM);
#endif
/* the cutoff can be adjusted, but this seems to work pretty well */
@@ -169,6 +177,9 @@ AVCodec ff_adpcm_adx_encoder = {
.id = AV_CODEC_ID_ADPCM_ADX,
.priv_data_size = sizeof(ADXContext),
.init = adx_encode_init,
+#if FF_API_OLD_ENCODE_AUDIO
+ .close = adx_encode_close,
+#endif
.encode2 = adx_encode_frame,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
More information about the ffmpeg-cvslog
mailing list