[FFmpeg-devel] [PATCH 08/15] avcodec/ffv1enc: Factor check out of a loop

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Wed Sep 25 01:03:03 EEST 2019


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

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 796d81f7c6..1bf9663053 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -428,9 +428,13 @@ static int write_extradata(FFV1Context *f)
         write_quant_tables(c, f->quant_tables[i]);
 
     for (i = 0; i < f->quant_table_count; i++) {
-        for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++)
-            if (f->initial_states[i] && f->initial_states[i][0][j] != 128)
-                break;
+        if (f->initial_states[i]) {
+            for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++)
+                if (f->initial_states[i][0][j] != 128)
+                    break;
+        } else {
+            j = f->context_count[i] * CONTEXT_SIZE;
+        }
         if (j < f->context_count[i] * CONTEXT_SIZE) {
             put_rac(c, state, 1);
             for (j = 0; j < f->context_count[i]; j++)
-- 
2.20.1



More information about the ffmpeg-devel mailing list