mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
imc/iac: decode directly to the user-provided AVFrame
This commit is contained in:
parent
6fdfdb23d3
commit
9b28e58357
@ -80,8 +80,6 @@ typedef struct IMCChannel {
|
|||||||
} IMCChannel;
|
} IMCChannel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVFrame frame;
|
|
||||||
|
|
||||||
IMCChannel chctx[2];
|
IMCChannel chctx[2];
|
||||||
|
|
||||||
/** MDCT tables */
|
/** MDCT tables */
|
||||||
@ -252,9 +250,6 @@ static av_cold int imc_decode_init(AVCodecContext *avctx)
|
|||||||
avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO
|
avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO
|
||||||
: AV_CH_LAYOUT_STEREO;
|
: AV_CH_LAYOUT_STEREO;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&q->frame);
|
|
||||||
avctx->coded_frame = &q->frame;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,6 +924,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
|
|||||||
static int imc_decode_frame(AVCodecContext *avctx, void *data,
|
static int imc_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
int *got_frame_ptr, AVPacket *avpkt)
|
int *got_frame_ptr, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
|
AVFrame *frame = data;
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
@ -943,14 +939,14 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
q->frame.nb_samples = COEFFS;
|
frame->nb_samples = COEFFS;
|
||||||
if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
|
if ((ret = ff_get_buffer(avctx, frame)) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < avctx->channels; i++) {
|
for (i = 0; i < avctx->channels; i++) {
|
||||||
q->out_samples = (float *)q->frame.extended_data[i];
|
q->out_samples = (float *)frame->extended_data[i];
|
||||||
|
|
||||||
q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
|
q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
|
||||||
|
|
||||||
@ -963,12 +959,11 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->channels == 2) {
|
if (avctx->channels == 2) {
|
||||||
q->fdsp.butterflies_float((float *)q->frame.extended_data[0],
|
q->fdsp.butterflies_float((float *)frame->extended_data[0],
|
||||||
(float *)q->frame.extended_data[1], COEFFS);
|
(float *)frame->extended_data[1], COEFFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = q->frame;
|
|
||||||
|
|
||||||
return IMC_BLOCK_SIZE * avctx->channels;
|
return IMC_BLOCK_SIZE * avctx->channels;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user