[patch] yadif code dump
Since I can't duplicate code any more, I put my additions into lavfi, enjoy.
Hi, On Sat, Nov 27, 2010 at 3:58 PM, James Darnley <james.darnley at gmail.com> wrote:
Since I can't duplicate code any more, I put my additions into lavfi, enjoy. [..] - int is_chroma = !!i; - int w = dstpic->video->w >> is_chroma; - int h = dstpic->video->h >> is_chroma; + for (i = 0; i < yadif->csp->nb_components; i++) { + int w = dstpic->video->w; + int h = dstpic->video->h; int refs = yadif->cur->linesize[i];
+ if (i) { + /* Why is this not part of the per-plane description thing? */ + w >>= yadif->csp->log2_chroma_w; + h >>= yadif->csp->log2_chroma_h; + }
w = dstpic->video->w >> (is_chroma * yadif->csp->log2_chroma_w); h = dstpic->video->h >> (is_chroma * yadif->csp->log2_chroma_h); I would merge the 16-bit and then factorization, or even inverse it (i.e. first factorize, then add 16-bit). Ronald
On Sat, Nov 27, 2010 at 09:58:06PM +0100, James Darnley wrote:
Since I can't duplicate code any more, I put my additions into lavfi, enjoy.
vf_yadif.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) 2307b6cbc1168768988398ef2c5bea08516f19e4 0001-Support-more-than-yuv420p-in-yadif.patch From 22cd772d7faa05907361d142579aa65b062f7ee3 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley at gmail.com> Date: Wed, 24 Nov 2010 21:13:52 +0100 Subject: [PATCH 1/6] Support more than yuv420p in yadif
(and correctly support grey8) --- libavfilter/vf_yadif.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 5c4a245..a3f5800 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -20,6 +20,7 @@
#include "libavutil/cpu.h" #include "libavutil/common.h" +#include "libavutil/pixdesc.h" #include "avfilter.h" #include "yadif.h"
@@ -51,6 +52,8 @@ typedef struct { void (*filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int refs, int parity, int mode); + + const AVPixFmtDescriptor *csp; } YADIFContext;
static void filter_line_c(uint8_t *dst, @@ -121,12 +124,17 @@ static void filter(AVFilterContext *ctx, AVFilterBufferRef *dstpic, YADIFContext *yadif = ctx->priv; int y, i;
- for (i = 0; i < 3; i++) { - int is_chroma = !!i; - int w = dstpic->video->w >> is_chroma; - int h = dstpic->video->h >> is_chroma; + for (i = 0; i < yadif->csp->nb_components; i++) { + int w = dstpic->video->w; + int h = dstpic->video->h; int refs = yadif->cur->linesize[i];
+ if (i) { + /* Why is this not part of the per-plane description thing? */ + w >>= yadif->csp->log2_chroma_w; + h >>= yadif->csp->log2_chroma_h; + } + for (y = 0; y < h; y++) { if ((y ^ parity) & 1) { uint8_t *prev = &yadif->prev->data[i][y*refs];
@@ -173,6 +181,9 @@ static void return_frame(AVFilterContext *ctx, int is_second) yadif->out = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE, link->w, link->h);
+ if (!yadif->csp) + yadif->csp = &av_pix_fmt_descriptors[link->format]; + filter(ctx, yadif->out, tff ^ !is_second, tff);
if (is_second) {
the if() is not worth it, same for =NULL [...]
vf_yadif.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 2caabfd2b8d88e3dafb0c69d1d9c1d248b0d129e 0004-Remove-unnecessary-shadowed-variable-in-yadif.patch From a51b8f9397c8dd3fdaa3f85449afa87bb3ef0ff8 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley at gmail.com> Date: Thu, 25 Nov 2010 21:43:39 +0100 Subject: [PATCH 4/6] Remove unnecessary shadowed variable in yadif
This could have performance effects and should be benchmarked [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
On 01/12/2010, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Nov 27, 2010 at 09:58:06PM +0100, James Darnley wrote:
Subject: [PATCH 4/6] Remove unnecessary shadowed variable in yadif
This could have performance effects and should be benchmarked
Good point. I benched it and got the following for a 704 pixel line (luma only) With the shadowing: 1912237 dezicycles in filter_line, 260884 runs, 1260 skips Without: 1920573 dezicycles in filter_line, 260438 runs, 1706 skips Per pixel, with: 2811 dezicycles in filter_line, 268356284 runs, 79172 skips Without: 2812 dezicycles in filter_line, 268356237 runs, 79219 skips What is more worrying is that this function takes twice as long as the same code in x264. It's just ~880000 dezicycles. What have you people done? The slowdown looks to start on the second filtered frame (single-rate) or the third (double-rate). That is when yadif should be requesting/using frames 0, 1 and 2. Something else, is it ffmpeg's fault can't I bob? I can use mode=1 and yadif filters twice as many frames but ffmpeg says it drops every other frame. But that's another topic.
On Fri, Dec 3, 2010 at 7:47 AM, James Darnley <james.darnley at gmail.com> wrote:
On 01/12/2010, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Nov 27, 2010 at 09:58:06PM +0100, James Darnley wrote:
Subject: [PATCH 4/6] Remove unnecessary shadowed variable in yadif
This could have performance effects and should be benchmarked
Good point. ?I benched it and got the following for a 704 pixel line (luma only) With the shadowing: 1912237 dezicycles in filter_line, 260884 runs, 1260 skips Without: 1920573 dezicycles in filter_line, 260438 runs, 1706 skips Per pixel, with: 2811 dezicycles in filter_line, 268356284 runs, 79172 skips Without: 2812 dezicycles in filter_line, 268356237 runs, 79219 skips
What is more worrying is that this function takes twice as long as the same code in x264. ?It's just ~880000 dezicycles. ?What have you people done? ?The slowdown looks to start on the second filtered frame (single-rate) or the third (double-rate). ?That is when yadif should be requesting/using frames 0, 1 and 2.
Keep in mind that ffmpeg's START/STOP_TIMER macros do not by default subtract the timing overhead, which will make small times incomparable to bench.h. Jason
On Fri, Dec 03, 2010 at 04:47:07PM +0100, James Darnley wrote:
On 01/12/2010, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sat, Nov 27, 2010 at 09:58:06PM +0100, James Darnley wrote:
Subject: [PATCH 4/6] Remove unnecessary shadowed variable in yadif
This could have performance effects and should be benchmarked
Good point. I benched it and got the following for a 704 pixel line (luma only) With the shadowing: 1912237 dezicycles in filter_line, 260884 runs, 1260 skips Without: 1920573 dezicycles in filter_line, 260438 runs, 1706 skips Per pixel, with: 2811 dezicycles in filter_line, 268356284 runs, 79172 skips Without: 2812 dezicycles in filter_line, 268356237 runs, 79219 skips
What is more worrying is that this function takes twice as long as the same code in x264. It's just ~880000 dezicycles. What have you people done? The slowdown looks to start on the second filtered frame (single-rate) or the third (double-rate). That is when yadif should be requesting/using frames 0, 1 and 2.
is this reproduceable with different video widths? what about the skip numbers, do they differ too? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
On Sat, Nov 27, 2010 at 09:58:06PM +0100, James Darnley wrote:
Since I can't duplicate code any more, I put my additions into lavfi, enjoy.
vf_yadif.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) 2307b6cbc1168768988398ef2c5bea08516f19e4 0001-Support-more-than-yuv420p-in-yadif.patch From 22cd772d7faa05907361d142579aa65b062f7ee3 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Wed, 24 Nov 2010 21:13:52 +0100 Subject: [PATCH 1/6] Support more than yuv420p in yadif
(and correctly support grey8)
applied & pushed [...]
vf_yadif.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) dc6ec75edae85403c2cd572b177de939265aa2b5 0002-Support-16-bit-in-yadif.patch From ad6a6023f92840566a796aa8f00d66b000c51e59 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Wed, 24 Nov 2010 21:25:09 +0100 Subject: [PATCH 2/6] Support 16-bit in yadif
applied & pushed [...]
vf_yadif.c | 150 +++++++++++++++++++------------------------------------------ 1 file changed, 48 insertions(+), 102 deletions(-) 9941c4f48e1ef65bdbb9adf2b6e2b73ac67cc6ad 0003-Factorise-the-C-filtering-in-yadif.patch From e6b18ccfb1484cb36adca8d4a845b40119a8d298 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Thu, 25 Nov 2010 21:38:47 +0100 Subject: [PATCH 3/6] Factorise the C filtering in yadif
applied & pushed with some bit of manual fixup [...]
vf_yadif.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 2caabfd2b8d88e3dafb0c69d1d9c1d248b0d129e 0004-Remove-unnecessary-shadowed-variable-in-yadif.patch From a51b8f9397c8dd3fdaa3f85449afa87bb3ef0ff8 Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Thu, 25 Nov 2010 21:43:39 +0100 Subject: [PATCH 4/6] Remove unnecessary shadowed variable in yadif
droped, due to speedlooss [...]
vf_yadif.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) 04b4a750e44e37cf3405983d59c0397ed52f4699 0005-Prevent-junk-in-top-and-bottom-2-lines-when-using-ya.patch From 52bad98494bf1ac37b026ea13a83a369b659f8ee Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Thu, 25 Nov 2010 23:25:50 +0100 Subject: [PATCH 5/6] Prevent junk in top and bottom 2 lines when using yadif
obsolete as the bug has been fixed differently [...]
vf_yadif.c | 2 ++ 1 file changed, 2 insertions(+) 7e4d19447e5aab2ee37cd4335c334c37e6fc3c1d 0006-Update-yadif-copyright-header.patch From 72e4c2293202ae67be8d399220ebee4366f878aa Mon Sep 17 00:00:00 2001 From: James Darnley <james.darnley@gmail.com> Date: Fri, 26 Nov 2010 10:50:28 +0100 Subject: [PATCH 6/6] Update yadif copyright header
i added your name, avisynth code seems not to have been merged if i understand correctly please correct me if iam wrong [..] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
participants (5)
-
james.darnley@gmail.com -
jason@x264.com -
Michael Niedermayer -
michaelni@gmx.at -
rsbultje@gmail.com