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

Submitted by Andreas Rheinhardt on Sept. 24, 2019, 10:03 p.m.

Details

Message ID 20190924220310.31157-9-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Sept. 24, 2019, 10:03 p.m.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/ffv1enc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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++)