Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/7] avcodec/cbs_mpeg2: Remove redundant counter
@ 2022-02-04 15:14 Andreas Rheinhardt
  2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 2/7] avcodec/cbs_jpeg: " Andreas Rheinhardt
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Andreas Rheinhardt @ 2022-02-04 15:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Use -1 as the position in ff_cbs_insert_unit_data()
which implicitly reuses frag->nb_units as the counter.

Also switch to a do-while-loop, as it is more natural
than a for-loop now that the counter is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/cbs_mpeg2.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 26400f279f..4395bbf047 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -148,7 +148,8 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx,
     CodedBitstreamUnitType unit_type;
     uint32_t start_code = -1;
     size_t unit_size;
-    int err, i, final = 0;
+    int err;
+    int final = 0;
 
     start = avpriv_find_start_code(frag->data, frag->data + frag->data_size,
                                    &start_code);
@@ -157,7 +158,7 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx,
         return AVERROR_INVALIDDATA;
     }
 
-    for (i = 0;; i++) {
+    do {
         unit_type = start_code & 0xff;
 
         if (start == frag->data + frag->data_size) {
@@ -185,16 +186,13 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx,
            final     = 1;
         }
 
-        err = ff_cbs_insert_unit_data(frag, i, unit_type, (uint8_t*)start,
+        err = ff_cbs_insert_unit_data(frag, -1, unit_type, (uint8_t*)start,
                                       unit_size, frag->data_ref);
         if (err < 0)
             return err;
 
-        if (final)
-            break;
-
         start = end;
-    }
+    } while (!final);
 
     return 0;
 }
-- 
2.32.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-02-07  2:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 15:14 [FFmpeg-devel] [PATCH 1/7] avcodec/cbs_mpeg2: Remove redundant counter Andreas Rheinhardt
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 2/7] avcodec/cbs_jpeg: " Andreas Rheinhardt
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 3/7] avcodec/cbs: Make ff_cbs_insert_unit_data() always append the new unit Andreas Rheinhardt
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 4/7] avcodec/cbs_mpeg2: Simplify splitting fragment Andreas Rheinhardt
2022-02-04 19:01   ` Scott Theisen
2022-02-05  8:16     ` Scott Theisen
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 5/7] all: Remove unnecessary libavcodec/internal.h inclusions Andreas Rheinhardt
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 6/7] avcodec/internal.h: Move avpriv_find_start_code() to startcode.h Andreas Rheinhardt
2022-02-04 19:05   ` Scott Theisen
2022-02-05  8:04     ` Andreas Rheinhardt
2022-02-04 15:16 ` [FFmpeg-devel] [PATCH 7/7] avcodec/cbs_mpeg2: Use smaller scope for variables Andreas Rheinhardt
2022-02-05  6:36   ` [FFmpeg-devel] [PATCH] cbs_mpeg2_split_fragment(): cache the buffer end Scott Theisen
2022-02-07  2:18 ` [FFmpeg-devel] [PATCH 1/7] avcodec/cbs_mpeg2: Remove redundant counter Andreas Rheinhardt

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