Re: [FFmpeg-devel] [PATCH]lavfi/minterpolate: Split struct Pixel to allow higher resolutions

2017-12-27 Thread Carl Eugen Hoyos
2017-12-05 1:43 GMT+01:00 Michael Niedermayer :
> On Mon, Dec 04, 2017 at 09:26:15PM +0100, Carl Eugen Hoyos wrote:
>> 2017-12-04 19:03 GMT+01:00 Michael Niedermayer :
>> > On Sun, Dec 03, 2017 at 05:30:32AM +0100, Carl Eugen Hoyos wrote:
>> >> Hi!
>> >>
>> >> Attached patch should fix ticket #6795, only tested with one filter
>> >> chain (bitexact): testsrc2=r=5:d=10,minterpolate=10
>> >>
>> >> Please comment, Carl Eugen
>> >
>> > Does this affect speed ? there are more pointers after the patch
>>
>> Yes (I had not tested before):
>> The following filter chain has a higher performance here on x86_64
>> with vanilla gcc 6.3 with the patch applied:
>> testsrc2=s=hd1080,minterpolate=50
>
> if its faster then LGTM

Patch applied.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavfi/minterpolate: Split struct Pixel to allow higher resolutions

2017-12-04 Thread Michael Niedermayer
On Mon, Dec 04, 2017 at 09:26:15PM +0100, Carl Eugen Hoyos wrote:
> 2017-12-04 19:03 GMT+01:00 Michael Niedermayer :
> > On Sun, Dec 03, 2017 at 05:30:32AM +0100, Carl Eugen Hoyos wrote:
> >> Hi!
> >>
> >> Attached patch should fix ticket #6795, only tested with one filter
> >> chain (bitexact): testsrc2=r=5:d=10,minterpolate=10
> >>
> >> Please comment, Carl Eugen
> >
> > Does this affect speed ? there are more pointers after the patch
> 
> Yes (I had not tested before):
> The following filter chain has a higher performance here on x86_64
> with vanilla gcc 6.3 with the patch applied:
> testsrc2=s=hd1080,minterpolate=50

if its faster then LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavfi/minterpolate: Split struct Pixel to allow higher resolutions

2017-12-04 Thread Carl Eugen Hoyos
2017-12-04 19:03 GMT+01:00 Michael Niedermayer :
> On Sun, Dec 03, 2017 at 05:30:32AM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch should fix ticket #6795, only tested with one filter
>> chain (bitexact): testsrc2=r=5:d=10,minterpolate=10
>>
>> Please comment, Carl Eugen
>
> Does this affect speed ? there are more pointers after the patch

Yes (I had not tested before):
The following filter chain has a higher performance here on x86_64
with vanilla gcc 6.3 with the patch applied:
testsrc2=s=hd1080,minterpolate=50

> also this does not truly fix the issue, it just moves the threshold
> of failure up

The new limit seems more reasonable to me.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavfi/minterpolate: Split struct Pixel to allow higher resolutions

2017-12-04 Thread Michael Niedermayer
On Sun, Dec 03, 2017 at 05:30:32AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch should fix ticket #6795, only tested with one filter
> chain (bitexact): testsrc2=r=5:d=10,minterpolate=10
> 
> Please comment, Carl Eugen

Does this affect speed ? there are more pointers after the patch

also this does not truly fix the issue, it just moves the threshold
of failure up

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavfi/minterpolate: Split struct Pixel to allow higher resolutions

2017-12-02 Thread Carl Eugen Hoyos
Hi!

Attached patch should fix ticket #6795, only tested with one filter
chain (bitexact): testsrc2=r=5:d=10,minterpolate=10

Please comment, Carl Eugen
From 618c6b77dd94fcb99bfb87e6245517a829b1eff4 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sun, 3 Dec 2017 05:26:25 +0100
Subject: [PATCH] lavfi/minterpolate: Split struct Pixel to allow higher
 resolutions.

Fixes ticket #6795.
---
 libavfilter/vf_minterpolate.c |  120 +
 1 file changed, 75 insertions(+), 45 deletions(-)

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 6c5c264..d534315 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -145,12 +145,18 @@ typedef struct Block {
 struct Block *subs;
 } Block;
 
