[FFmpeg-devel] [PATCH 14/18] avcodec/vp8: Move fade_present from context to stack

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat Sep 10 04:07:25 EEST 2022


It is only an auxiliary value used for parsing the VP7 frame header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
I think that vp7_fade_frame() needs a check for whether the
previous frame is writable before writing to it.
Does anyone have a sample for this fading?

 libavcodec/vp8.c | 6 +++---
 libavcodec/vp8.h | 5 -----
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index a7df4601ef..baf9820ce6 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -580,6 +580,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
     int height = s->avctx->height;
     int alpha = 0;
     int beta  = 0;
+    int fade_present = 1;
 
     if (buf_size < 4) {
         return AVERROR_INVALIDDATA;
@@ -679,7 +680,6 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
 
     s->update_last          = 1;
     s->update_probabilities = 1;
-    s->fade_present         = 1;
 
     if (s->profile > 0) {
         s->update_probabilities = vp89_rac_get(c);
@@ -687,13 +687,13 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
             s->prob[1] = s->prob[0];
 
         if (!s->keyframe)
-            s->fade_present = vp89_rac_get(c);
+            fade_present = vp89_rac_get(c);
     }
 
     if (vpx_rac_is_end(c))
         return AVERROR_INVALIDDATA;
     /* E. Fading information for previous frame */
-    if (s->fade_present && vp89_rac_get(c)) {
+    if (fade_present && vp89_rac_get(c)) {
         alpha = (int8_t) vp89_rac_get_uint(c, 8);
         beta  = (int8_t) vp89_rac_get_uint(c, 8);
     }
diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h
index ed79bc79c1..db0155237a 100644
--- a/libavcodec/vp8.h
+++ b/libavcodec/vp8.h
@@ -335,11 +335,6 @@ typedef struct VP8Context {
 
     int vp7;
 
-    /**
-     * Fade bit present in bitstream (VP7)
-     */
-    int fade_present;
-
     /**
      * Interframe DC prediction (VP7)
      * [0] VP8_FRAME_PREVIOUS
-- 
2.34.1



More information about the ffmpeg-devel mailing list