diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-02-13 12:20:39 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-02-13 12:33:48 +0000 |
commit | 2cced2a85442cd70cf6ceec29aff9ab1dc7880aa (patch) | |
tree | 734e8d5aa902028a833edb5414add96d8d3a1a3e | |
parent | 9145818ecd511854fc7578eb62730d4eec81c8d5 (diff) | |
download | ffmpeg-2cced2a85442cd70cf6ceec29aff9ab1dc7880aa.tar.gz |
paf: decode directly to the user-provided AVFrame
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/paf.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/libavcodec/paf.c b/libavcodec/paf.c index aa8370c9aa..78a5d97b20 100644 --- a/libavcodec/paf.c +++ b/libavcodec/paf.c @@ -377,22 +377,14 @@ static av_cold int paf_vid_close(AVCodecContext *avctx) return 0; } -typedef struct PAFAudioDecContext { - AVFrame frame; -} PAFAudioDecContext; - static av_cold int paf_aud_init(AVCodecContext *avctx) { - PAFAudioDecContext *c = avctx->priv_data; - if (avctx->channels != 2) { av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n"); return AVERROR_INVALIDDATA; } - avcodec_get_frame_defaults(&c->frame); avctx->channel_layout = AV_CH_LAYOUT_STEREO; - avctx->coded_frame = &c->frame; avctx->sample_fmt = AV_SAMPLE_FMT_S16; return 0; @@ -401,7 +393,7 @@ static av_cold int paf_aud_init(AVCodecContext *avctx) static int paf_aud_decode(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt) { - PAFAudioDecContext *c = avctx->priv_data; + AVFrame *frame = data; uint8_t *buf = pkt->data; int16_t *output_samples; const uint8_t *t; @@ -411,11 +403,11 @@ static int paf_aud_decode(AVCodecContext *avctx, void *data, if (frames < 1) return AVERROR_INVALIDDATA; - c->frame.nb_samples = PAF_SOUND_SAMPLES * frames; - if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) + frame->nb_samples = PAF_SOUND_SAMPLES * frames; + if ((ret = ff_get_buffer(avctx, frame)) < 0) return ret; - output_samples = (int16_t *)c->frame.data[0]; + output_samples = (int16_t *)frame->data[0]; for (i = 0; i < frames; i++) { t = buf + 256 * sizeof(uint16_t); for (j = 0; j < PAF_SOUND_SAMPLES; j++) { @@ -428,7 +420,6 @@ static int paf_aud_decode(AVCodecContext *avctx, void *data, } *got_frame_ptr = 1; - *(AVFrame *)data = c->frame; return pkt->size; } @@ -449,7 +440,6 @@ AVCodec ff_paf_audio_decoder = { .name = "paf_audio", .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_PAF_AUDIO, - .priv_data_size = sizeof(PAFAudioDecContext), .init = paf_aud_init, .decode = paf_aud_decode, .capabilities = CODEC_CAP_DR1, |