ffmpeg-cvslog
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
September 2021
- 2 participants
- 555 discussions
28 Sep '21
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com> | Wed Sep 22 00:09:54 2021 +0200| [ed6549887a1969636b30295b3da87313b7c46864] | committer: Andreas Rheinhardt
avcodec/encoders: Remove redundant setting of AV_PKT_FLAG_KEY
It is now set generically for all those encoders whose corresponding
AVCodecDescriptor has the AV_CODEC_PROP_INTRA_ONLY.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed6549887a1969636…
---
libavcodec/a64multienc.c | 1 -
libavcodec/aliaspixenc.c | 1 -
libavcodec/asvenc.c | 1 -
libavcodec/avuienc.c | 1 -
libavcodec/bmpenc.c | 1 -
libavcodec/cljrenc.c | 1 -
libavcodec/dnxhdenc.c | 1 -
libavcodec/dpxenc.c | 1 -
libavcodec/dvenc.c | 1 -
libavcodec/exrenc.c | 1 -
libavcodec/fitsenc.c | 1 -
libavcodec/hapenc.c | 1 -
libavcodec/huffyuvenc.c | 1 -
libavcodec/j2kenc.c | 1 -
libavcodec/jpeglsenc.c | 1 -
libavcodec/lclenc.c | 1 -
libavcodec/libopenjpegenc.c | 1 -
libavcodec/libwebpenc.c | 1 -
libavcodec/libwebpenc_animencoder.c | 1 -
libavcodec/ljpegenc.c | 1 -
libavcodec/magicyuvenc.c | 1 -
libavcodec/pamenc.c | 1 -
libavcodec/pcxenc.c | 1 -
libavcodec/pnmenc.c | 1 -
libavcodec/proresenc_anatoliy.c | 1 -
libavcodec/proresenc_kostya.c | 1 -
libavcodec/r210enc.c | 1 -
libavcodec/rawenc.c | 1 -
libavcodec/sgienc.c | 1 -
libavcodec/sunrastenc.c | 1 -
libavcodec/targaenc.c | 1 -
libavcodec/tiffenc.c | 1 -
libavcodec/utvideoenc.c | 5 -----
libavcodec/v210enc.c | 1 -
libavcodec/v308enc.c | 1 -
libavcodec/v408enc.c | 1 -
libavcodec/v410enc.c | 1 -
libavcodec/xbmenc.c | 1 -
libavcodec/xfaceenc.c | 1 -
libavcodec/xwdenc.c | 1 -
libavcodec/y41penc.c | 1 -
libavcodec/yuv4enc.c | 1 -
42 files changed, 46 deletions(-)
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 0cadf0ca28..7bdf4a61b1 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -385,7 +385,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
c->next_pts = AV_NOPTS_VALUE;
av_assert0(pkt->size == req_size);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = !!req_size;
}
return 0;
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 22234c091e..01461c984b 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -96,7 +96,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* Total length */
av_shrink_packet(pkt, buf - pkt->data);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index 6be7f5282a..ff96338e8a 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -299,7 +299,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
pkt->size = size * 4;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c
index b7f1347056..dac56d1ae5 100644
--- a/libavcodec/avuienc.c
+++ b/libavcodec/avuienc.c
@@ -87,7 +87,6 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 40c2f056fa..1eebf5a4b6 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -154,7 +154,6 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ptr -= p->linesize[0]; // ... and go back
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c
index 15fe43e073..aa53a110d0 100644
--- a/libavcodec/cljrenc.c
+++ b/libavcodec/cljrenc.c
@@ -91,7 +91,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
flush_put_bits(&pb);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index ee45c64ff4..b45fb41515 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -1308,7 +1308,6 @@ encode_coding_unit:
ff_side_data_set_encoder_stats(pkt, ctx->qscale * FF_QP2LAMBDA, NULL, 0, AV_PICTURE_TYPE_I);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c
index fa8b7d5ddc..09036a2125 100644
--- a/libavcodec/dpxenc.c
+++ b/libavcodec/dpxenc.c
@@ -271,7 +271,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
write32(buf + 16, size); /* file size */
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index a464e3ed87..045a29b833 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -1187,7 +1187,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
emms_c();
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
index a594cf5a8d..8bb2ea8386 100644
--- a/libavcodec/exrenc.c
+++ b/libavcodec/exrenc.c
@@ -507,7 +507,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
av_shrink_packet(pkt, bytestream2_tell_p(pb));
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
index d96baad986..dfaa04cdbd 100644
--- a/libavcodec/fitsenc.c
+++ b/libavcodec/fitsenc.c
@@ -105,7 +105,6 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytes_left = padded_data_size - data_size;
memset(bytestream, 0, bytes_left);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c
index f4313ecf6d..8db0af3a43 100644
--- a/libavcodec/hapenc.c
+++ b/libavcodec/hapenc.c
@@ -229,7 +229,6 @@ static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
hap_write_frame_header(ctx, pkt->data, final_data_size + header_length);
av_shrink_packet(pkt, final_data_size + header_length);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 266984c026..97497a8e75 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -994,7 +994,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->picture_number++;
pkt->size = size * 4;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 71010509ec..fa6fc208f5 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1661,7 +1661,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
av_log(s->avctx, AV_LOG_DEBUG, "end\n");
pkt->size = s->buf - s->buf_start;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index a0552b3c54..beae3bb77f 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -415,7 +415,6 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
emms_c();
- pkt->flags |= AV_PKT_FLAG_KEY;
av_shrink_packet(pkt, bytestream2_tell_p(&pb));
*got_packet = 1;
return 0;
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 1e15b09624..7deea4f20a 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -103,7 +103,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
pkt->size = c->zstream.total_out;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 7d29b34b04..3e52bcd4e9 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -708,7 +708,6 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
av_shrink_packet(pkt, writer.pos);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
ret = 0;
diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c
index afaf80047b..180fff93f6 100644
--- a/libavcodec/libwebpenc.c
+++ b/libavcodec/libwebpenc.c
@@ -63,7 +63,6 @@ static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
goto end;
memcpy(pkt->data, mw.mem, mw.size);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
end:
diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c
index 537f1576bd..f75e5636b9 100644
--- a/libavcodec/libwebpenc_animencoder.c
+++ b/libavcodec/libwebpenc_animencoder.c
@@ -73,7 +73,6 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
s->done = 1;
- pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pts = pkt->dts = s->first_frame_pts;
*got_packet = 1;
return 0;
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index ce5409da34..968ba1fb60 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -259,7 +259,6 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
flush_put_bits(&pb);
pkt->size = put_bits_ptr(&pb) - pb.buf;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 8a80441cf6..5aef810a58 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -522,7 +522,6 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream2_seek_p(&pb, pos, SEEK_SET);
pkt->size = bytestream2_tell_p(&pb);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index c38de5c607..d2ceb33555 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -123,7 +123,6 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index 4c43c9e344..27ebc1b2f4 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -187,7 +187,6 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
pkt->size = buf - pkt->data;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 2e8b6372a3..8378f90d08 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -142,7 +142,6 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ptr2 += p->linesize[2];
}
}
- pkt->flags |= AV_PKT_FLAG_KEY;
av_shrink_packet(pkt, bytestream - bytestream_start);
*got_packet = 1;
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index b7034eec80..21938c8f34 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -795,7 +795,6 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
AV_WB32(pkt->data, compress_frame_size);/* update frame size */
- pkt->flags |= AV_PKT_FLAG_KEY;
pkt->size = compress_frame_size;
*got_packet = 1;
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 4f303593ce..85651fce2a 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1136,7 +1136,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream_put_be32(&orig_buf, frame_size);
pkt->size = frame_size;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index 76271e2749..7a72ba4695 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -81,7 +81,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
srcb_line += pic->linesize[1];
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index bd992239a5..7e15084d71 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -76,7 +76,6 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
AV_WB64(&pkt->data[8 * x], v << 48 | v >> 16);
}
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index d323e41172..5ed5e71cdc 100644
--- a/libavcodec/sgienc.c
+++ b/libavcodec/sgienc.c
@@ -250,7 +250,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* total length */
pkt->size = bytestream2_tell_p(&pbc);
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c
index b77bed01a5..965ee5b818 100644
--- a/libavcodec/sunrastenc.c
+++ b/libavcodec/sunrastenc.c
@@ -189,7 +189,6 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
AV_WB32(&avpkt->data[16], s->length);
*got_packet_ptr = 1;
- avpkt->flags |= AV_PKT_FLAG_KEY;
avpkt->size = bytestream2_tell_p(&s->p);
return 0;
}
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index 82870c089b..cf1733bb2d 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -172,7 +172,6 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memcpy(out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.", 26);
pkt->size = out + 26 - pkt->data;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index f8623be3e9..a6c523364a 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -515,7 +515,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream_put_le32(&ptr, 0);
pkt->size = ptr - pkt->data;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
fail:
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 1402825fa7..30907faa0f 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -616,11 +616,6 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
frame_info = c->frame_pred << 8;
bytestream2_put_le32(&pb, frame_info);
- /*
- * At least currently Ut Video is IDR only.
- * Set flags accordingly.
- */
- pkt->flags |= AV_PKT_FLAG_KEY;
pkt->size = bytestream2_tell_p(&pb);
/* Packet should be done */
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index e50886021f..22875be7d5 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -147,7 +147,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memcpy(buf, side_data->data, side_data->size);
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index 6b58bb102c..85fb20729f 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -65,7 +65,6 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
v += pic->linesize[2];
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c
index e786f71f06..31bf48406c 100644
--- a/libavcodec/v408enc.c
+++ b/libavcodec/v408enc.c
@@ -70,7 +70,6 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
a += pic->linesize[3];
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index 164f939052..d14ecd5d27 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -69,7 +69,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
v += pic->linesize[2] >> 1;
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 37773bc382..5e552ce820 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -71,7 +71,6 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
buf += snprintf(buf, 5, " };\n");
pkt->size = buf - pkt->data;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/xfaceenc.c b/libavcodec/xfaceenc.c
index aa9e905965..55815e5c2f 100644
--- a/libavcodec/xfaceenc.c
+++ b/libavcodec/xfaceenc.c
@@ -206,7 +206,6 @@ static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
*(p++) = '\n';
*(p++) = 0;
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c
index d7d18f913c..a65f83abdd 100644
--- a/libavcodec/xwdenc.c
+++ b/libavcodec/xwdenc.c
@@ -211,7 +211,6 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ptr += p->linesize[0];
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index cd4c43b800..c5b211a1c2 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -72,7 +72,6 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c
index 995c994b53..5181a46403 100644
--- a/libavcodec/yuv4enc.c
+++ b/libavcodec/yuv4enc.c
@@ -55,7 +55,6 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
v += pic->linesize[2];
}
- pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
1
0
avcodec/encode: Set AV_PKT_FLAG_KEY based upon AV_CODEC_PROP_INTRA_ONLY
by Andreas Rheinhardt 28 Sep '21
by Andreas Rheinhardt 28 Sep '21
28 Sep '21
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com> | Wed Sep 22 00:04:31 2021 +0200| [3f11eac75741888c7b2b6f93c458766f2613bab5] | committer: Andreas Rheinhardt
avcodec/encode: Set AV_PKT_FLAG_KEY based upon AV_CODEC_PROP_INTRA_ONLY
Currently, the AV_PKT_FLAG_KEY is automatically set for audio encoders;
yet this is wrong, as both MLP and TrueHD have non-keyframes. So set it
based upon AV_CODEC_PROP_INTRA_ONLY (from the corresponding
AVCodecDescriptor) instead. This also sets it for some video codecs,
which is intended.
Reviewed-by: James Almer <jamrial(a)gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3f11eac75741888c7…
---
libavcodec/encode.c | 7 +++----
libavcodec/internal.h | 7 +++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 98dfbfdff3..dd25cf999b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -235,12 +235,9 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
}
}
if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
- /* NOTE: if we add any audio encoders which output non-keyframe packets,
- * this needs to be moved to the encoders, but for now we can do it
- * here to simplify things */
- avpkt->flags |= AV_PKT_FLAG_KEY;
avpkt->dts = avpkt->pts;
}
+ avpkt->flags |= avci->intra_only_flag;
}
if (avci->draining && !got_packet)
@@ -553,6 +550,8 @@ int ff_encode_preinit(AVCodecContext *avctx)
}
avctx->sw_pix_fmt = frames_ctx->sw_format;
}
+ if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY)
+ avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
return 0;
}
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 2111f2b9ae..b6180f15a5 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -153,6 +153,13 @@ typedef struct AVCodecInternal {
uint8_t *byte_buffer;
unsigned int byte_buffer_size;
+ /**
+ * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only
+ * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set).
+ * This is used to set said flag generically for said encoders.
+ */
+ int intra_only_flag;
+
void *frame_thread_encoder;
EncodeSimpleContext es;
1
0
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com> | Tue Sep 21 22:05:01 2021 +0200| [f09fd1c6c70505916a3d1b21530b3f71d8118688] | committer: Andreas Rheinhardt
avcodec/codec_desc: Mark MLP as not being intra-only
It has sync frames.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f09fd1c6c70505916…
---
libavcodec/codec_desc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a06992fce8..d954f0a428 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2764,7 +2764,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.type = AVMEDIA_TYPE_AUDIO,
.name = "mlp",
.long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ .props = AV_CODEC_PROP_LOSSLESS,
},
{
.id = AV_CODEC_ID_GSM_MS,
1
0
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com> | Tue Sep 21 21:34:32 2021 +0200| [db25180e9d0fbb500459d997a05f5752768f604d] | committer: Andreas Rheinhardt
avcodec/mlpenc: Set AV_PKT_FLAG_KEY manually
TrueHD/MLP is one of the audio formats with keyframes. Currently,
the generic encoding code just sets the keyframe flag for all
returned packets, yet this is wrong for these encoders and will
be changed in a future commit. So set the flag here for those
packets that ought to have it.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt(a)outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db25180e9d0fbb500…
---
libavcodec/mlpenc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index b2b3297669..1cb02f22a9 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -2114,6 +2114,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
restart_frame = !ctx->frame_index;
if (restart_frame) {
+ avpkt->flags |= AV_PKT_FLAG_KEY;
set_major_params(ctx);
if (ctx->min_restart_interval != ctx->max_restart_interval)
process_major_frame(ctx);
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Tue Sep 28 00:34:40 2021 +0200| [71f2a9a2e53fa0cd9707bc35ce4d56459aad61b7] | committer: Paul B Mahol
avfilter/vf_remap: remove timeline support
It is not supported, as it is possible to change frame video width
and height and that can lead to undefined output.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71f2a9a2e53fa0cd9…
---
libavfilter/vf_remap.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c
index d372ac1d7d..ec925e8948 100644
--- a/libavfilter/vf_remap.c
+++ b/libavfilter/vf_remap.c
@@ -283,11 +283,7 @@ static int process_frame(FFFrameSync *fs)
(ret = ff_framesync_get_frame(&s->fs, 2, &ypic, 0)) < 0)
return ret;
- if (ctx->is_disabled) {
- out = av_frame_clone(in);
- if (!out)
- return AVERROR(ENOMEM);
- } else {
+ {
ThreadData td;
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
@@ -407,5 +403,5 @@ const AVFilter ff_vf_remap = {
FILTER_INPUTS(remap_inputs),
FILTER_OUTPUTS(remap_outputs),
.priv_class = &remap_class,
- .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
+ .flags = AVFILTER_FLAG_SLICE_THREADS,
};
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Tue Sep 28 00:04:35 2021 +0200| [94e805235bff7e224f0276fdcdeb517b8541fa18] | committer: Paul B Mahol
avfilter/vf_blend: add 14bit pixel format support
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94e805235bff7e224…
---
libavfilter/vf_blend.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index e4569a255e..43595a1363 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -48,6 +48,10 @@
#define DEPTH 12
#include "blend_modes.c"
+#undef DEPTH
+#define DEPTH 14
+#include "blend_modes.c"
+
#undef DEPTH
#define DEPTH 16
#include "blend_modes.c"
@@ -331,6 +335,7 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12,
AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12,
AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GRAY12,
+ AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_GBRP14,
AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16,
AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP16, AV_PIX_FMT_GRAY16,
@@ -397,6 +402,7 @@ DEFINE_INIT_BLEND_FUNC(8, 8)
DEFINE_INIT_BLEND_FUNC(9, 16)
DEFINE_INIT_BLEND_FUNC(10, 16)
DEFINE_INIT_BLEND_FUNC(12, 16)
+DEFINE_INIT_BLEND_FUNC(14, 16)
DEFINE_INIT_BLEND_FUNC(16, 16)
DEFINE_INIT_BLEND_FUNC(32, 32)
@@ -415,6 +421,9 @@ void ff_blend_init(FilterParams *param, int depth)
case 12:
init_blend_func_12_16bit(param);
break;
+ case 14:
+ init_blend_func_14_16bit(param);
+ break;
case 16:
init_blend_func_16_16bit(param);
break;
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Mon Sep 27 20:38:26 2021 +0200| [dd190195007093da57959c68c740e729e1048c24] | committer: Paul B Mahol
avfilter/vf_blend: refactor blend modes
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd190195007093da5…
---
libavfilter/blend_modes.c | 142 +++++++++++++++++++++
libavfilter/vf_blend.c | 311 ++++------------------------------------------
2 files changed, 165 insertions(+), 288 deletions(-)
diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c
new file mode 100644
index 0000000000..d75560185c
--- /dev/null
+++ b/libavfilter/blend_modes.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/intfloat.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+#include "blend.h"
+
+#undef PIXEL
+#undef MAX
+#undef HALF
+#undef CLIP
+
+#if DEPTH == 8
+#define PIXEL uint8_t
+#define MAX 255
+#define HALF 128
+#define CLIP(x) (av_clip_uint8(x))
+#elif DEPTH == 32
+#define PIXEL float
+#define MAX 1.f
+#define HALF 0.5f
+#define CLIP(x) (x)
+#else
+#define PIXEL uint16_t
+#define MAX ((1 << DEPTH) - 1)
+#define HALF (1 << (DEPTH - 1))
+#define CLIP(x) ((int)av_clip_uintp2(x, DEPTH))
+#endif
+
+#undef MULTIPLY
+#undef SCREEN
+#undef BURN
+#undef DODGE
+#undef INT2FLOAT
+#undef FLOAT2INT
+#undef MDIV
+
+#if DEPTH < 32
+#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / MAX))
+#define SCREEN(x, a, b) (MAX - (x) * ((MAX - (a)) * (MAX - (b)) / MAX))
+#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, MAX - ((MAX - (b)) << DEPTH) / (a)))
+#define DODGE(a, b) (((a) == MAX) ? (a) : FFMIN(MAX, (((b) << DEPTH) / (MAX - (a)))))
+#define INT2FLOAT(x) (x)
+#define FLOAT2INT(x) (x)
+#define MDIV (0.125f * (1 << DEPTH))
+#else
+#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 1.0))
+#define SCREEN(x, a, b) (1.0 - (x) * ((1.0 - (a)) * (1.0 - (b)) / 1.0))
+#define BURN(a, b) (((a) <= 0.0) ? (a) : FFMAX(0.0, 1.0 - (1.0 - (b)) / (a)))
+#define DODGE(a, b) (((a) >= 1.0) ? (a) : FFMIN(1.0, ((b) / (1.0 - (a)))))
+#define INT2FLOAT(x) av_int2float(x)
+#define FLOAT2INT(x) av_float2int(x)
+#define MDIV 0.125f
+#endif
+
+#define A top[j]
+#define B bottom[j]
+
+#define fn2(a, b) blend_##a##_##b##bit
+#define fn1(name, depth) fn2(name, depth)
+#define fn0(name) fn1(name, DEPTH)
+
+#define fn(NAME, EXPR) \
+static void fn0(NAME)(const uint8_t *_top, ptrdiff_t top_linesize, \
+ const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
+ uint8_t *_dst, ptrdiff_t dst_linesize, \
+ ptrdiff_t width, ptrdiff_t height, \
+ FilterParams *param, double *values, int starty) \
+{ \
+ const PIXEL *top = (PIXEL *)_top; \
+ const PIXEL *bottom = (PIXEL *)_bottom; \
+ PIXEL *dst = (PIXEL *)_dst; \
+ const float opacity = param->opacity; \
+ \
+ dst_linesize /= sizeof(PIXEL); \
+ top_linesize /= sizeof(PIXEL); \
+ bottom_linesize /= sizeof(PIXEL); \
+ \
+ for (int i = 0; i < height; i++) { \
+ for (int j = 0; j < width; j++) { \
+ dst[j] = top[j] + ((EXPR)-top[j]) * opacity; \
+ } \
+ dst += dst_linesize; \
+ top += top_linesize; \
+ bottom += bottom_linesize; \
+ } \
+}
+
+fn(addition, FFMIN(MAX, A + B))
+fn(grainmerge, CLIP(A + B - HALF))
+fn(average, (A + B) / 2)
+fn(subtract, FFMAX(0, A - B))
+fn(multiply, MULTIPLY(1, A, B))
+fn(multiply128,CLIP((A - HALF) * B / MDIV + HALF))
+fn(negation, MAX - FFABS(MAX - A - B))
+fn(extremity, FFABS(MAX - A - B))
+fn(difference, FFABS(A - B))
+fn(grainextract, CLIP(HALF + A - B))
+fn(screen, SCREEN(1, A, B))
+fn(overlay, (A < HALF) ? MULTIPLY(2, A, B) : SCREEN(2, A, B))
+fn(hardlight, (B < HALF) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
+fn(hardmix, (A < (MAX - B)) ? 0: MAX)
+fn(heat, (A == 0) ? 0 : MAX - FFMIN(((MAX - B) * (MAX - B)) / A, MAX))
+fn(freeze, (B == 0) ? 0 : MAX - FFMIN(((MAX - A) * (MAX - A)) / B, MAX))
+fn(darken, FFMIN(A, B))
+fn(lighten, FFMAX(A, B))
+fn(divide, CLIP(B == 0 ? MAX : MAX * A / B))
+fn(dodge, DODGE(A, B))
+fn(burn, BURN(A, B))
+fn(softlight, CLIP(A * A / MAX + (2 * (B * ((A * (MAX - A)) / MAX) / MAX))))
+fn(exclusion, A + B - 2 * A * B / MAX)
+fn(pinlight, (B < HALF) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - HALF)))
+fn(phoenix, FFMIN(A, B) - FFMAX(A, B) + MAX)
+fn(reflect, (B == MAX) ? B : FFMIN(MAX, (A * A / (MAX - B))))
+fn(glow, (A == MAX) ? A : FFMIN(MAX, (B * B / (MAX - A))))
+fn(and, INT2FLOAT(FLOAT2INT(A) & FLOAT2INT(B)))
+fn(or, INT2FLOAT(FLOAT2INT(A) | FLOAT2INT(B)))
+fn(xor, INT2FLOAT(FLOAT2INT(A) ^ FLOAT2INT(B)))
+fn(vividlight, (A < HALF) ? BURN(2 * A, B) : DODGE(2 * (A - HALF), B))
+fn(linearlight,CLIP((B < HALF) ? B + 2 * A - MAX : B + 2 * (A - HALF)))
+fn(softdifference,CLIP((A > B) ? (B == MAX) ? 0 : (A - B) * MAX / (MAX - B) : (B == 0) ? 0 : (B - A) * MAX / B))
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 23cd22ff6f..e4569a255e 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -33,6 +33,29 @@
#define TOP 0
#define BOTTOM 1
+#define DEPTH 8
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 9
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 10
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 12
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 16
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 32
+#include "blend_modes.c"
+
typedef struct BlendContext {
const AVClass *class;
FFFrameSync fs;
@@ -172,294 +195,6 @@ BLEND_NORMAL(8bit, uint8_t)
BLEND_NORMAL(16bit, uint16_t)
BLEND_NORMAL(32bit, float)
-#define DEFINE_BLEND(name, expr, depth, type) \
-static void blend_## name##_##depth##bit(const uint8_t *_top, ptrdiff_t top_linesize, \
- const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
- uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- const type *top = (type*)_top; \
- const type *bottom = (type*)_bottom; \
- type *dst = (type*)_dst; \
- const float opacity = param->opacity; \
- \
- dst_linesize /= sizeof(type); \
- top_linesize /= sizeof(type); \
- bottom_linesize /= sizeof(type); \
- \
- for (int i = 0; i < height; i++) { \
- for (int j = 0; j < width; j++) { \
- dst[j] = top[j] + ((expr) - top[j]) * opacity; \
- } \
- dst += dst_linesize; \
- top += top_linesize; \
- bottom += bottom_linesize; \
- } \
-}
-
-#define A top[j]
-#define B bottom[j]
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 255))
-#define SCREEN(x, a, b) (255 - (x) * ((255 - (a)) * (255 - (b)) / 255))
-#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 255 - ((255 - (b)) << 8) / (a)))
-#define DODGE(a, b) (((a) == 255) ? (a) : FFMIN(255, (((b) << 8) / (255 - (a)))))
-
-DEFINE_BLEND(addition, FFMIN(255, A + B), 8, uint8_t)
-DEFINE_BLEND(grainmerge, av_clip_uint8(A + B - 128), 8, uint8_t)
-DEFINE_BLEND(average, (A + B) / 2, 8, uint8_t)
-DEFINE_BLEND(subtract, FFMAX(0, A - B), 8, uint8_t)
-DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 8, uint8_t)
-DEFINE_BLEND(multiply128,av_clip_uint8((A - 128) * B / 32. + 128), 8, uint8_t)
-DEFINE_BLEND(negation, 255 - FFABS(255 - A - B), 8, uint8_t)
-DEFINE_BLEND(extremity, FFABS(255 - A - B), 8, uint8_t)
-DEFINE_BLEND(difference, FFABS(A - B), 8, uint8_t)
-DEFINE_BLEND(grainextract, av_clip_uint8(128 + A - B), 8, uint8_t)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 8, uint8_t)
-DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 8, uint8_t)
-DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 8, uint8_t)
-DEFINE_BLEND(hardmix, (A < (255 - B)) ? 0: 255, 8, uint8_t)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 255 - FFMIN(((255 - B) * (255 - B)) / A, 255), 8, uint8_t)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 255 - FFMIN(((255 - A) * (255 - A)) / B, 255), 8, uint8_t)
-DEFINE_BLEND(darken, FFMIN(A, B), 8, uint8_t)
-DEFINE_BLEND(lighten, FFMAX(A, B), 8, uint8_t)
-DEFINE_BLEND(divide, av_clip_uint8(B == 0 ? 255 : 255 * A / B), 8, uint8_t)
-DEFINE_BLEND(dodge, DODGE(A, B), 8, uint8_t)
-DEFINE_BLEND(burn, BURN(A, B), 8, uint8_t)
-DEFINE_BLEND(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - fabs(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - fabs(B - 127.5)/255), 8, uint8_t)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 255, 8, uint8_t)
-DEFINE_BLEND(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128)), 8, uint8_t)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255, 8, uint8_t)
-DEFINE_BLEND(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B))), 8, uint8_t)
-DEFINE_BLEND(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A))), 8, uint8_t)
-DEFINE_BLEND(and, A & B, 8, uint8_t)
-DEFINE_BLEND(or, A | B, 8, uint8_t)
-DEFINE_BLEND(xor, A ^ B, 8, uint8_t)
-DEFINE_BLEND(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B), 8, uint8_t)
-DEFINE_BLEND(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128)), 8, uint8_t)
-DEFINE_BLEND(softdifference,av_clip_uint8((A > B) ? (B == 255) ? 0 : (A - B) * 255 / (255 - B) : (B == 0) ? 0 : (B - A) * 255 / B), 8, uint8_t)
-
-#undef MULTIPLY
-#undef SCREEN
-#undef BURN
-#undef DODGE
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 65535))
-#define SCREEN(x, a, b) (65535 - (x) * ((65535 - (a)) * (65535 - (b)) / 65535))
-#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 65535 - ((65535 - (b)) << 16) / (a)))
-#define DODGE(a, b) (((a) == 65535) ? (a) : FFMIN(65535, (((b) << 16) / (65535 - (a)))))
-
-DEFINE_BLEND(addition, FFMIN(65535, A + B), 16, uint16_t)
-DEFINE_BLEND(grainmerge, av_clip_uint16(A + B - 32768), 16, uint16_t)
-DEFINE_BLEND(average, (A + B) / 2, 16, uint16_t)
-DEFINE_BLEND(subtract, FFMAX(0, A - B), 16, uint16_t)
-DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 16, uint16_t)
-DEFINE_BLEND(multiply128, av_clip_uint16((A - 32768) * B / 8192. + 32768), 16, uint16_t)
-DEFINE_BLEND(negation, 65535 - FFABS(65535 - A - B), 16, uint16_t)
-DEFINE_BLEND(extremity, FFABS(65535 - A - B), 16, uint16_t)
-DEFINE_BLEND(difference, FFABS(A - B), 16, uint16_t)
-DEFINE_BLEND(grainextract, av_clip_uint16(32768 + A - B), 16, uint16_t)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 16, uint16_t)
-DEFINE_BLEND(overlay, (A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 16, uint16_t)
-DEFINE_BLEND(hardlight, (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 16, uint16_t)
-DEFINE_BLEND(hardmix, (A < (65535 - B)) ? 0: 65535, 16, uint16_t)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 65535 - FFMIN(((65535 - B) * (65535 - B)) / A, 65535), 16, uint16_t)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 65535 - FFMIN(((65535 - A) * (65535 - A)) / B, 65535), 16, uint16_t)
-DEFINE_BLEND(darken, FFMIN(A, B), 16, uint16_t)
-DEFINE_BLEND(lighten, FFMAX(A, B), 16, uint16_t)
-DEFINE_BLEND(divide, av_clip_uint16(B == 0 ? 65535 : 65535 * A / B), 16, uint16_t)
-DEFINE_BLEND(dodge, DODGE(A, B), 16, uint16_t)
-DEFINE_BLEND(burn, BURN(A, B), 16, uint16_t)
-DEFINE_BLEND(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - fabs(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - fabs(B - 32767.5)/65535), 16, uint16_t)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 65535, 16, uint16_t)
-DEFINE_BLEND(pinlight, (B < 32768) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 32768)), 16, uint16_t)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 65535, 16, uint16_t)
-DEFINE_BLEND(reflect, (B == 65535) ? B : FFMIN(65535, (A * A / (65535 - B))), 16, uint16_t)
-DEFINE_BLEND(glow, (A == 65535) ? A : FFMIN(65535, (B * B / (65535 - A))), 16, uint16_t)
-DEFINE_BLEND(and, A & B, 16, uint16_t)
-DEFINE_BLEND(or, A | B, 16, uint16_t)
-DEFINE_BLEND(xor, A ^ B, 16, uint16_t)
-DEFINE_BLEND(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 32768), B), 16, uint16_t)
-DEFINE_BLEND(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B + 2 * (A - 32768)), 16, uint16_t)
-DEFINE_BLEND(softdifference,av_clip_uint16((A > B) ? (B == 65535) ? 0 : (A - B) * 65535 / (65535 - B) : (B == 0) ? 0 : (B - A) * 65535 / B), 16, uint16_t)
-
-#undef MULTIPLY
-#undef SCREEN
-#undef BURN
-#undef DODGE
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 1023))
-#define SCREEN(x, a, b) (1023 - (x) * ((1023 - (a)) * (1023 - (b)) / 1023))
-#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 1023 - ((1023 - (b)) << 10) / (a)))
-#define DODGE(a, b) (((a) == 1023) ? (a) : FFMIN(1023, (((b) << 10) / (1023 - (a)))))
-
-DEFINE_BLEND(addition, FFMIN(1023, A + B), 10, uint16_t)
-DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 512, 10), 10, uint16_t)
-DEFINE_BLEND(average, (A + B) / 2, 10, uint16_t)
-DEFINE_BLEND(subtract, FFMAX(0, A - B), 10, uint16_t)
-DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 10, uint16_t)
-DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 512) * B / 128. + 512, 10), 10, uint16_t)
-DEFINE_BLEND(negation, 1023 - FFABS(1023 - A - B), 10, uint16_t)
-DEFINE_BLEND(extremity, FFABS(1023 - A - B), 10, uint16_t)
-DEFINE_BLEND(difference, FFABS(A - B), 10, uint16_t)
-DEFINE_BLEND(grainextract, (int)av_clip_uintp2(512 + A - B, 10), 10, uint16_t)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 10, uint16_t)
-DEFINE_BLEND(overlay, (A < 512) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 10, uint16_t)
-DEFINE_BLEND(hardlight, (B < 512) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 10, uint16_t)
-DEFINE_BLEND(hardmix, (A < (1023 - B)) ? 0: 1023, 10, uint16_t)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 1023 - FFMIN(((1023 - B) * (1023 - B)) / A, 1023), 10, uint16_t)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 1023 - FFMIN(((1023 - A) * (1023 - A)) / B, 1023), 10, uint16_t)
-DEFINE_BLEND(darken, FFMIN(A, B), 10, uint16_t)
-DEFINE_BLEND(lighten, FFMAX(A, B), 10, uint16_t)
-DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 1023 : 1023 * A / B, 10), 10, uint16_t)
-DEFINE_BLEND(dodge, DODGE(A, B), 10, uint16_t)
-DEFINE_BLEND(burn, BURN(A, B), 10, uint16_t)
-DEFINE_BLEND(softlight, (A > 511) ? B + (1023 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 1023): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/1023), 10, uint16_t)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 1023, 10, uint16_t)
-DEFINE_BLEND(pinlight, (B < 512) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 512)), 10, uint16_t)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1023, 10, uint16_t)
-DEFINE_BLEND(reflect, (B == 1023) ? B : FFMIN(1023, (A * A / (1023 - B))), 10, uint16_t)
-DEFINE_BLEND(glow, (A == 1023) ? A : FFMIN(1023, (B * B / (1023 - A))), 10, uint16_t)
-DEFINE_BLEND(and, A & B, 10, uint16_t)
-DEFINE_BLEND(or, A | B, 10, uint16_t)
-DEFINE_BLEND(xor, A ^ B, 10, uint16_t)
-DEFINE_BLEND(vividlight, (A < 512) ? BURN(2 * A, B) : DODGE(2 * (A - 512), B), 10, uint16_t)
-DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 512), 10), 10, uint16_t)
-DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (B == 1023) ? 0 : (A - B) * 1023 / (1023 - B) : (B == 0) ? 0 : (B - A) * 1023 / B, 10), 10, uint16_t)
-
-#undef MULTIPLY
-#undef SCREEN
-#undef BURN
-#undef DODGE
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 4095))
-#define SCREEN(x, a, b) (4095 - (x) * ((4095 - (a)) * (4095 - (b)) / 4095))
-#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 4095 - ((4095 - (b)) << 12) / (a)))
-#define DODGE(a, b) (((a) == 4095) ? (a) : FFMIN(4095, (((b) << 12) / (4095 - (a)))))
-
-DEFINE_BLEND(addition, FFMIN(4095, A + B), 12, uint16_t)
-DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 2048, 12), 12, uint16_t)
-DEFINE_BLEND(average, (A + B) / 2, 12, uint16_t)
-DEFINE_BLEND(subtract, FFMAX(0, A - B), 12, uint16_t)
-DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 12, uint16_t)
-DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 2048) * B / 512. + 2048, 12), 12, uint16_t)
-DEFINE_BLEND(negation, 4095 - FFABS(4095 - A - B), 12, uint16_t)
-DEFINE_BLEND(extremity, FFABS(4095 - A - B), 12, uint16_t)
-DEFINE_BLEND(difference, FFABS(A - B), 12, uint16_t)
-DEFINE_BLEND(grainextract, (int)av_clip_uintp2(2048 + A - B, 12), 12, uint16_t)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 12, uint16_t)
-DEFINE_BLEND(overlay, (A < 2048) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 12, uint16_t)
-DEFINE_BLEND(hardlight, (B < 2048) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 12, uint16_t)
-DEFINE_BLEND(hardmix, (A < (4095 - B)) ? 0: 4095, 12, uint16_t)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 4095 - FFMIN(((4095 - B) * (4095 - B)) / A, 4095), 12, uint16_t)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 4095 - FFMIN(((4095 - A) * (4095 - A)) / B, 4095), 12, uint16_t)
-DEFINE_BLEND(darken, FFMIN(A, B), 12, uint16_t)
-DEFINE_BLEND(lighten, FFMAX(A, B), 12, uint16_t)
-DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 4095 : 4095 * A / B, 12), 12, uint16_t)
-DEFINE_BLEND(dodge, DODGE(A, B), 12, uint16_t)
-DEFINE_BLEND(burn, BURN(A, B), 12, uint16_t)
-DEFINE_BLEND(softlight, (A > 2047) ? B + (4095 - B) * (A - 2047.5) / 2047.5 * (0.5 - fabs(B - 2047.5) / 4095): B - B * ((2047.5 - A) / 2047.5) * (0.5 - fabs(B - 2047.5)/4095), 12, uint16_t)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 4095, 12, uint16_t)
-DEFINE_BLEND(pinlight, (B < 2048) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 2048)), 12, uint16_t)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 4095, 12, uint16_t)
-DEFINE_BLEND(reflect, (B == 4095) ? B : FFMIN(4095, (A * A / (4095 - B))), 12, uint16_t)
-DEFINE_BLEND(glow, (A == 4095) ? A : FFMIN(4095, (B * B / (4095 - A))), 12, uint16_t)
-DEFINE_BLEND(and, A & B, 12, uint16_t)
-DEFINE_BLEND(or, A | B, 12, uint16_t)
-DEFINE_BLEND(xor, A ^ B, 12, uint16_t)
-DEFINE_BLEND(vividlight, (A < 2048) ? BURN(2 * A, B) : DODGE(2 * (A - 2048), B), 12, uint16_t)
-DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 2048) ? B + 2 * A - 4095 : B + 2 * (A - 2048), 12), 12, uint16_t)
-DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (B == 4095) ? 0 : (A - B) * 4095 / (4095 - B) : (B == 0) ? 0 : (B - A) * 4095 / B, 12), 12, uint16_t)
-
-#undef MULTIPLY
-#undef SCREEN
-#undef BURN
-#undef DODGE
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 511))
-#define SCREEN(x, a, b) (511 - (x) * ((511 - (a)) * (511 - (b)) / 511))
-#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 511 - ((511 - (b)) << 9) / (a)))
-#define DODGE(a, b) (((a) == 511) ? (a) : FFMIN(511, (((b) << 9) / (511 - (a)))))
-
-DEFINE_BLEND(addition, FFMIN(511, A + B), 9, uint16_t)
-DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 256, 9), 9, uint16_t)
-DEFINE_BLEND(average, (A + B) / 2, 9, uint16_t)
-DEFINE_BLEND(subtract, FFMAX(0, A - B), 9, uint16_t)
-DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 9, uint16_t)
-DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 256) * B / 64. + 256, 9), 9, uint16_t)
-DEFINE_BLEND(negation, 511 - FFABS(511 - A - B), 9, uint16_t)
-DEFINE_BLEND(extremity, FFABS(511 - A - B), 9, uint16_t)
-DEFINE_BLEND(difference, FFABS(A - B), 9, uint16_t)
-DEFINE_BLEND(grainextract, (int)av_clip_uintp2(256 + A - B, 9), 9, uint16_t)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 9, uint16_t)
-DEFINE_BLEND(overlay, (A < 256) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 9, uint16_t)
-DEFINE_BLEND(hardlight, (B < 256) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 9, uint16_t)
-DEFINE_BLEND(hardmix, (A < (511 - B)) ? 0: 511, 9, uint16_t)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 511 - FFMIN(((511 - B) * (511 - B)) / A, 511), 9, uint16_t)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 511 - FFMIN(((511 - A) * (511 - A)) / B, 511), 9, uint16_t)
-DEFINE_BLEND(darken, FFMIN(A, B), 9, uint16_t)
-DEFINE_BLEND(lighten, FFMAX(A, B), 9, uint16_t)
-DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 511 : 511 * A / B, 9), 9, uint16_t)
-DEFINE_BLEND(dodge, DODGE(A, B), 9, uint16_t)
-DEFINE_BLEND(burn, BURN(A, B), 9, uint16_t)
-DEFINE_BLEND(softlight, (A > 511) ? B + (511 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 511): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/511), 9, uint16_t)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 511, 9, uint16_t)
-DEFINE_BLEND(pinlight, (B < 256) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 256)), 9, uint16_t)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 511, 9, uint16_t)
-DEFINE_BLEND(reflect, (B == 511) ? B : FFMIN(511, (A * A / (511 - B))), 9, uint16_t)
-DEFINE_BLEND(glow, (A == 511) ? A : FFMIN(511, (B * B / (511 - A))), 9, uint16_t)
-DEFINE_BLEND(and, A & B, 9, uint16_t)
-DEFINE_BLEND(or, A | B, 9, uint16_t)
-DEFINE_BLEND(xor, A ^ B, 9, uint16_t)
-DEFINE_BLEND(vividlight, (A < 256) ? BURN(2 * A, B) : DODGE(2 * (A - 256), B), 9, uint16_t)
-DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 256) ? B + 2 * A - 511 : B + 2 * (A - 256), 9), 9, uint16_t)
-DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (A - B) * 511 / (511 - B) : (B == 0) ? 0 : (B - A) * 511 / B, 9), 9, uint16_t)
-
-#undef MULTIPLY
-#undef SCREEN
-#undef BURN
-#undef DODGE
-
-#define MULTIPLY(x, a, b) ((x) * (((a) * (b)) / 1.0))
-#define SCREEN(x, a, b) (1.0 - (x) * ((1.0 - (a)) * (1.0 - (b)) / 1.0))
-#define BURN(a, b) (((a) <= 0.0) ? (a) : FFMAX(0.0, 1.0 - (1.0 - (b)) / (a)))
-#define DODGE(a, b) (((a) >= 1.0) ? (a) : FFMIN(1.0, ((b) / (1.0 - (a)))))
-
-DEFINE_BLEND(addition, A + B, 32, float)
-DEFINE_BLEND(grainmerge, A + B - 0.5, 32, float)
-DEFINE_BLEND(average, (A + B) / 2, 32, float)
-DEFINE_BLEND(subtract, A - B, 32, float)
-DEFINE_BLEND(multiply, A * B, 32, float)
-DEFINE_BLEND(multiply128, (A - 0.5) * B / 0.125 + 0.5, 32, float)
-DEFINE_BLEND(negation, 1.0 - FFABS(1.0 - A - B), 32, float)
-DEFINE_BLEND(extremity, FFABS(1.0 - A - B), 32, float)
-DEFINE_BLEND(difference, FFABS(A - B), 32, float)
-DEFINE_BLEND(grainextract, 0.5 + A - B, 32, float)
-DEFINE_BLEND(screen, SCREEN(1, A, B), 32, float)
-DEFINE_BLEND(overlay, (A < 0.5) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 32, float)
-DEFINE_BLEND(hardlight, (B < 0.5) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 32, float)
-DEFINE_BLEND(hardmix, (A < (1.0 - B)) ? 0: 1.0, 32, float)
-DEFINE_BLEND(heat, (A == 0) ? 0 : 1.0 - FFMIN(((1.0 - B) * (1.0 - B)) / A, 1.0), 32, float)
-DEFINE_BLEND(freeze, (B == 0) ? 0 : 1.0 - FFMIN(((1.0 - A) * (1.0 - A)) / B, 1.0), 32, float)
-DEFINE_BLEND(darken, FFMIN(A, B), 32, float)
-DEFINE_BLEND(lighten, FFMAX(A, B), 32, float)
-DEFINE_BLEND(divide, B == 0 ? 1.0 : 1.0 * A / B, 32, float)
-DEFINE_BLEND(dodge, DODGE(A, B), 32, float)
-DEFINE_BLEND(burn, BURN(A, B), 32, float)
-DEFINE_BLEND(softlight, (A > 0.5) ? B + (1.0 - B) * (A - 0.5) / 0.5 * (0.5 - fabs(B - 0.5) / 1.0): B - B * ((0.5 - A) / 0.5) * (0.5 - fabs(B - 0.5)/1.0), 32, float)
-DEFINE_BLEND(exclusion, A + B - 2 * A * B / 1.0, 32, float)
-DEFINE_BLEND(pinlight, (B < 0.5) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 0.5)), 32, float)
-DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1.0, 32, float)
-DEFINE_BLEND(reflect, (B == 1.0) ? B : FFMIN(1.0, (A * A / (1.0 - B))), 32, float)
-DEFINE_BLEND(glow, (A == 1.0) ? A : FFMIN(1.0, (B * B / (1.0 - A))), 32, float)
-DEFINE_BLEND(and, av_int2float(av_float2int(A) & av_float2int(B)), 32, float)
-DEFINE_BLEND(or, av_int2float(av_float2int(A) | av_float2int(B)), 32, float)
-DEFINE_BLEND(xor, av_int2float(av_float2int(A) ^ av_float2int(B)), 32, float)
-DEFINE_BLEND(vividlight, (A < 0.5) ? BURN(2 * A, B) : DODGE(2 * (A - 0.5), B), 32, float)
-DEFINE_BLEND(linearlight,(B < 0.5) ? B + 2 * A - 1.0 : B + 2 * (A - 0.5), 32, float)
-DEFINE_BLEND(softdifference, (A > B) ? (B == 1.f) ? 0.f : (A - B) / (1.f - B) : (B == 0.f) ? 0.f : (B - A) / B, 32, float)
-
#define DEFINE_BLEND_EXPR(type, name, div) \
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Mon Sep 27 19:39:14 2021 +0200| [524407af0c3993a36fb8399e5ba7fa07b731b57c] | committer: Paul B Mahol
avfilter/vf_blend: add gray9 pixel format support
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=524407af0c3993a36…
---
libavfilter/vf_blend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index c9c23ef7fb..23cd22ff6f 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -589,7 +589,7 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8,
AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9,
- AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_GBRP9,
+ AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GRAY9,
AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV440P10,
AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GRAY10,
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Mon Sep 27 19:35:46 2021 +0200| [63b850c6046554b9a2ef5d73162e3841f3695e9f] | committer: Paul B Mahol
avfilter/vf_blend: refactor blend macros
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=63b850c6046554b9a…
---
libavfilter/vf_blend.c | 490 ++++++++++++++++++++++---------------------------
1 file changed, 222 insertions(+), 268 deletions(-)
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index db315fa86f..c9c23ef7fb 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -172,76 +172,30 @@ BLEND_NORMAL(8bit, uint8_t)
BLEND_NORMAL(16bit, uint16_t)
BLEND_NORMAL(32bit, float)
-#define DEFINE_BLEND8(name, expr) \
-static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize, \
- const uint8_t *bottom, ptrdiff_t bottom_linesize, \
- uint8_t *dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- const float opacity = param->opacity; \
- int i, j; \
- \
- for (i = 0; i < height; i++) { \
- for (j = 0; j < width; j++) { \
- dst[j] = top[j] + ((expr) - top[j]) * opacity; \
- } \
- dst += dst_linesize; \
- top += top_linesize; \
- bottom += bottom_linesize; \
- } \
-}
-
-#define DEFINE_BLEND16(name, expr, depth) \
-static void blend_## name##_##depth##bit(const uint8_t *_top, ptrdiff_t top_linesize,\
- const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
- uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- const uint16_t *top = (const uint16_t*)_top; \
- const uint16_t *bottom = (const uint16_t*)_bottom; \
- uint16_t *dst = (uint16_t*)_dst; \
- const float opacity = param->opacity; \
- int i, j; \
- dst_linesize /= 2; \
- top_linesize /= 2; \
- bottom_linesize /= 2; \
- \
- for (i = 0; i < height; i++) { \
- for (j = 0; j < width; j++) { \
- dst[j] = top[j] + ((expr) - top[j]) * opacity; \
- } \
- dst += dst_linesize; \
- top += top_linesize; \
- bottom += bottom_linesize; \
- } \
-}
-
-#define DEFINE_BLEND32(name, expr, depth) \
-static void blend_## name##_##depth##bit(const uint8_t *_top, ptrdiff_t top_linesize,\
- const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
- uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- const float *top = (const float*)_top; \
- const float *bottom = (const float*)_bottom; \
- float *dst = (float*)_dst; \
- const float opacity = param->opacity; \
- int i, j; \
- dst_linesize /= 4; \
- top_linesize /= 4; \
- bottom_linesize /= 4; \
- \
- for (i = 0; i < height; i++) { \
- for (j = 0; j < width; j++) { \
- dst[j] = top[j] + ((expr) - top[j]) * opacity; \
- } \
- dst += dst_linesize; \
- top += top_linesize; \
- bottom += bottom_linesize; \
- } \
+#define DEFINE_BLEND(name, expr, depth, type) \
+static void blend_## name##_##depth##bit(const uint8_t *_top, ptrdiff_t top_linesize, \
+ const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
+ uint8_t *_dst, ptrdiff_t dst_linesize, \
+ ptrdiff_t width, ptrdiff_t height, \
+ FilterParams *param, double *values, int starty) \
+{ \
+ const type *top = (type*)_top; \
+ const type *bottom = (type*)_bottom; \
+ type *dst = (type*)_dst; \
+ const float opacity = param->opacity; \
+ \
+ dst_linesize /= sizeof(type); \
+ top_linesize /= sizeof(type); \
+ bottom_linesize /= sizeof(type); \
+ \
+ for (int i = 0; i < height; i++) { \
+ for (int j = 0; j < width; j++) { \
+ dst[j] = top[j] + ((expr) - top[j]) * opacity; \
+ } \
+ dst += dst_linesize; \
+ top += top_linesize; \
+ bottom += bottom_linesize; \
+ } \
}
#define A top[j]
@@ -252,39 +206,39 @@ static void blend_## name##_##depth##bit(const uint8_t *_top, ptrdiff_t top_line
#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 255 - ((255 - (b)) << 8) / (a)))
#define DODGE(a, b) (((a) == 255) ? (a) : FFMIN(255, (((b) << 8) / (255 - (a)))))
-DEFINE_BLEND8(addition, FFMIN(255, A + B))
-DEFINE_BLEND8(grainmerge, av_clip_uint8(A + B - 128))
-DEFINE_BLEND8(average, (A + B) / 2)
-DEFINE_BLEND8(subtract, FFMAX(0, A - B))
-DEFINE_BLEND8(multiply, MULTIPLY(1, A, B))
-DEFINE_BLEND8(multiply128,av_clip_uint8((A - 128) * B / 32. + 128))
-DEFINE_BLEND8(negation, 255 - FFABS(255 - A - B))
-DEFINE_BLEND8(extremity, FFABS(255 - A - B))
-DEFINE_BLEND8(difference, FFABS(A - B))
-DEFINE_BLEND8(grainextract, av_clip_uint8(128 + A - B))
-DEFINE_BLEND8(screen, SCREEN(1, A, B))
-DEFINE_BLEND8(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B))
-DEFINE_BLEND8(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
-DEFINE_BLEND8(hardmix, (A < (255 - B)) ? 0: 255)
-DEFINE_BLEND8(heat, (A == 0) ? 0 : 255 - FFMIN(((255 - B) * (255 - B)) / A, 255))
-DEFINE_BLEND8(freeze, (B == 0) ? 0 : 255 - FFMIN(((255 - A) * (255 - A)) / B, 255))
-DEFINE_BLEND8(darken, FFMIN(A, B))
-DEFINE_BLEND8(lighten, FFMAX(A, B))
-DEFINE_BLEND8(divide, av_clip_uint8(B == 0 ? 255 : 255 * A / B))
-DEFINE_BLEND8(dodge, DODGE(A, B))
-DEFINE_BLEND8(burn, BURN(A, B))
-DEFINE_BLEND8(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - fabs(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - fabs(B - 127.5)/255))
-DEFINE_BLEND8(exclusion, A + B - 2 * A * B / 255)
-DEFINE_BLEND8(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128)))
-DEFINE_BLEND8(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255)
-DEFINE_BLEND8(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B))))
-DEFINE_BLEND8(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A))))
-DEFINE_BLEND8(and, A & B)
-DEFINE_BLEND8(or, A | B)
-DEFINE_BLEND8(xor, A ^ B)
-DEFINE_BLEND8(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B))
-DEFINE_BLEND8(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128)))
-DEFINE_BLEND8(softdifference,av_clip_uint8((A > B) ? (B == 255) ? 0 : (A - B) * 255 / (255 - B) : (B == 0) ? 0 : (B - A) * 255 / B))
+DEFINE_BLEND(addition, FFMIN(255, A + B), 8, uint8_t)
+DEFINE_BLEND(grainmerge, av_clip_uint8(A + B - 128), 8, uint8_t)
+DEFINE_BLEND(average, (A + B) / 2, 8, uint8_t)
+DEFINE_BLEND(subtract, FFMAX(0, A - B), 8, uint8_t)
+DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 8, uint8_t)
+DEFINE_BLEND(multiply128,av_clip_uint8((A - 128) * B / 32. + 128), 8, uint8_t)
+DEFINE_BLEND(negation, 255 - FFABS(255 - A - B), 8, uint8_t)
+DEFINE_BLEND(extremity, FFABS(255 - A - B), 8, uint8_t)
+DEFINE_BLEND(difference, FFABS(A - B), 8, uint8_t)
+DEFINE_BLEND(grainextract, av_clip_uint8(128 + A - B), 8, uint8_t)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 8, uint8_t)
+DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 8, uint8_t)
+DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 8, uint8_t)
+DEFINE_BLEND(hardmix, (A < (255 - B)) ? 0: 255, 8, uint8_t)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 255 - FFMIN(((255 - B) * (255 - B)) / A, 255), 8, uint8_t)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 255 - FFMIN(((255 - A) * (255 - A)) / B, 255), 8, uint8_t)
+DEFINE_BLEND(darken, FFMIN(A, B), 8, uint8_t)
+DEFINE_BLEND(lighten, FFMAX(A, B), 8, uint8_t)
+DEFINE_BLEND(divide, av_clip_uint8(B == 0 ? 255 : 255 * A / B), 8, uint8_t)
+DEFINE_BLEND(dodge, DODGE(A, B), 8, uint8_t)
+DEFINE_BLEND(burn, BURN(A, B), 8, uint8_t)
+DEFINE_BLEND(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - fabs(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - fabs(B - 127.5)/255), 8, uint8_t)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 255, 8, uint8_t)
+DEFINE_BLEND(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128)), 8, uint8_t)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255, 8, uint8_t)
+DEFINE_BLEND(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B))), 8, uint8_t)
+DEFINE_BLEND(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A))), 8, uint8_t)
+DEFINE_BLEND(and, A & B, 8, uint8_t)
+DEFINE_BLEND(or, A | B, 8, uint8_t)
+DEFINE_BLEND(xor, A ^ B, 8, uint8_t)
+DEFINE_BLEND(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B), 8, uint8_t)
+DEFINE_BLEND(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128)), 8, uint8_t)
+DEFINE_BLEND(softdifference,av_clip_uint8((A > B) ? (B == 255) ? 0 : (A - B) * 255 / (255 - B) : (B == 0) ? 0 : (B - A) * 255 / B), 8, uint8_t)
#undef MULTIPLY
#undef SCREEN
@@ -296,39 +250,39 @@ DEFINE_BLEND8(softdifference,av_clip_uint8((A > B) ? (B == 255) ? 0 : (A - B) *
#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 65535 - ((65535 - (b)) << 16) / (a)))
#define DODGE(a, b) (((a) == 65535) ? (a) : FFMIN(65535, (((b) << 16) / (65535 - (a)))))
-DEFINE_BLEND16(addition, FFMIN(65535, A + B), 16)
-DEFINE_BLEND16(grainmerge, av_clip_uint16(A + B - 32768), 16)
-DEFINE_BLEND16(average, (A + B) / 2, 16)
-DEFINE_BLEND16(subtract, FFMAX(0, A - B), 16)
-DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 16)
-DEFINE_BLEND16(multiply128, av_clip_uint16((A - 32768) * B / 8192. + 32768), 16)
-DEFINE_BLEND16(negation, 65535 - FFABS(65535 - A - B), 16)
-DEFINE_BLEND16(extremity, FFABS(65535 - A - B), 16)
-DEFINE_BLEND16(difference, FFABS(A - B), 16)
-DEFINE_BLEND16(grainextract, av_clip_uint16(32768 + A - B), 16)
-DEFINE_BLEND16(screen, SCREEN(1, A, B), 16)
-DEFINE_BLEND16(overlay, (A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 16)
-DEFINE_BLEND16(hardlight, (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 16)
-DEFINE_BLEND16(hardmix, (A < (65535 - B)) ? 0: 65535, 16)
-DEFINE_BLEND16(heat, (A == 0) ? 0 : 65535 - FFMIN(((65535 - B) * (65535 - B)) / A, 65535), 16)
-DEFINE_BLEND16(freeze, (B == 0) ? 0 : 65535 - FFMIN(((65535 - A) * (65535 - A)) / B, 65535), 16)
-DEFINE_BLEND16(darken, FFMIN(A, B), 16)
-DEFINE_BLEND16(lighten, FFMAX(A, B), 16)
-DEFINE_BLEND16(divide, av_clip_uint16(B == 0 ? 65535 : 65535 * A / B), 16)
-DEFINE_BLEND16(dodge, DODGE(A, B), 16)
-DEFINE_BLEND16(burn, BURN(A, B), 16)
-DEFINE_BLEND16(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - fabs(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - fabs(B - 32767.5)/65535), 16)
-DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 65535, 16)
-DEFINE_BLEND16(pinlight, (B < 32768) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 32768)), 16)
-DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 65535, 16)
-DEFINE_BLEND16(reflect, (B == 65535) ? B : FFMIN(65535, (A * A / (65535 - B))), 16)
-DEFINE_BLEND16(glow, (A == 65535) ? A : FFMIN(65535, (B * B / (65535 - A))), 16)
-DEFINE_BLEND16(and, A & B, 16)
-DEFINE_BLEND16(or, A | B, 16)
-DEFINE_BLEND16(xor, A ^ B, 16)
-DEFINE_BLEND16(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 32768), B), 16)
-DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B + 2 * (A - 32768)), 16)
-DEFINE_BLEND16(softdifference,av_clip_uint16((A > B) ? (B == 65535) ? 0 : (A - B) * 65535 / (65535 - B) : (B == 0) ? 0 : (B - A) * 65535 / B), 16)
+DEFINE_BLEND(addition, FFMIN(65535, A + B), 16, uint16_t)
+DEFINE_BLEND(grainmerge, av_clip_uint16(A + B - 32768), 16, uint16_t)
+DEFINE_BLEND(average, (A + B) / 2, 16, uint16_t)
+DEFINE_BLEND(subtract, FFMAX(0, A - B), 16, uint16_t)
+DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 16, uint16_t)
+DEFINE_BLEND(multiply128, av_clip_uint16((A - 32768) * B / 8192. + 32768), 16, uint16_t)
+DEFINE_BLEND(negation, 65535 - FFABS(65535 - A - B), 16, uint16_t)
+DEFINE_BLEND(extremity, FFABS(65535 - A - B), 16, uint16_t)
+DEFINE_BLEND(difference, FFABS(A - B), 16, uint16_t)
+DEFINE_BLEND(grainextract, av_clip_uint16(32768 + A - B), 16, uint16_t)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 16, uint16_t)
+DEFINE_BLEND(overlay, (A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 16, uint16_t)
+DEFINE_BLEND(hardlight, (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 16, uint16_t)
+DEFINE_BLEND(hardmix, (A < (65535 - B)) ? 0: 65535, 16, uint16_t)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 65535 - FFMIN(((65535 - B) * (65535 - B)) / A, 65535), 16, uint16_t)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 65535 - FFMIN(((65535 - A) * (65535 - A)) / B, 65535), 16, uint16_t)
+DEFINE_BLEND(darken, FFMIN(A, B), 16, uint16_t)
+DEFINE_BLEND(lighten, FFMAX(A, B), 16, uint16_t)
+DEFINE_BLEND(divide, av_clip_uint16(B == 0 ? 65535 : 65535 * A / B), 16, uint16_t)
+DEFINE_BLEND(dodge, DODGE(A, B), 16, uint16_t)
+DEFINE_BLEND(burn, BURN(A, B), 16, uint16_t)
+DEFINE_BLEND(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - fabs(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - fabs(B - 32767.5)/65535), 16, uint16_t)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 65535, 16, uint16_t)
+DEFINE_BLEND(pinlight, (B < 32768) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 32768)), 16, uint16_t)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 65535, 16, uint16_t)
+DEFINE_BLEND(reflect, (B == 65535) ? B : FFMIN(65535, (A * A / (65535 - B))), 16, uint16_t)
+DEFINE_BLEND(glow, (A == 65535) ? A : FFMIN(65535, (B * B / (65535 - A))), 16, uint16_t)
+DEFINE_BLEND(and, A & B, 16, uint16_t)
+DEFINE_BLEND(or, A | B, 16, uint16_t)
+DEFINE_BLEND(xor, A ^ B, 16, uint16_t)
+DEFINE_BLEND(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 32768), B), 16, uint16_t)
+DEFINE_BLEND(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B + 2 * (A - 32768)), 16, uint16_t)
+DEFINE_BLEND(softdifference,av_clip_uint16((A > B) ? (B == 65535) ? 0 : (A - B) * 65535 / (65535 - B) : (B == 0) ? 0 : (B - A) * 65535 / B), 16, uint16_t)
#undef MULTIPLY
#undef SCREEN
@@ -340,39 +294,39 @@ DEFINE_BLEND16(softdifference,av_clip_uint16((A > B) ? (B == 65535) ? 0 : (A - B
#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 1023 - ((1023 - (b)) << 10) / (a)))
#define DODGE(a, b) (((a) == 1023) ? (a) : FFMIN(1023, (((b) << 10) / (1023 - (a)))))
-DEFINE_BLEND16(addition, FFMIN(1023, A + B), 10)
-DEFINE_BLEND16(grainmerge, (int)av_clip_uintp2(A + B - 512, 10), 10)
-DEFINE_BLEND16(average, (A + B) / 2, 10)
-DEFINE_BLEND16(subtract, FFMAX(0, A - B), 10)
-DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 10)
-DEFINE_BLEND16(multiply128, (int)av_clip_uintp2((A - 512) * B / 128. + 512, 10), 10)
-DEFINE_BLEND16(negation, 1023 - FFABS(1023 - A - B), 10)
-DEFINE_BLEND16(extremity, FFABS(1023 - A - B), 10)
-DEFINE_BLEND16(difference, FFABS(A - B), 10)
-DEFINE_BLEND16(grainextract, (int)av_clip_uintp2(512 + A - B, 10), 10)
-DEFINE_BLEND16(screen, SCREEN(1, A, B), 10)
-DEFINE_BLEND16(overlay, (A < 512) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 10)
-DEFINE_BLEND16(hardlight, (B < 512) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 10)
-DEFINE_BLEND16(hardmix, (A < (1023 - B)) ? 0: 1023, 10)
-DEFINE_BLEND16(heat, (A == 0) ? 0 : 1023 - FFMIN(((1023 - B) * (1023 - B)) / A, 1023), 10)
-DEFINE_BLEND16(freeze, (B == 0) ? 0 : 1023 - FFMIN(((1023 - A) * (1023 - A)) / B, 1023), 10)
-DEFINE_BLEND16(darken, FFMIN(A, B), 10)
-DEFINE_BLEND16(lighten, FFMAX(A, B), 10)
-DEFINE_BLEND16(divide, (int)av_clip_uintp2(B == 0 ? 1023 : 1023 * A / B, 10), 10)
-DEFINE_BLEND16(dodge, DODGE(A, B), 10)
-DEFINE_BLEND16(burn, BURN(A, B), 10)
-DEFINE_BLEND16(softlight, (A > 511) ? B + (1023 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 1023): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/1023), 10)
-DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 1023, 10)
-DEFINE_BLEND16(pinlight, (B < 512) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 512)), 10)
-DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1023, 10)
-DEFINE_BLEND16(reflect, (B == 1023) ? B : FFMIN(1023, (A * A / (1023 - B))), 10)
-DEFINE_BLEND16(glow, (A == 1023) ? A : FFMIN(1023, (B * B / (1023 - A))), 10)
-DEFINE_BLEND16(and, A & B, 10)
-DEFINE_BLEND16(or, A | B, 10)
-DEFINE_BLEND16(xor, A ^ B, 10)
-DEFINE_BLEND16(vividlight, (A < 512) ? BURN(2 * A, B) : DODGE(2 * (A - 512), B), 10)
-DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 512), 10), 10)
-DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 1023) ? 0 : (A - B) * 1023 / (1023 - B) : (B == 0) ? 0 : (B - A) * 1023 / B, 10), 10)
+DEFINE_BLEND(addition, FFMIN(1023, A + B), 10, uint16_t)
+DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 512, 10), 10, uint16_t)
+DEFINE_BLEND(average, (A + B) / 2, 10, uint16_t)
+DEFINE_BLEND(subtract, FFMAX(0, A - B), 10, uint16_t)
+DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 10, uint16_t)
+DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 512) * B / 128. + 512, 10), 10, uint16_t)
+DEFINE_BLEND(negation, 1023 - FFABS(1023 - A - B), 10, uint16_t)
+DEFINE_BLEND(extremity, FFABS(1023 - A - B), 10, uint16_t)
+DEFINE_BLEND(difference, FFABS(A - B), 10, uint16_t)
+DEFINE_BLEND(grainextract, (int)av_clip_uintp2(512 + A - B, 10), 10, uint16_t)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 10, uint16_t)
+DEFINE_BLEND(overlay, (A < 512) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 10, uint16_t)
+DEFINE_BLEND(hardlight, (B < 512) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 10, uint16_t)
+DEFINE_BLEND(hardmix, (A < (1023 - B)) ? 0: 1023, 10, uint16_t)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 1023 - FFMIN(((1023 - B) * (1023 - B)) / A, 1023), 10, uint16_t)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 1023 - FFMIN(((1023 - A) * (1023 - A)) / B, 1023), 10, uint16_t)
+DEFINE_BLEND(darken, FFMIN(A, B), 10, uint16_t)
+DEFINE_BLEND(lighten, FFMAX(A, B), 10, uint16_t)
+DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 1023 : 1023 * A / B, 10), 10, uint16_t)
+DEFINE_BLEND(dodge, DODGE(A, B), 10, uint16_t)
+DEFINE_BLEND(burn, BURN(A, B), 10, uint16_t)
+DEFINE_BLEND(softlight, (A > 511) ? B + (1023 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 1023): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/1023), 10, uint16_t)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 1023, 10, uint16_t)
+DEFINE_BLEND(pinlight, (B < 512) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 512)), 10, uint16_t)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1023, 10, uint16_t)
+DEFINE_BLEND(reflect, (B == 1023) ? B : FFMIN(1023, (A * A / (1023 - B))), 10, uint16_t)
+DEFINE_BLEND(glow, (A == 1023) ? A : FFMIN(1023, (B * B / (1023 - A))), 10, uint16_t)
+DEFINE_BLEND(and, A & B, 10, uint16_t)
+DEFINE_BLEND(or, A | B, 10, uint16_t)
+DEFINE_BLEND(xor, A ^ B, 10, uint16_t)
+DEFINE_BLEND(vividlight, (A < 512) ? BURN(2 * A, B) : DODGE(2 * (A - 512), B), 10, uint16_t)
+DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 512) ? B + 2 * A - 1023 : B + 2 * (A - 512), 10), 10, uint16_t)
+DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (B == 1023) ? 0 : (A - B) * 1023 / (1023 - B) : (B == 0) ? 0 : (B - A) * 1023 / B, 10), 10, uint16_t)
#undef MULTIPLY
#undef SCREEN
@@ -384,39 +338,39 @@ DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 1023) ? 0 : (A
#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 4095 - ((4095 - (b)) << 12) / (a)))
#define DODGE(a, b) (((a) == 4095) ? (a) : FFMIN(4095, (((b) << 12) / (4095 - (a)))))
-DEFINE_BLEND16(addition, FFMIN(4095, A + B), 12)
-DEFINE_BLEND16(grainmerge, (int)av_clip_uintp2(A + B - 2048, 12), 12)
-DEFINE_BLEND16(average, (A + B) / 2, 12)
-DEFINE_BLEND16(subtract, FFMAX(0, A - B), 12)
-DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 12)
-DEFINE_BLEND16(multiply128, (int)av_clip_uintp2((A - 2048) * B / 512. + 2048, 12), 12)
-DEFINE_BLEND16(negation, 4095 - FFABS(4095 - A - B), 12)
-DEFINE_BLEND16(extremity, FFABS(4095 - A - B), 12)
-DEFINE_BLEND16(difference, FFABS(A - B), 12)
-DEFINE_BLEND16(grainextract, (int)av_clip_uintp2(2048 + A - B, 12), 12)
-DEFINE_BLEND16(screen, SCREEN(1, A, B), 12)
-DEFINE_BLEND16(overlay, (A < 2048) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 12)
-DEFINE_BLEND16(hardlight, (B < 2048) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 12)
-DEFINE_BLEND16(hardmix, (A < (4095 - B)) ? 0: 4095, 12)
-DEFINE_BLEND16(heat, (A == 0) ? 0 : 4095 - FFMIN(((4095 - B) * (4095 - B)) / A, 4095), 12)
-DEFINE_BLEND16(freeze, (B == 0) ? 0 : 4095 - FFMIN(((4095 - A) * (4095 - A)) / B, 4095), 12)
-DEFINE_BLEND16(darken, FFMIN(A, B), 12)
-DEFINE_BLEND16(lighten, FFMAX(A, B), 12)
-DEFINE_BLEND16(divide, (int)av_clip_uintp2(B == 0 ? 4095 : 4095 * A / B, 12), 12)
-DEFINE_BLEND16(dodge, DODGE(A, B), 12)
-DEFINE_BLEND16(burn, BURN(A, B), 12)
-DEFINE_BLEND16(softlight, (A > 2047) ? B + (4095 - B) * (A - 2047.5) / 2047.5 * (0.5 - fabs(B - 2047.5) / 4095): B - B * ((2047.5 - A) / 2047.5) * (0.5 - fabs(B - 2047.5)/4095), 12)
-DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 4095, 12)
-DEFINE_BLEND16(pinlight, (B < 2048) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 2048)), 12)
-DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 4095, 12)
-DEFINE_BLEND16(reflect, (B == 4095) ? B : FFMIN(4095, (A * A / (4095 - B))), 12)
-DEFINE_BLEND16(glow, (A == 4095) ? A : FFMIN(4095, (B * B / (4095 - A))), 12)
-DEFINE_BLEND16(and, A & B, 12)
-DEFINE_BLEND16(or, A | B, 12)
-DEFINE_BLEND16(xor, A ^ B, 12)
-DEFINE_BLEND16(vividlight, (A < 2048) ? BURN(2 * A, B) : DODGE(2 * (A - 2048), B), 12)
-DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 2048) ? B + 2 * A - 4095 : B + 2 * (A - 2048), 12), 12)
-DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 4095) ? 0 : (A - B) * 4095 / (4095 - B) : (B == 0) ? 0 : (B - A) * 4095 / B, 12), 12)
+DEFINE_BLEND(addition, FFMIN(4095, A + B), 12, uint16_t)
+DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 2048, 12), 12, uint16_t)
+DEFINE_BLEND(average, (A + B) / 2, 12, uint16_t)
+DEFINE_BLEND(subtract, FFMAX(0, A - B), 12, uint16_t)
+DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 12, uint16_t)
+DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 2048) * B / 512. + 2048, 12), 12, uint16_t)
+DEFINE_BLEND(negation, 4095 - FFABS(4095 - A - B), 12, uint16_t)
+DEFINE_BLEND(extremity, FFABS(4095 - A - B), 12, uint16_t)
+DEFINE_BLEND(difference, FFABS(A - B), 12, uint16_t)
+DEFINE_BLEND(grainextract, (int)av_clip_uintp2(2048 + A - B, 12), 12, uint16_t)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 12, uint16_t)
+DEFINE_BLEND(overlay, (A < 2048) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 12, uint16_t)
+DEFINE_BLEND(hardlight, (B < 2048) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 12, uint16_t)
+DEFINE_BLEND(hardmix, (A < (4095 - B)) ? 0: 4095, 12, uint16_t)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 4095 - FFMIN(((4095 - B) * (4095 - B)) / A, 4095), 12, uint16_t)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 4095 - FFMIN(((4095 - A) * (4095 - A)) / B, 4095), 12, uint16_t)
+DEFINE_BLEND(darken, FFMIN(A, B), 12, uint16_t)
+DEFINE_BLEND(lighten, FFMAX(A, B), 12, uint16_t)
+DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 4095 : 4095 * A / B, 12), 12, uint16_t)
+DEFINE_BLEND(dodge, DODGE(A, B), 12, uint16_t)
+DEFINE_BLEND(burn, BURN(A, B), 12, uint16_t)
+DEFINE_BLEND(softlight, (A > 2047) ? B + (4095 - B) * (A - 2047.5) / 2047.5 * (0.5 - fabs(B - 2047.5) / 4095): B - B * ((2047.5 - A) / 2047.5) * (0.5 - fabs(B - 2047.5)/4095), 12, uint16_t)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 4095, 12, uint16_t)
+DEFINE_BLEND(pinlight, (B < 2048) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 2048)), 12, uint16_t)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 4095, 12, uint16_t)
+DEFINE_BLEND(reflect, (B == 4095) ? B : FFMIN(4095, (A * A / (4095 - B))), 12, uint16_t)
+DEFINE_BLEND(glow, (A == 4095) ? A : FFMIN(4095, (B * B / (4095 - A))), 12, uint16_t)
+DEFINE_BLEND(and, A & B, 12, uint16_t)
+DEFINE_BLEND(or, A | B, 12, uint16_t)
+DEFINE_BLEND(xor, A ^ B, 12, uint16_t)
+DEFINE_BLEND(vividlight, (A < 2048) ? BURN(2 * A, B) : DODGE(2 * (A - 2048), B), 12, uint16_t)
+DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 2048) ? B + 2 * A - 4095 : B + 2 * (A - 2048), 12), 12, uint16_t)
+DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (B == 4095) ? 0 : (A - B) * 4095 / (4095 - B) : (B == 0) ? 0 : (B - A) * 4095 / B, 12), 12, uint16_t)
#undef MULTIPLY
#undef SCREEN
@@ -428,39 +382,39 @@ DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 4095) ? 0 : (A
#define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, 511 - ((511 - (b)) << 9) / (a)))
#define DODGE(a, b) (((a) == 511) ? (a) : FFMIN(511, (((b) << 9) / (511 - (a)))))
-DEFINE_BLEND16(addition, FFMIN(511, A + B), 9)
-DEFINE_BLEND16(grainmerge, (int)av_clip_uintp2(A + B - 256, 9), 9)
-DEFINE_BLEND16(average, (A + B) / 2, 9)
-DEFINE_BLEND16(subtract, FFMAX(0, A - B), 9)
-DEFINE_BLEND16(multiply, MULTIPLY(1, A, B), 9)
-DEFINE_BLEND16(multiply128, (int)av_clip_uintp2((A - 256) * B / 64. + 256, 9), 9)
-DEFINE_BLEND16(negation, 511 - FFABS(511 - A - B), 9)
-DEFINE_BLEND16(extremity, FFABS(511 - A - B), 9)
-DEFINE_BLEND16(difference, FFABS(A - B), 9)
-DEFINE_BLEND16(grainextract, (int)av_clip_uintp2(256 + A - B, 9), 9)
-DEFINE_BLEND16(screen, SCREEN(1, A, B), 9)
-DEFINE_BLEND16(overlay, (A < 256) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 9)
-DEFINE_BLEND16(hardlight, (B < 256) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 9)
-DEFINE_BLEND16(hardmix, (A < (511 - B)) ? 0: 511, 9)
-DEFINE_BLEND16(heat, (A == 0) ? 0 : 511 - FFMIN(((511 - B) * (511 - B)) / A, 511), 9)
-DEFINE_BLEND16(freeze, (B == 0) ? 0 : 511 - FFMIN(((511 - A) * (511 - A)) / B, 511), 9)
-DEFINE_BLEND16(darken, FFMIN(A, B), 9)
-DEFINE_BLEND16(lighten, FFMAX(A, B), 9)
-DEFINE_BLEND16(divide, (int)av_clip_uintp2(B == 0 ? 511 : 511 * A / B, 9), 9)
-DEFINE_BLEND16(dodge, DODGE(A, B), 9)
-DEFINE_BLEND16(burn, BURN(A, B), 9)
-DEFINE_BLEND16(softlight, (A > 511) ? B + (511 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 511): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/511), 9)
-DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 511, 9)
-DEFINE_BLEND16(pinlight, (B < 256) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 256)), 9)
-DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 511, 9)
-DEFINE_BLEND16(reflect, (B == 511) ? B : FFMIN(511, (A * A / (511 - B))), 9)
-DEFINE_BLEND16(glow, (A == 511) ? A : FFMIN(511, (B * B / (511 - A))), 9)
-DEFINE_BLEND16(and, A & B, 9)
-DEFINE_BLEND16(or, A | B, 9)
-DEFINE_BLEND16(xor, A ^ B, 9)
-DEFINE_BLEND16(vividlight, (A < 256) ? BURN(2 * A, B) : DODGE(2 * (A - 256), B), 9)
-DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 256) ? B + 2 * A - 511 : B + 2 * (A - 256), 9), 9)
-DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (A - B) * 511 / (511 - B) : (B == 0) ? 0 : (B - A) * 511 / B, 9), 9)
+DEFINE_BLEND(addition, FFMIN(511, A + B), 9, uint16_t)
+DEFINE_BLEND(grainmerge, (int)av_clip_uintp2(A + B - 256, 9), 9, uint16_t)
+DEFINE_BLEND(average, (A + B) / 2, 9, uint16_t)
+DEFINE_BLEND(subtract, FFMAX(0, A - B), 9, uint16_t)
+DEFINE_BLEND(multiply, MULTIPLY(1, A, B), 9, uint16_t)
+DEFINE_BLEND(multiply128, (int)av_clip_uintp2((A - 256) * B / 64. + 256, 9), 9, uint16_t)
+DEFINE_BLEND(negation, 511 - FFABS(511 - A - B), 9, uint16_t)
+DEFINE_BLEND(extremity, FFABS(511 - A - B), 9, uint16_t)
+DEFINE_BLEND(difference, FFABS(A - B), 9, uint16_t)
+DEFINE_BLEND(grainextract, (int)av_clip_uintp2(256 + A - B, 9), 9, uint16_t)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 9, uint16_t)
+DEFINE_BLEND(overlay, (A < 256) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 9, uint16_t)
+DEFINE_BLEND(hardlight, (B < 256) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 9, uint16_t)
+DEFINE_BLEND(hardmix, (A < (511 - B)) ? 0: 511, 9, uint16_t)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 511 - FFMIN(((511 - B) * (511 - B)) / A, 511), 9, uint16_t)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 511 - FFMIN(((511 - A) * (511 - A)) / B, 511), 9, uint16_t)
+DEFINE_BLEND(darken, FFMIN(A, B), 9, uint16_t)
+DEFINE_BLEND(lighten, FFMAX(A, B), 9, uint16_t)
+DEFINE_BLEND(divide, (int)av_clip_uintp2(B == 0 ? 511 : 511 * A / B, 9), 9, uint16_t)
+DEFINE_BLEND(dodge, DODGE(A, B), 9, uint16_t)
+DEFINE_BLEND(burn, BURN(A, B), 9, uint16_t)
+DEFINE_BLEND(softlight, (A > 511) ? B + (511 - B) * (A - 511.5) / 511.5 * (0.5 - fabs(B - 511.5) / 511): B - B * ((511.5 - A) / 511.5) * (0.5 - fabs(B - 511.5)/511), 9, uint16_t)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 511, 9, uint16_t)
+DEFINE_BLEND(pinlight, (B < 256) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 256)), 9, uint16_t)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 511, 9, uint16_t)
+DEFINE_BLEND(reflect, (B == 511) ? B : FFMIN(511, (A * A / (511 - B))), 9, uint16_t)
+DEFINE_BLEND(glow, (A == 511) ? A : FFMIN(511, (B * B / (511 - A))), 9, uint16_t)
+DEFINE_BLEND(and, A & B, 9, uint16_t)
+DEFINE_BLEND(or, A | B, 9, uint16_t)
+DEFINE_BLEND(xor, A ^ B, 9, uint16_t)
+DEFINE_BLEND(vividlight, (A < 256) ? BURN(2 * A, B) : DODGE(2 * (A - 256), B), 9, uint16_t)
+DEFINE_BLEND(linearlight,(int)av_clip_uintp2((B < 256) ? B + 2 * A - 511 : B + 2 * (A - 256), 9), 9, uint16_t)
+DEFINE_BLEND(softdifference,(int)av_clip_uintp2((A > B) ? (A - B) * 511 / (511 - B) : (B == 0) ? 0 : (B - A) * 511 / B, 9), 9, uint16_t)
#undef MULTIPLY
#undef SCREEN
@@ -472,39 +426,39 @@ DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (A - B) * 511 / (511
#define BURN(a, b) (((a) <= 0.0) ? (a) : FFMAX(0.0, 1.0 - (1.0 - (b)) / (a)))
#define DODGE(a, b) (((a) >= 1.0) ? (a) : FFMIN(1.0, ((b) / (1.0 - (a)))))
-DEFINE_BLEND32(addition, A + B, 32)
-DEFINE_BLEND32(grainmerge, A + B - 0.5, 32)
-DEFINE_BLEND32(average, (A + B) / 2, 32)
-DEFINE_BLEND32(subtract, A - B, 32)
-DEFINE_BLEND32(multiply, A * B, 32)
-DEFINE_BLEND32(multiply128, (A - 0.5) * B / 0.125 + 0.5, 32)
-DEFINE_BLEND32(negation, 1.0 - FFABS(1.0 - A - B), 32)
-DEFINE_BLEND32(extremity, FFABS(1.0 - A - B), 32)
-DEFINE_BLEND32(difference, FFABS(A - B), 32)
-DEFINE_BLEND32(grainextract, 0.5 + A - B, 32)
-DEFINE_BLEND32(screen, SCREEN(1, A, B), 32)
-DEFINE_BLEND32(overlay, (A < 0.5) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 32)
-DEFINE_BLEND32(hardlight, (B < 0.5) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 32)
-DEFINE_BLEND32(hardmix, (A < (1.0 - B)) ? 0: 1.0, 32)
-DEFINE_BLEND32(heat, (A == 0) ? 0 : 1.0 - FFMIN(((1.0 - B) * (1.0 - B)) / A, 1.0), 32)
-DEFINE_BLEND32(freeze, (B == 0) ? 0 : 1.0 - FFMIN(((1.0 - A) * (1.0 - A)) / B, 1.0), 32)
-DEFINE_BLEND32(darken, FFMIN(A, B), 32)
-DEFINE_BLEND32(lighten, FFMAX(A, B), 32)
-DEFINE_BLEND32(divide, B == 0 ? 1.0 : 1.0 * A / B, 32)
-DEFINE_BLEND32(dodge, DODGE(A, B), 32)
-DEFINE_BLEND32(burn, BURN(A, B), 32)
-DEFINE_BLEND32(softlight, (A > 0.5) ? B + (1.0 - B) * (A - 0.5) / 0.5 * (0.5 - fabs(B - 0.5) / 1.0): B - B * ((0.5 - A) / 0.5) * (0.5 - fabs(B - 0.5)/1.0), 32)
-DEFINE_BLEND32(exclusion, A + B - 2 * A * B / 1.0, 32)
-DEFINE_BLEND32(pinlight, (B < 0.5) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 0.5)), 32)
-DEFINE_BLEND32(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1.0, 32)
-DEFINE_BLEND32(reflect, (B == 1.0) ? B : FFMIN(1.0, (A * A / (1.0 - B))), 32)
-DEFINE_BLEND32(glow, (A == 1.0) ? A : FFMIN(1.0, (B * B / (1.0 - A))), 32)
-DEFINE_BLEND32(and, av_int2float(av_float2int(A) & av_float2int(B)), 32)
-DEFINE_BLEND32(or, av_int2float(av_float2int(A) | av_float2int(B)), 32)
-DEFINE_BLEND32(xor, av_int2float(av_float2int(A) ^ av_float2int(B)), 32)
-DEFINE_BLEND32(vividlight, (A < 0.5) ? BURN(2 * A, B) : DODGE(2 * (A - 0.5), B), 32)
-DEFINE_BLEND32(linearlight,(B < 0.5) ? B + 2 * A - 1.0 : B + 2 * (A - 0.5), 32)
-DEFINE_BLEND32(softdifference, (A > B) ? (B == 1.f) ? 0.f : (A - B) / (1.f - B) : (B == 0.f) ? 0.f : (B - A) / B, 32)
+DEFINE_BLEND(addition, A + B, 32, float)
+DEFINE_BLEND(grainmerge, A + B - 0.5, 32, float)
+DEFINE_BLEND(average, (A + B) / 2, 32, float)
+DEFINE_BLEND(subtract, A - B, 32, float)
+DEFINE_BLEND(multiply, A * B, 32, float)
+DEFINE_BLEND(multiply128, (A - 0.5) * B / 0.125 + 0.5, 32, float)
+DEFINE_BLEND(negation, 1.0 - FFABS(1.0 - A - B), 32, float)
+DEFINE_BLEND(extremity, FFABS(1.0 - A - B), 32, float)
+DEFINE_BLEND(difference, FFABS(A - B), 32, float)
+DEFINE_BLEND(grainextract, 0.5 + A - B, 32, float)
+DEFINE_BLEND(screen, SCREEN(1, A, B), 32, float)
+DEFINE_BLEND(overlay, (A < 0.5) ? MULTIPLY(2, A, B) : SCREEN(2, A, B), 32, float)
+DEFINE_BLEND(hardlight, (B < 0.5) ? MULTIPLY(2, B, A) : SCREEN(2, B, A), 32, float)
+DEFINE_BLEND(hardmix, (A < (1.0 - B)) ? 0: 1.0, 32, float)
+DEFINE_BLEND(heat, (A == 0) ? 0 : 1.0 - FFMIN(((1.0 - B) * (1.0 - B)) / A, 1.0), 32, float)
+DEFINE_BLEND(freeze, (B == 0) ? 0 : 1.0 - FFMIN(((1.0 - A) * (1.0 - A)) / B, 1.0), 32, float)
+DEFINE_BLEND(darken, FFMIN(A, B), 32, float)
+DEFINE_BLEND(lighten, FFMAX(A, B), 32, float)
+DEFINE_BLEND(divide, B == 0 ? 1.0 : 1.0 * A / B, 32, float)
+DEFINE_BLEND(dodge, DODGE(A, B), 32, float)
+DEFINE_BLEND(burn, BURN(A, B), 32, float)
+DEFINE_BLEND(softlight, (A > 0.5) ? B + (1.0 - B) * (A - 0.5) / 0.5 * (0.5 - fabs(B - 0.5) / 1.0): B - B * ((0.5 - A) / 0.5) * (0.5 - fabs(B - 0.5)/1.0), 32, float)
+DEFINE_BLEND(exclusion, A + B - 2 * A * B / 1.0, 32, float)
+DEFINE_BLEND(pinlight, (B < 0.5) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 0.5)), 32, float)
+DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 1.0, 32, float)
+DEFINE_BLEND(reflect, (B == 1.0) ? B : FFMIN(1.0, (A * A / (1.0 - B))), 32, float)
+DEFINE_BLEND(glow, (A == 1.0) ? A : FFMIN(1.0, (B * B / (1.0 - A))), 32, float)
+DEFINE_BLEND(and, av_int2float(av_float2int(A) & av_float2int(B)), 32, float)
+DEFINE_BLEND(or, av_int2float(av_float2int(A) | av_float2int(B)), 32, float)
+DEFINE_BLEND(xor, av_int2float(av_float2int(A) ^ av_float2int(B)), 32, float)
+DEFINE_BLEND(vividlight, (A < 0.5) ? BURN(2 * A, B) : DODGE(2 * (A - 0.5), B), 32, float)
+DEFINE_BLEND(linearlight,(B < 0.5) ? B + 2 * A - 1.0 : B + 2 * (A - 0.5), 32, float)
+DEFINE_BLEND(softdifference, (A > B) ? (B == 1.f) ? 0.f : (A - B) / (1.f - B) : (B == 0.f) ? 0.f : (B - A) / B, 32, float)
#define DEFINE_BLEND_EXPR(type, name, div) \
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \
1
0
ffmpeg | branch: master | Paul B Mahol <onemda(a)gmail.com> | Mon Sep 27 19:10:17 2021 +0200| [d7408a786f350d4cd9a338821a4c63a0642eb000] | committer: Paul B Mahol
avfilter/vf_blend: refactor similar code
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7408a786f350d4cd…
---
libavfilter/vf_blend.c | 93 +++++++++++++++-----------------------------------
1 file changed, 27 insertions(+), 66 deletions(-)
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index ff06940a66..db315fa86f 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -142,74 +142,35 @@ COPY(bottom, 32)
#undef COPY
-static void blend_normal_8bit(const uint8_t *top, ptrdiff_t top_linesize,
- const uint8_t *bottom, ptrdiff_t bottom_linesize,
- uint8_t *dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t height,
- FilterParams *param, double *values, int starty)
-{
- const float opacity = param->opacity;
- int i, j;
-
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity);
- }
- dst += dst_linesize;
- top += top_linesize;
- bottom += bottom_linesize;
- }
+#define BLEND_NORMAL(name, type) \
+static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
+ const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
+ uint8_t *_dst, ptrdiff_t dst_linesize, \
+ ptrdiff_t width, ptrdiff_t height, \
+ FilterParams *param, double *values, int starty) \
+{ \
+ const type *top = (type*)_top; \
+ const type *bottom = (type*)_bottom; \
+ type *dst = (type*)_dst; \
+ const float opacity = param->opacity; \
+ \
+ dst_linesize /= sizeof(type); \
+ top_linesize /= sizeof(type); \
+ bottom_linesize /= sizeof(type); \
+ \
+ for (int i = 0; i < height; i++) { \
+ for (int j = 0; j < width; j++) { \
+ dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \
+ } \
+ dst += dst_linesize; \
+ top += top_linesize; \
+ bottom += bottom_linesize; \
+ } \
}
-static void blend_normal_16bit(const uint8_t *_top, ptrdiff_t top_linesize,
- const uint8_t *_bottom, ptrdiff_t bottom_linesize,
- uint8_t *_dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t height,
- FilterParams *param, double *values, int starty)
-{
- const uint16_t *top = (uint16_t*)_top;
- const uint16_t *bottom = (uint16_t*)_bottom;
- uint16_t *dst = (uint16_t*)_dst;
- const float opacity = param->opacity;
- int i, j;
- dst_linesize /= 2;
- top_linesize /= 2;
- bottom_linesize /= 2;
-
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity);
- }
- dst += dst_linesize;
- top += top_linesize;
- bottom += bottom_linesize;
- }
-}
-
-static void blend_normal_32bit(const uint8_t *_top, ptrdiff_t top_linesize,
- const uint8_t *_bottom, ptrdiff_t bottom_linesize,
- uint8_t *_dst, ptrdiff_t dst_linesize,
- ptrdiff_t width, ptrdiff_t height,
- FilterParams *param, double *values, int starty)
-{
- const float *top = (float*)_top;
- const float *bottom = (float*)_bottom;
- float *dst = (float*)_dst;
- const float opacity = param->opacity;
- int i, j;
- dst_linesize /= 4;
- top_linesize /= 4;
- bottom_linesize /= 4;
-
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity);
- }
- dst += dst_linesize;
- top += top_linesize;
- bottom += bottom_linesize;
- }
-}
+BLEND_NORMAL(8bit, uint8_t)
+BLEND_NORMAL(16bit, uint16_t)
+BLEND_NORMAL(32bit, float)
#define DEFINE_BLEND8(name, expr) \
static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize, \
1
0