]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/fic.c
pthread_frame: ensure the threads don't run simultaneously with hwaccel
[ffmpeg] / libavcodec / fic.c
index f5a2ffe3695a419b6b9696aa991b23bf62e60f5c..b1286ebe6536242fa58c7ade6fdabbe200640ded 100644 (file)
@@ -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)
@@ -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;
@@ -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;
     }
 
@@ -452,5 +454,5 @@ AVCodec ff_fic_decoder = {
     .init           = fic_decode_init,
     .decode         = fic_decode_frame,
     .close          = fic_decode_close,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
+    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
 };