Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Dai, Jianhui J" <jianhui.j.dai-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH v1] avformat/ivfenc: Set the "number of frames" in IVF header
Date: Fri, 2 Jun 2023 07:39:03 +0000
Message-ID: <DM6PR11MB268101D9DA0D3EAEC0B7D5DEB14EA@DM6PR11MB2681.namprd11.prod.outlook.com> (raw)

Should set "number of frames" to bytes 24-27 of IVF header, not duration.
It is described by [1]. Also confirm it by parsing IVF files in [2].

[1] Duck IVF - MultimediaWiki
https://wiki.multimedia.cx/index.php/Duck_IVF

[2] webm/vp8-test-vectors - Git at Google
https://chromium.googlesource.com/webm/vp8-test-vectors

Signed-off-by: Jianhui Dai <jianhui.j.dai@intel.com>
---
 libavformat/ivfenc.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 47b4efbcd1..88399099d4 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -72,7 +72,8 @@ 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); // length is overwritten at the end of muxing
+    avio_wl32(pb, 0xFFFFFFFF); // "number of frames" is overwritten at the end of muxing
+    avio_wl32(pb, 0); // unused
 
     return 0;
 }
@@ -99,16 +100,12 @@ static int ivf_write_trailer(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     IVFEncContext *ctx = s->priv_data;
 
-    if ((pb->seekable & AVIO_SEEKABLE_NORMAL) &&
-        (ctx->frame_cnt > 1 || (ctx->frame_cnt == 1 && ctx->last_pkt_duration))) {
+    // overwrite the "number of frames"
+    if ((pb->seekable & AVIO_SEEKABLE_NORMAL)) {
         int64_t end = avio_tell(pb);
 
         avio_seek(pb, 24, SEEK_SET);
-        // overwrite the "length" field (duration)
-        avio_wl32(pb, ctx->last_pkt_duration ?
-                  ctx->sum_delta_pts + ctx->last_pkt_duration :
-                  ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
-        avio_wl32(pb, 0); // zero out unused bytes
+        avio_wl32(pb, ctx->frame_cnt);
         avio_seek(pb, end, SEEK_SET);
     }
 
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

                 reply	other threads:[~2023-06-02  7:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM6PR11MB268101D9DA0D3EAEC0B7D5DEB14EA@DM6PR11MB2681.namprd11.prod.outlook.com \
    --to=jianhui.j.dai-at-intel.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git