huffyuv: change left prediction access in BGRA

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/74/head
Christophe Gisquet 11 years ago committed by Michael Niedermayer
parent c609f803e1
commit 25e6310a3e
  1. 24
      libavcodec/huffyuvdec.c
  2. 14
      libavcodec/huffyuvdsp.c
  3. 3
      libavcodec/huffyuvdsp.h

@ -1028,19 +1028,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
} }
} else { } else {
int y; int y;
int leftr, leftg, leftb, lefta; uint8_t left[4];
const int last_line = (height - 1) * p->linesize[0]; const int last_line = (height - 1) * p->linesize[0];
if (s->bitstream_bpp == 32) { if (s->bitstream_bpp == 32) {
lefta = p->data[0][last_line+A] = get_bits(&s->gb, 8); left[A] = p->data[0][last_line+A] = get_bits(&s->gb, 8);
leftr = p->data[0][last_line+R] = get_bits(&s->gb, 8); left[R] = p->data[0][last_line+R] = get_bits(&s->gb, 8);
leftg = p->data[0][last_line+G] = get_bits(&s->gb, 8); left[G] = p->data[0][last_line+G] = get_bits(&s->gb, 8);
leftb = p->data[0][last_line+B] = get_bits(&s->gb, 8); left[B] = p->data[0][last_line+B] = get_bits(&s->gb, 8);
} else { } else {
leftr = p->data[0][last_line+R] = get_bits(&s->gb, 8); left[R] = p->data[0][last_line+R] = get_bits(&s->gb, 8);
leftg = p->data[0][last_line+G] = get_bits(&s->gb, 8); left[G] = p->data[0][last_line+G] = get_bits(&s->gb, 8);
leftb = p->data[0][last_line+B] = get_bits(&s->gb, 8); left[B] = p->data[0][last_line+B] = get_bits(&s->gb, 8);
lefta = p->data[0][last_line+A] = 255; left[A] = p->data[0][last_line+A] = 255;
skip_bits(&s->gb, 8); skip_bits(&s->gb, 8);
} }
@ -1049,14 +1049,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
case LEFT: case LEFT:
case PLANE: case PLANE:
decode_bgr_bitstream(s, width - 1); decode_bgr_bitstream(s, width - 1);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + last_line + 4, s->temp[0], width - 1, &leftr, &leftg, &leftb, &lefta); s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + last_line + 4, s->temp[0], width - 1, left);
for (y = s->height - 2; y >= 0; y--) { //Yes it is stored upside down. for (y = s->height - 2; y >= 0; y--) { //Yes it is stored upside down.
decode_bgr_bitstream(s, width); decode_bgr_bitstream(s, width);
s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + p->linesize[0] * y, s->temp[0], width, &leftr, &leftg, &leftb, &lefta); s->hdsp.add_hfyu_left_pred_bgr32(p->data[0] + p->linesize[0] * y, s->temp[0], width, left);
if (s->predictor == PLANE) { if (s->predictor == PLANE) {
if (s->bitstream_bpp != 32) lefta = 0; if (s->bitstream_bpp != 32) left[A] = 0;
if ((y & s->interlaced) == 0 && if ((y & s->interlaced) == 0 &&
y < s->height - 1 - s->interlaced) { y < s->height - 1 - s->interlaced) {
s->hdsp.add_bytes(p->data[0] + p->linesize[0] * y, s->hdsp.add_bytes(p->data[0] + p->linesize[0] * y,

@ -82,10 +82,10 @@ static int add_hfyu_left_pred_c(uint8_t *dst, const uint8_t *src, int w,
} }
static void add_hfyu_left_pred_bgr32_c(uint8_t *dst, const uint8_t *src, static void add_hfyu_left_pred_bgr32_c(uint8_t *dst, const uint8_t *src,
int w, int *red, int *green, intptr_t w, uint8_t *left)
int *blue, int *alpha)
{ {
int i, r = *red, g = *green, b = *blue, a = *alpha; int i;
uint8_t r = left[R], g = left[G], b = left[B], a = left[A];
for (i = 0; i < w; i++) { for (i = 0; i < w; i++) {
b += src[4 * i + B]; b += src[4 * i + B];
@ -99,10 +99,10 @@ static void add_hfyu_left_pred_bgr32_c(uint8_t *dst, const uint8_t *src,
dst[4 * i + A] = a; dst[4 * i + A] = a;
} }
*red = r; left[B] = b;
*green = g; left[G] = g;
*blue = b; left[R] = r;
*alpha = a; left[A] = a;
} }
av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c) av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c)

@ -42,8 +42,7 @@ typedef struct HuffYUVDSPContext {
int (*add_hfyu_left_pred)(uint8_t *dst, const uint8_t *src, int (*add_hfyu_left_pred)(uint8_t *dst, const uint8_t *src,
int w, int left); int w, int left);
void (*add_hfyu_left_pred_bgr32)(uint8_t *dst, const uint8_t *src, void (*add_hfyu_left_pred_bgr32)(uint8_t *dst, const uint8_t *src,
int w, int *red, int *green, intptr_t w, uint8_t *left);
int *blue, int *alpha);
} HuffYUVDSPContext; } HuffYUVDSPContext;
void ff_huffyuvdsp_init(HuffYUVDSPContext *c); void ff_huffyuvdsp_init(HuffYUVDSPContext *c);

Loading…
Cancel
Save