You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
tak: decode directly to the user-provided AVFrame
This commit is contained in:
@@ -45,7 +45,6 @@ typedef struct MCDParam {
|
|||||||
|
|
||||||
typedef struct TAKDecContext {
|
typedef struct TAKDecContext {
|
||||||
AVCodecContext *avctx; // parent AVCodecContext
|
AVCodecContext *avctx; // parent AVCodecContext
|
||||||
AVFrame frame; // AVFrame for decoded output
|
|
||||||
DSPContext dsp;
|
DSPContext dsp;
|
||||||
TAKStreamInfo ti;
|
TAKStreamInfo ti;
|
||||||
GetBitContext gb; // bitstream reader initialized to start at the current frame
|
GetBitContext gb; // bitstream reader initialized to start at the current frame
|
||||||
@@ -176,8 +175,6 @@ static av_cold int tak_decode_init(AVCodecContext *avctx)
|
|||||||
ff_dsputil_init(&s->dsp, avctx);
|
ff_dsputil_init(&s->dsp, avctx);
|
||||||
|
|
||||||
s->avctx = avctx;
|
s->avctx = avctx;
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
|
||||||
avctx->coded_frame = &s->frame;
|
|
||||||
|
|
||||||
set_sample_rate_params(avctx);
|
set_sample_rate_params(avctx);
|
||||||
|
|
||||||
@@ -675,6 +672,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int *got_frame_ptr, AVPacket *pkt)
|
int *got_frame_ptr, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
TAKDecContext *s = avctx->priv_data;
|
TAKDecContext *s = avctx->priv_data;
|
||||||
|
AVFrame *frame = data;
|
||||||
GetBitContext *gb = &s->gb;
|
GetBitContext *gb = &s->gb;
|
||||||
int chan, i, ret, hsize;
|
int chan, i, ret, hsize;
|
||||||
|
|
||||||
@@ -741,8 +739,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples
|
s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples
|
||||||
: s->ti.frame_samples;
|
: s->ti.frame_samples;
|
||||||
|
|
||||||
s->frame.nb_samples = s->nb_samples;
|
frame->nb_samples = s->nb_samples;
|
||||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0)
|
if ((ret = ff_get_buffer(avctx, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (avctx->bits_per_coded_sample <= 16) {
|
if (avctx->bits_per_coded_sample <= 16) {
|
||||||
@@ -759,7 +757,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
for (chan = 0; chan < avctx->channels; chan++)
|
for (chan = 0; chan < avctx->channels; chan++)
|
||||||
s->decoded[chan] = (int32_t *)s->frame.extended_data[chan];
|
s->decoded[chan] = (int32_t *)frame->extended_data[chan];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->nb_samples < 16) {
|
if (s->nb_samples < 16) {
|
||||||
@@ -877,7 +875,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
switch (avctx->sample_fmt) {
|
switch (avctx->sample_fmt) {
|
||||||
case AV_SAMPLE_FMT_U8P:
|
case AV_SAMPLE_FMT_U8P:
|
||||||
for (chan = 0; chan < avctx->channels; chan++) {
|
for (chan = 0; chan < avctx->channels; chan++) {
|
||||||
uint8_t *samples = (uint8_t *)s->frame.extended_data[chan];
|
uint8_t *samples = (uint8_t *)frame->extended_data[chan];
|
||||||
int32_t *decoded = s->decoded[chan];
|
int32_t *decoded = s->decoded[chan];
|
||||||
for (i = 0; i < s->nb_samples; i++)
|
for (i = 0; i < s->nb_samples; i++)
|
||||||
samples[i] = decoded[i] + 0x80;
|
samples[i] = decoded[i] + 0x80;
|
||||||
@@ -885,7 +883,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
break;
|
break;
|
||||||
case AV_SAMPLE_FMT_S16P:
|
case AV_SAMPLE_FMT_S16P:
|
||||||
for (chan = 0; chan < avctx->channels; chan++) {
|
for (chan = 0; chan < avctx->channels; chan++) {
|
||||||
int16_t *samples = (int16_t *)s->frame.extended_data[chan];
|
int16_t *samples = (int16_t *)frame->extended_data[chan];
|
||||||
int32_t *decoded = s->decoded[chan];
|
int32_t *decoded = s->decoded[chan];
|
||||||
for (i = 0; i < s->nb_samples; i++)
|
for (i = 0; i < s->nb_samples; i++)
|
||||||
samples[i] = decoded[i];
|
samples[i] = decoded[i];
|
||||||
@@ -893,15 +891,14 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
break;
|
break;
|
||||||
case AV_SAMPLE_FMT_S32P:
|
case AV_SAMPLE_FMT_S32P:
|
||||||
for (chan = 0; chan < avctx->channels; chan++) {
|
for (chan = 0; chan < avctx->channels; chan++) {
|
||||||
int32_t *samples = (int32_t *)s->frame.extended_data[chan];
|
int32_t *samples = (int32_t *)frame->extended_data[chan];
|
||||||
for (i = 0; i < s->nb_samples; i++)
|
for (i = 0; i < s->nb_samples; i++)
|
||||||
samples[i] <<= 8;
|
samples[i] <<= 8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = s->frame;
|
|
||||||
|
|
||||||
return pkt->size;
|
return pkt->size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user