Re: [FFmpeg-devel] [PATCH v4] libavcodec: Add FLAC API test

2015-04-21 Thread Michael Niedermayer
Hi Ludmila

It appears several developers had additional review comments on your
patch
ccing you so you dont miss the mail


On Mon, Apr 20, 2015 at 03:03:08AM +0300, Ludmila Glinskih wrote:
> Signed-off-by: Ludmila Glinskih 

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH] avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for H264 lpf and weight/biweight functions

2015-04-21 Thread Parag Salasakar
These are 'optimization' patches for MSA.
We surely have plans to add runtime CPU detection code in near future as a 
separate patch.

Parag

-Original Message-
From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
On Behalf Of Timothy Gu
Sent: Tuesday, April 21, 2015 1:59 AM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mips: MSA (MIPS-SIMD-Arch) 
optimizations for H264 lpf and weight/biweight functions

On Mon, Apr 20, 2015 at 12:04 PM James Almer  wrote:
>
> For that matter, do mips processors even have some sort of cpuid 
> instruction at all?


AFAIK it does. See:

-
https://github.com/torvalds/linux/blob/master/arch/mips/kernel/cpu-probe.c#L519-L520
-
https://github.com/torvalds/linux/blob/master/arch/mips/include/asm/mipsregs.h#L1176
-
https://github.com/torvalds/linux/blob/master/arch/mips/include/asm/mipsregs.h#L903-L916


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


Re: [FFmpeg-devel] [PATCH] Fixed remuxing of HDMV PGS subtitles

2015-04-21 Thread Petri Hintukainen
On ma, 2015-04-13 at 09:41 -0700, Philip Langdale wrote:
> On 2015-04-13 03:39, Petri Hintukainen wrote:
> > 
> > I don't know if it is a good idea to use HDMV stream types without HDMV
> > program registration descriptor. If this is fixed incrementally, fixing
> > should be started from the opposite direction:
> > - Using HDMV stream type requires HDMV registration descriptor
> > - using HDMV registration descriptor requires HDMV conforming stream
> > 
> > I've attached a simple patch to add HDMV registration descriptor to the
> > program. With it streams are correctly detected with ffmpeg. But, I
> > don't think the patch should be applied: using HDMV registration
> > descriptor in a stream that is not HDMV conforming is a really bad
> > idea.
> 
> Your patch is equivalent to the first thing I tried and it had no 
> visible
> effect in so far as how ffmpeg decoded the resulting m2ts file. It still
> marked the subtitle streams as unknown.

I didn't try playing the file, but ffprobe seems to detect PGS streams
correctly from files remuxed with my patch:

$ ffprobe a.m2ts
Input #0, mpegts, from 'a.m2ts':
  Duration: 00:03:21.16, start: 13.050667, bitrate: 36372 kb/s
  Program 1 
Metadata:
  service_name: Service01
  service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 
1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0:1[0x101]: Audio: dts (DTS-HD MA) ([130][0][0][0] / 0x0082), 48000 
Hz, 5.1(side), fltp, 1536 kb/s
Stream #0:2[0x102]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)

> I guess, you don't get any useful
> progress until the whole stream is conforming, and we are
> along way from that.

see ex.
http://mplayerhq.hu/pipermail/ffmpeg-devel/2010-July/088844.html

Current m2ts output mode only adds extra transport header with more
or less incorrect timestamp. So, it is not "real" m2ts but plain
mpeg-ts with an extra header.

I think remuxing m2ts->m2ts should be quite easy to implement:
- Assign proper pids (in m2ts pids are fixed)
- Allow PCR in separate PID, without any stream/payload
- Fix PES headers (at least audio stream PES
  headers seem to be incorrect)
- Check if PAT and SI are correctly created
- Check/fix PCR/PAT/SI timings
- Fix generating ATC (or output just plain .ts without ATC)
- Add proper descriptors to PMT
- Pad output file to N*32 packets

There's probably something else too, but those issues were "easy" to
spot from mpegtsenc.c.

What would be the use case for m2ts output ? Authoring / modifying
BluRay discs ?
For BluRay use one should note that also associated metadata files
(.clpi, possibly also .mpls) become invalid and need to be re-created.


- Petri

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


[FFmpeg-devel] [PATCH 3/3] avformat/img2dec: remove special case for custom io contexts

2015-04-21 Thread Michael Niedermayer
its not needed anymore

Signed-off-by: Michael Niedermayer 
---
 libavformat/img2dec.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 5fc5b83..5da06b7 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -341,10 +341,8 @@ int ff_img_read_header(AVFormatContext *s1)
 break;
 }
 }
-if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
-avio_seek(s1->pb, 0, SEEK_SET);
-} else
-ffio_rewind_with_probe_data(s1->pb, &probe_buffer, 
probe_buffer_size);
+
+ffio_rewind_with_probe_data(s1->pb, &probe_buffer, 
probe_buffer_size);
 }
 if (st->codec->codec_id == AV_CODEC_ID_NONE)
 st->codec->codec_id = ff_guess_image2_codec(s->path);
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread Michael Niedermayer
This indicates that its safe to use av_free/av_malloc on the IO context

Signed-off-by: Michael Niedermayer 
---
 libavformat/avio.h|7 +++
 libavformat/aviobuf.c |1 +
 libavformat/segment.c |1 +
 libavformat/wtvdec.c  |3 ++-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 51913e3..73d1645 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -196,6 +196,13 @@ typedef struct AVIOContext {
  * This field is internal to libavformat and access from outside is not 
allowed.
  */
 int orig_buffer_size;
+
+/**
+ * The io buffer can be resized or freed with av_free / av_malloc.
+ * The user application does not keep a private copy of the buffer pointer
+ * which would become stale on such reallocation.
+ */
+int resizeable;
 } AVIOContext;
 
 /* unbuffered I/O */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 7de59f1..b32ff9f 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
 (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
int))h->prot->url_read_seek;
 }
 (*s)->av_class = &ff_avio_class;
+(*s)->resizeable = 1;
 return 0;
 }
 
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 1162ea2..6504b46 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
 av_free(buf);
 return AVERROR(ENOMEM);
 }
+(*ctx)->resizeable = 1;
 return 0;
 }
 
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index e226690..7b5477b 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int first_sector, 
uint64_t length, int
 av_freep(&buffer);
 av_freep(&wf->sectors);
 av_freep(&wf);
-}
+} else
+pb->resizeable = 1;
 return pb;
 }
 
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 2/3] avformat/aviobuf: Check if the IO context is resizeable before resizing

2015-04-21 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavformat/aviobuf.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index b32ff9f..3aa2b2d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -809,6 +809,8 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
 if (buf_size < filled || s->seekable)
 return 0;
 av_assert0(!s->write_flag);
+if (!s->resizeable)
+return AVERROR(EINVAL);
 
 buffer = av_malloc(buf_size);
 if (!buffer)
@@ -873,6 +875,14 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned 
char **bufp, int buf_si
 return AVERROR(EINVAL);
 }
 
+if (!s->resizeable) {
+int64_t ret = avio_seek(s, 0, SEEK_SET);
+av_freep(bufp);
+if (ret < 0)
+return ret;
+return 0;
+}
+
 overlap = buf_size - buffer_start;
 new_size = buf_size + buffer_size - overlap;
 
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 13:22:00 +0200
Michael Niedermayer  wrote:

> This indicates that its safe to use av_free/av_malloc on the IO context
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/avio.h|7 +++
>  libavformat/aviobuf.c |1 +
>  libavformat/segment.c |1 +
>  libavformat/wtvdec.c  |3 ++-
>  4 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 51913e3..73d1645 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -196,6 +196,13 @@ typedef struct AVIOContext {
>   * This field is internal to libavformat and access from outside is not 
> allowed.
>   */
>  int orig_buffer_size;
> +
> +/**
> + * The io buffer can be resized or freed with av_free / av_malloc.
> + * The user application does not keep a private copy of the buffer 
> pointer
> + * which would become stale on such reallocation.
> + */
> +int resizeable;
>  } AVIOContext;
>  
>  /* unbuffered I/O */
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 7de59f1..b32ff9f 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
>  (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
> int))h->prot->url_read_seek;
>  }
>  (*s)->av_class = &ff_avio_class;
> +(*s)->resizeable = 1;
>  return 0;
>  }
>  
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 1162ea2..6504b46 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
>  av_free(buf);
>  return AVERROR(ENOMEM);
>  }
> +(*ctx)->resizeable = 1;
>  return 0;
>  }
>  
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index e226690..7b5477b 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int 
> first_sector, uint64_t length, int
>  av_freep(&buffer);
>  av_freep(&wf->sectors);
>  av_freep(&wf);
> -}
> +} else
> +pb->resizeable = 1;
>  return pb;
>  }
>  

Isn't it already required by default that AVIOContext might resize the
buffer?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, Michael Niedermayer a écrit :
> This indicates that its safe to use av_free/av_malloc on the IO context
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/avio.h|7 +++
>  libavformat/aviobuf.c |1 +
>  libavformat/segment.c |1 +
>  libavformat/wtvdec.c  |3 ++-
>  4 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 51913e3..73d1645 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -196,6 +196,13 @@ typedef struct AVIOContext {
>   * This field is internal to libavformat and access from outside is not 
> allowed.
>   */
>  int orig_buffer_size;
> +
> +/**
> + * The io buffer can be resized or freed with av_free / av_malloc.
> + * The user application does not keep a private copy of the buffer 
> pointer
> + * which would become stale on such reallocation.
> + */
> +int resizeable;

I suspect you should replace av_malloc() with av_realloc(). For example,
aviobuf.c uses av_realloc(); buffers created with av_malloc() can not
officially be used with av_realloc().

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 13:22:00 +0200
Michael Niedermayer  wrote:

> This indicates that its safe to use av_free/av_malloc on the IO context
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/avio.h|7 +++
>  libavformat/aviobuf.c |1 +
>  libavformat/segment.c |1 +
>  libavformat/wtvdec.c  |3 ++-
>  4 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 51913e3..73d1645 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -196,6 +196,13 @@ typedef struct AVIOContext {
>   * This field is internal to libavformat and access from outside is not 
> allowed.
>   */
>  int orig_buffer_size;
> +
> +/**
> + * The io buffer can be resized or freed with av_free / av_malloc.
> + * The user application does not keep a private copy of the buffer 
> pointer
> + * which would become stale on such reallocation.
> + */
> +int resizeable;
>  } AVIOContext;
>  
>  /* unbuffered I/O */
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 7de59f1..b32ff9f 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
>  (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
> int))h->prot->url_read_seek;
>  }
>  (*s)->av_class = &ff_avio_class;
> +(*s)->resizeable = 1;
>  return 0;
>  }
>  
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 1162ea2..6504b46 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
>  av_free(buf);
>  return AVERROR(ENOMEM);
>  }
> +(*ctx)->resizeable = 1;
>  return 0;
>  }
>  
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index e226690..7b5477b 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int 
> first_sector, uint64_t length, int
>  av_freep(&buffer);
>  av_freep(&wf->sectors);
>  av_freep(&wf);
> -}
> +} else
> +pb->resizeable = 1;
>  return pb;
>  }
>  

Looking at it again, ffio_ensure_seekback and ffio_set_buf_size are
functions which resize the buffer (but by allocating a new buffer to
avoid av_realloc incompatibility, as Nicolas pointed out).

So what's the point of this patch?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 01:52:05PM +0200, wm4 wrote:
> On Tue, 21 Apr 2015 13:22:00 +0200
> Michael Niedermayer  wrote:
> 
> > This indicates that its safe to use av_free/av_malloc on the IO context
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/avio.h|7 +++
> >  libavformat/aviobuf.c |1 +
> >  libavformat/segment.c |1 +
> >  libavformat/wtvdec.c  |3 ++-
> >  4 files changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/avio.h b/libavformat/avio.h
> > index 51913e3..73d1645 100644
> > --- a/libavformat/avio.h
> > +++ b/libavformat/avio.h
> > @@ -196,6 +196,13 @@ typedef struct AVIOContext {
> >   * This field is internal to libavformat and access from outside is 
> > not allowed.
> >   */
> >  int orig_buffer_size;
> > +
> > +/**
> > + * The io buffer can be resized or freed with av_free / av_malloc.
> > + * The user application does not keep a private copy of the buffer 
> > pointer
> > + * which would become stale on such reallocation.
> > + */
> > +int resizeable;
> >  } AVIOContext;
> >  
> >  /* unbuffered I/O */
> > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > index 7de59f1..b32ff9f 100644
> > --- a/libavformat/aviobuf.c
> > +++ b/libavformat/aviobuf.c
> > @@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
> >  (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
> > int))h->prot->url_read_seek;
> >  }
> >  (*s)->av_class = &ff_avio_class;
> > +(*s)->resizeable = 1;
> >  return 0;
> >  }
> >  
> > diff --git a/libavformat/segment.c b/libavformat/segment.c
> > index 1162ea2..6504b46 100644
> > --- a/libavformat/segment.c
> > +++ b/libavformat/segment.c
> > @@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
> >  av_free(buf);
> >  return AVERROR(ENOMEM);
> >  }
> > +(*ctx)->resizeable = 1;
> >  return 0;
> >  }
> >  
> > diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> > index e226690..7b5477b 100644
> > --- a/libavformat/wtvdec.c
> > +++ b/libavformat/wtvdec.c
> > @@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int 
> > first_sector, uint64_t length, int
> >  av_freep(&buffer);
> >  av_freep(&wf->sectors);
> >  av_freep(&wf);
> > -}
> > +} else
> > +pb->resizeable = 1;
> >  return pb;
> >  }
> >  
> 
> Isn't it already required by default that AVIOContext might resize the
> buffer?

technically yes, but theres alot of code, well possibly most code
using it that gets this wrong (videolan is one) and the consequences
are rather bad (double free and such)
so i think its better i we dont assume that the buffer can be resized
by default

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 14:37:36 +0200
Michael Niedermayer  wrote:

> On Tue, Apr 21, 2015 at 01:52:05PM +0200, wm4 wrote:
> > On Tue, 21 Apr 2015 13:22:00 +0200
> > Michael Niedermayer  wrote:
> > 
> > > This indicates that its safe to use av_free/av_malloc on the IO context
> > > 
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavformat/avio.h|7 +++
> > >  libavformat/aviobuf.c |1 +
> > >  libavformat/segment.c |1 +
> > >  libavformat/wtvdec.c  |3 ++-
> > >  4 files changed, 11 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/libavformat/avio.h b/libavformat/avio.h
> > > index 51913e3..73d1645 100644
> > > --- a/libavformat/avio.h
> > > +++ b/libavformat/avio.h
> > > @@ -196,6 +196,13 @@ typedef struct AVIOContext {
> > >   * This field is internal to libavformat and access from outside is 
> > > not allowed.
> > >   */
> > >  int orig_buffer_size;
> > > +
> > > +/**
> > > + * The io buffer can be resized or freed with av_free / av_malloc.
> > > + * The user application does not keep a private copy of the buffer 
> > > pointer
> > > + * which would become stale on such reallocation.
> > > + */
> > > +int resizeable;
> > >  } AVIOContext;
> > >  
> > >  /* unbuffered I/O */
> > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > > index 7de59f1..b32ff9f 100644
> > > --- a/libavformat/aviobuf.c
> > > +++ b/libavformat/aviobuf.c
> > > @@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
> > >  (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
> > > int))h->prot->url_read_seek;
> > >  }
> > >  (*s)->av_class = &ff_avio_class;
> > > +(*s)->resizeable = 1;
> > >  return 0;
> > >  }
> > >  
> > > diff --git a/libavformat/segment.c b/libavformat/segment.c
> > > index 1162ea2..6504b46 100644
> > > --- a/libavformat/segment.c
> > > +++ b/libavformat/segment.c
> > > @@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
> > >  av_free(buf);
> > >  return AVERROR(ENOMEM);
> > >  }
> > > +(*ctx)->resizeable = 1;
> > >  return 0;
> > >  }
> > >  
> > > diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> > > index e226690..7b5477b 100644
> > > --- a/libavformat/wtvdec.c
> > > +++ b/libavformat/wtvdec.c
> > > @@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int 
> > > first_sector, uint64_t length, int
> > >  av_freep(&buffer);
> > >  av_freep(&wf->sectors);
> > >  av_freep(&wf);
> > > -}
> > > +} else
> > > +pb->resizeable = 1;
> > >  return pb;
> > >  }
> > >  
> > 
> > Isn't it already required by default that AVIOContext might resize the
> > buffer?
> 
> technically yes, but theres alot of code, well possibly most code
> using it that gets this wrong (videolan is one) and the consequences
> are rather bad (double free and such)
> so i think its better i we dont assume that the buffer can be resized
> by default
> 
> [...]
> 

