[FFmpeg-devel] [PATCH 27/36] avcodec/mjpega_dump_header_bsf: Cosmetics

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


Reindentation; furthermore, the names of the out and out_buf variables
have been switched: The latter is now an AVBufferRef * whereas the
former is directly used for writing. And some variables have been put
into a smaller scope.

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

diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c
index 2d49b042ec..4ea55e88ba 100644
--- a/libavcodec/mjpega_dump_header_bsf.c
+++ b/libavcodec/mjpega_dump_header_bsf.c
@@ -33,15 +33,14 @@
 
 static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt)
 {
-    uint8_t *out_buf;
     unsigned dqt = 0, dht = 0, sof0 = 0;
-    int ret = 0, i;
+    int ret;
 
     ret = ff_bsf_get_packet_ref(ctx, pkt);
     if (ret < 0)
         return ret;
 
-    for (i = 0; i < pkt->size - 3; i++) {
+    for (int i = 0; i < pkt->size - 3; i++) {
         if (pkt->data[i] == 0xff) {
             switch (pkt->data[i + 1]) {
             case DQT:  dqt  = i + 46U; break;
@@ -49,31 +48,32 @@ static int mjpega_dump_header(AVBSFContext *ctx, AVPacket *pkt)
             case SOF0: sof0 = i + 46U; break;
             case SOS:
             {
-                AVBufferRef *out = NULL;
+                AVBufferRef *out_buf = NULL;
+                uint8_t *out;
 
-                ret = ff_buffer_padded_realloc(&out, pkt->size + 44U);
-    if (ret < 0)
-        goto fail;
+                ret = ff_buffer_padded_realloc(&out_buf, pkt->size + 44U);
+                if (ret < 0)
+                    goto fail;
 
-    out_buf = out->data;
-    bytestream_put_byte(&out_buf, 0xff);
-    bytestream_put_byte(&out_buf, SOI);
-    bytestream_put_byte(&out_buf, 0xff);
-    bytestream_put_byte(&out_buf, APP1);
-    bytestream_put_be16(&out_buf, 42); /* size */
-    bytestream_put_be32(&out_buf, 0);
-    bytestream_put_buffer(&out_buf, "mjpg", 4);
-                bytestream_put_be32(&out_buf, pkt->size + 44U); /* field size */
-                bytestream_put_be32(&out_buf, pkt->size + 44U); /* pad field size */
-                bytestream_put_be32(&out_buf, 0);             /* next ptr */
-                bytestream_put_be32(&out_buf, dqt); /* quant off */
-                bytestream_put_be32(&out_buf, dht); /* huff off */
-                bytestream_put_be32(&out_buf, sof0); /* image off */
-                bytestream_put_be32(&out_buf, i + 46U); /* scan off */
-                bytestream_put_be32(&out_buf, i + 46U + AV_RB16(pkt->data + i + 2)); /* data off */
-                bytestream_put_buffer(&out_buf, pkt->data + 2, pkt->size - 2); /* skip already written SOI */
+                out = out_buf->data;
+                bytestream_put_byte(&out, 0xff);
+                bytestream_put_byte(&out, SOI);
+                bytestream_put_byte(&out, 0xff);
+                bytestream_put_byte(&out, APP1);
+                bytestream_put_be16(&out, 42);              /* size */
+                bytestream_put_be32(&out, 0);
+                bytestream_put_buffer(&out, "mjpg", 4);
+                bytestream_put_be32(&out, pkt->size + 44U); /* field size */
+                bytestream_put_be32(&out, pkt->size + 44U); /* pad field size */
+                bytestream_put_be32(&out, 0);               /* next ptr */
+                bytestream_put_be32(&out, dqt);             /* quant off */
+                bytestream_put_be32(&out, dht);             /* huff off */
+                bytestream_put_be32(&out, sof0);            /* image off */
+                bytestream_put_be32(&out, i + 46U);         /* scan off */
+                bytestream_put_be32(&out, i + 46U + AV_RB16(pkt->data + i + 2)); /* data off */
+                bytestream_put_buffer(&out, pkt->data + 2, pkt->size - 2); /* skip already written SOI */
 
-                ff_packet_replace_buffer(pkt, out);
+                ff_packet_replace_buffer(pkt, out_buf);
                 return 0;
             }
             case APP1:
-- 
2.20.1



More information about the ffmpeg-devel mailing list