Commit 2cced2a8 authored by Paul B Mahol's avatar Paul B Mahol

paf: decode directly to the user-provided AVFrame

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 9145818e
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment