[FFmpeg-cvslog] lavf/gsmdec: Add raw gsm autodetection.

Carl Eugen Hoyos git at videolan.org
Sat Apr 9 11:40:20 CEST 2016


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Sat Apr  9 11:38:46 2016 +0200| [56cb465b38ab29afedd502c1e2ad66e6dce16b93] | committer: Carl Eugen Hoyos

lavf/gsmdec: Add raw gsm autodetection.

Fixes bug 555.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=56cb465b38ab29afedd502c1e2ad66e6dce16b93
---

 libavformat/gsmdec.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c
index 97dd8c5..267ad6f 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,



More information about the ffmpeg-cvslog mailing list