diff mbox series

[FFmpeg-devel,25/27] avformat/avienc: Simplify writing padding

Message ID AM7PR03MB6660ADF8B35599A10209DE028FA39@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 5eafbf0b087034771c680f15c6f43608dab5422e
Headers show
Series [FFmpeg-devel,01/27] avformat/astenc: Simplify writing padding
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 23, 2021, 3:29 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
write_odml_master() was responsible for 134406 of the 135347
calls to avio_wl64() during a fate-run.

 libavformat/avienc.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9eb072ce12..3b11841cd3 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -237,7 +237,6 @@  static void write_odml_master(AVFormatContext *s, int stream_index)
     AVCodecParameters *par = st->codecpar;
     AVIStream *avist = st->priv_data;
     unsigned char tag[5];
-    int j;
 
     /* Starting to lay out AVI OpenDML master index.
         * We want to make it JUNK entry for now, since we'd
@@ -250,10 +249,8 @@  static void write_odml_master(AVFormatContext *s, int stream_index)
     avio_wl32(pb, 0);   /* nEntriesInUse (will fill out later on) */
     ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
                         /* dwChunkId */
-    avio_wl64(pb, 0);   /* dwReserved[3] */
-    avio_wl32(pb, 0);   /* Must be 0.    */
-    for (j = 0; j < avi->master_index_max_size * 2; j++)
-        avio_wl64(pb, 0);
+    ffio_fill(pb, 0, 3 * 4 /* dwReserved[3] */
+                     + 16LL * avi->master_index_max_size);
     ff_end_tag(pb, avist->indexes.indx_start);
 }
 
@@ -351,10 +348,7 @@  static int avi_write_header(AVFormatContext *s)
         avio_wl32(pb, 0);
         avio_wl32(pb, 0);
     }
-    avio_wl32(pb, 0); /* reserved */
-    avio_wl32(pb, 0); /* reserved */
-    avio_wl32(pb, 0); /* reserved */
-    avio_wl32(pb, 0); /* reserved */
+    ffio_fill(pb, 0, 4 * 4); /* reserved */
 
     /* stream list */
     for (i = 0; i < n; i++) {
@@ -569,8 +563,7 @@  static int avi_write_header(AVFormatContext *s)
         ffio_wfourcc(pb, "odml");
         ffio_wfourcc(pb, "dmlh");
         avio_wl32(pb, 248);
-        for (i = 0; i < 248; i += 4)
-            avio_wl32(pb, 0);
+        ffio_fill(pb, 0, 248);
         ff_end_tag(pb, avi->odml_list);
     }
 
@@ -586,8 +579,7 @@  static int avi_write_header(AVFormatContext *s)
     /* some padding for easier tag editing */
     if (padding) {
         list2 = ff_start_tag(pb, "JUNK");
-        for (i = padding; i > 0; i -= 4)
-            avio_wl32(pb, 0);
+        ffio_fill(pb, 0, FFALIGN((uint32_t)padding, 4));
         ff_end_tag(pb, list2);
     }