Re: [FFmpeg-devel] [PATCH] Fix vf_cropdetect returning negative rectangles

2014-09-10 Thread hjiodjf 97xgw46
On Wed, Sep 10, 2014 at 11:26 AM, Michael Niedermayer  wrote:
> On Wed, Sep 10, 2014 at 10:35:23AM -0700, hjiodjf 97xgw46 wrote:
>> It appears to work for me:
>
>
> ./ffmpeg -i matrixbench_mpeg2.mpg -vframes 5 -an -vf "cropdetect" -f null -
>
> before patch:
> [Parsed_cropdetect_0 @ 0x27a46e0] x1:91 x2:719 y1:201 y2:437 w:624 h:224 x:94 
> y:208 pts:7200 t:0.08 crop=624:224:94:208
> [Parsed_cropdetect_0 @ 0x27a46e0] x1:91 x2:719 y1:198 y2:437 w:624 h:240 x:94 
> y:198 pts:10800 t:0.12 crop=624:240:94:198
> [Parsed_cropdetect_0 @ 0x27a46e0] x1:91 x2:719 y1:198 y2:437 w:624 h:240 x:94 
> y:198 pts:14400 t:0.16 crop=624:240:94:198
> [Parsed_cropdetect_0 @ 0x27a46e0] x1:91 x2:719 y1:198 y2:437 w:624 h:240 x:94 
> y:198 pts:18000 t:0.20 crop=624:240:94:198
>
> after patch:
> [Parsed_cropdetect_0 @ 0x1e686e0] x1:91 x2:719 y1:201 y2:575 w:624 h:368 x:94 
> y:206 pts:7200 t:0.08 crop=624:368:94:206
> [Parsed_cropdetect_0 @ 0x1e686e0] x1:91 x2:719 y1:198 y2:575 w:624 h:368 x:94 
> y:204 pts:10800 t:0.12 crop=624:368:94:204
> [Parsed_cropdetect_0 @ 0x1e686e0] x1:91 x2:719 y1:198 y2:575 w:624 h:368 x:94 
> y:204 pts:14400 t:0.16 crop=624:368:94:204
> [Parsed_cropdetect_0 @ 0x1e686e0] x1:91 x2:719 y1:198 y2:575 w:624 h:368 x:94 
> y:204 pts:18000 t:0.20 crop=624:368:94:204
>
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Good people do not need laws to tell them to act responsibly, while bad
> people will find a way around the laws. -- Plato
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Sorry about that. That was a brainfart on my end. I will leave the
s->[x1,x2,y1,y2] parameters as they are and just change the reporting
of w/h/x/y. Amended patch attached.


0001-Avoid-returning-negative-rectangles-from-cropdetect.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix vf_cropdetect returning negative rectangles

2014-09-10 Thread hjiodjf 97xgw46
It appears to work for me:

