mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-02 13:02:13 +00:00
libgsm: simplify decoding by using a loop
This commit is contained in:
parent
9d52f0a711
commit
480324e7ca
@ -166,8 +166,11 @@ static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
|
|||||||
static int libgsm_decode_frame(AVCodecContext *avctx,
|
static int libgsm_decode_frame(AVCodecContext *avctx,
|
||||||
void *data, int *data_size,
|
void *data, int *data_size,
|
||||||
AVPacket *avpkt) {
|
AVPacket *avpkt) {
|
||||||
|
int i, ret;
|
||||||
|
struct gsm_state *s = avctx->priv_data;
|
||||||
uint8_t *buf = avpkt->data;
|
uint8_t *buf = avpkt->data;
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
|
int16_t *samples = data;
|
||||||
int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
|
int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
|
||||||
|
|
||||||
if (*data_size < out_size) {
|
if (*data_size < out_size) {
|
||||||
@ -180,13 +183,11 @@ static int libgsm_decode_frame(AVCodecContext *avctx,
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(avctx->codec_id) {
|
for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
|
||||||
case CODEC_ID_GSM:
|
if ((ret = gsm_decode(s, buf, samples)) < 0)
|
||||||
if(gsm_decode(avctx->priv_data,buf,data)) return -1;
|
return -1;
|
||||||
break;
|
buf += GSM_BLOCK_SIZE;
|
||||||
case CODEC_ID_GSM_MS:
|
samples += GSM_FRAME_SIZE;
|
||||||
if(gsm_decode(avctx->priv_data,buf,data) ||
|
|
||||||
gsm_decode(avctx->priv_data,buf+33,((int16_t*)data)+GSM_FRAME_SIZE)) return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*data_size = out_size;
|
*data_size = out_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user