You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
evrcdec: decode directly to the user-provided AVFrame
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@@ -66,7 +66,6 @@ typedef struct EVRCAFrame {
|
|||||||
} EVRCAFrame;
|
} EVRCAFrame;
|
||||||
|
|
||||||
typedef struct EVRCContext {
|
typedef struct EVRCContext {
|
||||||
AVFrame avframe;
|
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
evrc_packet_rate bitrate;
|
evrc_packet_rate bitrate;
|
||||||
evrc_packet_rate last_valid_bitrate;
|
evrc_packet_rate last_valid_bitrate;
|
||||||
@@ -230,9 +229,6 @@ static av_cold int evrc_decode_init(AVCodecContext *avctx)
|
|||||||
int i, n, idx = 0;
|
int i, n, idx = 0;
|
||||||
float denom = 2.0 / (2.0 * 8.0 + 1.0);
|
float denom = 2.0 / (2.0 * 8.0 + 1.0);
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&e->avframe);
|
|
||||||
avctx->coded_frame = &e->avframe;
|
|
||||||
|
|
||||||
avctx->channels = 1;
|
avctx->channels = 1;
|
||||||
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||||
@@ -742,16 +738,17 @@ static int evrc_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int *got_frame_ptr, AVPacket *avpkt)
|
int *got_frame_ptr, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
|
AVFrame *frame = data;
|
||||||
EVRCContext *e = avctx->priv_data;
|
EVRCContext *e = avctx->priv_data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
float ilspf[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];
|
float ilspf[FILTER_ORDER], ilpc[FILTER_ORDER], idelay[NB_SUBFRAMES];
|
||||||
float *samples;
|
float *samples;
|
||||||
int i, j, ret, error_flag = 0;
|
int i, j, ret, error_flag = 0;
|
||||||
|
|
||||||
e->avframe.nb_samples = 160;
|
frame->nb_samples = 160;
|
||||||
if ((ret = ff_get_buffer(avctx, &e->avframe)) < 0)
|
if ((ret = ff_get_buffer(avctx, frame)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
samples = (float *)e->avframe.data[0];
|
samples = (float *)frame->data[0];
|
||||||
|
|
||||||
if ((e->bitrate = determine_bitrate(avctx, &buf_size, &buf)) == RATE_ERRS) {
|
if ((e->bitrate = determine_bitrate(avctx, &buf_size, &buf)) == RATE_ERRS) {
|
||||||
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
|
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
|
||||||
@@ -899,12 +896,11 @@ erasure:
|
|||||||
if (e->bitrate != RATE_QUANT)
|
if (e->bitrate != RATE_QUANT)
|
||||||
e->prev_pitch_delay = e->pitch_delay;
|
e->prev_pitch_delay = e->pitch_delay;
|
||||||
|
|
||||||
samples = (float *)e->avframe.data[0];
|
samples = (float *)frame->data[0];
|
||||||
for (i = 0; i < 160; i++)
|
for (i = 0; i < 160; i++)
|
||||||
samples[i] /= 32768;
|
samples[i] /= 32768;
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = e->avframe;
|
|
||||||
|
|
||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user