Commit 260de8a2 authored by Paul B Mahol's avatar Paul B Mahol

avcodec/sheervideo: fix Y prediction in decode_ybr(i) for older formats

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 6cbd47bf
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
typedef struct SheerVideoContext { typedef struct SheerVideoContext {
unsigned format; unsigned format;
int alt;
VLC vlc[2]; VLC vlc[2];
void (*decode_frame)(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb); void (*decode_frame)(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb);
} SheerVideoContext; } SheerVideoContext;
...@@ -2038,7 +2039,7 @@ static void decode_ybri(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) ...@@ -2038,7 +2039,7 @@ static void decode_ybri(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
dst_v[x] = get_bits(gb, 8); dst_v[x] = get_bits(gb, 8);
} }
} else { } else {
int pred[4] = { 125, -128, -128, -128 }; int pred[4] = { s->alt ? 125 : -146, -128, -128, -128 };
for (x = 0; x < avctx->width; x++) { for (x = 0; x < avctx->width; x++) {
int y, u, v; int y, u, v;
...@@ -2106,7 +2107,7 @@ static void decode_ybr(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) ...@@ -2106,7 +2107,7 @@ static void decode_ybr(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
dst_v[x] = get_bits(gb, 8); dst_v[x] = get_bits(gb, 8);
} }
} else { } else {
int pred[4] = { 125, -128, -128, -128 }; int pred[4] = { s->alt ? 125 : -146, -128, -128, -128 };
for (x = 0; x < avctx->width; x++) { for (x = 0; x < avctx->width; x++) {
int y, u, v; int y, u, v;
...@@ -2887,6 +2888,7 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -2887,6 +2888,7 @@ static int decode_frame(AVCodecContext *avctx,
AV_RL32(avpkt->data) != MKTAG('Z','w','a','k')) AV_RL32(avpkt->data) != MKTAG('Z','w','a','k'))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->alt = 0;
format = AV_RL32(avpkt->data + 16); format = AV_RL32(avpkt->data + 16);
switch (format) { switch (format) {
case MKTAG(' ', 'R', 'G', 'B'): case MKTAG(' ', 'R', 'G', 'B'):
...@@ -2972,6 +2974,7 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -2972,6 +2974,7 @@ static int decode_frame(AVCodecContext *avctx,
} }
break; break;
case MKTAG(' ', 'Y', 'B', 'R'): case MKTAG(' ', 'Y', 'B', 'R'):
s->alt = 1;
case MKTAG(' ', 'Y', 'b', 'R'): case MKTAG(' ', 'Y', 'b', 'R'):
avctx->pix_fmt = AV_PIX_FMT_YUV444P; avctx->pix_fmt = AV_PIX_FMT_YUV444P;
s->decode_frame = decode_ybr; s->decode_frame = decode_ybr;
...@@ -2981,6 +2984,7 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -2981,6 +2984,7 @@ static int decode_frame(AVCodecContext *avctx,
} }
break; break;
case MKTAG(' ', 'y', 'B', 'R'): case MKTAG(' ', 'y', 'B', 'R'):
s->alt = 1;
case MKTAG(' ', 'y', 'b', 'R'): case MKTAG(' ', 'y', 'b', 'R'):
avctx->pix_fmt = AV_PIX_FMT_YUV444P; avctx->pix_fmt = AV_PIX_FMT_YUV444P;
s->decode_frame = decode_ybri; s->decode_frame = decode_ybri;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment