avcodec/lcldec: Make PNG filter addressing match the code afterwards

Also update check accordingly

Fixes: tickets/10237/mszh_306_306_yuv422_nocompress.avi
Fixes: tickets/10237/mszh_306_306_yuv411_nocompress.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d11b8bd0c6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2023-06-01 00:50:15 +02:00
parent 5f4b9be7e8
commit 43c3acb60e
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 6 additions and 3 deletions

View File

@ -227,16 +227,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break;
case COMP_MSZH_NOCOMP: {
int bppx2;
int aligned_width = width;
switch (c->imgtype) {
case IMGTYPE_YUV111:
case IMGTYPE_RGB24:
bppx2 = 6;
break;
case IMGTYPE_YUV422:
aligned_width &= ~3;
case IMGTYPE_YUV211:
bppx2 = 4;
break;
case IMGTYPE_YUV411:
aligned_width &= ~3;
case IMGTYPE_YUV420:
bppx2 = 3;
break;
@ -244,7 +247,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
bppx2 = 0; // will error out below
break;
}
if (len < ((width * height * bppx2) >> 1))
if (len < ((aligned_width * height * bppx2) >> 1))
return AVERROR_INVALIDDATA;
break;
}
@ -310,8 +313,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
}
break;
case IMGTYPE_YUV422:
pixel_ptr = 0;
for (row = 0; row < height; row++) {
pixel_ptr = row * width * 2;
yq = uq = vq =0;
for (col = 0; col < width/4; col++) {
encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
@ -327,8 +330,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
}
break;
case IMGTYPE_YUV411:
pixel_ptr = 0;
for (row = 0; row < height; row++) {
pixel_ptr = row * width / 2 * 3;
yq = uq = vq =0;
for (col = 0; col < width/4; col++) {
encoded[pixel_ptr] = yq -= encoded[pixel_ptr];