avcodec/x86/lossless_videoencdsp_init: Don't read from before the buffer

sub_median_pred_mmxext() calculates a predictor from the left, top
and topleft pixel values. The left value is simply read via
ptr[-1], although this is not guaranteed to be inside the buffer
in case of negative strides. This happens e.g. with

ffmpeg -i fate-suite/mpeg2/dvd_single_frame.vob -vf vflip \
       -c:v magicyuv -pred median -f null -

Fix this by reading the first value like the topleft value.
Also change the documentation of sub_median_pred to reflect this
change (and the one from 791b5954bc).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-12-14 10:16:25 +01:00
parent f8a06da4ec
commit 2b9aea7756
2 changed files with 5 additions and 2 deletions
-1
View File
@@ -29,7 +29,6 @@ typedef struct LLVidEncDSPContext {
intptr_t w);
/**
* Subtract HuffYUV's variant of median prediction.
* Note, this might read from src1[-1], src2[-1].
*/
void (*sub_median_pred)(uint8_t *dst, const uint8_t *src1,
const uint8_t *src2, intptr_t w,
+5 -1
View File
@@ -49,9 +49,13 @@ static void sub_median_pred_mmxext(uint8_t *dst, const uint8_t *src1,
__asm__ volatile (
"movq (%1, %0), %%mm0 \n\t" // LT
"psllq $8, %%mm0 \n\t"
"movq (%2, %0), %%mm2 \n\t" // L
"psllq $8, %%mm2 \n\t"
"jmp 2f \n\t"
"1: \n\t"
"movq (%1, %0), %%mm1 \n\t" // T
"movq -1(%2, %0), %%mm2 \n\t" // L
"2: \n\t"
"movq (%1, %0), %%mm1 \n\t" // T
"movq (%2, %0), %%mm3 \n\t" // X
"movq %%mm2, %%mm4 \n\t" // L
"psubb %%mm0, %%mm2 \n\t"