[FFmpeg-cvslog] avformat/wavdec: Remove direct s->pb->buffer access

Michael Niedermayer git at videolan.org
Sun Apr 3 03:51:35 CEST 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr  3 02:15:06 2016 +0200| [cf4d050b7231d7d96ed4d9a1bfaad87b8981e19d] | committer: Michael Niedermayer

avformat/wavdec: Remove direct s->pb->buffer access

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/wavdec.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 0391737..c620963 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -64,12 +64,34 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
 {
     if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codec->codec_tag == 1) {
         enum AVCodecID codec;
-        int ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer,
-                                 &codec);
+        uint8_t *buf = NULL;
+        int ret = ffio_ensure_seekback(s->pb, sizeof(buf));
+        int len = 1<<16;
+        int64_t pos = avio_tell(s->pb);
+
+        if (ret < 0)
+            goto end;
+
+        buf = av_malloc(len);
+        if (!buf) {
+            ret = AVERROR(ENOMEM);
+            goto end;
+        }
+
+        len = ret = avio_read(s->pb, buf, len);
+        if (ret < 0)
+            goto end;
+
+        ret = ff_spdif_probe(buf, len, &codec);
         if (ret > AVPROBE_SCORE_EXTENSION) {
             s->streams[0]->codec->codec_id = codec;
             wav->spdif = 1;
         }
+end:
+        avio_seek(s->pb, pos, SEEK_SET);
+        if (ret < 0)
+            av_log(s, AV_LOG_WARNING, "Cannot check for SPDIF\n");
+        av_free(buf);
     }
 }
 



More information about the ffmpeg-cvslog mailing list