That comes a bit late. Wouldn't it be better to free the user from the
responsibility of allocating this buffer entirely?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 02:03:43PM +0200, Nicolas George wrote:
> Le duodi 2 floréal, an CCXXIII, Michael Niedermayer a écrit :
> > This indicates that its safe to use av_free/av_malloc on the IO context
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/avio.h|7 +++
> >  libavformat/aviobuf.c |1 +
> >  libavformat/segment.c |1 +
> >  libavformat/wtvdec.c  |3 ++-
> >  4 files changed, 11 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/avio.h b/libavformat/avio.h
> > index 51913e3..73d1645 100644
> > --- a/libavformat/avio.h
> > +++ b/libavformat/avio.h
> > @@ -196,6 +196,13 @@ typedef struct AVIOContext {
> >   * This field is internal to libavformat and access from outside is 
> > not allowed.
> >   */
> >  int orig_buffer_size;
> > +
> > +/**
> > + * The io buffer can be resized or freed with av_free / av_malloc.
> > + * The user application does not keep a private copy of the buffer 
> > pointer
> > + * which would become stale on such reallocation.
> > + */
> > +int resizeable;
> 
> I suspect you should replace av_malloc() with av_realloc(). For example,

the API requires av_malloc(), this is documented in the
avio_alloc_context() doxy


> aviobuf.c uses av_realloc(); buffers created with av_malloc() can not
> officially be used with av_realloc().

[...]

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


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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/avio: add resizeable field to AVIOContext

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 02:41:15PM +0200, wm4 wrote:
> On Tue, 21 Apr 2015 14:37:36 +0200
> Michael Niedermayer  wrote:
> 
> > On Tue, Apr 21, 2015 at 01:52:05PM +0200, wm4 wrote:
> > > On Tue, 21 Apr 2015 13:22:00 +0200
> > > Michael Niedermayer  wrote:
> > > 
> > > > This indicates that its safe to use av_free/av_malloc on the IO context
> > > > 
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >  libavformat/avio.h|7 +++
> > > >  libavformat/aviobuf.c |1 +
> > > >  libavformat/segment.c |1 +
> > > >  libavformat/wtvdec.c  |3 ++-
> > > >  4 files changed, 11 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/libavformat/avio.h b/libavformat/avio.h
> > > > index 51913e3..73d1645 100644
> > > > --- a/libavformat/avio.h
> > > > +++ b/libavformat/avio.h
> > > > @@ -196,6 +196,13 @@ typedef struct AVIOContext {
> > > >   * This field is internal to libavformat and access from outside 
> > > > is not allowed.
> > > >   */
> > > >  int orig_buffer_size;
> > > > +
> > > > +/**
> > > > + * The io buffer can be resized or freed with av_free / av_malloc.
> > > > + * The user application does not keep a private copy of the buffer 
> > > > pointer
> > > > + * which would become stale on such reallocation.
> > > > + */
> > > > +int resizeable;
> > > >  } AVIOContext;
> > > >  
> > > >  /* unbuffered I/O */
> > > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > > > index 7de59f1..b32ff9f 100644
> > > > --- a/libavformat/aviobuf.c
> > > > +++ b/libavformat/aviobuf.c
> > > > @@ -793,6 +793,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
> > > >  (*s)->read_seek  = (int64_t (*)(void *, int, int64_t, 
> > > > int))h->prot->url_read_seek;
> > > >  }
> > > >  (*s)->av_class = &ff_avio_class;
> > > > +(*s)->resizeable = 1;
> > > >  return 0;
> > > >  }
> > > >  
> > > > diff --git a/libavformat/segment.c b/libavformat/segment.c
> > > > index 1162ea2..6504b46 100644
> > > > --- a/libavformat/segment.c
> > > > +++ b/libavformat/segment.c
> > > > @@ -511,6 +511,7 @@ static int open_null_ctx(AVIOContext **ctx)
> > > >  av_free(buf);
> > > >  return AVERROR(ENOMEM);
> > > >  }
> > > > +(*ctx)->resizeable = 1;
> > > >  return 0;
> > > >  }
> > > >  
> > > > diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> > > > index e226690..7b5477b 100644
> > > > --- a/libavformat/wtvdec.c
> > > > +++ b/libavformat/wtvdec.c
> > > > @@ -243,7 +243,8 @@ static AVIOContext * wtvfile_open_sector(int 
> > > > first_sector, uint64_t length, int
> > > >  av_freep(&buffer);
> > > >  av_freep(&wf->sectors);
> > > >  av_freep(&wf);
> > > > -}
> > > > +} else
> > > > +pb->resizeable = 1;
> > > >  return pb;
> > > >  }
> > > >  
> > > 
> > > Isn't it already required by default that AVIOContext might resize the
> > > buffer?
> > 
> > technically yes, but theres alot of code, well possibly most code
> > using it that gets this wrong (videolan is one) and the consequences
> > are rather bad (double free and such)
> > so i think its better i we dont assume that the buffer can be resized
> > by default
> > 
> > [...]
> > 
> 
> That comes a bit late. Wouldn't it be better to free the user from the
> responsibility of allocating this buffer entirely?

yes this was easily possible through the use of a custom URLProtocol
and as far as my oppinion is concerned, i do want URLProtocol and
all other things like AVFilters AVIn/OutputFormats, ... to be
creatable by user applications ...

Also simple user apps dont need to create the buffer anyway, ffmpeg*c
ffplay*c and most of our examples do not do. But that limits them
to the existing URLProtocols for IO which is a problem for many user
apps i think

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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


[FFmpeg-devel] [PATCH] avutil/mem: remove av_realloc / av_malloc incompatibility warning

2015-04-21 Thread Michael Niedermayer
memalign() is not guranteed to be compatible with free() or realloc()
and for platforms in this category we have --enable-memalign-hack
(which should be enabled automatically if such system is detected)
Trying to somehow half support systems that can free() memalign memory
but not reallocate it seems not worth the amount of work needed to
keep 2 then incompatible allocation systems and ensure their
seperation. That is unless this would affect a major platform
on which we want to avoid the memalign hack code

Signed-off-by: Michael Niedermayer 
---
 libavutil/mem.h |   24 
 1 file changed, 24 deletions(-)

diff --git a/libavutil/mem.h b/libavutil/mem.h
index 2a1e36d..761d3c6 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -107,12 +107,6 @@ av_alloc_size(1, 2) static inline void 
*av_malloc_array(size_t nmemb, size_t siz
  * reallocated.
  * @return Pointer to a newly-reallocated block or NULL if the block
  * cannot be reallocated or the function is used to free the memory block.
- * @warning Pointers originating from the av_malloc() family of functions must
- *  not be passed to av_realloc(). The former can be implemented using
- *  memalign() (or other functions), and there is no guarantee that
- *  pointers from such functions can be passed to realloc() at all.
- *  The situation is undefined according to POSIX and may crash with
- *  some libc implementations.
  * @see av_fast_realloc()
  */
 void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
@@ -137,12 +131,6 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
  * @param   size Size in bytes for the memory block to be allocated or
  *  reallocated
  * @return  Zero on success, an AVERROR error code on failure.
- * @warning Pointers originating from the av_malloc() family of functions must
- *  not be passed to av_reallocp(). The former can be implemented using
- *  memalign() (or other functions), and there is no guarantee that
- *  pointers from such functions can be passed to realloc() at all.
- *  The situation is undefined according to POSIX and may crash with
- *  some libc implementations.
  */
 int av_reallocp(void *ptr, size_t size);
 
@@ -156,12 +144,6 @@ int av_reallocp(void *ptr, size_t size);
  * @param size Size of the single element
  * @return Pointer to a newly-reallocated block or NULL if the block
  * cannot be reallocated or the function is used to free the memory block.
- * @warning Pointers originating from the av_malloc() family of functions must
- *  not be passed to av_realloc(). The former can be implemented using
- *  memalign() (or other functions), and there is no guarantee that
- *  pointers from such functions can be passed to realloc() at all.
- *  The situation is undefined according to POSIX and may crash with
- *  some libc implementations.
  */
 av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t 
size);
 
@@ -175,12 +157,6 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, 
size_t nmemb, size_t size)
  * @param nmemb Number of elements
  * @param size Size of the single element
  * @return Zero on success, an AVERROR error code on failure.
- * @warning Pointers originating from the av_malloc() family of functions must
- *  not be passed to av_realloc(). The former can be implemented using
- *  memalign() (or other functions), and there is no guarantee that
- *  pointers from such functions can be passed to realloc() at all.
- *  The situation is undefined according to POSIX and may crash with
- *  some libc implementations.
  */
 av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t 
size);
 
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH] avutil/mem: remove av_realloc / av_malloc incompatibility warning

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 15:12:36 +0200
Michael Niedermayer  wrote:

> memalign() is not guranteed to be compatible with free() or realloc()
> and for platforms in this category we have --enable-memalign-hack
> (which should be enabled automatically if such system is detected)
> Trying to somehow half support systems that can free() memalign memory
> but not reallocate it seems not worth the amount of work needed to
> keep 2 then incompatible allocation systems and ensure their
> seperation. That is unless this would affect a major platform
> on which we want to avoid the memalign hack code

Isn't the problem that realloc() doesn't keep the alignment?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/mem: remove av_realloc / av_malloc incompatibility warning

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, wm4 a écrit :
> Isn't the problem that realloc() doesn't keep the alignment?

No. That problem exists too, but is irrelevant for the current code base:
there has been one bug of that kind about three years ago, AFAIK that is
all.

The problem that was addressed here was that, officially according to POSIX,
using realloc() on a buffer returned by posix_memalign() is an undefined
behaviour. In practice, we had quite a few of these cases but that never
caused any problem.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avutil/mem: remove av_realloc / av_malloc incompatibility warning

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 03:43:59PM +0200, Nicolas George wrote:
> Le duodi 2 floréal, an CCXXIII, wm4 a écrit :
> > Isn't the problem that realloc() doesn't keep the alignment?
> 
> No. That problem exists too, but is irrelevant for the current code base:
> there has been one bug of that kind about three years ago, AFAIK that is
> all.

the only case iam aware of was some memory debugger which crashed
when realloc & malloc where mixed (thats clearly a bug in the debugger
as it should never crash, warn / fail maybe but not crash)

[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] [PATCH] avutil/mem: remove av_realloc / av_malloc incompatibility warning

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, Michael Niedermayer a écrit :
> the only case iam aware of was some memory debugger which crashed
> when realloc & malloc where mixed (thats clearly a bug in the debugger
> as it should never crash, warn / fail maybe but not crash)

I was referring to this one:

commit a5704659e3e41b7698812b89f67d9a7467a74d20
Author: Nicolas George 
Date:   2012-08-28 18:15:49 +0200

lavfi/af_atempo: use av_malloc for rDFT buffers.

Memory obtained from av_realloc is not aligned enough for AVX.
The other similar allocations are changed too because they use
the same macro. The buffers were cleared afterwards anyway.

Fix trac ticket #1692.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Pedro Arthur
Patch which adds support for gamma correct scaling in libswscale.
From fe34ea493ffae9b6c1655112a66b5e0c4cfef26d Mon Sep 17 00:00:00 2001
From: Pedro Arthur 
Date: Fri, 17 Apr 2015 17:08:42 -0300
Subject: [PATCH] Add gamma encodign/decoding before/after scaling in
 libswscale

---
 libswscale/options.c  |  3 ++
 libswscale/swscale.c  | 51 
 libswscale/swscale.h  |  1 +
 libswscale/swscale_internal.h |  9 -
 libswscale/utils.c| 77 +++
 5 files changed, 140 insertions(+), 1 deletion(-)

diff --git a/libswscale/options.c b/libswscale/options.c
index 4d49c3e..f08267c 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -75,6 +75,9 @@ static const AVOption swscale_options[] = {
 { "ed",  "error diffusion",   0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_ED  }, INT_MIN, INT_MAX,VE, "sws_dither" },
 { "a_dither","arithmetic addition dither",0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_A_DITHER}, INT_MIN, INT_MAX,VE, "sws_dither" },
 { "x_dither","arithmetic xor dither", 0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_X_DITHER}, INT_MIN, INT_MAX,VE, "sws_dither" },
+{ "gamma",   "gamma correct scaling", OFFSET(gamma_flag),AV_OPT_TYPE_INT,{ .i64  = 0  }, 0,   INT_MAX,VE, "gamma" },
+{ "true","enable",0, AV_OPT_TYPE_CONST,  { .i64  = 1  }, INT_MIN, INT_MAX,VE, "gamma" },
+{ "false",   "disable",   0, AV_OPT_TYPE_CONST,  { .i64  = 0  }, INT_MIN, INT_MAX,VE, "gamma" },
 
 { NULL }
 };
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index dff44dd..9c36c18 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -52,6 +52,22 @@ DECLARE_ALIGNED(8, static const uint8_t, sws_pb_64)[8] = {
 64, 64, 64, 64, 64, 64, 64, 64
 };
 
+static void gamma_convert(uint8_t * src[], int width, uint16_t *gamma)
+{
+int i;
+uint16_t *src1 = (uint16_t*)src[0];
+
+for (i = 0; i < width; ++i) {
+uint16_t r = AV_RL16(src1 + i*4 + 0);
+uint16_t g = AV_RL16(src1 + i*4 + 1);
+uint16_t b = AV_RL16(src1 + i*4 + 2);
+
+AV_WL16(src1 + i*4 + 0, gamma[r]);
+AV_WL16(src1 + i*4 + 1, gamma[g]);
+AV_WL16(src1 + i*4 + 2, gamma[b]);
+}
+}
+
 static av_always_inline void fillPlane(uint8_t *plane, int stride, int width,
int height, int y, uint8_t val)
 {
@@ -353,6 +369,8 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 int chrBufIndex  = c->chrBufIndex;
 int lastInLumBuf = c->lastInLumBuf;
 int lastInChrBuf = c->lastInChrBuf;
+int perform_gamma = c->gamma_flag && (c->srcH != c->dstH || c->srcW != dstW);
+
 
 if (!usePal(c->srcFormat)) {
 pal = c->input_rgb2yuv_table;
@@ -480,6 +498,10 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 av_assert0(lumBufIndex < 2 * vLumBufSize);
 av_assert0(lastInLumBuf + 1 - srcSliceY < srcSliceH);
 av_assert0(lastInLumBuf + 1 - srcSliceY >= 0);
+
+if (perform_gamma)
+gamma_convert((uint8_t **)src1, srcW, c->inv_gamma);
+
 hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
 hLumFilter, hLumFilterPos, hLumFilterSize,
 formatConvBuffer, pal, 0);
@@ -641,6 +663,8 @@ static int swscale(SwsContext *c, const uint8_t *src[],
  chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
  alpSrcPtr, dest, dstW, dstY);
 }
+if (perform_gamma)
+gamma_convert(dest, dstW, c->gamma);
 }
 }
 if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) {
@@ -900,6 +924,33 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
 av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
 return 0;
 }
+
+if (c->gamma_flag && c->cascaded_context[0]) {
+
+
+ret = sws_scale(c->cascaded_context[0],
+srcSlice, srcStride, srcSliceY, srcSliceH,
+c->cascaded_tmp, c->cascaded_tmpStride);
+
+if (ret < 0)
+return ret;
+
+if (c->cascaded_context[2])
+ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride);
+else 
+ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride);
+
+if (ret < 0)
+return ret;
+
+if (c->cascaded_conte

Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, Pedro Arthur a écrit :
> Subject: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct

"sws: add support for gamma-correct scaling"

> +{ "true","enable",0, 
> AV_OPT_TYPE_CONST,  { .i64  = 1  }, INT_MIN, INT_MAX,
> VE, "gamma" },
> +{ "false",   "disable",   0, 
> AV_OPT_TYPE_CONST,  { .i64  = 0  }, INT_MIN, INT_MAX,
> VE, "gamma" },

This is not usually done.

> +float gamma_value;

> +static uint16_t * alloc_gamma_tbl(float e)

> +tbl[i] = (int) (pow( ((float)i)/65535.f, e) * 65535.f);

Do you have reasons to use float specifically? AFAIK, except when memory
consumption is relevant (i.e. large arrays), double should be preferred.

This is especially true in your last formula: you force i to float, you
force 65535 to float, but you use pow() rather than powf().

The cast to int seems dubious too, since your array is uint16_t.

IMHO, just use a double argument and write:

tbl[i] = pow(i / 65535.0, e) * 65535.0);

More readable, less confusing for the compiler.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 12:07:54PM -0300, Pedro Arthur wrote:
> Patch which adds support for gamma correct scaling in libswscale.

>  options.c  |3 ++
>  swscale.c  |   51 +++
>  swscale.h  |1 
>  swscale_internal.h |9 +-
>  utils.c|   77 
> +
>  5 files changed, 140 insertions(+), 1 deletion(-)
> 1d46073b1193535dc8a26b68da126b355251443b  
> 0001-Add-gamma-encodign-decoding-before-after-scaling-in-.patch
> From fe34ea493ffae9b6c1655112a66b5e0c4cfef26d Mon Sep 17 00:00:00 2001
> From: Pedro Arthur 
> Date: Fri, 17 Apr 2015 17:08:42 -0300
> Subject: [PATCH] Add gamma encodign/decoding before/after scaling in
>  libswscale

review sent privatly a few minutes before i saw it on the mailing
list

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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


Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Kevin Wheatley
Pedro

I understand the desire to 'degamma' images prior to scaling, I'd be
interested in understanding how this could work with the colour_trc
options rather than only assuming a simple gamma.

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


Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Pedro Arthur
I intended to fetch the correct gamma value from the video/image metada
or pass it by flag (like gamma=x) but yet I don't know how to get the
correct gamma based on the input, thus for now it is hardcode.

2015-04-21 12:31 GMT-03:00 Kevin Wheatley :

