[FFmpeg-devel] [PATCH 21/36] avcodec/hevc_mp4toannexb_bsf: Reindent after last commit

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat May 30 19:05:26 EEST 2020


While just at it, use a smaller scope for a loop counter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/hevc_mp4toannexb_bsf.c | 45 +++++++++++++++----------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
index 3776d5b279..731ff2e7d3 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -121,8 +121,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
     HEVCBSFContext *s = ctx->priv_data;
     PutByteContext pb;
     AVPacket *in;
-
-    int i, ret = 0;
+    int ret;
 
     ret = ff_bsf_get_packet(ctx, &in);
     if (ret < 0)
@@ -139,32 +138,32 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
         uint64_t out_size = 0;
         int got_irap = 0;
 
-    bytestream2_init(&gb, in->data, in->size);
+        bytestream2_init(&gb, in->data, in->size);
 
-    while (bytestream2_get_bytes_left(&gb)) {
-        uint32_t nalu_size = 0;
-        int      nalu_type;
+        while (bytestream2_get_bytes_left(&gb)) {
+            uint32_t nalu_size = 0;
+            int      nalu_type;
             int is_irap, add_extradata, extra_size;
 
-        if (bytestream2_get_bytes_left(&gb) < s->length_size) {
-            ret = AVERROR_INVALIDDATA;
-            goto fail;
-        }
-        for (i = 0; i < s->length_size; i++)
-            nalu_size = (nalu_size << 8) | bytestream2_get_byteu(&gb);
+            if (bytestream2_get_bytes_left(&gb) < s->length_size) {
+                ret = AVERROR_INVALIDDATA;
+                goto fail;
+            }
+            for (int i = 0; i < s->length_size; i++)
+                nalu_size = (nalu_size << 8) | bytestream2_get_byteu(&gb);
 
-        if (nalu_size < 2 || nalu_size > bytestream2_get_bytes_left(&gb)) {
-            ret = AVERROR_INVALIDDATA;
-            goto fail;
-        }
+            if (nalu_size < 2 || nalu_size > bytestream2_get_bytes_left(&gb)) {
+                ret = AVERROR_INVALIDDATA;
+                goto fail;
+            }
 
-        nalu_type = (bytestream2_peek_byteu(&gb) >> 1) & 0x3f;
+            nalu_type = (bytestream2_peek_byteu(&gb) >> 1) & 0x3f;
 
-        /* prepend extradata to IRAP frames */
-        is_irap       = nalu_type >= 16 && nalu_type <= 23;
-        add_extradata = is_irap && !got_irap;
-        extra_size    = add_extradata * ctx->par_out->extradata_size;
-        got_irap     |= is_irap;
+            /* prepend extradata to IRAP frames */
+            is_irap       = nalu_type >= 16 && nalu_type <= 23;
+            add_extradata = is_irap && !got_irap;
+            extra_size    = add_extradata * ctx->par_out->extradata_size;
+            got_irap     |= is_irap;
 
             if (!pass) {
                 out_size += extra_size + 4ULL + nalu_size;
@@ -175,7 +174,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
                 bytestream2_put_be32u(&pb, 1);
                 bytestream2_copy_bufferu(&pb, &gb, nalu_size);
             }
-    }
+        }
 
         if (!pass) {
             if (out_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
-- 
2.20.1



More information about the ffmpeg-devel mailing list