[FFmpeg-devel] [PATCH] avformat/ivf: Change the length field to 32 bits

Raphaël Zumer rzumer at tebako.net
Tue Oct 1 20:05:12 EEST 2019


Signed-off-by: Raphaël Zumer <rzumer at tebako.net>
---
 libavformat/ivfdec.c | 3 ++-
 libavformat/ivfenc.c | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c
index 40ae464b76..2fdb6f5a04 100644
--- a/libavformat/ivfdec.c
+++ b/libavformat/ivfdec.c
@@ -53,7 +53,8 @@ static int read_header(AVFormatContext *s)
     st->codecpar->height     = avio_rl16(s->pb);
     time_base.den         = avio_rl32(s->pb);
     time_base.num         = avio_rl32(s->pb);
-    st->duration          = avio_rl64(s->pb);
+    st->duration          = avio_rl32(s->pb);
+    avio_rl32(s->pb); // unused
 
     st->need_parsing      = AVSTREAM_PARSE_HEADERS;
 
diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index adf72117e9..e135a78213 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -53,7 +53,7 @@ static int ivf_write_header(AVFormatContext *s)
     avio_wl16(pb, par->height);
     avio_wl32(pb, s->streams[0]->time_base.den);
     avio_wl32(pb, s->streams[0]->time_base.num);
-    avio_wl64(pb, 0xFFFFFFFFFFFFFFFFULL);
+    avio_wl64(pb, 0xFFFFFFFFFFFFFFFFULL); // length is overwritten at the end of muxing
 
     return 0;
 }
@@ -83,7 +83,8 @@ static int ivf_write_trailer(AVFormatContext *s)
         size_t end = avio_tell(pb);
 
         avio_seek(pb, 24, SEEK_SET);
-        avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
+        // overwrite the "length" field (duration)
+        avio_wl32(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
         avio_seek(pb, end, SEEK_SET);
     }
 
-- 
2.23.0



More information about the ffmpeg-devel mailing list