Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-03 05:01:37 +0400
committerMichael Niedermayer <michaelni@gmx.at>2011-11-03 05:16:26 +0400
commit988f585fcb1cfb40fe4b706c32b31594b536bba0 (patch)
tree659b8d9f4daf4ce497b42c83f7adb45725fa4f65 /libavcodec/libgsm.c
parent0b3e9d5dc61bb705d93db1e87d78d8d5131905c6 (diff)
parent594b54b51e9f3af8aac18184d634b85a836b42b6 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (44 commits) replacement Indeo 3 decoder gsm demuxer: do not allocate packet twice. flvenc: use first packet delay as global delay. ac3enc: doxygen update. imc: return error codes instead of 0 for error conditions. imc: return meaningful error codes instead of -1 imc: do not set channel layout for stereo imc: validate channel count imc: check for ff_fft_init() failure imc: check output buffer size before decoding imc: use DSPContext.bswap16_buf() to byte-swap packet data rtsp: add allowed_media_types option libgsm: add flush function to reset the decoder state when seeking libgsm: simplify decoding by using a loop gsm: log error message when packet is too small libgsmdec: do not needlessly set *data_size to 0 gsmdec: do not needlessly set *data_size to 0 gsmdec: add flush function to reset the decoder state when seeking libgsmdec: check output buffer size before decoding gsmdec: log error message when output buffer is too small. ... Conflicts: Changelog ffplay.c libavcodec/indeo3.c libavcodec/mjpeg_parser.c libavcodec/vp3.c libavformat/cutils.c libavformat/id3v2.c libavutil/parseutils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libgsm.c')
-rw-r--r--libavcodec/libgsm.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c
index 1541b3b29e..95919a4c43 100644
--- a/libavcodec/libgsm.c
+++ b/libavcodec/libgsm.c
@@ -166,23 +166,39 @@ static av_cold int libgsm_decode_close(AVCodecContext *avctx) {
static int libgsm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt) {
+ int i, ret;
+ struct gsm_state *s = avctx->priv_data;
uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- *data_size = 0; /* In case of error */
- if(buf_size < avctx->block_align) return -1;
- switch(avctx->codec_id) {
- case CODEC_ID_GSM:
- if(gsm_decode(avctx->priv_data,buf,data)) return -1;
- *data_size = GSM_FRAME_SIZE*sizeof(int16_t);
- break;
- case CODEC_ID_GSM_MS:
- 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 = GSM_FRAME_SIZE*sizeof(int16_t)*2;
+ int16_t *samples = data;
+ int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
+
+ if (*data_size < out_size) {
+ av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (buf_size < avctx->block_align) {
+ av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
+ return AVERROR_INVALIDDATA;
}
+
+ for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) {
+ if ((ret = gsm_decode(s, buf, samples)) < 0)
+ return -1;
+ buf += GSM_BLOCK_SIZE;
+ samples += GSM_FRAME_SIZE;
+ }
+
+ *data_size = out_size;
return avctx->block_align;
}
+static void libgsm_flush(AVCodecContext *avctx) {
+ gsm_destroy(avctx->priv_data);
+ avctx->priv_data = gsm_create();
+}
+
AVCodec ff_libgsm_decoder = {
.name = "libgsm",
.type = AVMEDIA_TYPE_AUDIO,
@@ -190,6 +206,7 @@ AVCodec ff_libgsm_decoder = {
.init = libgsm_decode_init,
.close = libgsm_decode_close,
.decode = libgsm_decode_frame,
+ .flush = libgsm_flush,
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
@@ -200,5 +217,6 @@ AVCodec ff_libgsm_ms_decoder = {
.init = libgsm_decode_init,
.close = libgsm_decode_close,
.decode = libgsm_decode_frame,
+ .flush = libgsm_flush,
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};