[FFmpeg-devel] [PATCH 4/7] avcodec/cbs_vp9: Combine two loops

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Dec 10 00:26:01 EET 2019


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

diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index ea7747182e..807d066690 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -581,9 +581,11 @@ static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx,
         }
 
         max = 0;
-        for (i = 0; i < frag->nb_units; i++)
+        for (i = 0; i < frag->nb_units; i++) {
+            sfi.frame_sizes[i] = frag->units[i].data_size;
             if (max < frag->units[i].data_size)
                 max = frag->units[i].data_size;
+        }
 
         if (max < 2)
             size_len = 1;
@@ -599,10 +601,6 @@ static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx,
         if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
             return AVERROR(ERANGE);
 
-        for (i = 0; i < frag->nb_units; i++) {
-            sfi.frame_sizes[i] = frag->units[i].data_size;
-        }
-
         ref = av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
         if (!ref)
             return AVERROR(ENOMEM);
-- 
2.20.1



More information about the ffmpeg-devel mailing list