[FFmpeg-cvslog] avformat/adxdec: demux multiple blocks at once

Paul B Mahol git at videolan.org
Sat Oct 3 22:51:58 EEST 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Sep 18 12:08:42 2020 +0200| [e0d0565425b418d8ac6f383c5377e690feaf181f] | committer: Paul B Mahol

avformat/adxdec: demux multiple blocks at once

Improves decoding speed by 24x

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

 libavformat/adxdec.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c
index ccd5049acd..a265c87dea 100644
--- a/libavformat/adxdec.c
+++ b/libavformat/adxdec.c
@@ -53,6 +53,9 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
     AVCodecParameters *par = s->streams[0]->codecpar;
     int ret, size;
 
+    if (avio_feof(s->pb))
+        return AVERROR_EOF;
+
     if (par->channels <= 0) {
         av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
         return AVERROR_INVALIDDATA;
@@ -63,16 +66,21 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->pos = avio_tell(s->pb);
     pkt->stream_index = 0;
 
-    ret = av_get_packet(s->pb, pkt, size);
-    if (ret != size) {
-        return ret < 0 ? ret : AVERROR(EIO);
-    }
-    if (AV_RB16(pkt->data) & 0x8000) {
-        return AVERROR_EOF;
+    ret = av_get_packet(s->pb, pkt, size * 128);
+    if (ret < 0)
+        return ret;
+    if ((ret % size) && ret >= size) {
+        size = ret - (ret % size);
+        av_shrink_packet(pkt, size);
+        pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
+    } else if (ret < size) {
+        return AVERROR(EIO);
+    } else {
+        size = ret;
     }
-    pkt->size     = size;
-    pkt->duration = 1;
-    pkt->pts      = (pkt->pos - c->header_size) / size;
+
+    pkt->duration = size / (BLOCK_SIZE * par->channels);
+    pkt->pts      = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->channels);
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list