[FFmpeg-devel] [PATCH] avfilter: add signalstats filter

Clément Bœsch u at pkh.me
Wed Jun 11 00:01:10 CEST 2014


On Mon, Jun 09, 2014 at 07:48:01PM +0200, Michael Niedermayer wrote:
> On Mon, Jun 09, 2014 at 01:40:28PM +0200, Clément Bœsch wrote:
> > Signed-off-by: Mark Heath <silicontrip at gmail.com>
> > Signed-off-by: Dave Rice <dericed at yahoo.com>
> > Signed-off-by: Clément Bœsch <u at pkh.me>
> > ---
> > - Includes Dave's changes
> > - fixed Mark's mail in signed-off (got a delivery error last time)
> > - remove libavcodec dependency (using hypot) to fix link errors
> > 
> > TODO: lavfi minor bump
> [...]
> > +static int filter_brng(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int y, int w, int h)
> > +{
> > +    int x, score = 0;
> > +    const int yc = y >> s->vsub;
> > +    const uint8_t *pluma    = &in->data[0][y  * in->linesize[0]];
> > +    const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]];
> > +    const uint8_t *pchromav = &in->data[2][yc * in->linesize[2]];
> > +
> > +    for (x = 0; x < w; x++) {
> > +        const int xc = x >> s->hsub;
> > +        const int luma    = pluma[x];
> > +        const int chromau = pchromau[xc];
> > +        const int chromav = pchromav[xc];
> > +        const int filt = luma    < 16 || luma    > 235 ||
> > +                         chromau < 16 || chromau > 240 ||
> > +                         chromav < 16 || chromav > 240;
> 
> checks like:
> luma - 16U > 235 - 16
> 
> might be faster
> 

Doesn't look necessary here:

[/tmp]☭ cat a.c
int f1(int x) { return x < 16 || x > 235; }
int f2(int x) { return x - 16U > 235 - 16; }
[/tmp]☭ gcc -O2 -c a.c && objdump -d -Mintel a.o

a.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <f1>:
   0:   83 ef 10                sub    edi,0x10
   3:   31 c0                   xor    eax,eax
   5:   81 ff db 00 00 00       cmp    edi,0xdb
   b:   0f 97 c0                seta   al
   e:   c3                      ret    
   f:   90                      nop

0000000000000010 <f2>:
  10:   83 ef 10                sub    edi,0x10
  13:   31 c0                   xor    eax,eax
  15:   81 ff db 00 00 00       cmp    edi,0xdb
  1b:   0f 97 c0                seta   al
  1e:   c3                      ret    

> 
> [...]
> > +    lowp   = s->fs  * 10 / 100;
> > +    highp  = s->fs  * 90 / 100;
> > +    clowp  = s->cfs * 10 / 100;
> > +    chighp = s->cfs * 90 / 100;
> 
> is the rounding toward 0 instead of nearest intentional ?
> 

Changed locally into:

    lowp   = lrint(s->fs  * 10 / 100);
    highp  = lrint(s->fs  * 90 / 100);
    clowp  = lrint(s->cfs * 10 / 100);
    chighp = lrint(s->cfs * 90 / 100);

> no more comments from me, rest LGTM
> 

I'll apply soon, thanks.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140611/79938e82/attachment.asc>


More information about the ffmpeg-devel mailing list