aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/gsmdec.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2016-04-09 11:38:46 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2016-04-09 11:38:46 +0200
commit56cb465b38ab29afedd502c1e2ad66e6dce16b93 (patch)
tree6a14a29a9d4b107b5e02c80ea6f40c8fc70143e0 /libavformat/gsmdec.c
parentd433623fba2b273491ff7dda401648e7d07e19fe (diff)
downloadffmpeg-56cb465b38ab29afedd502c1e2ad66e6dce16b93.tar.gz
lavf/gsmdec: Add raw gsm autodetection.
Fixes bug 555.
Diffstat (limited to 'libavformat/gsmdec.c')
-rw-r--r--libavformat/gsmdec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c
index 97dd8c589b..267ad6fe87 100644
--- a/libavformat/gsmdec.c
+++ b/libavformat/gsmdec.c
@@ -34,6 +34,23 @@ typedef struct GSMDemuxerContext {
int sample_rate;
} GSMDemuxerContext;
+static int gsm_probe(AVProbeData *p)
+{
+ int valid = 0, invalid = 0;
+ uint8_t *b = p->buf;
+ while (b < p->buf + p->buf_size - 32) {
+ if ((*b & 0xf0) == 0xd0) {
+ valid++;
+ } else {
+ invalid++;
+ }
+ b += 33;
+ }
+ if (valid >> 5 > invalid)
+ return AVPROBE_SCORE_EXTENSION + 1;
+ return 0;
+}
+
static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
@@ -91,6 +108,7 @@ AVInputFormat ff_gsm_demuxer = {
.name = "gsm",
.long_name = NULL_IF_CONFIG_SMALL("raw GSM"),
.priv_data_size = sizeof(GSMDemuxerContext),
+ .read_probe = gsm_probe,
.read_header = gsm_read_header,
.read_packet = gsm_read_packet,
.flags = AVFMT_GENERIC_INDEX,