-typedef struct Pixel {
+typedef struct PixelMVS {
 int16_t mvs[NB_PIXEL_MVS][2];
+} PixelMVS;
+
+typedef struct PixelWeights {
 uint32_t weights[NB_PIXEL_MVS];
+} PixelWeights;
+
+typedef struct PixelRefs {
 int8_t refs[NB_PIXEL_MVS];
 int nb;
-} Pixel;
+} PixelRefs;
 
 typedef struct Frame {
 AVFrame *avf;
@@ -172,7 +178,9 @@ typedef struct MIContext {
 Frame frames[NB_FRAMES];
 Cluster clusters[NB_CLUSTERS];
 Block *int_blocks;
-Pixel *pixels;
+PixelMVS *pixel_mvs;
+PixelWeights *pixel_weights;
+PixelRefs *pixel_refs;
 int (*mv_table[3])[2][2];
 int64_t out_pts;
 int b_width, b_height, b_count;
@@ -331,7 +339,7 @@ static int config_input(AVFilterLink *inlink)
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 const int height = inlink->h;
 const int width  = inlink->w;
-int i;
+int i, ret = 0;
 
 mi_ctx->log2_chroma_h = desc->log2_chroma_h;
 mi_ctx->log2_chroma_w = desc->log2_chroma_w;
@@ -353,8 +361,13 @@ static int config_input(AVFilterLink *inlink)
 }
 
 if (mi_ctx->mi_mode == MI_MODE_MCI) {
-if (!(mi_ctx->pixels = av_mallocz_array(width * height, sizeof(Pixel
-return AVERROR(ENOMEM);
+mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS));
+mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights));
+mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs));
+if (!mi_ctx->pixel_mvs || !mi_ctx->pixel_weights || !mi_ctx->pixel_refs) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 
 if (mi_ctx->me_mode == ME_MODE_BILAT)
 if (!(mi_ctx->int_blocks = av_mallocz_array(mi_ctx->b_count, sizeof(Block
@@ -383,6 +396,13 @@ static int config_input(AVFilterLink *inlink)
 me_ctx->get_cost = &get_sbad_ob;
 
 return 0;
+fail:
+for (i = 0; i < NB_FRAMES; i++)
+av_freep(&mi_ctx->frames[i].blocks);
+av_freep(&mi_ctx->pixel_mvs);
+av_freep(&mi_ctx->pixel_weights);
+av_freep(&mi_ctx->pixel_refs);
+return ret;
 }
 
 static int config_output(AVFilterLink *outlink)
@@ -833,18 +853,18 @@ static int detect_scene_change(MIContext *mi_ctx)
 
 #define ADD_PIXELS(b_weight, mv_x, mv_y)\
 do {\
-if (!b_weight || pixel->nb + 1 >= NB_PIXEL_MVS)\
+if (!b_weight || pixel_refs->nb + 1 >= NB_PIXEL_MVS)\
 continue;\
-pixel->refs[pixel->nb] = 1;\
-pixel->weights[pixel->nb] = b_weight * (ALPHA_MAX - alpha);\
-pixel->mvs[pixel->nb][0] = av_clip((mv_x * alpha) / ALPHA_MAX, x_min, x_max);\
-pixel->mvs[pixel->nb][1] = av_clip((mv_y * alpha) / ALPHA_MAX, y_min, y_max);\
-pixel->nb++;\
-pixel->refs[pixel->nb] = 2;\
-pixel->weights[pixel->nb] = b_weight * alpha;\
-pixel->mvs[pixel->nb][0] = av_clip(-mv_x * (ALPHA_MAX - alpha) / ALPHA_MAX, x_min, x_max);\
-pixel->mvs[pixel->nb][1] = av_clip(-mv_y * (ALPHA_MAX - alpha) / ALPHA_MAX, y_min, y_max);\
-pixel->nb++;\
+pixel_refs->refs[pixel_refs->nb] = 1;\
+pixel_weights->weights[pixel_refs->nb] = b_weight * (ALPHA_MAX - alpha);\
+pixel_mvs->mvs[pixel_refs->nb][0] = av_clip((mv_x * alpha) / ALPHA_MAX, x_min, x_max);\
+pixel_mvs->mvs[pixel_refs->nb][1] = av_clip((mv_y * alpha) / ALPHA_MAX, y_min, y_max);\
+pixel_refs->nb++;\
+pixel_refs->refs[pixel_refs->nb] = 2;\
+pixel_weights->weights[pixel_refs->nb] = b_weight * alpha;\
+pixel_mvs->mvs[pixel_refs->nb][0] = av_clip(-mv_x * (ALPHA_MAX - alpha) / ALPHA_MAX, x_min, x_max);\
+pixel_mvs->mvs[pixel_refs->nb][1] = av_clip(-mv_y * (ALPHA_MAX - alpha) / ALPHA_MAX, y_min, y_max);\
+pixel_refs->nb++;\
 } while(0)
 
 static void bidirectional_obmc(MIContext *mi_ctx, int alpha)
@@ -856,7 +876,7 @@ static void bidirectional_obmc(MIContext *mi_ctx, int alpha)
 
 for (y = 0; y < height; y++)
 for (x = 0; x < width; x++)
-mi_ctx->pixels[x + y * width].nb = 0;
+mi_ctx->pixel_refs[x + y * width].nb = 0;
 
 for (dir = 0; dir < 2; dir++)
 for (mb_y = 0;