[FFmpeg-devel] [PATCH 01/18] avcodec/vp8: Disable segmentation for VP7

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat Sep 10 03:19:07 EEST 2022


Segmentation is a VP8-feature.

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

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 0e16e75faa..c00c5c975e 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -637,7 +637,6 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
         for (i = 0; i < 2; i++)
             memcpy(s->prob->mvc[i], vp7_mv_default_prob[i],
                    sizeof(vp7_mv_default_prob[i]));
-        memset(&s->segmentation, 0, sizeof(s->segmentation));
         memset(&s->lf_delta, 0, sizeof(s->lf_delta));
         memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan));
     }
@@ -2165,7 +2164,7 @@ void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb,
 {
     int interior_limit, filter_level;
 
-    if (s->segmentation.enabled) {
+    if (!is_vp7 && s->segmentation.enabled) {
         filter_level = s->segmentation.filter_level[mb->segment];
         if (!s->segmentation.absolute_vals)
             filter_level += s->filter.level;
@@ -2435,7 +2434,7 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void
     else {
         // Make sure the previous frame has read its segmentation map,
         // if we re-use the same map.
-        if (prev_frame && s->segmentation.enabled &&
+        if (!is_vp7 && prev_frame && s->segmentation.enabled &&
             !s->segmentation.update_map)
             ff_thread_await_progress(&prev_frame->tf, mb_y, 0);
         mb = s->macroblocks + (s->mb_height - mb_y - 1) * 2;
@@ -2791,15 +2790,16 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
         memset(s->ref_count, 0, sizeof(s->ref_count));
 
         if (s->mb_layout == 1) {
-            // Make sure the previous frame has read its segmentation map,
-            // if we re-use the same map.
-            if (prev_frame && s->segmentation.enabled &&
-                !s->segmentation.update_map)
-                ff_thread_await_progress(&prev_frame->tf, 1, 0);
-            if (is_vp7)
+            if (is_vp7) {
                 ret = vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
-            else
+            } else {
+                // Make sure the previous frame has read its segmentation map,
+                // if we re-use the same map.
+                if (prev_frame && s->segmentation.enabled &&
+                    !s->segmentation.update_map)
+                    ff_thread_await_progress(&prev_frame->tf, 1, 0);
                 ret = vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
+            }
             if (ret < 0)
                 goto err;
         }
-- 
2.34.1



More information about the ffmpeg-devel mailing list