From 97c7bdc6d417457c81cade090de4a85ad5f34b8a Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 23 Dec 2012 17:47:02 -0500 Subject: cinaudio: decode directly to the user-provided AVFrame --- libavcodec/dsicinav.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index 39b6a4cabb..4da7d26670 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -46,7 +46,6 @@ typedef struct CinVideoContext { } CinVideoContext; typedef struct CinAudioContext { - AVFrame frame; int initial_decode_frame; int delta; } CinAudioContext; @@ -327,15 +326,13 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx) avctx->channels = 1; avctx->channel_layout = AV_CH_LAYOUT_MONO; - avcodec_get_frame_defaults(&cin->frame); - avctx->coded_frame = &cin->frame; - return 0; } static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; CinAudioContext *cin = avctx->priv_data; const uint8_t *buf_end = buf + avpkt->size; @@ -343,12 +340,12 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, int delta, ret; /* get output buffer */ - cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame; - if ((ret = ff_get_buffer(avctx, &cin->frame)) < 0) { + frame->nb_samples = avpkt->size - cin->initial_decode_frame; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = (int16_t *)cin->frame.data[0]; + samples = (int16_t *)frame->data[0]; delta = cin->delta; if (cin->initial_decode_frame) { @@ -364,8 +361,7 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data, } cin->delta = delta; - *got_frame_ptr = 1; - *(AVFrame *)data = cin->frame; + *got_frame_ptr = 1; return avpkt->size; } -- cgit v1.2.3 From b8e9c99ef19c21d20962e90237697722cbc96ff8 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 23 Dec 2012 17:49:27 -0500 Subject: flac: decode directly to the user-provided AVFrame --- libavcodec/flacdec.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index f273d145cb..6bb6be3477 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -51,7 +51,6 @@ typedef struct FLACContext { FLACSTREAMINFO AVCodecContext *avctx; ///< parent AVCodecContext - AVFrame frame; GetBitContext gb; ///< GetBitContext initialized to start at the current frame int blocksize; ///< number of samples in the current frame @@ -115,9 +114,6 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) ff_flacdsp_init(&s->dsp, avctx->sample_fmt, s->bps); s->got_streaminfo = 1; - avcodec_get_frame_defaults(&s->frame); - avctx->coded_frame = &s->frame; - return 0; } @@ -493,6 +489,7 @@ static int decode_frame(FLACContext *s) static int flac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; FLACContext *s = avctx->priv_data; @@ -531,13 +528,13 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data, bytes_read = (get_bits_count(&s->gb)+7)/8; /* get output buffer */ - s->frame.nb_samples = s->blocksize; - if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) { + frame->nb_samples = s->blocksize; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - s->dsp.decorrelate[s->ch_mode](s->frame.data, s->decoded, s->channels, + s->dsp.decorrelate[s->ch_mode](frame->data, s->decoded, s->channels, s->blocksize, s->sample_shift); if (bytes_read > buf_size) { @@ -549,8 +546,7 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data, buf_size - bytes_read, buf_size); } - *got_frame_ptr = 1; - *(AVFrame *)data = s->frame; + *got_frame_ptr = 1; return bytes_read; } -- cgit v1.2.3 From 036e9b045f14233fd39781d9afe4b7fb54151fba Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 23 Dec 2012 17:53:06 -0500 Subject: g722: decode directly to the user-provided AVFrame --- libavcodec/g722.h | 1 - libavcodec/g722dec.c | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/g722.h b/libavcodec/g722.h index bab1da48cc..71d03fc5fa 100644 --- a/libavcodec/g722.h +++ b/libavcodec/g722.h @@ -32,7 +32,6 @@ typedef struct G722Context { const AVClass *class; - AVFrame frame; int bits_per_codeword; int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples int prev_samples_pos; ///< the number of values in prev_samples diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c index 51d5721e8f..c100a90d34 100644 --- a/libavcodec/g722dec.c +++ b/libavcodec/g722dec.c @@ -67,9 +67,6 @@ static av_cold int g722_decode_init(AVCodecContext * avctx) c->band[1].scale_factor = 2; c->prev_samples_pos = 22; - avcodec_get_frame_defaults(&c->frame); - avctx->coded_frame = &c->frame; - return 0; } @@ -88,6 +85,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { G722Context *c = avctx->priv_data; + AVFrame *frame = data; int16_t *out_buf; int j, ret; const int skip = 8 - c->bits_per_codeword; @@ -95,12 +93,12 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, GetBitContext gb; /* get output buffer */ - c->frame.nb_samples = avpkt->size * 2; - if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) { + frame->nb_samples = avpkt->size * 2; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - out_buf = (int16_t *)c->frame.data[0]; + out_buf = (int16_t *)frame->data[0]; init_get_bits(&gb, avpkt->data, avpkt->size * 8); @@ -135,8 +133,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data, } } - *got_frame_ptr = 1; - *(AVFrame *)data = c->frame; + *got_frame_ptr = 1; return avpkt->size; } -- cgit v1.2.3 From 7e52fd6bca83043750d7a1cbcc52e89aad9847f8 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 23 Dec 2012 17:55:09 -0500 Subject: g723.1: decode directly to the user-provided AVFrame --- libavcodec/g723_1.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index b1fbe9869a..377a718ffb 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -76,7 +76,6 @@ typedef struct { typedef struct g723_1_context { AVClass *class; - AVFrame frame; G723_1_Subframe subframe[4]; enum FrameType cur_frame_type; @@ -117,9 +116,6 @@ static av_cold int g723_1_decode_init(AVCodecContext *avctx) avctx->sample_rate = 8000; p->pf_gain = 1 << 12; - avcodec_get_frame_defaults(&p->frame); - avctx->coded_frame = &p->frame; - memcpy(p->prev_lsp, dc_lsp, LPC_ORDER * sizeof(*p->prev_lsp)); memcpy(p->sid_lsp, dc_lsp, LPC_ORDER * sizeof(*p->sid_lsp)); @@ -1191,6 +1187,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { G723_1_Context *p = avctx->priv_data; + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int dec_mode = buf[0] & 3; @@ -1220,13 +1217,13 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, p->cur_frame_type = UNTRANSMITTED_FRAME; } - p->frame.nb_samples = FRAME_LEN; - if ((ret = ff_get_buffer(avctx, &p->frame)) < 0) { + frame->nb_samples = FRAME_LEN; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - out = (int16_t *)p->frame.data[0]; + out = (int16_t *)frame->data[0]; if (p->cur_frame_type == ACTIVE_FRAME) { if (!bad_frame) @@ -1297,7 +1294,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, (FRAME_LEN + PITCH_MAX) * sizeof(*p->excitation)); memset(p->prev_excitation, 0, PITCH_MAX * sizeof(*p->excitation)); - memset(p->frame.data[0], 0, + memset(frame->data[0], 0, (FRAME_LEN + LPC_ORDER) * sizeof(int16_t)); } else { int16_t *buf = p->audio + LPC_ORDER; @@ -1346,8 +1343,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data, out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1); } - *got_frame_ptr = 1; - *(AVFrame *)data = p->frame; + *got_frame_ptr = 1; return frame_size[dec_mode]; } -- cgit v1.2.3 From cb7b47a61dba0b9329ecede5dd3211dc0662dc05 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 23 Dec 2012 17:56:53 -0500 Subject: g726: decode directly to the user-provided AVFrame --- libavcodec/g726.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/g726.c b/libavcodec/g726.c index dbe9e02240..d6ae9b2679 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -77,7 +77,6 @@ typedef struct G726Tables { typedef struct G726Context { AVClass *class; - AVFrame frame; G726Tables tbls; /**< static tables needed for computation */ Float11 sr[2]; /**< prev. reconstructed samples */ @@ -434,15 +433,13 @@ static av_cold int g726_decode_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_S16; - avcodec_get_frame_defaults(&c->frame); - avctx->coded_frame = &c->frame; - return 0; } static int g726_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; G726Context *c = avctx->priv_data; @@ -453,12 +450,12 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data, out_samples = buf_size * 8 / c->code_size; /* get output buffer */ - c->frame.nb_samples = out_samples; - if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) { + frame->nb_samples = out_samples; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = (int16_t *)c->frame.data[0]; + samples = (int16_t *)frame->data[0]; init_get_bits(&gb, buf, buf_size * 8); @@ -468,8 +465,7 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data, if (get_bits_left(&gb) > 0) av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n"); - *got_frame_ptr = 1; - *(AVFrame *)data = c->frame; + *got_frame_ptr = 1; return buf_size; } -- cgit v1.2.3