> Pedro
>
> I understand the desire to 'degamma' images prior to scaling, I'd be
> interested in understanding how this could work with the colour_trc
> options rather than only assuming a simple gamma.
>
> Kevin
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [libav-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2015-04-21 Thread Andreas Cadhalpun
On 21.04.2015 02:20, Claudio Freire wrote:
> On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  wrote:
>> On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
>>> On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire  
>>> wrote:
 On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
  wrote:
 The long version:

 ath should approximate the shape of the absolute hearing threshold, so
 yes, it's best if it really uses the minimum, since that will prevent
 clipping of the ath curve and result in a more accurate threshold
 computation.
>>>
>>> So you agree with my patch fixing minath?
>>> Or would you prefer a version with:
>>> minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)
>>
>> Well, that's not really closer to the minimum (a few tests with gnuplot 
>> say).
>
> Are you sure your plots were done correctly?
> Because I'm quite sure this is the correct first order approximation
> of the minimum.
>
> For ATH_ADD = 4 this gives 3407.068, which is quite close to Michael's 
> value
> (3407.080774800152).

 I checked the formula several times, but still, I could have made a 
 mistake.
>>>
>>>
>>> This is what I did if you want to check it out (maybe you spot the mistake)
>>>
>>> gnuplot> ath(f,a) = _ath(f/1000.0, a)
>>> gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
>>> (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
>>> 0.001 * f * f * f
>>   ^^
>> missing * f
> 
> Much better now :)
> 
> So yes. I'd say it's a good change.

OK, patch attached.

Best regards,
Andreas

>From c1ec8336f7de45b1919e3f76ee979c47a28ca33e Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun 
Date: Tue, 21 Apr 2015 18:43:55 +0200
Subject: [PATCH] aacpsy: correct calculation of minath in psy_3gpp_init

The minimum of the ath(x, ATH_ADD) function depends on ATH_ADD.
This patch uses the first order approximation to determine it.

For ATH_ADD = 4 this results in the value at 3407.06812 (-5.24241638)
not the one at 3410 (-5.24237967).

Signed-off-by: Andreas Cadhalpun 
---
 libavcodec/aacpsy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 7205ee3..49ff3fe 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -313,7 +313,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
 ctx->bitres.size   = 6144 - pctx->frame_bits;
 ctx->bitres.size  -= ctx->bitres.size % 8;
 pctx->fill_level   = ctx->bitres.size;
