diff mbox series

[FFmpeg-devel,17/27] avformat/movenchint: Simplify writing padding

Message ID AM7PR03MB6660C5378642A973A89AC8548FA39@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 0f12d79a88fcd08789fe826e40ea7d1324896b18
Headers show
Series [FFmpeg-devel,01/27] avformat/astenc: Simplify writing padding | expand

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:28 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/movenchint.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Paul B Mahol Sept. 23, 2021, 7:11 p.m. UTC | #1
lgtm if ffio_fill does not turn negative argument into very positive one.
Andreas Rheinhardt Sept. 23, 2021, 7:17 p.m. UTC | #2
Paul B Mahol:
> lgtm if ffio_fill does not turn negative argument into very positive one.
> 

ffio_fill does not do that; and the argument here is always nonnegative.
Here is the loop:

    while (size > 0) {
        int len = size; // size is an int and > 0 and so is len is now
        if (len > 14)
            len = 14;
        /* From here on len is always <= 14 */
        avio_w8(out, 1); /* immediate constructor */
        avio_w8(out, len); /* amount of valid data */
        avio_write(out, data, len);
        data += len;
        size -= len;

        for (; len < 14; len++)
            avio_w8(out, 0);

        (*entries)++;
    }
diff mbox series

Patch

diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 47276091f3..35212f2c5d 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -260,8 +260,7 @@  static void output_immediate(const uint8_t *data, int size,
         data += len;
         size -= len;
 
-        for (; len < 14; len++)
-            avio_w8(out, 0);
+        ffio_fill(out, 0, 14 - len);
 
         (*entries)++;
     }