[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:1919 x2:1919 y1:1079 y2:1079
w:0 h:0 x:1920 y:1080 pts:80 t:0.08

...

[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:1524 x2:1919 y1:251 y2:1079
w:384 h:816 x:1530 y:258 pts:1160 t:1.16 crop=384:816:1530:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:1496 x2:1919 y1:251 y2:1079
w:416 h:816 x:1500 y:258 pts:1200 t:1.20 crop=416:816:1500:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:1397 x2:1919 y1:251 y2:1079
w:512 h:816 x:1404 y:258 pts:1240 t:1.24 crop=512:816:1404:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:281 x2:1919 y1:251 y2:1079
w:1632 h:816 x:286 y:258 pts:1280 t:1.28 crop=1632:816:286:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:247 x2:1919 y1:251 y2:1079
w:1664 h:816 x:252 y:258 pts:1320 t:1.32 crop=1664:816:252:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:174 x2:1919 y1:251 y2:1079
w:1744 h:816 x:176 y:258 pts:1360 t:1.36 crop=1744:816:176:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:156 x2:1919 y1:251 y2:1079
w:1760 h:816 x:158 y:258 pts:1400 t:1.40 crop=1760:816:158:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:139 x2:1919 y1:251 y2:1079
w:1776 h:816 x:142 y:258 pts:1440 t:1.44 crop=1776:816:142:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:123 x2:1919 y1:251 y2:1079
w:1792 h:816 x:126 y:258 pts:1480 t:1.48 crop=1792:816:126:258
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:106 x2:1919 y1:175 y2:1079
w:1808 h:896 x:110 y:180 pts:1520 t:1.52 crop=1808:896:110:180
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:90 x2:1919 y1:175 y2:1079
w:1824 h:896 x:94 y:180 pts:1560 t:1.56 crop=1824:896:94:180
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:74 x2:1919 y1:175 y2:1079
w:1840 h:896 x:78 y:180 pts:1600 t:1.60 crop=1840:896:78:180
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:57 x2:1919 y1:175 y2:1079
w:1856 h:896 x:62 y:180 pts:1640 t:1.64 crop=1856:896:62:180
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:41 x2:1919 y1:140 y2:1079
w:1872 h:928 x:46 y:146 pts:1680 t:1.68 crop=1872:928:46:146
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:26 x2:1919 y1:140 y2:1079
w:1888 h:928 x:30 y:146 pts:1720 t:1.72 crop=1888:928:30:146
[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:13 x2:1919 y1:140 y2:1079
w:1904 h:928 x:16 y:146 pts:1760 t:1.76 crop=1904:928:16:146

...

Stable after this point

On Tue, Sep 9, 2014 at 6:29 PM, Michael Niedermayer  wrote:
> On Tue, Sep 09, 2014 at 06:10:01PM -0700, hjiodjf 97xgw46 wrote:
>> On Mon, Sep 8, 2014 at 5:21 PM, Michael Niedermayer  wrote:
>> > On Mon, Sep 08, 2014 at 11:16:49AM -0700, hjiodjf 97xgw46 wrote:
>> >> On Thu, Sep 4, 2014 at 1:08 PM, Michael Niedermayer  
>> >> wrote:
>> >> > On Tue, Sep 02, 2014 at 02:20:40PM -0700, hjiodjf 97xgw46 wrote:
>> > [...]
>> >
>> >> Moreover, as you said, this patch reduces the number of passes through
>> >> a blank frame from 4 to 2, which should improve performance on movies
>> >> with many dark scenes.
>> >
>> > yes but thats seperate from what values are output for blank frames
>> >
>> > should be fixed so it only needs 2 passes now
>> >
>> > [...]
>> >
>> > --
>> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>> >
>> > When the tyrant has disposed of foreign enemies by conquest or treaty, and
>> > there is nothing more to fear from them, then he is always stirring up
>> > some war or other, in order that the people may require a leader. -- Plato
>> >
>> > ___
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>>
>> I was not aware that the cropdetect filter was designed to prevent
>> shrinking the window over a given number of frames. I have attached a
>> revised patch that prevents negative window sizes based on your patch.
>> I still believe that negative windows should be avoided. My reasoning
>> for this was provided in my previous email.
>
>>  vf_cropdetect.c |8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>> 9b9f96427726e38cd3ae5d1f2fc7d77307bbc366  
>> 0001-Avoid-returning-negative-rectangles-from-cropdetect.patch
>> From e86c0bd1b2f855c53c78be0a7269e1132bc1daf6 Mon Sep 17 00:00:00 2001
>> From: tue46wsdgxfjrt 
>> Date: Tue, 9 Sep 2014 18:05:44 -0700
>> Subject: [PATCH] Avoid returning negative rectangles from cropdetect
>>
>> ---
>>  libavfilter/vf_cropdetect.c | 8 
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
>> index 76aa7b2..4b6ee91 100644
>> --- a

Re: [FFmpeg-devel] [PATCH] Fix vf_cropdetect returning negative rectangles

2014-09-09 Thread hjiodjf 97xgw46
On Mon, Sep 8, 2014 at 5:21 PM, Michael Niedermayer  wrote:
> On Mon, Sep 08, 2014 at 11:16:49AM -0700, hjiodjf 97xgw46 wrote:
>> On Thu, Sep 4, 2014 at 1:08 PM, Michael Niedermayer  wrote:
>> > On Tue, Sep 02, 2014 at 02:20:40PM -0700, hjiodjf 97xgw46 wrote:
> [...]
>
>> Moreover, as you said, this patch reduces the number of passes through
>> a blank frame from 4 to 2, which should improve performance on movies
>> with many dark scenes.
>
> yes but thats seperate from what values are output for blank frames
>
> should be fixed so it only needs 2 passes now
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- Plato
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

I was not aware that the cropdetect filter was designed to prevent
shrinking the window over a given number of frames. I have attached a
revised patch that prevents negative window sizes based on your patch.
I still believe that negative windows should be avoided. My reasoning
for this was provided in my previous email.


0001-Avoid-returning-negative-rectangles-from-cropdetect.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fix vf_cropdetect returning negative rectangles

2014-09-08 Thread hjiodjf 97xgw46
On Thu, Sep 4, 2014 at 1:08 PM, Michael Niedermayer  wrote:
> On Tue, Sep 02, 2014 at 02:20:40PM -0700, hjiodjf 97xgw46 wrote:
>> The cropdetect filter is prone to reporting negative-sized rectangles,
>> particularly for dark images. This patch adjusts the limits of the
>> filter loops, preventing the left/right and top/bottom offsets from
>> crossing each other, so that such a zero-sized rectangle is reported
>> instead of a negative one. This improves the reliability of using
>> cropdetect to find a maximum bounding rectangle.
>
> why would this improve the reliability of using the values ?
>
> i think its mostly a question if when no rectangle is found
> negative w/h is returned or 0,0 with a random x/y
> i dont know which is better but this patch also reduces the amount
> of computations in that case so i tend toward applying it
>
>
>>  vf_cropdetect.c |   12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>> 07877d20186041d6ad44359d10c2c079ba954d06  
>> 0001-Prevent-vf_cropdetect-from-returning-negative-rectan.patch
>> From 971e0ec056e6200064598dbca49c18b8653e08d4 Mon Sep 17 00:00:00 2001
>> From: tue46wsdgxfjrt 
>> Date: Tue, 2 Sep 2014 13:57:45 -0700
>> Subject: [PATCH] Prevent vf_cropdetect from returning negative rectangle
>>  sizes.
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Into a blind darkness they enter who follow after the Ignorance,
> they as if into a greater darkness enter who devote themselves
> to the Knowledge alone. -- Isha Upanishad
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
I think this change should be made because I don't see a reason not to
make it. Negative values are confusing (and not documented), and if
the parameters are passed directly into another application (e.g.
Avisynth), unexpected behavior could occur instead of just getting an
empty frame or error message.

Moreover, as you said, this patch reduces the number of passes through
a blank frame from 4 to 2, which should improve performance on movies
with many dark scenes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Fix vf_cropdetect returning negative rectangles

2014-09-02 Thread hjiodjf 97xgw46
The cropdetect filter is prone to reporting negative-sized rectangles,
particularly for dark images. This patch adjusts the limits of the
filter loops, preventing the left/right and top/bottom offsets from
crossing each other, so that such a zero-sized rectangle is reported
instead of a negative one. This improves the reliability of using
cropdetect to find a maximum bounding rectangle.


0001-Prevent-vf_cropdetect-from-returning-negative-rectan.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel