qcelp: decode directly to the user-provided AVFrame

This commit is contained in:
Justin Ruggles 2012-12-23 19:43:11 -05:00
parent 0905c96390
commit 1b9b6d6e5e

View File

@ -53,7 +53,6 @@ typedef enum {
} qcelp_packet_rate; } qcelp_packet_rate;
typedef struct { typedef struct {
AVFrame avframe;
GetBitContext gb; GetBitContext gb;
qcelp_packet_rate bitrate; qcelp_packet_rate bitrate;
QCELPFrame frame; /**< unpacked data frame */ QCELPFrame frame; /**< unpacked data frame */
@ -97,9 +96,6 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx)
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
q->prev_lspf[i] = (i + 1) / 11.; q->prev_lspf[i] = (i + 1) / 11.;
avcodec_get_frame_defaults(&q->avframe);
avctx->coded_frame = &q->avframe;
return 0; return 0;
} }
@ -690,6 +686,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
QCELPContext *q = avctx->priv_data; QCELPContext *q = avctx->priv_data;
AVFrame *frame = data;
float *outbuffer; float *outbuffer;
int i, ret; int i, ret;
float quantized_lspf[10], lpc[10]; float quantized_lspf[10], lpc[10];
@ -697,12 +694,12 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
float *formant_mem; float *formant_mem;
/* get output buffer */ /* get output buffer */
q->avframe.nb_samples = 160; frame->nb_samples = 160;
if ((ret = ff_get_buffer(avctx, &q->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;
} }
outbuffer = (float *)q->avframe.data[0]; outbuffer = (float *)frame->data[0];
if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) { if ((q->bitrate = determine_bitrate(avctx, buf_size, &buf)) == I_F_Q) {
warn_insufficient_frame_quality(avctx, "bitrate cannot be determined."); warn_insufficient_frame_quality(avctx, "bitrate cannot be determined.");
@ -786,7 +783,6 @@ erasure:
q->prev_bitrate = q->bitrate; q->prev_bitrate = q->bitrate;
*got_frame_ptr = 1; *got_frame_ptr = 1;
*(AVFrame *)data = q->avframe;
return buf_size; return buf_size;
} }