From e299cb2cd37330bf58225d45b06dc179f8dd8dac Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Tue, 22 Apr 2014 16:42:11 -0400 Subject: [PATCH 1/3] fic: Simplify alpha blending Signed-off-by: Derek Buitenhuis --- libavcodec/fic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/fic.c b/libavcodec/fic.c index f5a2ffe369..0f9f798e43 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -195,7 +195,7 @@ static av_always_inline void fic_alpha_blend(uint8_t *dst, uint8_t *src, int i; for (i = 0; i < size; i++) - dst[i] = (dst[i] * (256 - alpha[i]) + src[i] * alpha[i]) >> 8; + dst[i] += ((src[i] - dst[i]) * alpha[i]) >> 8; } static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y) From 7596fc3d4b616318ac42a6cc011fe20f3ff7aaa9 Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Wed, 23 Apr 2014 12:18:36 -0400 Subject: [PATCH 2/3] fic: Remove redundant clips The equations can't overflow or underflow anyway. Signed-off-by: Derek Buitenhuis --- libavcodec/fic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/fic.c b/libavcodec/fic.c index 0f9f798e43..45f56b9558 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -209,9 +209,9 @@ static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y) /* Convert to YUVA444. */ for (i = 0; i < 1024; i++) { - planes[0][i] = av_clip_uint8((( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16); - planes[1][i] = av_clip_uint8(((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128); - planes[2][i] = av_clip_uint8(((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128); + planes[0][i] = (( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16; + planes[1][i] = ((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128; + planes[2][i] = ((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128; planes[3][i] = ptr[3]; ptr += 4; From d7eb8f903338048c0b222d92357d67f5d3b54295 Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Wed, 23 Apr 2014 17:53:00 +0100 Subject: [PATCH 3/3] fic: Make warning message more accurate Signed-off-by: Derek Buitenhuis --- libavcodec/fic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/fic.c b/libavcodec/fic.c index 45f56b9558..8512ef3400 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -296,7 +296,9 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data, /* Skip cursor data. */ tsize = AV_RB24(src + 24); if (tsize > avpkt->size - FIC_HEADER_SIZE) { - av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size.\n"); + av_log(avctx, AV_LOG_ERROR, + "Packet is too small to contain cursor (%d vs %d bytes).\n", + tsize, avpkt->size - FIC_HEADER_SIZE); return AVERROR_INVALIDDATA; }