-minath = ath(3410, ATH_ADD);
+minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD);
 for (j = 0; j < 2; j++) {
 AacPsyCoeffs *coeffs = pctx->psy_coef[j];
 const uint8_t *band_sizes = ctx->bands[j];
-- 
2.1.4

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


Re: [FFmpeg-devel] [libav-devel] [PATCH] alsdec: validate time diff index

2015-04-21 Thread Andreas Cadhalpun
On 21.04.2015 08:14, Thilo Borgmann wrote:
> Am 20.04.15 um 23:20 schrieb Andreas Cadhalpun:
>> On 19.04.2015 22:20, Luca Barbato wrote:
>>> I'd check that `master` is always between `raw_buffer` and the end of it.
>>
>> You mean something like the attached patch?
>>
>>> (I'm not sure if `div_blocks` is validated before, same for `offset`)
>>
>> That should catch problems in those as well.
> 
> Have you tested with fate after applying this patch locally?

Yes, but only on amd64, where fate passes.

Attached is a new patch, which should work everywhere.

Best regards,
Andreas

>From 9063f33f9787940175428a76a79995bbfee34dd7 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun 
Date: Tue, 21 Apr 2015 19:25:50 +0200
Subject: [PATCH] alsdec: check sample pointer range in
 revert_channel_correlation

Also change the type of begin, end and smp to ptrdiff_t to make the
comparison well-defined.

Signed-off-by: Andreas Cadhalpun 
---
 libavcodec/alsdec.c | 34 +++---
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index c81db18..e34cf6e 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1246,6 +1246,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
 ALSChannelData *ch = cd[c];
 unsigned int   dep = 0;
 unsigned int channels = ctx->avctx->channels;
+unsigned int channel_size = ctx->sconf.frame_length + ctx->sconf.max_order;
 
 if (reverted[c])
 return 0;
@@ -1276,9 +1277,9 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
 bd->raw_samples = ctx->raw_samples[c] + offset;
 
 for (dep = 0; !ch[dep].stop_flag; dep++) {
-unsigned int smp;
-unsigned int begin = 1;
-unsigned int end   = bd->block_length - 1;
+ptrdiff_t smp;
+ptrdiff_t begin = 1;
+ptrdiff_t end   = bd->block_length - 1;
 int64_t y;
 int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;
 
@@ -1290,19 +1291,28 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
 
 if (ch[dep].time_diff_sign) {
 t  = -t;
-if (t > 0 && begin < t) {
-av_log(ctx->avctx, AV_LOG_ERROR, "begin %u smaller than time diff index %d.\n", begin, t);
+if (begin < t) {
+av_log(ctx->avctx, AV_LOG_ERROR, "begin %td smaller than time diff index %d.\n", begin, t);
 return AVERROR_INVALIDDATA;
 }
 begin -= t;
 } else {
-if (t > 0 && end < t) {
-av_log(ctx->avctx, AV_LOG_ERROR, "end %u smaller than time diff index %d.\n", end, t);
+if (end < t) {
+av_log(ctx->avctx, AV_LOG_ERROR, "end %td smaller than time diff index %d.\n", end, t);
 return AVERROR_INVALIDDATA;
 }
 end   -= t;
 }
 
+if (FFMIN(begin - 1, begin - 1 + t) < ctx->raw_buffer - master ||
+FFMAX(end   + 1,   end + 1 + t) > ctx->raw_buffer + channels * channel_size - master) {
+av_log(ctx->avctx, AV_LOG_ERROR,
+   "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
+   master + FFMIN(begin - 1, begin - 1 + t), master + FFMAX(end + 1,   end + 1 + t),
+   ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
+return AVERROR_INVALIDDATA;
+}
+
 for (smp = begin; smp < end; smp++) {
 y  = (1 << 6) +
  MUL64(ch[dep].weighting[0], master[smp - 1]) +
@@ -1315,6 +1325,16 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
 bd->raw_samples[smp] += y >> 7;
 }
 } else {
+
+if (begin - 1 < ctx->raw_buffer - master ||
+end   + 1 > ctx->raw_buffer + channels * channel_size - master) {
+av_log(ctx->avctx, AV_LOG_ERROR,
+   "sample pointer range [%p, %p] not contained in raw_buffer [%p, %p].\n",
+   master + begin - 1, master + end + 1,
+   ctx->raw_buffer, ctx->raw_buffer + channels * channel_size);
+return AVERROR_INVALIDDATA;
+}
+
 for (smp = begin; smp < end; smp++) {
 y  = (1 << 6) +
  MUL64(ch[dep].weighting[0], master[smp - 1]) +
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 1/5] avformat: add common mechanism for skipping samples at the start of file

2015-04-21 Thread wm4
This makes using the generic indexing code with mp3 easier at a later
point.
---
 libavformat/avformat.h | 8 
 libavformat/utils.c| 4 
 2 files changed, 12 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 514e646..93cfb20 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1083,6 +1083,14 @@ typedef struct AVStream {
 int skip_samples;
 
 /**
+ * The number of samples that should be skipped from the start of the 
stream
+ * (i.e. the timestamp of the first sample that should be actually output).
+ * Intended for use with formats such as mp3 with ad-hoc gapless audio
+ * support. It is assumed that negative timestamps do not exist.
+ */
+int64_t start_skip_samples;
+
+/**
  * If not 0, the first audio sample that should be discarded from the 
stream.
  * This is broken by design (needs global sample count), but can't be
  * avoided for broken by design formats such as mp3 with ad-hoc gapless
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 950b3c6..2f6122d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1416,6 +1416,8 @@ static int read_frame_internal(AVFormatContext *s, 
AVPacket *pkt)
 sample < st->last_discard_sample)
 discard_padding = FFMIN(end_sample - st->first_discard_sample, 
duration);
 }
+if (st->start_skip_samples && (pkt->pts == 0 || pkt->pts == 
RELATIVE_TS_BASE))
+st->skip_samples = st->start_skip_samples;
 if (st->skip_samples || discard_padding) {
 uint8_t *p = av_packet_new_side_data(pkt, 
AV_PKT_DATA_SKIP_SAMPLES, 10);
 if (p) {
@@ -1645,6 +1647,8 @@ void ff_read_frame_flush(AVFormatContext *s)
 
 if (s->internal->inject_global_side_data)
 st->inject_global_side_data = 1;
+
+st->skip_samples = 0;
 }
 }
 
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 5/5] fate: gapless: remove useless tests

2015-04-21 Thread wm4
These could be kept, but they are not overly useful. The only thing they
had over the remaining mp3 gapless test was seeking, which was incorrect
in both modes they used.
---
 tests/fate/gapless.mak   | 6 ++
 tests/ref/fate/gapless-mp3-cbr   | 5 -
 tests/ref/fate/gapless-mp3-notoc | 5 -
 3 files changed, 2 insertions(+), 14 deletions(-)
 delete mode 100644 tests/ref/fate/gapless-mp3-cbr
 delete mode 100644 tests/ref/fate/gapless-mp3-notoc

diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak
index 6860d74..2fb005f 100644
--- a/tests/fate/gapless.mak
+++ b/tests/fate/gapless.mak
@@ -1,7 +1,5 @@
-FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-cbr 
fate-gapless-mp3-notoc
-fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 "-usetoc 
2"
-fate-gapless-mp3-cbr: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 1"
-fate-gapless-mp3-notoc: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 0"
+FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3
+fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3
 
 FATE_GAPLESS = $(FATE_GAPLESS-yes)
 
diff --git a/tests/ref/fate/gapless-mp3-cbr b/tests/ref/fate/gapless-mp3-cbr
deleted file mode 100644
index 7ecc328..000
--- a/tests/ref/fate/gapless-mp3-cbr
+++ /dev/null
@@ -1,5 +0,0 @@
-d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-cbr.out-1
-c96c3ae7bd3300fd2f4debac222de5b7
-3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-cbr.out-2
-c96c3ae7bd3300fd2f4debac222de5b7
-70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3-cbr.out-3
diff --git a/tests/ref/fate/gapless-mp3-notoc b/tests/ref/fate/gapless-mp3-notoc
deleted file mode 100644
index 936d0ba..000
--- a/tests/ref/fate/gapless-mp3-notoc
+++ /dev/null
@@ -1,5 +0,0 @@
-d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-notoc.out-1
-c96c3ae7bd3300fd2f4debac222de5b7
-3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-notoc.out-2
-c96c3ae7bd3300fd2f4debac222de5b7
-92e37f050ad4fc817730c8af17ee6d1b *tests/data/fate/gapless-mp3-notoc.out-3
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode

2015-04-21 Thread wm4
"-usetoc 2" now invokes the generic seek and indexing mode. This mode
skips data until the seek target is reached, and this is exact. It also
makes gapless audio actually work if a seek past the start of the file
is involved.
---
Strange option value. On the other hand, it will be made default, so
this option will generally be used only to select the "old" seek modes.
But in general, libavformat should probably have something to switch
between slow/accurate and fast/inaccurate seeking.
---
 libavformat/mp3dec.c   | 12 +---
 tests/fate/gapless.mak |  5 +++--
 tests/ref/fate/gapless-mp3 |  5 -
 tests/ref/fate/gapless-mp3-cbr |  5 +
 4 files changed, 17 insertions(+), 10 deletions(-)
 delete mode 100644 tests/ref/fate/gapless-mp3
 create mode 100644 tests/ref/fate/gapless-mp3-cbr

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 008cb23..8a4dfbd 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t 
filesize, int64_t duration
 {
 int i;
 MP3DecContext *mp3 = s->priv_data;
-int fill_index = mp3->usetoc && duration > 0;
+int fill_index = mp3->usetoc == 1 && duration > 0;
 
 if (!filesize &&
 !(filesize = avio_size(s->pb))) {
@@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s)
 int ret;
 int i;
 
+if (mp3->usetoc < 0)
+mp3->usetoc = 0;
+
 st = avformat_new_stream(s, NULL);
 if (!st)
 return AVERROR(ENOMEM);
@@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 int64_t best_pos;
 int best_score;
 
+if (mp3->usetoc == 2)
+return -1; // generic index code
+
 if (   mp3->is_cbr
-&& (mp3->usetoc <= 0 || !mp3->xing_toc)
+&& (mp3->usetoc == 0 || !mp3->xing_toc)
 && st->duration > 0
 && mp3->header_filesize > s->internal->data_offset
 && mp3->frames) {
@@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 }
 
 static const AVOption options[] = {
-{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
+{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
 { NULL },
 };
 
diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak
index a09dac6..6860d74 100644
--- a/tests/fate/gapless.mak
+++ b/tests/fate/gapless.mak
@@ -1,5 +1,6 @@
-FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-notoc
-fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 "-usetoc 
1"
+FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-cbr 
fate-gapless-mp3-notoc
+fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 "-usetoc 
2"
+fate-gapless-mp3-cbr: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 1"
 fate-gapless-mp3-notoc: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 0"
 
 FATE_GAPLESS = $(FATE_GAPLESS-yes)
diff --git a/tests/ref/fate/gapless-mp3 b/tests/ref/fate/gapless-mp3
deleted file mode 100644
index 984ae84..000
--- a/tests/ref/fate/gapless-mp3
+++ /dev/null
@@ -1,5 +0,0 @@
-d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3.out-1
-c96c3ae7bd3300fd2f4debac222de5b7
-3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3.out-2
-c96c3ae7bd3300fd2f4debac222de5b7
-70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3.out-3
diff --git a/tests/ref/fate/gapless-mp3-cbr b/tests/ref/fate/gapless-mp3-cbr
new file mode 100644
index 000..7ecc328
--- /dev/null
+++ b/tests/ref/fate/gapless-mp3-cbr
@@ -0,0 +1,5 @@
+d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-cbr.out-1
+c96c3ae7bd3300fd2f4debac222de5b7
+3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-cbr.out-2
+c96c3ae7bd3300fd2f4debac222de5b7
+70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3-cbr.out-3
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 4/5] avformat/mp3dec: make generic index mode the default

2015-04-21 Thread wm4
It's the most useful one, because it seeks accurately, and does not
break features like gapless audio.
---
 libavformat/mp3dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 8a4dfbd..2227428 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -504,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 }
 
 static const AVOption options[] = {
-{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
+{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = 2}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
 { NULL },
 };
 
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 2/5] avformat/mp3dec: use the common mechanism for skipping samples

2015-04-21 Thread wm4
---
Feel free to squash with the previous patch if it's too fine-grained.
---
 libavformat/mp3dec.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 0604e31..008cb23 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -228,13 +228,13 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
AVStream *st,
 
 mp3->start_pad = v>>12;
 mp3->  end_pad = v&4095;
-st->skip_samples = mp3->start_pad + 528 + 1;
+st->start_skip_samples = mp3->start_pad + 528 + 1;
 if (mp3->frames) {
 st->first_discard_sample = -mp3->end_pad + 528 + 1 + mp3->frames * 
(int64_t)spf;
 st->last_discard_sample = mp3->frames * (int64_t)spf;
 }
 if (!st->start_time)
-st->start_time = av_rescale_q(st->skip_samples,
+st->start_time = av_rescale_q(st->start_skip_samples,
 (AVRational){1, c->sample_rate},
 st->time_base);
 av_log(s, AV_LOG_DEBUG, "pad %d %d\n", mp3->start_pad, mp3->  end_pad);
@@ -447,8 +447,6 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 
 ie = &st->index_entries[ret];
 } else {
-st->skip_samples = timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0;
-
 return -1;
 }
 
@@ -496,7 +494,6 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 }
 
 ff_update_cur_dts(s, st, ie->timestamp);
-st->skip_samples = ie->timestamp <= 0 ? mp3->start_pad + 528 + 1 : 0;
 return 0;
 }
 
-- 
2.1.4

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


Re: [FFmpeg-devel] [PATCH][GSoC] dshow add support for saving and loading of capture devices

2015-04-21 Thread Roger Pack
OK some verbiage nits:


+@item capture_audio_device_load
I'd suggest naming it it audio_device_load_from_filename instead.
Similar for video.

+Load an audio capture filter device from file instead of searching
+it by name. It c, if the filter
+supports the serialization of its properties to.
+To use this an audio capture source has to be specified, but it can
+be anything even fake one.

"It may load"

I'd probably say "even a fake one, but we recommend just specifying
the name of the desired device."

+If a file with the same name existed before it will be overwritten.

suggest:

If a file with the same name exists it will be overwritten.

+@item capture_audio_device_save
suggest rename to audio_device_to_filename, similar for video.

Somehow this diff changed all the line endings so it appears as if the
entire file has changed.  You can use "dos2unix" command to convert
them back then do the diff again, so we can see what really changed.

+if (file_stream)
+IStream_Release(file_stream);

I'd prefer to only have this only "once" which means either putting it
in the error:
section
or creating your own error section "error1:" and on failure say "goto
error1" or the like.

GL!

On 4/21/15, Máté Sebők  wrote:
> This patch allows for saving and loading of audio and video capture filter
> devices (and in some cases its parameters) .
> (similar to IPersistStream, but with the cleaner OleSaveToStream and
> OleLoadFromStream methods)
>
> Regards,
> Máté
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mp3dec: allow enabling generic seek mode

2015-04-21 Thread wm4
"-usetoc 2" now invokes the generic seek and indexing mode. This mode
skips data until the seek target is reached, and this is exact. It also
makes gapless audio actually work if a seek past the start of the file
is involved.
---
Oops, accidentally removed tests/ref/fate/gapless-mp3 in the previous patch.
---
 libavformat/mp3dec.c   | 12 +---
 tests/fate/gapless.mak |  5 +++--
 tests/ref/fate/gapless-mp3 |  2 +-
 tests/ref/fate/gapless-mp3-cbr |  5 +
 4 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 tests/ref/fate/gapless-mp3-cbr

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 008cb23..8a4dfbd 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t 
filesize, int64_t duration
 {
 int i;
 MP3DecContext *mp3 = s->priv_data;
-int fill_index = mp3->usetoc && duration > 0;
+int fill_index = mp3->usetoc == 1 && duration > 0;
 
 if (!filesize &&
 !(filesize = avio_size(s->pb))) {
@@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s)
 int ret;
 int i;
 
+if (mp3->usetoc < 0)
+mp3->usetoc = 0;
+
 st = avformat_new_stream(s, NULL);
 if (!st)
 return AVERROR(ENOMEM);
@@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 int64_t best_pos;
 int best_score;
 
+if (mp3->usetoc == 2)
+return -1; // generic index code
+
 if (   mp3->is_cbr
-&& (mp3->usetoc <= 0 || !mp3->xing_toc)
+&& (mp3->usetoc == 0 || !mp3->xing_toc)
 && st->duration > 0
 && mp3->header_filesize > s->internal->data_offset
 && mp3->frames) {
@@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 }
 
 static const AVOption options[] = {
-{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
+{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
 { NULL },
 };
 
diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak
index a09dac6..6860d74 100644
--- a/tests/fate/gapless.mak
+++ b/tests/fate/gapless.mak
@@ -1,5 +1,6 @@
-FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-notoc
-fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 "-usetoc 
1"
+FATE_GAPLESS-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3 fate-gapless-mp3-cbr 
fate-gapless-mp3-notoc
+fate-gapless-mp3: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 "-usetoc 
2"
+fate-gapless-mp3-cbr: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 1"
 fate-gapless-mp3-notoc: CMD = gapless $(TARGET_SAMPLES)/gapless/gapless.mp3 
"-usetoc 0"
 
 FATE_GAPLESS = $(FATE_GAPLESS-yes)
diff --git a/tests/ref/fate/gapless-mp3 b/tests/ref/fate/gapless-mp3
index 984ae84..e6a7a33 100644
--- a/tests/ref/fate/gapless-mp3
+++ b/tests/ref/fate/gapless-mp3
@@ -2,4 +2,4 @@ d5c88cf38416329a052a9b0cb140fb4c 
*tests/data/fate/gapless-mp3.out-1
 c96c3ae7bd3300fd2f4debac222de5b7
 3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3.out-2
 c96c3ae7bd3300fd2f4debac222de5b7
-70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3.out-3
+92e37f050ad4fc817730c8af17ee6d1b *tests/data/fate/gapless-mp3.out-3
diff --git a/tests/ref/fate/gapless-mp3-cbr b/tests/ref/fate/gapless-mp3-cbr
new file mode 100644
index 000..7ecc328
--- /dev/null
+++ b/tests/ref/fate/gapless-mp3-cbr
@@ -0,0 +1,5 @@
+d5c88cf38416329a052a9b0cb140fb4c *tests/data/fate/gapless-mp3-cbr.out-1
+c96c3ae7bd3300fd2f4debac222de5b7
+3386bc2009b31b7ef39247918cbb02a5 *tests/data/fate/gapless-mp3-cbr.out-2
+c96c3ae7bd3300fd2f4debac222de5b7
+70e7cd7f2b6365e7f48ed206113f06fc *tests/data/fate/gapless-mp3-cbr.out-3
-- 
2.1.4

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


Re: [FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode

2015-04-21 Thread Clément Bœsch
On Tue, Apr 21, 2015 at 09:33:52PM +0200, wm4 wrote:
> "-usetoc 2" now invokes the generic seek and indexing mode. This mode
> skips data until the seek target is reached, and this is exact. It also
> makes gapless audio actually work if a seek past the start of the file
> is involved.
> ---
> Strange option value. On the other hand, it will be made default, so
> this option will generally be used only to select the "old" seek modes.
> But in general, libavformat should probably have something to switch
> between slow/accurate and fast/inaccurate seeking.
> ---
>  libavformat/mp3dec.c   | 12 +---
>  tests/fate/gapless.mak |  5 +++--
>  tests/ref/fate/gapless-mp3 |  5 -
>  tests/ref/fate/gapless-mp3-cbr |  5 +
>  4 files changed, 17 insertions(+), 10 deletions(-)
>  delete mode 100644 tests/ref/fate/gapless-mp3
>  create mode 100644 tests/ref/fate/gapless-mp3-cbr
> 
> diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> index 008cb23..8a4dfbd 100644
> --- a/libavformat/mp3dec.c
> +++ b/libavformat/mp3dec.c
> @@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t 
> filesize, int64_t duration
>  {
>  int i;
>  MP3DecContext *mp3 = s->priv_data;
> -int fill_index = mp3->usetoc && duration > 0;
> +int fill_index = mp3->usetoc == 1 && duration > 0;
>  
>  if (!filesize &&
>  !(filesize = avio_size(s->pb))) {
> @@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s)
>  int ret;
>  int i;
>  
> +if (mp3->usetoc < 0)
> +mp3->usetoc = 0;
> +
>  st = avformat_new_stream(s, NULL);
>  if (!st)
>  return AVERROR(ENOMEM);
> @@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int 
> stream_index, int64_t timestamp,
>  int64_t best_pos;
>  int best_score;
>  
> +if (mp3->usetoc == 2)
> +return -1; // generic index code
> +
>  if (   mp3->is_cbr
> -&& (mp3->usetoc <= 0 || !mp3->xing_toc)
> +&& (mp3->usetoc == 0 || !mp3->xing_toc)
>  && st->duration > 0
>  && mp3->header_filesize > s->internal->data_offset
>  && mp3->frames) {
> @@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
> int64_t timestamp,
>  }
>  
>  static const AVOption options[] = {
> -{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
> +{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},

Can you use AV_OPT_TYPE_CONST for the different special values?

(and document it)

[...]

-- 
Clément B.


pgp_42L80KHgT.pgp
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/5] avformat/mp3dec: allow enabling generic seek mode

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 22:07:07 +0200
Clément Bœsch  wrote:

> On Tue, Apr 21, 2015 at 09:33:52PM +0200, wm4 wrote:
> > "-usetoc 2" now invokes the generic seek and indexing mode. This mode
> > skips data until the seek target is reached, and this is exact. It also
> > makes gapless audio actually work if a seek past the start of the file
> > is involved.
> > ---
> > Strange option value. On the other hand, it will be made default, so
> > this option will generally be used only to select the "old" seek modes.
> > But in general, libavformat should probably have something to switch
> > between slow/accurate and fast/inaccurate seeking.
> > ---
> >  libavformat/mp3dec.c   | 12 +---
> >  tests/fate/gapless.mak |  5 +++--
> >  tests/ref/fate/gapless-mp3 |  5 -
> >  tests/ref/fate/gapless-mp3-cbr |  5 +
> >  4 files changed, 17 insertions(+), 10 deletions(-)
> >  delete mode 100644 tests/ref/fate/gapless-mp3
> >  create mode 100644 tests/ref/fate/gapless-mp3-cbr
> > 
> > diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> > index 008cb23..8a4dfbd 100644
> > --- a/libavformat/mp3dec.c
> > +++ b/libavformat/mp3dec.c
> > @@ -110,7 +110,7 @@ static void read_xing_toc(AVFormatContext *s, int64_t 
> > filesize, int64_t duration
> >  {
> >  int i;
> >  MP3DecContext *mp3 = s->priv_data;
> > -int fill_index = mp3->usetoc && duration > 0;
> > +int fill_index = mp3->usetoc == 1 && duration > 0;
> >  
> >  if (!filesize &&
> >  !(filesize = avio_size(s->pb))) {
> > @@ -336,6 +336,9 @@ static int mp3_read_header(AVFormatContext *s)
> >  int ret;
> >  int i;
> >  
> > +if (mp3->usetoc < 0)
> > +mp3->usetoc = 0;
> > +
> >  st = avformat_new_stream(s, NULL);
> >  if (!st)
> >  return AVERROR(ENOMEM);
> > @@ -432,8 +435,11 @@ static int mp3_seek(AVFormatContext *s, int 
> > stream_index, int64_t timestamp,
> >  int64_t best_pos;
> >  int best_score;
> >  
> > +if (mp3->usetoc == 2)
> > +return -1; // generic index code
> > +
> >  if (   mp3->is_cbr
> > -&& (mp3->usetoc <= 0 || !mp3->xing_toc)
> > +&& (mp3->usetoc == 0 || !mp3->xing_toc)
> >  && st->duration > 0
> >  && mp3->header_filesize > s->internal->data_offset
> >  && mp3->frames) {
> > @@ -498,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int 
> > stream_index, int64_t timestamp,
> >  }
> >  
> >  static const AVOption options[] = {
> > -{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> > AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
> > +{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> > AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
> 
> Can you use AV_OPT_TYPE_CONST for the different special values?
> 
> (and document it)
> 
> [...]
> 

I'm not sure if it's a good idea to set this in stone. I'd much rather
have something similar to AVFMT_FLAG_IGNIDX, which can be checked by
all demuxers.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Pedro Arthur
New patch with changes.

2015-04-21 13:14 GMT-03:00 Pedro Arthur :

> I intended to fetch the correct gamma value from the video/image metada
> or pass it by flag (like gamma=x) but yet I don't know how to get the
> correct gamma based on the input, thus for now it is hardcode.
>
> 2015-04-21 12:31 GMT-03:00 Kevin Wheatley :
>
> Pedro
>>
>> I understand the desire to 'degamma' images prior to scaling, I'd be
>> interested in understanding how this could work with the colour_trc
>> options rather than only assuming a simple gamma.
>>
>> Kevin
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
>
From aff2c1c0f73e867f2aed90aa01cf3e0a1ba95261 Mon Sep 17 00:00:00 2001
From: Pedro Arthur 
Date: Fri, 17 Apr 2015 17:08:42 -0300
Subject: [PATCH] Add gamma encodign/decoding before/after scaling in
 libswscale

---
 libswscale/options.c  |  3 ++
 libswscale/swscale.c  | 51 +
 libswscale/swscale.h  |  1 +
 libswscale/swscale_internal.h |  9 -
 libswscale/utils.c| 76 +++
 5 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/libswscale/options.c b/libswscale/options.c
index 4d49c3e..f08267c 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -75,6 +75,9 @@ static const AVOption swscale_options[] = {
 { "ed",  "error diffusion",   0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_ED  }, INT_MIN, INT_MAX,VE, "sws_dither" },
 { "a_dither","arithmetic addition dither",0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_A_DITHER}, INT_MIN, INT_MAX,VE, "sws_dither" },
 { "x_dither","arithmetic xor dither", 0, AV_OPT_TYPE_CONST,  { .i64  = SWS_DITHER_X_DITHER}, INT_MIN, INT_MAX,VE, "sws_dither" },
+{ "gamma",   "gamma correct scaling", OFFSET(gamma_flag),AV_OPT_TYPE_INT,{ .i64  = 0  }, 0,   INT_MAX,VE, "gamma" },
+{ "true","enable",0, AV_OPT_TYPE_CONST,  { .i64  = 1  }, INT_MIN, INT_MAX,VE, "gamma" },
+{ "false",   "disable",   0, AV_OPT_TYPE_CONST,  { .i64  = 0  }, INT_MIN, INT_MAX,VE, "gamma" },
 
 { NULL }
 };
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index dff44dd..39dda35 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -52,6 +52,22 @@ DECLARE_ALIGNED(8, static const uint8_t, sws_pb_64)[8] = {
 64, 64, 64, 64, 64, 64, 64, 64
 };
 
+static void gamma_convert(uint8_t * src[], int width, uint16_t *gamma)
+{
+int i;
+uint16_t *src1 = (uint16_t*)src[0];
+
+for (i = 0; i < width; ++i) {
+uint16_t r = AV_RL16(src1 + i*4 + 0);
+uint16_t g = AV_RL16(src1 + i*4 + 1);
+uint16_t b = AV_RL16(src1 + i*4 + 2);
+
+AV_WL16(src1 + i*4 + 0, gamma[r]);
+AV_WL16(src1 + i*4 + 1, gamma[g]);
+AV_WL16(src1 + i*4 + 2, gamma[b]);
+}
+}
+
 static av_always_inline void fillPlane(uint8_t *plane, int stride, int width,
int height, int y, uint8_t val)
 {
@@ -353,6 +369,8 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 int chrBufIndex  = c->chrBufIndex;
 int lastInLumBuf = c->lastInLumBuf;
 int lastInChrBuf = c->lastInChrBuf;
+int perform_gamma = c->flags & SWS_GAMMA_CORRECT;
+
 
 if (!usePal(c->srcFormat)) {
 pal = c->input_rgb2yuv_table;
@@ -480,6 +498,10 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 av_assert0(lumBufIndex < 2 * vLumBufSize);
 av_assert0(lastInLumBuf + 1 - srcSliceY < srcSliceH);
 av_assert0(lastInLumBuf + 1 - srcSliceY >= 0);
+
+if (perform_gamma)
+gamma_convert((uint8_t **)src1, srcW, c->inv_gamma);
+
 hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
 hLumFilter, hLumFilterPos, hLumFilterSize,
 formatConvBuffer, pal, 0);
@@ -641,6 +663,8 @@ static int swscale(SwsContext *c, const uint8_t *src[],
  chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
  alpSrcPtr, dest, dstW, dstY);
 }
+if (perform_gamma)
+gamma_convert(dest, dstW, c->gamma);
 }
 }
 if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) {
@@ -900,6 +924,33 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
 av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
 return 0;
 }
+
+if (c->gamma_flag && c->cascaded_context[0]) {
+
+
+ret = sws_scale(c->cascaded_context[0],
+srcSlice,

[FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/acelp_vectors.c |  8 +++-
 libavcodec/adpcm.c |  2 +-
 libavcodec/alacenc.c   |  3 +--
 libavcodec/atrac3plus.c|  4 ++--
 libavcodec/dnxhdenc.c  |  2 +-
 libavcodec/dvenc.c |  2 +-
 libavcodec/ffv1.h  |  2 +-
 libavcodec/ffv1dec.c   |  3 +--
 libavcodec/g726.c  |  2 +-
 libavcodec/g729dec.c   |  2 +-
 libavcodec/golomb.h|  2 +-
 libavcodec/h264.c  |  5 ++---
 libavcodec/h264_refs.c |  2 +-
 libavcodec/hevc.c  | 26 --
 libavcodec/hevc_cabac.c|  8 
 libavcodec/hevc_filter.c   | 15 ++-
 libavcodec/hevc_mvs.c  |  4 ++--
 libavcodec/hevc_ps.c   |  4 ++--
 libavcodec/hevc_refs.c |  5 ++---
 libavcodec/hevcpred_template.c |  4 ++--
 libavcodec/mpeg12enc.c |  8 
 libavcodec/opus.h  |  2 +-
 libavcodec/opus_celt.c |  9 -
 libavcodec/proresenc_kostya.c  |  6 ++
 libavcodec/put_bits.h  |  2 +-
 libavcodec/vorbisdec.c |  5 ++---
 26 files changed, 61 insertions(+), 76 deletions(-)

diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index 86851a3..7aef8c7 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
 int pulse_count,
 int bits)
 {
-int mask = (1 << bits) - 1;
 int i;
 
 for(i=0; i>= bits;
@@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
*fixed_index,
 int half_pulse_count, int bits)
 {
 int i;
-int mask = (1 << bits) - 1;
 
 fixed_sparse->no_repeat_mask = 0;
 fixed_sparse->n = 2 * half_pulse_count;
 for (i = 0; i < half_pulse_count; i++) {
-const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
-const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
+const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
bits)] + i;
+const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
bits)] + i;
 const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
 fixed_sparse->x[2*i+1] = pos1;
 fixed_sparse->x[2*i  ] = pos2;
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 56d1660..251ed1d 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -197,7 +197,7 @@ static inline int16_t 
adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitC
 step_index = av_clip(step_index, 0, 88);
 
 sign = nibble & (1 << shift);
-delta = nibble & ((1 << shift) - 1);
+delta = av_mod_uintp2(nibble, shift);
 diff = ((2 * delta + 1) * step) >> shift;
 predictor = c->predictor;
 if (sign) predictor -= diff;
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index ce63da6..415796d 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -396,12 +396,11 @@ static void write_element(AlacEncodeContext *s,
 
 // extract extra bits if needed
 if (s->extra_bits) {
-uint32_t mask = (1 << s->extra_bits) - 1;
 for (j = 0; j < channels; j++) {
 int32_t *extra = s->predictor_buf[j];
 int32_t *smp   = s->sample_buf[j];
 for (i = 0; i < s->frame_size; i++) {
-extra[i] = smp[i] & mask;
+extra[i] = av_mod_uintp2(smp[i], s->extra_bits);
 smp[i] >>= s->extra_bits;
 }
 }
diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c
index 575a493..f998a7f 100644
--- a/libavcodec/atrac3plus.c
+++ b/libavcodec/atrac3plus.c
@@ -820,7 +820,7 @@ static void decode_qu_spectra(GetBitContext *gb, const 
Atrac3pSpecCodeTab *tab,
 int num_coeffs = tab->num_coeffs;
 int bits   = tab->bits;
 int is_signed  = tab->is_signed;
-unsigned val, mask = (1 << bits) - 1;
+unsigned val;
 
 for (pos = 0; pos < num_specs;) {
 if (group_size == 1 || get_bits1(gb)) {
@@ -828,7 +828,7 @@ static void decode_qu_spectra(GetBitContext *gb, const 
Atrac3pSpecCodeTab *tab,
 val = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
 
 for (i = 0; i < num_coeffs; i++) {
-cf = val & mask;
+cf = av_mod_uintp2(val, bits);
 if (is_signed)
 cf = sign_extend(cf, bits);
 else if (cf && get_bits1(gb))
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 005602e..90d51ff 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -450,7 +450,7 @@ static av_always_inline void 
dnxhd_encode_dc(DNXHDEncContext *ctx, int diff)
 }
 put_bits(&ctx->m.pb, ctx->cid_table->dc_bits[nbits] + nbits,
  (ctx->cid_table->dc_codes[nbits] << nbits) +
- (diff & ((1 << nbits) - 

Re: [FFmpeg-devel] [PATCH v4] libavcodec: Add FLAC API test

2015-04-21 Thread Ludmila Glinskih
Sorry for the delay, thanks for comments!

вт, 21 апр. 2015 г. в 1:40, Kieran Kunhya :

> On 20 April 2015 at 01:03, Ludmila Glinskih  wrote:
> > Signed-off-by: Ludmila Glinskih 
> > ---
> >  libavcodec/Makefile|   1 +
> >  libavcodec/api-flac-test.c | 290
> +
>
> I would put this in its own directory.
>
Do you mean libavcodec/api directory? I think the best is to put it in the
tests/api directory, but don't know how to make it (now).


> I think the next thing you should work on is a simple, shared version
> of framecrc so these tests can be integrated into FATE.
> Or you can use the framecrc in libavformat - I have no preference.
>
Now my test is running with all FATE tests, doesn't this mean, that it is
integrated?
Can you please explain to me, why framecrc is so important?


> You may need some help though from people who understand the build
> system better then me about fate integration.
>
> Kieran
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat: add AVFMT_FLAG_FASTSEEK, use it for mp3

2015-04-21 Thread wm4
---
Proposal. Is not mp3-specific, and can be reused for other formats.
---
 doc/APIchanges  | 4 
 doc/formats.texi| 2 ++
 libavformat/avformat.h  | 1 +
 libavformat/mp3dec.c| 4 ++--
 libavformat/options_table.h | 1 +
 5 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index b422e29..b65fd62 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavf 56.xx.xxx - avformat.h
+  Add AVFMT_FLAG_FAST_SEEK flag. Some formats (initially mp3) use it to enable
+  fast, but inaccurate seeking.
+
 2015-xx-xx - xxx - lavu 54.12.0
   Add AV_LOG_TRACE for extremely verbose debugging.
 
diff --git a/doc/formats.texi b/doc/formats.texi
index cbbdc10..aa39d4b 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -37,6 +37,8 @@ Possible values:
 @table @samp
 @item ignidx
 Ignore index.
+@item fastseek
+Enable fast, but inaccurate seeks for some formats.
 @item genpts
 Generate PTS.
 @item nofillin
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 93cfb20..85b5a1a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1390,6 +1390,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_SORT_DTS0x1 ///< try to interleave outputted 
packets by dts (using this flag can slow demuxing down)
 #define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
delaying codec open (this could be made default once all code is converted)
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x4 ///< Don't merge side data but keep 
it separate.
+#define AVFMT_FLAG_FAST_SEEK   0x8000 ///< Enable fast, but inaccurate seeks 
for some formats
 
 /**
  * @deprecated deprecated in favor of probesize2
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 2227428..8c17776 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -337,7 +337,7 @@ static int mp3_read_header(AVFormatContext *s)
 int i;
 
 if (mp3->usetoc < 0)
-mp3->usetoc = 0;
+mp3->usetoc = (s->flags & AVFMT_FLAG_FAST_SEEK) ? 0 : 2;
 
 st = avformat_new_stream(s, NULL);
 if (!st)
@@ -504,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
 }
 
 static const AVOption options[] = {
-{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = 2}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
+{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
 { NULL },
 };
 
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 40f1e0a..58670b0 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -49,6 +49,7 @@ static const AVOption avformat_options[] = {
 {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
 {"sortdts", "try to interleave outputted packets by dts", 0, 
AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, 
"fflags"},
 {"keepside", "don't merge side data", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
+{"fastseek", "fast but inaccurate seeks", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVFMT_FLAG_FAST_SEEK }, INT_MIN, INT_MAX, D, "fflags"},
 {"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.i64 = 
AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
 {"nobuffer", "reduce the latency introduced by optional buffering", 0, 
AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
 {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", 
OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D},
-- 
2.1.4

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] libavcodec: Add FLAC API test

2015-04-21 Thread Ludmila Glinskih
вт, 21 апр. 2015 г. в 6:19, Clément Bœsch :

> On Mon, Apr 20, 2015 at 02:37:27PM +0200, Ludmila Glinskih wrote:
> > ffmpeg | branch: master | Ludmila Glinskih  | Mon
> Apr 20 03:03:08 2015 +0300| [be70c79af2bbbf8818707075ebc376d0be137582] |
> committer: Michael Niedermayer
> >
> > libavcodec: Add FLAC API test
> >
> > Signed-off-by: Ludmila Glinskih 
> > Signed-off-by: Michael Niedermayer 
> >
> > >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be70c79af2bbbf8818707075ebc376d0be137582
> > ---
> >
> >  libavcodec/Makefile|1 +
> >  libavcodec/api-flac-test.c |  290
> 
> >  tests/fate/libavcodec.mak  |6 +
> >  3 files changed, 297 insertions(+)
> >
> [...]
>
> > +TESTPROGS += api-flac
>
> Mmh... no TESTPROGRES-$(CONFIG_FLAC_DECODER) or similar?
>
For building this test It's not necessary for encodec/decodec to be
available. When FATE tests are running, my test won't be ran without
FLAC-codec/decodec, because in /tests/fate/libavcodec.mak I check
availability of the codec:
FATE_LIBAVCODEC-$(call ENCDEC, FLAC, FLAC) += fate-api-flac


> [...]
> > +if (!ctx)
> > +{
>
> Sorry to comment on such superficial issue, but this style (repeated all
> over the file) is an obvious violation of the coding style of the project.
> If the author or the person pushing the patch could fix this, that would
> be appreciated.
>
Ok, I'll fix it!)


> Thanks
>
> [...]
>
> --
> Clément B.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

2015-04-21 Thread Christopher Watkins
Hi, this patch just removes a compiler warning.

Thanks!
Chris
From a0e11238d7d8199403c4ea0b4e8eef3eae0affa8 Mon Sep 17 00:00:00 2001
From: Chris Watkins 
Date: Tue, 21 Apr 2015 14:14:19 -0700
Subject: [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

Using the PRIu8 format specifier to print an enum value causes a
compiler warning, so use %d instead.
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1af8fb6..0601830 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1230,7 +1230,7 @@ static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 av_log(c, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", range_value);
 break;
 }
-av_dlog(c, "color_range: %"PRIu8"\n", codec->color_range);
+av_dlog(c, "color_range: %d\n", codec->color_range);
 } else {
   /* For some reason the whole atom was not added to the extradata */
   av_log(c, AV_LOG_ERROR, "aclr not decoded - incomplete atom\n");
-- 
2.2.0.rc0.207.ga3a616c

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


Re: [FFmpeg-devel] [PATCH v4] libavcodec: Add FLAC API test

2015-04-21 Thread Ludmila Glinskih
OOPS

вт, 21 апр. 2015 г. в 8:03, James Almer :

> On 19/04/15 9:03 PM, Ludmila Glinskih wrote:
>
> > +static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
> > +AVCodecContext *dec_ctx)
> > +{
> > +AVPacket enc_pkt;
> > +AVFrame *in_frame, *out_frame;
> > +uint8_t *raw_in = NULL, *raw_out = NULL;
> > +int in_offset = 0, out_offset = 0;
> > +int frame_data_size = 0;
>
> This
>
> [...]
>
> > +if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) !=
> 0)
>
> And this are the only lines where frame_data_size is used. This means it's
> always 0.
> Is that intended? Because unless i'm missing something, that doesn't seem
> right for
> a memcmp.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

2015-04-21 Thread Carl Eugen Hoyos
Christopher Watkins  chromium.org> writes:

> Hi, this patch just removes a compiler warning.

Please mention ticket #4467 is the commit message.

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH v4] libavcodec: Add FLAC API test

2015-04-21 Thread Kieran Kunhya
On 21 April 2015 at 21:52, Ludmila Glinskih  wrote:
> Sorry for the delay, thanks for comments!
>
> вт, 21 апр. 2015 г. в 1:40, Kieran Kunhya :
>
>> On 20 April 2015 at 01:03, Ludmila Glinskih  wrote:
>> > Signed-off-by: Ludmila Glinskih 
>> > ---
>> >  libavcodec/Makefile|   1 +
>> >  libavcodec/api-flac-test.c | 290
>> +
>>
>> I would put this in its own directory.
>>
> Do you mean libavcodec/api directory? I think the best is to put it in the
> tests/api directory, but don't know how to make it (now).
>
>
>> I think the next thing you should work on is a simple, shared version
>> of framecrc so these tests can be integrated into FATE.
>> Or you can use the framecrc in libavformat - I have no preference.
>>
> Now my test is running with all FATE tests, doesn't this mean, that it is
> integrated?
> Can you please explain to me, why framecrc is so important?

It should be possible for your tests to use the same input test clips
and produce the same output data which are tested using stored
framecrcs in FATE currently. It's easy when you are encoding FLAC and
then decoding it but for example there are official h264 samples which
need to be decoded and checked for accuracy.

Please let me know if this doesn't make sense.

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


Re: [FFmpeg-devel] [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

2015-04-21 Thread Chris Watkins
On Tue, Apr 21, 2015 at 2:23 PM Carl Eugen Hoyos  wrote:

> Christopher Watkins  chromium.org> writes:
>
> > Hi, this patch just removes a compiler warning.
>
> Please mention ticket #4467 is the commit message.
>
>
Oh, I didn't see that. Done.
From 041b6899c10a082c5d019678e78588dc26474a6c Mon Sep 17 00:00:00 2001
From: Chris Watkins 
Date: Tue, 21 Apr 2015 14:14:19 -0700
Subject: [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

Using the PRIu8 format specifier to print an enum value causes a
compiler warning, so use %d instead.

Fixes ticket #4467.

Signed-off-by: Chris Watkins 
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1af8fb6..0601830 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1230,7 +1230,7 @@ static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 av_log(c, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", range_value);
 break;
 }
-av_dlog(c, "color_range: %"PRIu8"\n", codec->color_range);
+av_dlog(c, "color_range: %d\n", codec->color_range);
 } else {
   /* For some reason the whole atom was not added to the extradata */
   av_log(c, AV_LOG_ERROR, "aclr not decoded - incomplete atom\n");
-- 
2.2.0.rc0.207.ga3a616c

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


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/acelp_vectors.c |  8 +++-
>  libavcodec/adpcm.c |  2 +-
>  libavcodec/alacenc.c   |  3 +--
>  libavcodec/atrac3plus.c|  4 ++--
>  libavcodec/dnxhdenc.c  |  2 +-
>  libavcodec/dvenc.c |  2 +-
>  libavcodec/ffv1.h  |  2 +-
>  libavcodec/ffv1dec.c   |  3 +--
>  libavcodec/g726.c  |  2 +-
>  libavcodec/g729dec.c   |  2 +-
>  libavcodec/golomb.h|  2 +-
>  libavcodec/h264.c  |  5 ++---
>  libavcodec/h264_refs.c |  2 +-
>  libavcodec/hevc.c  | 26 --
>  libavcodec/hevc_cabac.c|  8 
>  libavcodec/hevc_filter.c   | 15 ++-
>  libavcodec/hevc_mvs.c  |  4 ++--
>  libavcodec/hevc_ps.c   |  4 ++--
>  libavcodec/hevc_refs.c |  5 ++---
>  libavcodec/hevcpred_template.c |  4 ++--
>  libavcodec/mpeg12enc.c |  8 
>  libavcodec/opus.h  |  2 +-
>  libavcodec/opus_celt.c |  9 -
>  libavcodec/proresenc_kostya.c  |  6 ++
>  libavcodec/put_bits.h  |  2 +-
>  libavcodec/vorbisdec.c |  5 ++---
>  26 files changed, 61 insertions(+), 76 deletions(-)
> 
> diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
> index 86851a3..7aef8c7 100644
> --- a/libavcodec/acelp_vectors.c
> +++ b/libavcodec/acelp_vectors.c
> @@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
>  int pulse_count,
>  int bits)
>  {
> -int mask = (1 << bits) - 1;
>  int i;
>  
>  for(i=0; i  {
> -fc_v[i + tab1[pulse_indexes & mask]] +=
> +fc_v[i + tab1[av_mod_uintp2(pulse_indexes, bits)]] +=
>  (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
>  
>  pulse_indexes >>= bits;
> @@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
> *fixed_index,
>  int half_pulse_count, int bits)
>  {
>  int i;
> -int mask = (1 << bits) - 1;
>  
>  fixed_sparse->no_repeat_mask = 0;
>  fixed_sparse->n = 2 * half_pulse_count;
>  for (i = 0; i < half_pulse_count; i++) {
> -const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
> -const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
> +const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
> bits)] + i;
> +const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
> bits)] + i;
>  const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
>  fixed_sparse->x[2*i+1] = pos1;
>  fixed_sparse->x[2*i  ] = pos2;
[...]
> diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
> index 5081397..bfc4d71 100644
> --- a/libavcodec/ffv1.h
> +++ b/libavcodec/ffv1.h
> @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
>  diff = (int8_t)diff;
>  else {
>  diff +=  1 << (bits  - 1);
> -diff &= (1 <<  bits) - 1;
> +diff  = av_mod_uintp2(diff, bits);
>  diff -=  1 << (bits  - 1);
>  }
>  

iam not sure some of these changes are are a good idea
for example above the mask has to be calculated anyway what can be
gained from av_mod_uintp2() use here ?
i think this should be bechmarked when its in performance critical code

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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


Re: [FFmpeg-devel] [PATCH] avformat: add AVFMT_FLAG_FASTSEEK, use it for mp3

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, wm4 a écrit :
>  #define AVFMT_FLAG_SORT_DTS0x1 ///< try to interleave outputted 
> packets by dts (using this flag can slow demuxing down)
>  #define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
> delaying codec open (this could be made default once all code is converted)
>  #define AVFMT_FLAG_KEEP_SIDE_DATA 0x4 ///< Don't merge side data but 
> keep it separate.
> +#define AVFMT_FLAG_FAST_SEEK   0x8000 ///< Enable fast, but inaccurate seeks 
> for some formats

Am I seeing double or is it the same value as AVFMT_FLAG_MP4A_LATM? May this
just be a typo?

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling

2015-04-21 Thread Nicolas George
Le duodi 2 floréal, an CCXXIII, Pedro Arthur a écrit :
>  #define SWS_SPLINE0x400
> +#define SWS_GAMMA_CORRECT 0x800

Sorry, I forgot one comment in my first email:

This has risks of conflicts if the avconv fork adds a different flag with
the same value. To avoid that, we usually leave a gap in the values.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 11:38:32PM +0200, Michael Niedermayer wrote:
> On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
> > Signed-off-by: James Almer 
> > ---
> >  libavcodec/acelp_vectors.c |  8 +++-
> >  libavcodec/adpcm.c |  2 +-
> >  libavcodec/alacenc.c   |  3 +--
> >  libavcodec/atrac3plus.c|  4 ++--
> >  libavcodec/dnxhdenc.c  |  2 +-
> >  libavcodec/dvenc.c |  2 +-
> >  libavcodec/ffv1.h  |  2 +-
> >  libavcodec/ffv1dec.c   |  3 +--
> >  libavcodec/g726.c  |  2 +-
> >  libavcodec/g729dec.c   |  2 +-
> >  libavcodec/golomb.h|  2 +-
> >  libavcodec/h264.c  |  5 ++---
> >  libavcodec/h264_refs.c |  2 +-
> >  libavcodec/hevc.c  | 26 --
> >  libavcodec/hevc_cabac.c|  8 
> >  libavcodec/hevc_filter.c   | 15 ++-
> >  libavcodec/hevc_mvs.c  |  4 ++--
> >  libavcodec/hevc_ps.c   |  4 ++--
> >  libavcodec/hevc_refs.c |  5 ++---
> >  libavcodec/hevcpred_template.c |  4 ++--
> >  libavcodec/mpeg12enc.c |  8 
> >  libavcodec/opus.h  |  2 +-
> >  libavcodec/opus_celt.c |  9 -
> >  libavcodec/proresenc_kostya.c  |  6 ++
> >  libavcodec/put_bits.h  |  2 +-
> >  libavcodec/vorbisdec.c |  5 ++---
> >  26 files changed, 61 insertions(+), 76 deletions(-)
> > 
> > diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
> > index 86851a3..7aef8c7 100644
> > --- a/libavcodec/acelp_vectors.c
> > +++ b/libavcodec/acelp_vectors.c
> > @@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
> >  int pulse_count,
> >  int bits)
> >  {
> > -int mask = (1 << bits) - 1;
> >  int i;
> >  
> >  for(i=0; i >  {
> > -fc_v[i + tab1[pulse_indexes & mask]] +=
> > +fc_v[i + tab1[av_mod_uintp2(pulse_indexes, bits)]] +=
> >  (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> >  
> >  pulse_indexes >>= bits;
> > @@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
> > *fixed_index,
> >  int half_pulse_count, int bits)
> >  {
> >  int i;
> > -int mask = (1 << bits) - 1;
> >  
> >  fixed_sparse->no_repeat_mask = 0;
> >  fixed_sparse->n = 2 * half_pulse_count;
> >  for (i = 0; i < half_pulse_count; i++) {
> > -const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
> > -const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
> > +const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
> > bits)] + i;
> > +const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
> > bits)] + i;
> >  const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
> >  fixed_sparse->x[2*i+1] = pos1;
> >  fixed_sparse->x[2*i  ] = pos2;
> [...]
> > diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
> > index 5081397..bfc4d71 100644
> > --- a/libavcodec/ffv1.h
> > +++ b/libavcodec/ffv1.h
> > @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
> >  diff = (int8_t)diff;
> >  else {
> >  diff +=  1 << (bits  - 1);
> > -diff &= (1 <<  bits) - 1;
> > +diff  = av_mod_uintp2(diff, bits);
> >  diff -=  1 << (bits  - 1);
> >  }
> >  
> 
> iam not sure some of these changes are are a good idea
> for example above the mask has to be calculated anyway what can be
> gained from av_mod_uintp2() use here ?
> i think this should be bechmarked when its in performance critical code

but the changes look ok when it can be ensured theres no speed loss
or the code changed is not speed relevant

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread James Almer
On 21/04/15 6:38 PM, Michael Niedermayer wrote:
> On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/acelp_vectors.c |  8 +++-
>>  libavcodec/adpcm.c |  2 +-
>>  libavcodec/alacenc.c   |  3 +--
>>  libavcodec/atrac3plus.c|  4 ++--
>>  libavcodec/dnxhdenc.c  |  2 +-
>>  libavcodec/dvenc.c |  2 +-
>>  libavcodec/ffv1.h  |  2 +-
>>  libavcodec/ffv1dec.c   |  3 +--
>>  libavcodec/g726.c  |  2 +-
>>  libavcodec/g729dec.c   |  2 +-
>>  libavcodec/golomb.h|  2 +-
>>  libavcodec/h264.c  |  5 ++---
>>  libavcodec/h264_refs.c |  2 +-
>>  libavcodec/hevc.c  | 26 --
>>  libavcodec/hevc_cabac.c|  8 
>>  libavcodec/hevc_filter.c   | 15 ++-
>>  libavcodec/hevc_mvs.c  |  4 ++--
>>  libavcodec/hevc_ps.c   |  4 ++--
>>  libavcodec/hevc_refs.c |  5 ++---
>>  libavcodec/hevcpred_template.c |  4 ++--
>>  libavcodec/mpeg12enc.c |  8 
>>  libavcodec/opus.h  |  2 +-
>>  libavcodec/opus_celt.c |  9 -
>>  libavcodec/proresenc_kostya.c  |  6 ++
>>  libavcodec/put_bits.h  |  2 +-
>>  libavcodec/vorbisdec.c |  5 ++---
>>  26 files changed, 61 insertions(+), 76 deletions(-)
>>
>> diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
>> index 86851a3..7aef8c7 100644
>> --- a/libavcodec/acelp_vectors.c
>> +++ b/libavcodec/acelp_vectors.c
>> @@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
>>  int pulse_count,
>>  int bits)
>>  {
>> -int mask = (1 << bits) - 1;
>>  int i;
>>  
>>  for(i=0; i>  {
>> -fc_v[i + tab1[pulse_indexes & mask]] +=
>> +fc_v[i + tab1[av_mod_uintp2(pulse_indexes, bits)]] +=
>>  (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
>>  
>>  pulse_indexes >>= bits;
>> @@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
>> *fixed_index,
>>  int half_pulse_count, int bits)
>>  {
>>  int i;
>> -int mask = (1 << bits) - 1;
>>  
>>  fixed_sparse->no_repeat_mask = 0;
>>  fixed_sparse->n = 2 * half_pulse_count;
>>  for (i = 0; i < half_pulse_count; i++) {
>> -const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
>> -const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
>> +const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
>> bits)] + i;
>> +const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
>> bits)] + i;
>>  const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
>>  fixed_sparse->x[2*i+1] = pos1;
>>  fixed_sparse->x[2*i  ] = pos2;
> [...]
>> diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
>> index 5081397..bfc4d71 100644
>> --- a/libavcodec/ffv1.h
>> +++ b/libavcodec/ffv1.h
>> @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
>>  diff = (int8_t)diff;
>>  else {
>>  diff +=  1 << (bits  - 1);
>> -diff &= (1 <<  bits) - 1;
>> +diff  = av_mod_uintp2(diff, bits);
>>  diff -=  1 << (bits  - 1);
>>  }
>>  
> 
> iam not sure some of these changes are are a good idea
> for example above the mask has to be calculated anyway what can be
> gained from av_mod_uintp2() use here ?
> i think this should be bechmarked when its in performance critical code

"1 << (bits  - 1)" is not the same as "(1 <<  bits) - 1". The latter is not 
going to be
calculated if the arch optimized version of av_mod_uintp2 is used.

The one file where i don't know if there's going to be any gain is in one of 
the opus_celt.c
changes, where the mask needs to be calculated even if arch optimized 
av_mod_uintp2 is used.
That one can be removed, but every other change is pretty straightforward.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 09:30:41PM +, Chris Watkins wrote:
> On Tue, Apr 21, 2015 at 2:23 PM Carl Eugen Hoyos  wrote:
> 
> > Christopher Watkins  chromium.org> writes:
> >
> > > Hi, this patch just removes a compiler warning.
> >
> > Please mention ticket #4467 is the commit message.
> >
> >
> Oh, I didn't see that. Done.

>  mov.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> c06d5c5428408cb619075dbf18863461cadb420b  
> 0001-avformat-mov.c-Use-d-to-print-an-enum-not-PRIu8.patch
> From 041b6899c10a082c5d019678e78588dc26474a6c Mon Sep 17 00:00:00 2001
> From: Chris Watkins 
> Date: Tue, 21 Apr 2015 14:14:19 -0700
> Subject: [PATCH] avformat/mov.c: Use %d to print an enum, not PRIu8
> 
> Using the PRIu8 format specifier to print an enum value causes a
> compiler warning, so use %d instead.
> 
> Fixes ticket #4467.

applied

thanks

[...]

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


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


Re: [FFmpeg-devel] [PATCH] avformat: add AVFMT_FLAG_FASTSEEK, use it for mp3

2015-04-21 Thread wm4
On Tue, 21 Apr 2015 23:04:32 +0200
wm4  wrote:

> ---
> Proposal. Is not mp3-specific, and can be reused for other formats.
> ---
>  doc/APIchanges  | 4 
>  doc/formats.texi| 2 ++
>  libavformat/avformat.h  | 1 +
>  libavformat/mp3dec.c| 4 ++--
>  libavformat/options_table.h | 1 +
>  5 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index b422e29..b65fd62 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,10 @@ libavutil: 2014-08-09
>  
>  API changes, most recent first:
>  
> +2015-xx-xx - xxx - lavf 56.xx.xxx - avformat.h
> +  Add AVFMT_FLAG_FAST_SEEK flag. Some formats (initially mp3) use it to 
> enable
> +  fast, but inaccurate seeking.
> +
>  2015-xx-xx - xxx - lavu 54.12.0
>Add AV_LOG_TRACE for extremely verbose debugging.
>  
> diff --git a/doc/formats.texi b/doc/formats.texi
> index cbbdc10..aa39d4b 100644
> --- a/doc/formats.texi
> +++ b/doc/formats.texi
> @@ -37,6 +37,8 @@ Possible values:
>  @table @samp
>  @item ignidx
>  Ignore index.
> +@item fastseek
> +Enable fast, but inaccurate seeks for some formats.
>  @item genpts
>  Generate PTS.
>  @item nofillin
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 93cfb20..85b5a1a 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1390,6 +1390,7 @@ typedef struct AVFormatContext {
>  #define AVFMT_FLAG_SORT_DTS0x1 ///< try to interleave outputted 
> packets by dts (using this flag can slow demuxing down)
>  #define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
> delaying codec open (this could be made default once all code is converted)
>  #define AVFMT_FLAG_KEEP_SIDE_DATA 0x4 ///< Don't merge side data but 
> keep it separate.
> +#define AVFMT_FLAG_FAST_SEEK   0x8000 ///< Enable fast, but inaccurate seeks 
> for some formats
>  
>  /**
>   * @deprecated deprecated in favor of probesize2
> diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> index 2227428..8c17776 100644
> --- a/libavformat/mp3dec.c
> +++ b/libavformat/mp3dec.c
> @@ -337,7 +337,7 @@ static int mp3_read_header(AVFormatContext *s)
>  int i;
>  
>  if (mp3->usetoc < 0)
> -mp3->usetoc = 0;
> +mp3->usetoc = (s->flags & AVFMT_FLAG_FAST_SEEK) ? 0 : 2;
>  
>  st = avformat_new_stream(s, NULL);
>  if (!st)
> @@ -504,7 +504,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
> int64_t timestamp,
>  }
>  
>  static const AVOption options[] = {
> -{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> AV_OPT_TYPE_INT, {.i64 = 2}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
> +{ "usetoc", "use table of contents", offsetof(MP3DecContext, usetoc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, AV_OPT_FLAG_DECODING_PARAM},
>  { NULL },
>  };
>  
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index 40f1e0a..58670b0 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -49,6 +49,7 @@ static const AVOption avformat_options[] = {
>  {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
>  {"sortdts", "try to interleave outputted packets by dts", 0, 
> AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, 
> "fflags"},
>  {"keepside", "don't merge side data", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
> +{"fastseek", "fast but inaccurate seeks", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AVFMT_FLAG_FAST_SEEK }, INT_MIN, INT_MAX, D, "fflags"},
>  {"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.i64 = 
> AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
>  {"nobuffer", "reduce the latency introduced by optional buffering", 0, 
> AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
>  {"seek2any", "allow seeking to non-keyframes on demuxer level when 
> supported", OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D},

What also should be up to discussion: should this maybe be a flag to
the seek API call instead? It would be slightly harder to implement
though (in the case of mp3 - have to add the xing index lazily).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 06:51:52PM -0300, James Almer wrote:
> On 21/04/15 6:38 PM, Michael Niedermayer wrote:
> > On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
> >> Signed-off-by: James Almer 
> >> ---
> >>  libavcodec/acelp_vectors.c |  8 +++-
> >>  libavcodec/adpcm.c |  2 +-
> >>  libavcodec/alacenc.c   |  3 +--
> >>  libavcodec/atrac3plus.c|  4 ++--
> >>  libavcodec/dnxhdenc.c  |  2 +-
> >>  libavcodec/dvenc.c |  2 +-
> >>  libavcodec/ffv1.h  |  2 +-
> >>  libavcodec/ffv1dec.c   |  3 +--
> >>  libavcodec/g726.c  |  2 +-
> >>  libavcodec/g729dec.c   |  2 +-
> >>  libavcodec/golomb.h|  2 +-
> >>  libavcodec/h264.c  |  5 ++---
> >>  libavcodec/h264_refs.c |  2 +-
> >>  libavcodec/hevc.c  | 26 --
> >>  libavcodec/hevc_cabac.c|  8 
> >>  libavcodec/hevc_filter.c   | 15 ++-
> >>  libavcodec/hevc_mvs.c  |  4 ++--
> >>  libavcodec/hevc_ps.c   |  4 ++--
> >>  libavcodec/hevc_refs.c |  5 ++---
> >>  libavcodec/hevcpred_template.c |  4 ++--
> >>  libavcodec/mpeg12enc.c |  8 
> >>  libavcodec/opus.h  |  2 +-
> >>  libavcodec/opus_celt.c |  9 -
> >>  libavcodec/proresenc_kostya.c  |  6 ++
> >>  libavcodec/put_bits.h  |  2 +-
> >>  libavcodec/vorbisdec.c |  5 ++---
> >>  26 files changed, 61 insertions(+), 76 deletions(-)
> >>
> >> diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
> >> index 86851a3..7aef8c7 100644
> >> --- a/libavcodec/acelp_vectors.c
> >> +++ b/libavcodec/acelp_vectors.c
> >> @@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
> >>  int pulse_count,
> >>  int bits)
> >>  {
> >> -int mask = (1 << bits) - 1;
> >>  int i;
> >>  
> >>  for(i=0; i >>  {
> >> -fc_v[i + tab1[pulse_indexes & mask]] +=
> >> +fc_v[i + tab1[av_mod_uintp2(pulse_indexes, bits)]] +=
> >>  (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> >>  
> >>  pulse_indexes >>= bits;
> >> @@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
> >> *fixed_index,
> >>  int half_pulse_count, int bits)
> >>  {
> >>  int i;
> >> -int mask = (1 << bits) - 1;
> >>  
> >>  fixed_sparse->no_repeat_mask = 0;
> >>  fixed_sparse->n = 2 * half_pulse_count;
> >>  for (i = 0; i < half_pulse_count; i++) {
> >> -const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
> >> -const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
> >> +const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
> >> bits)] + i;
> >> +const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
> >> bits)] + i;
> >>  const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 
> >> 1.0;
> >>  fixed_sparse->x[2*i+1] = pos1;
> >>  fixed_sparse->x[2*i  ] = pos2;
> > [...]
> >> diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
> >> index 5081397..bfc4d71 100644
> >> --- a/libavcodec/ffv1.h
> >> +++ b/libavcodec/ffv1.h
> >> @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
> >>  diff = (int8_t)diff;
> >>  else {
> >>  diff +=  1 << (bits  - 1);
> >> -diff &= (1 <<  bits) - 1;
> >> +diff  = av_mod_uintp2(diff, bits);
> >>  diff -=  1 << (bits  - 1);
> >>  }
> >>  
> > 
> > iam not sure some of these changes are are a good idea
> > for example above the mask has to be calculated anyway what can be
> > gained from av_mod_uintp2() use here ?
> > i think this should be bechmarked when its in performance critical code
> 
> "1 << (bits  - 1)" is not the same as "(1 <<  bits) - 1". The latter is not 
> going to be
> calculated if the arch optimized version of av_mod_uintp2 is used.

yep, i should not review patches when i am in a (IRC) meeting

before the patch fold looks like this: (for the non 8bit case)
addl100(%rsp), %ecx
andl104(%rsp), %ecx
subl100(%rsp), %ecx
.L869:
afterwards it looks like this:

addl104(%rsp), %ecx
andl64(%rsp), %ecx
subl104(%rsp), %ecx
.L869:

so it seems ok


> 
> The one file where i don't know if there's going to be any gain is in one of 
> the opus_celt.c
> changes, where the mask needs to be calculated even if arch optimized 
> av_mod_uintp2 is used.
> That one can be removed, but every other change is pretty straightforward.

ok, then iam fine with the patch

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-deve

Re: [FFmpeg-devel] [PATCH 2/5] avformat/mp3dec: use the common mechanism for skipping samples

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 09:33:51PM +0200, wm4 wrote:
> ---
> Feel free to squash with the previous patch if it's too fine-grained.
> ---
>  libavformat/mp3dec.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)

this breaks fate-seek-acodec-mp2

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread James Almer
On 21/04/15 7:12 PM, Michael Niedermayer wrote:
> On Tue, Apr 21, 2015 at 06:51:52PM -0300, James Almer wrote:
>> On 21/04/15 6:38 PM, Michael Niedermayer wrote:
>>> On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
 Signed-off-by: James Almer 
 ---
  libavcodec/acelp_vectors.c |  8 +++-
  libavcodec/adpcm.c |  2 +-
  libavcodec/alacenc.c   |  3 +--
  libavcodec/atrac3plus.c|  4 ++--
  libavcodec/dnxhdenc.c  |  2 +-
  libavcodec/dvenc.c |  2 +-
  libavcodec/ffv1.h  |  2 +-
  libavcodec/ffv1dec.c   |  3 +--
  libavcodec/g726.c  |  2 +-
  libavcodec/g729dec.c   |  2 +-
  libavcodec/golomb.h|  2 +-
  libavcodec/h264.c  |  5 ++---
  libavcodec/h264_refs.c |  2 +-
  libavcodec/hevc.c  | 26 --
  libavcodec/hevc_cabac.c|  8 
  libavcodec/hevc_filter.c   | 15 ++-
  libavcodec/hevc_mvs.c  |  4 ++--
  libavcodec/hevc_ps.c   |  4 ++--
  libavcodec/hevc_refs.c |  5 ++---
  libavcodec/hevcpred_template.c |  4 ++--
  libavcodec/mpeg12enc.c |  8 
  libavcodec/opus.h  |  2 +-
  libavcodec/opus_celt.c |  9 -
  libavcodec/proresenc_kostya.c  |  6 ++
  libavcodec/put_bits.h  |  2 +-
  libavcodec/vorbisdec.c |  5 ++---
  26 files changed, 61 insertions(+), 76 deletions(-)

 diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
 index 86851a3..7aef8c7 100644
 --- a/libavcodec/acelp_vectors.c
 +++ b/libavcodec/acelp_vectors.c
 @@ -133,12 +133,11 @@ void ff_acelp_fc_pulse_per_track(
  int pulse_count,
  int bits)
  {
 -int mask = (1 << bits) - 1;
  int i;
  
  for(i=0; i>>>  {
 -fc_v[i + tab1[pulse_indexes & mask]] +=
 +fc_v[i + tab1[av_mod_uintp2(pulse_indexes, bits)]] +=
  (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
  
  pulse_indexes >>= bits;
 @@ -154,13 +153,12 @@ void ff_decode_10_pulses_35bits(const int16_t 
 *fixed_index,
  int half_pulse_count, int bits)
  {
  int i;
 -int mask = (1 << bits) - 1;
  
  fixed_sparse->no_repeat_mask = 0;
  fixed_sparse->n = 2 * half_pulse_count;
  for (i = 0; i < half_pulse_count; i++) {
 -const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
 -const int pos2   = gray_decode[fixed_index[2*i  ] & mask] + i;
 +const int pos1   = gray_decode[av_mod_uintp2(fixed_index[2*i+1], 
 bits)] + i;
 +const int pos2   = gray_decode[av_mod_uintp2(fixed_index[2*i  ], 
 bits)] + i;
  const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 
 1.0;
  fixed_sparse->x[2*i+1] = pos1;
  fixed_sparse->x[2*i  ] = pos2;
>>> [...]
 diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
 index 5081397..bfc4d71 100644
 --- a/libavcodec/ffv1.h
 +++ b/libavcodec/ffv1.h
 @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
  diff = (int8_t)diff;
  else {
  diff +=  1 << (bits  - 1);
 -diff &= (1 <<  bits) - 1;
 +diff  = av_mod_uintp2(diff, bits);
  diff -=  1 << (bits  - 1);
  }
  
>>>
>>> iam not sure some of these changes are are a good idea
>>> for example above the mask has to be calculated anyway what can be
>>> gained from av_mod_uintp2() use here ?
>>> i think this should be bechmarked when its in performance critical code
>>
>> "1 << (bits  - 1)" is not the same as "(1 <<  bits) - 1". The latter is not 
>> going to be
>> calculated if the arch optimized version of av_mod_uintp2 is used.
> 
> yep, i should not review patches when i am in a (IRC) meeting
> 
> before the patch fold looks like this: (for the non 8bit case)
> addl100(%rsp), %ecx
> andl104(%rsp), %ecx
> subl100(%rsp), %ecx
> .L869:
> afterwards it looks like this:
> 
> addl104(%rsp), %ecx
> andl64(%rsp), %ecx
> subl104(%rsp), %ecx
> .L869:
> 
> so it seems ok
> 
> 
>>
>> The one file where i don't know if there's going to be any gain is in one of 
>> the opus_celt.c
>> changes, where the mask needs to be calculated even if arch optimized 
>> av_mod_uintp2 is used.
>> That one can be removed, but every other change is pretty straightforward.
> 
> ok, then iam fine with the patch
> 
> Thanks

I'm going to apply the changes that are straightforward (single line changes 
that didn't use
mask variables prior to this patch, or that created one but then used it once). 
av_mod_uintp2
should generate the same a

Re: [FFmpeg-devel] [PATCH 2/5] avformat/mp3dec: use the common mechanism for skipping samples

2015-04-21 Thread wm4
On Wed, 22 Apr 2015 00:48:30 +0200
Michael Niedermayer  wrote:

> On Tue, Apr 21, 2015 at 09:33:51PM +0200, wm4 wrote:
> > ---
> > Feel free to squash with the previous patch if it's too fine-grained.
> > ---
> >  libavformat/mp3dec.c | 7 ++-
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> this breaks fate-seek-acodec-mp2
> 
> [...]

The old behavior is quite inconsistent:

- if the file has a LAME header
 - the start of the file skps at least 529 samples
 - seeking to the start also does
- if the file has no LAME hesder
 - the start of the file skips no samples
 - seeking to the start skips 529 samples

So should it skip data on the start or not? (If no LAME header.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [libav-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 06:50:20PM +0200, Andreas Cadhalpun wrote:
> On 21.04.2015 02:20, Claudio Freire wrote:
> > On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  
> > wrote:
> >> On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
> >>> On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire  
> >>> wrote:
>  On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
>   wrote:
>  The long version:
> 
>  ath should approximate the shape of the absolute hearing threshold, 
>  so
>  yes, it's best if it really uses the minimum, since that will prevent
>  clipping of the ath curve and result in a more accurate threshold
>  computation.
> >>>
> >>> So you agree with my patch fixing minath?
> >>> Or would you prefer a version with:
> >>> minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)
> >>
> >> Well, that's not really closer to the minimum (a few tests with 
> >> gnuplot say).
> >
> > Are you sure your plots were done correctly?
> > Because I'm quite sure this is the correct first order approximation
> > of the minimum.
> >
> > For ATH_ADD = 4 this gives 3407.068, which is quite close to Michael's 
> > value
> > (3407.080774800152).
> 
>  I checked the formula several times, but still, I could have made a 
>  mistake.
> >>>
> >>>
> >>> This is what I did if you want to check it out (maybe you spot the 
> >>> mistake)
> >>>
> >>> gnuplot> ath(f,a) = _ath(f/1000.0, a)
> >>> gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
> >>> (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
> >>> 0.001 * f * f * f
> >>   ^^
> >> missing * f
> > 
> > Much better now :)
> > 
> > So yes. I'd say it's a good change.
> 
> OK, patch attached.

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH 2/5] avformat/mp3dec: use the common mechanism for skipping samples

2015-04-21 Thread Michael Niedermayer
On Wed, Apr 22, 2015 at 01:09:26AM +0200, wm4 wrote:
> On Wed, 22 Apr 2015 00:48:30 +0200
> Michael Niedermayer  wrote:
> 
> > On Tue, Apr 21, 2015 at 09:33:51PM +0200, wm4 wrote:
> > > ---
> > > Feel free to squash with the previous patch if it's too fine-grained.
> > > ---
> > >  libavformat/mp3dec.c | 7 ++-
> > >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > this breaks fate-seek-acodec-mp2
> > 
> > [...]
> 
> The old behavior is quite inconsistent:
> 
> - if the file has a LAME header
>  - the start of the file skps at least 529 samples
>  - seeking to the start also does
> - if the file has no LAME hesder
>  - the start of the file skips no samples
>  - seeking to the start skips 529 samples
> 
> So should it skip data on the start or not? (If no LAME header.)

hmm, i was not conciously aware of it being inconsistent

iam not against the change the patch does if you think its ok and
the patch that introduces it also updates the fate checksum

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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


Re: [FFmpeg-devel] [PATCH] webmdashenc: Add minimumUpdatePeriod

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 04:36:52PM -0700, Vignesh Venkatasubramanian wrote:
> DASH spec requires the presence of either duration of the period
> or the minimumUpdatePeriod element. This patch adds the
> minimumUpdatePeriod element hardcoded with the value 0 as the
> manifest will never be updated for WebM DASH Live streams. Also
> updating the fate test reference file.
> 
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  libavformat/webmdashenc.c  | 3 ++-
>  tests/ref/fate/webm-dash-manifest-live | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


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


[FFmpeg-devel] [PATCH] webmdashenc: parameter'ize minimumUpdatePeriod

2015-04-21 Thread Vignesh Venkatasubramanian
Some players do not support setting minimumUpdatePeriod to zero.
This patch adds a new parameter that will let the users set any
value to this field. Also updates the test and the documentation.

Signed-off-by: Vignesh Venkatasubramanian 
---
 doc/muxers.texi| 4 
 libavformat/webmdashenc.c  | 4 +++-
 tests/fate/vpx.mak | 2 +-
 tests/ref/fate/webm-dash-manifest-live | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 335f093..ddd7c7a 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1253,6 +1253,10 @@ Smallest time (in seconds) shifting buffer for which any 
Representation is
 guaranteed to be available. This will go in the @samp{timeShiftBufferDepth}
 attribute of the @samp{MPD} element. Default: 60.
 
+@item minimum_update_period
+Minimum update period (in seconds) of the manifest. This will go in the
+@samp{minimumUpdatePeriod} attribute of the @samp{MPD} element. Default: 0.
+
 @end table
 
 @subsection Example
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index e627a15..1c63a5b 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -56,6 +56,7 @@ typedef struct WebMDashMuxContext {
 int chunk_duration;
 char *utc_timing_url;
 double time_shift_buffer_depth;
+int minimum_update_period;
 int debug_mode;
 } WebMDashMuxContext;
 
@@ -116,7 +117,7 @@ static void write_header(AVFormatContext *s)
 }
 avio_printf(s->pb, "  availabilityStartTime=\"%s\"\n", gmt_iso);
 avio_printf(s->pb, "  timeShiftBufferDepth=\"PT%gS\"\n", 
w->time_shift_buffer_depth);
-avio_printf(s->pb, "  minimumUpdatePeriod=\"0\"");
+avio_printf(s->pb, "  minimumUpdatePeriod=\"PT%dS\"", 
w->minimum_update_period);
 avio_printf(s->pb, ">\n");
 avio_printf(s->pb, "pb, "  schemeIdUri=\"%s\"\n",
@@ -517,6 +518,7 @@ static const AVOption options[] = {
 { "chunk_duration_ms", "duration of each chunk (in milliseconds)", 
OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "utc_timing_url", "URL of the page that will return the UTC timestamp in 
ISO format", OFFSET(utc_timing_url), AV_OPT_TYPE_STRING, { 0 }, 0, 0, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "time_shift_buffer_depth", "Smallest time (in seconds) shifting buffer 
for which any Representation is guaranteed to be available.", 
OFFSET(time_shift_buffer_depth), AV_OPT_TYPE_DOUBLE, { .dbl = 60.0 }, 1.0, 
DBL_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+{ "minimum_update_period", "Minimum Update Period (in seconds) of the 
manifest.", OFFSET(minimum_update_period), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
 { NULL },
 };
 
diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak
index 5eaf8fb..0e7e7eb 100644
--- a/tests/fate/vpx.mak
+++ b/tests/fate/vpx.mak
@@ -44,7 +44,7 @@ FATE_VP8-$(call DEMDEC, WEBM_DASH_MANIFEST, VP8) += 
fate-webm-dash-manifest-repr
 fate-webm-dash-manifest-representations: CMD = run ffmpeg -f 
webm_dash_manifest -i $(TARGET_SAMPLES)/vp8/dash_video1.webm -f 
webm_dash_manifest -i $(TARGET_SAMPLES)/vp8/dash_video4.webm -c copy -map 0 
-map 1 -f webm_dash_manifest -adaptation_sets "id=0,streams=0,1" -
 
 FATE_VP8-$(call DEMDEC, WEBM_DASH_MANIFEST, VP8) += 
fate-webm-dash-manifest-live
-fate-webm-dash-manifest-live: CMD = run ffmpeg -f webm_dash_manifest -live 1 
-i $(TARGET_SAMPLES)/vp8/dash_live_video_360.hdr -f webm_dash_manifest -live 1 
-i $(TARGET_SAMPLES)/vp8/dash_live_audio_171.hdr -c copy -map 0 -map 1 -f 
webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0 id=1,streams=1" 
-chunk_start_index 1 -chunk_duration_ms 5000 -time_shift_buffer_depth 7200 
-debug_mode 1 -
+fate-webm-dash-manifest-live: CMD = run ffmpeg -f webm_dash_manifest -live 1 
-i $(TARGET_SAMPLES)/vp8/dash_live_video_360.hdr -f webm_dash_manifest -live 1 
-i $(TARGET_SAMPLES)/vp8/dash_live_audio_171.hdr -c copy -map 0 -map 1 -f 
webm_dash_manifest -live 1 -adaptation_sets "id=0,streams=0 id=1,streams=1" 
-chunk_start_index 1 -chunk_duration_ms 5000 -time_shift_buffer_depth 7200 
-minimum_update_period 60 -debug_mode 1 -
 
 FATE_SAMPLES_AVCONV += $(FATE_VP6-yes)
 fate-vp6: $(FATE_VP6-yes)
diff --git a/tests/ref/fate/webm-dash-manifest-live 
b/tests/ref/fate/webm-dash-manifest-live
index c682ecc..91a1c1d 100644
--- a/tests/ref/fate/webm-dash-manifest-live
+++ b/tests/ref/fate/webm-dash-manifest-live
@@ -8,7 +8,7 @@
   profiles="urn:mpeg:dash:profile:isoff-live:2011"
   availabilityStartTime=""
   timeShiftBufferDepth="PT7200S"
-  minimumUpdatePeriod="0">
+  minimumUpdatePeriod="PT60S">
 
-- 
2.2.0.rc0.207.ga3a616c

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


[FFmpeg-devel] [PATCH 1/2] vp9: add support for resolution changes in inter frames.

2015-04-21 Thread Ronald S. Bultje
---
 libavcodec/vp9.c | 316 ++-
 libavcodec/vp9_mc_template.c | 171 +++
 libavcodec/vp9_parser.c  |   5 +-
 libavcodec/vp9dsp.c  | 205 ++--
 libavcodec/vp9dsp.h  |   9 ++
 5 files changed, 535 insertions(+), 171 deletions(-)
 create mode 100644 libavcodec/vp9_mc_template.c

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 89257fa..ee73325 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -242,7 +242,7 @@ typedef struct VP9Context {
 // whole-frame cache
 uint8_t *intra_pred_data[3];
 struct VP9Filter *lflvl;
-DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
+DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135*144];
 
 // block reconstruction intermediates
 int block_alloc_using_2pass;
@@ -251,6 +251,8 @@ typedef struct VP9Context {
 struct { int x, y; } min_mv, max_mv;
 DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
 DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
+uint16_t mvscale[3][2];
+uint8_t mvstep[3][2];
 } VP9Context;
 
 static const uint8_t bwh_tab[2][N_BS_SIZES][2] = {
@@ -577,6 +579,26 @@ static int decode_frame_header(AVCodecContext *ctx,
 s->varcompref[1] = 2;
 }
 }
+
+for (i = 0; i < 3; i++) {
+AVFrame *ref = s->refs[s->refidx[i]].f;
+int refw = ref->width, refh = ref->height;
+
+if (refw == w && refh == h) {
+s->mvscale[i][0] = s->mvscale[i][1] = 0;
+} else {
+if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 
16 * refh) {
+av_log(ctx, AV_LOG_ERROR,
+   "Invalid ref frame dimensions %dx%d for frame 
size %dx%d\n",
+   refw, refh, w, h);
+return AVERROR_INVALIDDATA;
+}
+s->mvscale[i][0] = (refw << 14) / w;
+s->mvscale[i][1] = (refh << 14) / h;
+s->mvstep[i][0] = 16 * s->mvscale[i][0] >> 14;
+s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
+}
+}
 }
 }
 s->refreshctx   = s->errorres ? 0 : get_bits1(&s->gb);
@@ -2524,12 +2546,118 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t 
y_off, ptrdiff_t uv_off)
 }
 }
 
-static av_always_inline void mc_luma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
- uint8_t *dst, ptrdiff_t dst_stride,
- const uint8_t *ref, ptrdiff_t 
ref_stride,
- ThreadFrame *ref_frame,
- ptrdiff_t y, ptrdiff_t x, const 
VP56mv *mv,
- int bw, int bh, int w, int h)
+static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func 
smc,
+uint8_t *dst, ptrdiff_t dst_stride,
+const uint8_t *ref, ptrdiff_t 
ref_stride,
+ThreadFrame *ref_frame,
+ptrdiff_t y, ptrdiff_t x, const 
VP56mv *mv,
+int bw, int bh, int w, int h,
+const uint16_t *scale, const 
uint8_t *step)
+{
+#define scale_mv(n, dim) (((int64_t)n * scale[dim]) >> 14)
+// BUG libvpx seems to scale the two components separately. This introduces
+// rounding errors but we have to reproduce them to be exactly compatible
+// with the output from libvpx...
+int mx = scale_mv(mv->x * 2, 0) + scale_mv(x * 16, 0);
+int my = scale_mv(mv->y * 2, 1) + scale_mv(y * 16, 1);
+int refbw_m1, refbh_m1;
+int th;
+
+y = my >> 4;
+x = mx >> 4;
+ref += y * ref_stride + x;
+mx &= 15;
+my &= 15;
+refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
+refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
+// FIXME bilinear filter only needs 0/1 pixels, not 3/4
+// we use +7 because the last 7 pixels of each sbrow can be changed in
+// the longest loopfilter of the next sbrow
+th = (y + refbh_m1 + 4 + 7) >> 6;
+ff_thread_await_progress(ref_frame, FFMAX(th, 0), 0);
+if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
+s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
+ ref - 3 * ref_stride - 3,
+ 144, ref_stride,
+ refbw_m1 + 8, refbh_m1 + 8,
+ x - 3, y - 3, w, h);
+ref = s->edge_emu_buffer + 3 * 144 + 3;
+ref_stride = 144;
+}
+smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
+}
+
+static av_always_inline void mc_chroma_scaled(VP9Context *s, 
vp9_s

[FFmpeg-devel] [PATCH 2/2] vp9: add fate size for resolution changes.

2015-04-21 Thread Ronald S. Bultje
See sample:
http://downloads.webmproject.org/test_data/libvpx/vp90-2-05-resize.ivf
---
 tests/fate/vpx.mak   |  3 +++
 tests/ref/fate/vp9-05-resize | 15 +++
 2 files changed, 18 insertions(+)
 create mode 100644 tests/ref/fate/vp9-05-resize

diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak
index 5eaf8fb..a5449c8 100644
--- a/tests/fate/vpx.mak
+++ b/tests/fate/vpx.mak
@@ -109,6 +109,9 @@ $(eval $(call FATE_VP9_SUITE,trac4359,$(1),$(2)))
 endef
 
 $(eval $(call FATE_VP9_FULL))
+FATE_VP9-$(CONFIG_IVF_DEMUXER) += fate-vp9-05-resize
+fate-vp9-05-resize: CMD = framemd5 -i 
$(TARGET_SAMPLES)/vp9-test-vectors/vp90-2-05-resize.ivf -s 352x288 -sws_flags 
bitexact+bilinear
+fate-vp9-05-resize: REF = $(SRC_PATH)/tests/ref/fate/vp9-05-resize
 
 FATE_SAMPLES_AVCONV-$(CONFIG_VP9_DECODER) += $(FATE_VP9-yes)
 fate-vp9: $(FATE_VP9-yes)
diff --git a/tests/ref/fate/vp9-05-resize b/tests/ref/fate/vp9-05-resize
new file mode 100644
index 000..4a3cd09
--- /dev/null
+++ b/tests/ref/fate/vp9-05-resize
@@ -0,0 +1,15 @@
+#format: frame checksums
+#version: 1
+#hash: MD5
+#tb 0: 1/30
+#stream#, dts,pts, duration, size, hash
+0,  0,  0,1,   152064, 539e9964364c1db09ad18f2e01713799
+0,  1,  1,1,   152064, fb76e673ba2a5342bfed8a1523e0a425
+0,  2,  2,1,   152064, b0e6881ac6c1e0d839f80f292cb1afd4
+0,  3,  3,1,   152064, f69a4d7f784e1619e45ffd65e3f103b9
+0,  4,  4,1,   152064, a9cefc3088de0b403c7cc1ffd117479a
+0,  5,  5,1,   152064, 6a053249fe6fdc52ed00a21668fe330f
+0,  6,  6,1,   152064, 2c6f7b8c72a0103cd1fa37270f6d9962
+0,  7,  7,1,   152064, 9f837ba58bf07d1e1a8b6a30a9a588e8
+0,  8,  8,1,   152064, 81ecfd1810b25395af999e557ed4b938
+0,  9,  9,1,   152064, cee53e71d6347333fd76d421ece1740f
-- 
2.1.2

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


Re: [FFmpeg-devel] [PATCH] webmdashenc: parameter'ize minimumUpdatePeriod

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 05:35:29PM -0700, Vignesh Venkatasubramanian wrote:
> Some players do not support setting minimumUpdatePeriod to zero.
> This patch adds a new parameter that will let the users set any
> value to this field. Also updates the test and the documentation.
> 
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  doc/muxers.texi| 4 
>  libavformat/webmdashenc.c  | 4 +++-
>  tests/fate/vpx.mak | 2 +-
>  tests/ref/fate/webm-dash-manifest-live | 2 +-
>  4 files changed, 9 insertions(+), 3 deletions(-)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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


Re: [FFmpeg-devel] [PATCH] avcodec: use av_mod_intp2() where possible

2015-04-21 Thread James Almer
On 21/04/15 7:49 PM, James Almer wrote:
> On 21/04/15 7:12 PM, Michael Niedermayer wrote:
>> On Tue, Apr 21, 2015 at 06:51:52PM -0300, James Almer wrote:
>>> On 21/04/15 6:38 PM, Michael Niedermayer wrote:
 On Tue, Apr 21, 2015 at 05:45:25PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
> index 5081397..bfc4d71 100644
> --- a/libavcodec/ffv1.h
> +++ b/libavcodec/ffv1.h
> @@ -143,7 +143,7 @@ static av_always_inline int fold(int diff, int bits)
>  diff = (int8_t)diff;
>  else {
>  diff +=  1 << (bits  - 1);
> -diff &= (1 <<  bits) - 1;
> +diff  = av_mod_uintp2(diff, bits);
>  diff -=  1 << (bits  - 1);
>  }
>  

 iam not sure some of these changes are are a good idea
 for example above the mask has to be calculated anyway what can be
 gained from av_mod_uintp2() use here ?
 i think this should be bechmarked when its in performance critical code
>>>
>>> "1 << (bits  - 1)" is not the same as "(1 <<  bits) - 1". The latter is not 
>>> going to be
>>> calculated if the arch optimized version of av_mod_uintp2 is used.
>>
>> yep, i should not review patches when i am in a (IRC) meeting
>>
>> before the patch fold looks like this: (for the non 8bit case)
>> addl100(%rsp), %ecx
>> andl104(%rsp), %ecx
>> subl100(%rsp), %ecx
>> .L869:
>> afterwards it looks like this:
>>
>> addl104(%rsp), %ecx
>> andl64(%rsp), %ecx
>> subl104(%rsp), %ecx
>> .L869:
>>
>> so it seems ok
>>
>>
>>>
>>> The one file where i don't know if there's going to be any gain is in one 
>>> of the opus_celt.c
>>> changes, where the mask needs to be calculated even if arch optimized 
>>> av_mod_uintp2 is used.
>>> That one can be removed, but every other change is pretty straightforward.
>>
>> ok, then iam fine with the patch
>>
>> Thanks
> 
> I'm going to apply the changes that are straightforward (single line changes 
> that didn't use
> mask variables prior to this patch, or that created one but then used it 
> once). av_mod_uintp2
> should generate the same assembly with the non bmi2 optimized version.

Done and pushed, thanks.

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


Re: [FFmpeg-devel] [PATCH 2/2] vp9: add fate size for resolution changes.

2015-04-21 Thread Michael Niedermayer
On Tue, Apr 21, 2015 at 08:54:52PM -0400, Ronald S. Bultje wrote:
> See sample:
> http://downloads.webmproject.org/test_data/libvpx/vp90-2-05-resize.ivf

uploaded

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


Re: [FFmpeg-devel] [PATCH 1/2] vp9: add support for resolution changes in inter frames.

2015-04-21 Thread James Almer
On 21/04/15 9:54 PM, Ronald S. Bultje wrote:
> ---
>  libavcodec/vp9.c | 316 
> ++-
>  libavcodec/vp9_mc_template.c | 171 +++
>  libavcodec/vp9_parser.c  |   5 +-
>  libavcodec/vp9dsp.c  | 205 ++--
>  libavcodec/vp9dsp.h  |   9 ++
>  5 files changed, 535 insertions(+), 171 deletions(-)
>  create mode 100644 libavcodec/vp9_mc_template.c
> 
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index 89257fa..ee73325 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -242,7 +242,7 @@ typedef struct VP9Context {
>  // whole-frame cache
>  uint8_t *intra_pred_data[3];
>  struct VP9Filter *lflvl;
> -DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
> +DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135*144];
>  
>  // block reconstruction intermediates
>  int block_alloc_using_2pass;
> @@ -251,6 +251,8 @@ typedef struct VP9Context {
>  struct { int x, y; } min_mv, max_mv;
>  DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
>  DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
> +uint16_t mvscale[3][2];
> +uint8_t mvstep[3][2];
>  } VP9Context;
>  
>  static const uint8_t bwh_tab[2][N_BS_SIZES][2] = {
> @@ -577,6 +579,26 @@ static int decode_frame_header(AVCodecContext *ctx,
>  s->varcompref[1] = 2;
>  }
>  }
> +
> +for (i = 0; i < 3; i++) {
> +AVFrame *ref = s->refs[s->refidx[i]].f;
> +int refw = ref->width, refh = ref->height;
> +
> +if (refw == w && refh == h) {
> +s->mvscale[i][0] = s->mvscale[i][1] = 0;
> +} else {
> +if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 
> 16 * refh) {
> +av_log(ctx, AV_LOG_ERROR,
> +   "Invalid ref frame dimensions %dx%d for frame 
> size %dx%d\n",
> +   refw, refh, w, h);
> +return AVERROR_INVALIDDATA;
> +}
> +s->mvscale[i][0] = (refw << 14) / w;
> +s->mvscale[i][1] = (refh << 14) / h;
> +s->mvstep[i][0] = 16 * s->mvscale[i][0] >> 14;
> +s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
> +}
> +}
>  }
>  }
>  s->refreshctx   = s->errorres ? 0 : get_bits1(&s->gb);
> @@ -2524,12 +2546,118 @@ static void intra_recon(AVCodecContext *ctx, 
> ptrdiff_t y_off, ptrdiff_t uv_off)
>  }
>  }
>  
> -static av_always_inline void mc_luma_dir(VP9Context *s, vp9_mc_func (*mc)[2],
> - uint8_t *dst, ptrdiff_t dst_stride,
> - const uint8_t *ref, ptrdiff_t 
> ref_stride,
> - ThreadFrame *ref_frame,
> - ptrdiff_t y, ptrdiff_t x, const 
> VP56mv *mv,
> - int bw, int bh, int w, int h)
> +static av_always_inline void mc_luma_scaled(VP9Context *s, 
> vp9_scaled_mc_func smc,
> +uint8_t *dst, ptrdiff_t 
> dst_stride,
> +const uint8_t *ref, ptrdiff_t 
> ref_stride,
> +ThreadFrame *ref_frame,
> +ptrdiff_t y, ptrdiff_t x, const 
> VP56mv *mv,
> +int bw, int bh, int w, int h,
> +const uint16_t *scale, const 
> uint8_t *step)
> +{
> +#define scale_mv(n, dim) (((int64_t)n * scale[dim]) >> 14)
> +// BUG libvpx seems to scale the two components separately. This 
> introduces
> +// rounding errors but we have to reproduce them to be exactly compatible
> +// with the output from libvpx...

Did you report it to libvpx? It's probably a better idea to fix the bug in the 
reference
library than purposely reproduce the buggy behavior in our implementation to 
remain
compatible.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] vp9: add support for resolution changes in inter frames.

2015-04-21 Thread James Almer
On 22/04/15 12:20 AM, James Almer wrote:
> On 21/04/15 9:54 PM, Ronald S. Bultje wrote:
>> ---
>>  libavcodec/vp9.c | 316 
>> ++-
>>  libavcodec/vp9_mc_template.c | 171 +++
>>  libavcodec/vp9_parser.c  |   5 +-
>>  libavcodec/vp9dsp.c  | 205 ++--
>>  libavcodec/vp9dsp.h  |   9 ++
>>  5 files changed, 535 insertions(+), 171 deletions(-)
>>  create mode 100644 libavcodec/vp9_mc_template.c
>>
>> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
>> index 89257fa..ee73325 100644
>> --- a/libavcodec/vp9.c
>> +++ b/libavcodec/vp9.c
>> @@ -242,7 +242,7 @@ typedef struct VP9Context {
>>  // whole-frame cache
>>  uint8_t *intra_pred_data[3];
>>  struct VP9Filter *lflvl;
>> -DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71*80];
>> +DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135*144];
>>  
>>  // block reconstruction intermediates
>>  int block_alloc_using_2pass;
>> @@ -251,6 +251,8 @@ typedef struct VP9Context {
>>  struct { int x, y; } min_mv, max_mv;
>>  DECLARE_ALIGNED(32, uint8_t, tmp_y)[64*64];
>>  DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32*32];
>> +uint16_t mvscale[3][2];
>> +uint8_t mvstep[3][2];
>>  } VP9Context;
>>  
>>  static const uint8_t bwh_tab[2][N_BS_SIZES][2] = {
>> @@ -577,6 +579,26 @@ static int decode_frame_header(AVCodecContext *ctx,
>>  s->varcompref[1] = 2;
>>  }
>>  }
>> +
>> +for (i = 0; i < 3; i++) {
>> +AVFrame *ref = s->refs[s->refidx[i]].f;
>> +int refw = ref->width, refh = ref->height;
>> +
>> +if (refw == w && refh == h) {
>> +s->mvscale[i][0] = s->mvscale[i][1] = 0;
>> +} else {
>> +if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h 
>> > 16 * refh) {
>> +av_log(ctx, AV_LOG_ERROR,
>> +   "Invalid ref frame dimensions %dx%d for 
>> frame size %dx%d\n",
>> +   refw, refh, w, h);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +s->mvscale[i][0] = (refw << 14) / w;
>> +s->mvscale[i][1] = (refh << 14) / h;
>> +s->mvstep[i][0] = 16 * s->mvscale[i][0] >> 14;
>> +s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
>> +}
>> +}
>>  }
>>  }
>>  s->refreshctx   = s->errorres ? 0 : get_bits1(&s->gb);
>> @@ -2524,12 +2546,118 @@ static void intra_recon(AVCodecContext *ctx, 
>> ptrdiff_t y_off, ptrdiff_t uv_off)
>>  }
>>  }
>>  
>> -static av_always_inline void mc_luma_dir(VP9Context *s, vp9_mc_func 
>> (*mc)[2],
>> - uint8_t *dst, ptrdiff_t dst_stride,
>> - const uint8_t *ref, ptrdiff_t 
>> ref_stride,
>> - ThreadFrame *ref_frame,
>> - ptrdiff_t y, ptrdiff_t x, const 
>> VP56mv *mv,
>> - int bw, int bh, int w, int h)
>> +static av_always_inline void mc_luma_scaled(VP9Context *s, 
>> vp9_scaled_mc_func smc,
>> +uint8_t *dst, ptrdiff_t 
>> dst_stride,
>> +const uint8_t *ref, ptrdiff_t 
>> ref_stride,
>> +ThreadFrame *ref_frame,
>> +ptrdiff_t y, ptrdiff_t x, const 
>> VP56mv *mv,
>> +int bw, int bh, int w, int h,
>> +const uint16_t *scale, const 
>> uint8_t *step)
>> +{
>> +#define scale_mv(n, dim) (((int64_t)n * scale[dim]) >> 14)
>> +// BUG libvpx seems to scale the two components separately. This 
>> introduces
>> +// rounding errors but we have to reproduce them to be exactly 
>> compatible
>> +// with the output from libvpx...
> 
> Did you report it to libvpx? It's probably a better idea to fix the bug in 
> the reference
> library than purposely reproduce the buggy behavior in our implementation to 
> remain
> compatible.

Just checked the link further down the patch (As i should have done before 
replying).
Assuming it's the same bug as this one then forget what i said, they decided to 
leave
the bitstream unchanged.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for H264 lpf and weight/biweight functions

2015-04-21 Thread Timothy Gu
On Tue, Apr 21, 2015 at 10:22:48AM +, Parag Salasakar wrote:
> These are 'optimization' patches for MSA.
> We surely have plans to add runtime CPU detection code in near future as a
> separate patch.

OK, looking forward to that.

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


Re: [FFmpeg-devel] Loongson Optimization Patchs and Machine Express Issuse

2015-04-21 Thread 周晓勇
Sorry about the duplicated wrong patch-0007, 
0007-avcodec-optimize-mpegvideo-decode-for-Loongson-3-v1.patch is the right one.


> -原始邮件-
> 发件人: "周晓勇" 
> 发送时间: 2015年4月22日 星期三
> 收件人: ffmpeg-devel 
> 抄送: gaoxiang , "孟小甫" 
> 主题: [FFmpeg-devel] Loongson Optimization Patchs and Machine Express Issuse
> 
> Hi Michael,
> We have prepared the patchs and Loongson-3A machine for you, but DHL 
> needs consignee's phone number in case they could not contact u. Could you 
> send me your phone number right now? I have make an appointment with courier 
> tomorrow morning.
> The enclosures are our Loongson-3 patchs for ffmpeg-master based on 
> fbdaebb29861d32acc93fa55fd13554a2ae32eb4.
> Cause the machine belong to the company, our boss need one Electronic 
> Receipt to confirm that i do not keep the machine privately. Could you email 
> me one receipt with your sign after you receive it?
> 
> Thanks.
> 
> 
> 
> --
> 周晓勇 @系统研发部
> Christian Zhou @System R & D
> 
> 龙芯中科技术有限公司
> Loongson Technology Corporation Limited
> 
> 北京市海淀区温泉镇中关村环保科技示范园龙芯产业园2号楼
> Loongson Industrial Park, building 2 , Zhongguancun Environmental protection 
> park,
> Haidian District, Beijing, China



--
周晓勇 @系统研发部
Christian Zhou @System R & D

龙芯中科技术有限公司
Loongson Technology Corporation Limited

北京市海淀区温泉镇中关村环保科技示范园龙芯产业园2号楼
Loongson Industrial Park, building 2 , Zhongguancun Environmental protection 
park,
Haidian District, Beijing, China


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