[FFmpeg-cvslog] avcodec/smcenc: unbreak skip blocks for inter coding

Paul B Mahol git at videolan.org
Sun Nov 13 01:48:27 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Nov 13 00:48:38 2022 +0100| [2d25f33a7ed36003de9a62c9cb165db183663d1c] | committer: Paul B Mahol

avcodec/smcenc: unbreak skip blocks for inter coding

When using frames with different linesize.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d25f33a7ed36003de9a62c9cb165db183663d1c
---

 libavcodec/smcenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c
index 59b9d9e0ff..a2d224bd09 100644
--- a/libavcodec/smcenc.c
+++ b/libavcodec/smcenc.c
@@ -116,6 +116,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
     const uint8_t *src_pixels = (const uint8_t *)frame->data[0];
     const int stride = frame->linesize[0];
     const uint8_t *prev_pixels = (const uint8_t *)s->prev_frame->data[0];
+    const int prev_stride = s->prev_frame->linesize[0];
     uint8_t *distinct_values = s->distinct_values;
     const uint8_t *pixel_ptr, *row_ptr;
     const int height = frame->height;
@@ -155,10 +156,10 @@ static void smc_encode_stream(SMCContext *s, const AVFrame *frame,
             int compare = 0;
 
             for (int y = 0; y < y_size; y++) {
-                const ptrdiff_t offset = pixel_ptr - src_pixels;
-                const uint8_t *prev_pixel_ptr = prev_pixels + offset;
+                const ptrdiff_t offset = pixel_ptr - row_ptr;
+                const uint8_t *prev_pixel_ptr = prev_pixels + cur_y * prev_stride + offset;
 
-                compare |= memcmp(prev_pixel_ptr + y * stride, pixel_ptr + y * stride, 4);
+                compare |= memcmp(prev_pixel_ptr + y * prev_stride, pixel_ptr + y * stride, 4);
                 if (compare)
                     break;
             }



More information about the ffmpeg-cvslog mailing list