You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
amrwb: decode directly to the user-provided AVFrame
This commit is contained in:
@@ -43,7 +43,6 @@
|
|||||||
#include "amrwbdata.h"
|
#include "amrwbdata.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVFrame avframe; ///< AVFrame for decoded samples
|
|
||||||
AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
|
AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
|
||||||
enum Mode fr_cur_mode; ///< mode index of current frame
|
enum Mode fr_cur_mode; ///< mode index of current frame
|
||||||
uint8_t fr_quality; ///< frame quality index (FQI)
|
uint8_t fr_quality; ///< frame quality index (FQI)
|
||||||
@@ -113,9 +112,6 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
ctx->prediction_error[i] = MIN_ENERGY;
|
ctx->prediction_error[i] = MIN_ENERGY;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&ctx->avframe);
|
|
||||||
avctx->coded_frame = &ctx->avframe;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1077,6 +1073,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int *got_frame_ptr, AVPacket *avpkt)
|
int *got_frame_ptr, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
AMRWBContext *ctx = avctx->priv_data;
|
AMRWBContext *ctx = avctx->priv_data;
|
||||||
|
AVFrame *frame = data;
|
||||||
AMRWBFrame *cf = &ctx->frame;
|
AMRWBFrame *cf = &ctx->frame;
|
||||||
const uint8_t *buf = avpkt->data;
|
const uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
@@ -1094,12 +1091,12 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
int sub, i, ret;
|
int sub, i, ret;
|
||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k;
|
frame->nb_samples = 4 * AMRWB_SFR_SIZE_16k;
|
||||||
if ((ret = ff_get_buffer(avctx, &ctx->avframe)) < 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;
|
||||||
}
|
}
|
||||||
buf_out = (float *)ctx->avframe.data[0];
|
buf_out = (float *)frame->data[0];
|
||||||
|
|
||||||
header_size = decode_mime_header(ctx, buf);
|
header_size = decode_mime_header(ctx, buf);
|
||||||
if (ctx->fr_cur_mode > MODE_SID) {
|
if (ctx->fr_cur_mode > MODE_SID) {
|
||||||
@@ -1244,8 +1241,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
|
memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
|
||||||
memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
|
memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = ctx->avframe;
|
|
||||||
|
|
||||||
return expected_fr_size;
|
return expected_fr_size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user