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

hjiodjf 97xgw46 jfbvxt at gmail.com
Wed Sep 10 19:35:23 CEST 2014


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.080000

...

[Parsed_cropdetect_0 @ 0x7ffbb050e420] x1:1524 x2:1919 y1:251 y2:1079
w:384 h:816 x:1530 y:258 pts:1160 t:1.160000 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.200000 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.240000 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.280000 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.320000 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.360000 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.400000 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.440000 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.480000 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.520000 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.560000 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.600000 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.640000 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.680000 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.720000 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.760000 crop=1904:928:16:146

...

Stable after this point

On Tue, Sep 9, 2014 at 6:29 PM, Michael Niedermayer <michaelni at gmx.at> 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 <michaelni at gmx.at> 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 <michaelni at gmx.at> 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 at 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 <jfbvxt at gmail.com>
>> 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/libavfilter/vf_cropdetect.c
>> +++ b/libavfilter/vf_cropdetect.c
>> @@ -106,8 +106,8 @@ static int config_input(AVFilterLink *inlink)
>>
>>      s->x1 = inlink->w - 1;
>>      s->y1 = inlink->h - 1;
>> -    s->x2 = 0;
>> -    s->y2 = 0;
>> +    s->x2 = s->x1;
>> +    s->y2 = s->y1;
>>
>>      return 0;
>>  }
>> @@ -131,8 +131,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>>          if (s->reset_count > 0 && s->frame_nb > s->reset_count) {
>>              s->x1 = frame->width  - 1;
>>              s->y1 = frame->height - 1;
>> -            s->x2 = 0;
>> -            s->y2 = 0;
>> +            s->x2 = s->x1;
>> +            s->y2 = s->y1;
>>              s->frame_nb = 1;
>>          }
>
> this will simply break the code, not just affect negative dimensions
> just compare the output of cropdetect from before this change to
> afterwards
>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are best at talking, realize last or never when they are wrong.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list