[FFmpeg-cvslog] avformat/wvdec: parse last chunk that may store MD5 checksum

Paul B Mahol git at videolan.org
Wed Feb 23 18:00:53 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Feb 20 22:57:19 2022 +0100| [470ed586c44fda58078e861e9bad370d7fe05c25] | committer: Paul B Mahol

avformat/wvdec: parse last chunk that may store MD5 checksum

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

 libavformat/wvdec.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
index 0d5a86953d..ffefda1cce 100644
--- a/libavformat/wvdec.c
+++ b/libavformat/wvdec.c
@@ -108,7 +108,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
     /* Blocks with zero samples don't contain actual audio information
      * and should be ignored */
     if (!wc->header.samples)
-        return 0;
+        wc->block_parsed = 0;
     // parse flags
     flags  = wc->header.flags;
     rate_x = (flags & WV_DSD) ? 4 : 1;
@@ -121,7 +121,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
         chan   = wc->chan;
         chmask = wc->chmask;
     }
-    if ((rate == -1 || !chan || flags & WV_DSD) && !wc->block_parsed) {
+    if ((rate == -1 || !chan || flags & WV_DSD || !wc->header.samples) && !wc->block_parsed) {
         int64_t block_end = avio_tell(pb) + wc->header.blocksize;
         if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
             av_log(ctx, AV_LOG_ERROR,
@@ -187,6 +187,17 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
             case 0x27:
                 rate = avio_rl24(pb);
                 break;
+            case 0x26:
+                if (size == 16) {
+                    uint8_t md5[16];
+                    char md5_hex[2 * sizeof(md5) + 1];
+
+                    if (avio_read(pb, md5, 16) == 16) {
+                        ff_data_to_hex(md5_hex, md5, sizeof(md5), 1);
+                        av_log(ctx, AV_LOG_VERBOSE, "MD5=%s\n", md5_hex);
+                    }
+                    break;
+                }
             default:
                 avio_skip(pb, size);
             }
@@ -200,6 +211,8 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
         }
         avio_seek(pb, block_end - wc->header.blocksize, SEEK_SET);
     }
+    if (!wc->header.samples)
+        return 0;
     if (!wc->bpp)
         wc->bpp    = bpp;
     if (!wc->chan)



More information about the ffmpeg-cvslog mailing list