diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-01-16 18:33:17 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-01-16 18:33:17 +0100 |
commit | 2fd39642c9aa34bae7e08fbdcba15ef1ae6f3b2e (patch) | |
tree | c8becb08ddbb415b00fb06c8ee9af78e109f652e /libavcodec/huffyuvdec.c | |
parent | 3d87927959bac2763087d193de1568c149a9405a (diff) | |
download | ffmpeg-2fd39642c9aa34bae7e08fbdcba15ef1ae6f3b2e.tar.gz |
avcodec/huffyuv: fix median prediction for >8bps
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/huffyuvdec.c')
-rw-r--r-- | libavcodec/huffyuvdec.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index c1e029db2f..ced22f620a 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -725,6 +725,32 @@ static void add_bytes(HYuvContext *s, uint8_t *dst, uint8_t *src, int w) } } +static void add_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, const uint8_t *diff, int w, int *left, int *left_top) +{ + if (s->bps <= 8) { + s->dsp.add_hfyu_median_prediction(dst, src, diff, w, left, left_top); + } else { + //FIXME optimize + unsigned mask = s->n-1; + int i; + uint16_t l, lt; + const uint16_t *src16 = (const uint16_t *)src; + const uint16_t *diff16 = (const uint16_t *)diff; + uint16_t *dst16 = ( uint16_t *)dst; + + l = *left; + lt = *left_top; + + for(i=0; i<w; i++){ + l = (mid_pred(l, src16[i], (l + src16[i] - lt) & mask) + diff16[i]) & mask; + lt = src16[i]; + dst16[i] = l; + } + + *left = l; + *left_top = lt; + } +} static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { @@ -817,7 +843,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, lefttop = p->data[plane][0]; decode_plane_bitstream(s, w, plane); - s->dsp.add_hfyu_median_prediction(p->data[plane] + fake_stride, p->data[plane], s->temp[0], w, &left, &lefttop); + add_median_prediction(s, p->data[plane] + fake_stride, p->data[plane], s->temp[0], w, &left, &lefttop); y++; for (; y<h; y++) { @@ -827,7 +853,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, dst = p->data[plane] + p->linesize[plane] * y; - s->dsp.add_hfyu_median_prediction(dst, dst - fake_stride, s->temp[0], w, &left, &lefttop); + add_median_prediction(s, dst, dst - fake_stride, s->temp[0], w, &left, &lefttop); } break; |