Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 11:05:22PM -0300, James Almer wrote:
> On 11/25/2017 10:56 PM, Michael Niedermayer wrote:
> > On Sat, Nov 25, 2017 at 05:01:55PM +, Rostislav Pehlivanov wrote:
> >> Signed-off-by: Rostislav Pehlivanov 
> >> ---
> >>  libavcodec/utils.c | 9 +
> >>  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > LGTM
> > 
> > The whole lock manager should possibly be simplified using some
> > more standard mutex stuff from C11 or use that as default.
> > 
> > thx
> 
> If you mean threads.h stuff, afaik it's optional and glibc doesn't
> include it, so hardly an option today.

that is sad

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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/dirac_dwt: Fix integer overflow in COMPOSE_FIDELITYi*

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 03:43:29AM +0100, Michael Niedermayer wrote:
> Fixes: runtime error: signed integer overflow: -2143827186 - 7404944 cannot 
> be represented in type 'int'
> Fixes: 4354/clusterfuzz-testcase-minimized-4671122764201984
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dirac_dwt.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

applied

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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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


Re: [FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread Rostislav Pehlivanov
On 25 November 2017 at 19:48, Rostislav Pehlivanov 
wrote:

>
>
> On 25 November 2017 at 18:40, James Almer  wrote:
>
>> On 11/25/2017 2:01 PM, Rostislav Pehlivanov wrote:
>> > Also makes it more robust than using volatiles.
>> >
>> > Signed-off-by: Rostislav Pehlivanov 
>> > ---
>> >  libavcodec/internal.h |  1 -
>> >  libavcodec/utils.c| 12 ++--
>> >  2 files changed, 6 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/libavcodec/internal.h b/libavcodec/internal.h
>> > index d3310b6afe..1c54966f37 100644
>> > --- a/libavcodec/internal.h
>> > +++ b/libavcodec/internal.h
>> > @@ -246,7 +246,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame
>> *frame);
>> >
>> >  void ff_color_frame(AVFrame *frame, const int color[4]);
>> >
>> > -extern volatile int ff_avcodec_locked;
>> >  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
>> >  int ff_unlock_avcodec(const AVCodec *codec);
>> >
>> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
>> > index 3a0f3c11f5..96bc9ff4a4 100644
>> > --- a/libavcodec/utils.c
>> > +++ b/libavcodec/utils.c
>> > @@ -114,7 +114,7 @@ static int (*lockmgr_cb)(void **mutex, enum
>> AVLockOp op) = NULL;
>> >  #endif
>> >
>> >
>> > -volatile int ff_avcodec_locked;
>> > +static atomic_bool ff_avcodec_locked;
>> >  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>> >  static void *codec_mutex;
>> >  static void *avformat_mutex;
>> > @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex,
>> enum AVLockOp op))
>> >
>> >  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
>> >  {
>> > +_Bool exp = 1;
>> >  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE ||
>> !codec->init)
>> >  return 0;
>> >
>> > @@ -1952,22 +1953,21 @@ int ff_lock_avcodec(AVCodecContext *log_ctx,
>> const AVCodec *codec)
>> > atomic_load(_thread_counter));
>> >  if (!lockmgr_cb)
>> >  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set,
>> please see av_lockmgr_register()\n");
>> > -ff_avcodec_locked = 1;
>> > +atomic_store(_avcodec_locked, 1);
>> >  ff_unlock_avcodec(codec);
>> >  return AVERROR(EINVAL);
>> >  }
>> > -av_assert0(!ff_avcodec_locked);
>> > -ff_avcodec_locked = 1;
>> > +av_assert0(atomic_compare_exchange_strong(_avcodec_locked,
>> , 1));
>>
>> _Bool atomic_compare_exchange_strong( volatile A* obj,
>>   C* expected, C desired );
>>
>> "Atomically compares the value pointed to by obj with the value pointed
>> to by expected, and if those are equal, replaces the former with desired
>> (performs read-modify-write operation).
>> Return value: The result of the comparison: true if *obj was equal to
>> *exp, false otherwise."
>>
>> exp should be 0. You need to assert that ff_avcodec_locked == 0, then
>> set it to 1.
>>
>
> The whole experssion seems fine to me as-is and works as expected.
>
>
>>
>> >  return 0;
>> >  }
>> >
>> >  int ff_unlock_avcodec(const AVCodec *codec)
>> >  {
>> > +_Bool exp = 0;
>> >  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE ||
>> !codec->init)
>> >  return 0;
>> >
>> > -av_assert0(ff_avcodec_locked);
>> > -ff_avcodec_locked = 0;
>> > +av_assert0(atomic_compare_exchange_strong(_avcodec_locked,
>> , 0));
>>
>> And here exp should be 1.
>>
>> >  atomic_fetch_add(_thread_counter, -1);
>> >  if (lockmgr_cb) {
>> >  if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
>> >
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> Seems like I sent an older version of the patch (had to rebase to fix
> older commit), attached patch fixed both.
>

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


Re: [FFmpeg-devel] [PATCH v3 3/3] error_resilience: remove avpriv_atomic usage

2017-11-25 Thread Rostislav Pehlivanov
On 26 November 2017 at 01:58, Michael Niedermayer 
wrote:

> On Sat, Nov 25, 2017 at 05:01:57PM +, Rostislav Pehlivanov wrote:
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/error_resilience.c | 20 ++--
> >  libavcodec/error_resilience.h |  3 ++-
> >  2 files changed, 12 insertions(+), 11 deletions(-)
>
> LGTM
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I have never wished to cater to the crowd; for what I know they do not
> approve, and what they approve I do not know. -- Epicurus
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
pushed, thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread Rostislav Pehlivanov
On 26 November 2017 at 01:56, Michael Niedermayer 
wrote:

> On Sat, Nov 25, 2017 at 05:01:55PM +, Rostislav Pehlivanov wrote:
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/utils.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
>
> LGTM
>
> The whole lock manager should possibly be simplified using some
> more standard mutex stuff from C11 or use that as default.
>
> thx
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
pushed, thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mov_esds: check return value of ff_mp4_read_dec_config_descr

2017-11-25 Thread James Almer
On 11/25/2017 11:09 PM, Michael Niedermayer wrote:
> On Sat, Nov 25, 2017 at 03:54:57PM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/mov_esds.c | 7 ---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> should be ok
> 
> thx

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/isom: return proper error values in ff_mp4_read_dec_config_descr

2017-11-25 Thread James Almer
On 11/25/2017 11:05 PM, Michael Niedermayer wrote:
> On Sat, Nov 25, 2017 at 03:54:56PM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/isom.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> probably ok
> 
> thx

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mov_esds: check return value of ff_mp4_read_dec_config_descr

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 03:54:57PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavformat/mov_esds.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

should be ok

thx

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

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



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


Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread James Almer
On 11/25/2017 10:56 PM, Michael Niedermayer wrote:
> On Sat, Nov 25, 2017 at 05:01:55PM +, Rostislav Pehlivanov wrote:
>> Signed-off-by: Rostislav Pehlivanov 
>> ---
>>  libavcodec/utils.c | 9 +
>>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> LGTM
> 
> The whole lock manager should possibly be simplified using some
> more standard mutex stuff from C11 or use that as default.
> 
> thx

If you mean threads.h stuff, afaik it's optional and glibc doesn't
include it, so hardly an option today.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/isom: return proper error values in ff_mp4_read_dec_config_descr

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 03:54:56PM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavformat/isom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

probably ok

thx

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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


Re: [FFmpeg-devel] [PATCH v3 3/3] error_resilience: remove avpriv_atomic usage

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 05:01:57PM +, Rostislav Pehlivanov wrote:
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/error_resilience.c | 20 ++--
>  libavcodec/error_resilience.h |  3 ++-
>  2 files changed, 12 insertions(+), 11 deletions(-)

LGTM

thx

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 05:01:55PM +, Rostislav Pehlivanov wrote:
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/utils.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)

LGTM

The whole lock manager should possibly be simplified using some
more standard mutex stuff from C11 or use that as default.

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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


Re: [FFmpeg-devel] [PATCH 0/1][TOOL][HACK] Allocation NULL check fuzzer

2017-11-25 Thread Derek Buitenhuis
On 11/26/2017 12:14 AM, Carl Eugen Hoyos wrote:
> I am of course in favour of such checks but is there an allocator we support
> that actually returns NULL on oom?

Anything that doesn't use overcommit. Windows is the big obvious one here. Also
various UNIX-like things, and even Linux is not guaranteed to return non-NULL,
depending on how the kernel is set up (e.g. on some RHELs I think, or on
plenty of embedded setups.) 

Some libcs will fail if the requested size is outside of the allowed range.

In any case, the checks should be done.

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


Re: [FFmpeg-devel] [PATCH] lavf/mov: fix huge alloc in mov_read_ctts

2017-11-25 Thread James Almer
On 11/25/2017 10:00 PM, John Stebbins wrote:
> On 11/25/2017 04:03 PM, Carl Eugen Hoyos wrote:
>> 2017-11-25 21:11 GMT+01:00 John Stebbins :
>>> An invalid file may cause huge alloc.  Delay expansion of ctts entries
>>> until the number of samples is known in mov_build_index.
>> Please mention zhao dongzhuo from ADlab of Venustech who found this
>> issue, I can confirm that the memory allocation gets fixed.
>>
>>
> 
> Sure. Should I amend the commit message to add something like, "Thanks to 
> zhao dongzhuo from ADlab of Venustech for
> reporting this issue"?

Or just a "Found-by:" line.

See commit 837cb4325b712ff1aab531bf41668933f61d75d2 for an example.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov: fix huge alloc in mov_read_ctts

2017-11-25 Thread John Stebbins
On 11/25/2017 04:03 PM, Carl Eugen Hoyos wrote:
> 2017-11-25 21:11 GMT+01:00 John Stebbins :
>> An invalid file may cause huge alloc.  Delay expansion of ctts entries
>> until the number of samples is known in mov_build_index.
> Please mention zhao dongzhuo from ADlab of Venustech who found this
> issue, I can confirm that the memory allocation gets fixed.
>
>

Sure. Should I amend the commit message to add something like, "Thanks to zhao 
dongzhuo from ADlab of Venustech for
reporting this issue"?

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




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


Re: [FFmpeg-devel] [PATCH 0/1][TOOL][HACK] Allocation NULL check fuzzer

2017-11-25 Thread Michael Niedermayer
On Sun, Nov 26, 2017 at 01:14:31AM +0100, Carl Eugen Hoyos wrote:
> 2017-11-24 20:45 GMT+01:00 Derek Buitenhuis :
> > I've had this kicking around for like 4 years, maybe it can be of use to 
> > some people.
> > I haven't done full scale fuzzing with this because laziness. I just 
> > sometimes run it
> > when I'm bored. It's not thread-safe, but it would be trivial to make it so.
> >
> > It's based off my old LD_PRELOAD hack from here:
> >
> > https://gist.github.com/dwbuiten/7101755
> >
> > Optionally takes two env vars, MALLOC_SEED (the seed), and MALLOC_FAILPROB 
> > for the
> > probability of failing.
> >
> > I've been running it directly integrated inside FFmpeg's allocator because 
> > it makes
> > it easier to run under gdb to find where it actually crashes, if the stack 
> > trace of
> > the failure is not enough info/context.
> >
> > Currently FFmpeg has a lot of unchecked allocations - just one single FATE 
> > run with
> > this found:
> 
> I am of course in favour of such checks but is there an allocator we support
> that actually returns NULL on oom?

try
ulimit -S -v 1
and then try to malloc() more


[...]
-- 
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 0/1][TOOL][HACK] Allocation NULL check fuzzer

2017-11-25 Thread Carl Eugen Hoyos
2017-11-24 20:45 GMT+01:00 Derek Buitenhuis :
> I've had this kicking around for like 4 years, maybe it can be of use to some 
> people.
> I haven't done full scale fuzzing with this because laziness. I just 
> sometimes run it
> when I'm bored. It's not thread-safe, but it would be trivial to make it so.
>
> It's based off my old LD_PRELOAD hack from here:
>
> https://gist.github.com/dwbuiten/7101755
>
> Optionally takes two env vars, MALLOC_SEED (the seed), and MALLOC_FAILPROB 
> for the
> probability of failing.
>
> I've been running it directly integrated inside FFmpeg's allocator because it 
> makes
> it easier to run under gdb to find where it actually crashes, if the stack 
> trace of
> the failure is not enough info/context.
>
> Currently FFmpeg has a lot of unchecked allocations - just one single FATE 
> run with
> this found:

I am of course in favour of such checks but is there an allocator we support
that actually returns NULL on oom?

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


Re: [FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-11-25 Thread Carl Eugen Hoyos
2017-11-24 7:52 GMT+01:00 Rainer Hochecker :
>> Shouldn't this be:
>> 0 (or -1) for all streams (default), n>0 (or > -1) for the nth stream.
>> I guess it is at least possible that the user knows in advance which
>> streams the source will offer.
>> No?

> It is very unlikely that this is known in advance.

> Also there is no reason why you want to load
> more than a single variant at a time.

It is generally impossible to load the second (third)
variant?

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


Re: [FFmpeg-devel] [PATCH] lavf/mov: fix huge alloc in mov_read_ctts

2017-11-25 Thread Carl Eugen Hoyos
2017-11-25 21:11 GMT+01:00 John Stebbins :
> An invalid file may cause huge alloc.  Delay expansion of ctts entries
> until the number of samples is known in mov_build_index.

Please mention zhao dongzhuo from ADlab of Venustech who found this
issue, I can confirm that the memory allocation gets fixed.

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


Re: [FFmpeg-devel] [PATCH] web/index: add news entry for release 3.4

2017-11-25 Thread Carl Eugen Hoyos
2017-11-25 4:59 GMT+01:00 James Almer :

> +We strongly recommend users, distributors, and system integrators to
> +upgrade unless they use current git master.

I wonder if this can be misinterpreted...

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


Re: [FFmpeg-devel] [PATCH] avformat/aacdec: Fix leak in adts_aac_read_packet()

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 03:42:16PM -0300, James Almer wrote:
> On 11/25/2017 3:30 PM, Michael Niedermayer wrote:
> > Fixes: chromium-773637/clusterfuzz-testcase-minimized-6418078673141760
> > 
> > Found-by: ossfuzz/chromium
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/aacdec.c | 8 +++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> > index 364b33404f..101e8dbea5 100644
> > --- a/libavformat/aacdec.c
> > +++ b/libavformat/aacdec.c
> > @@ -139,7 +139,13 @@ static int adts_aac_read_packet(AVFormatContext *s, 
> > AVPacket *pkt)
> >  return AVERROR_INVALIDDATA;
> >  }
> >  
> > -return av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
> > +ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
> > +if (ret < 0) {
> > +av_packet_unref(pkt);
> > +return AVERROR_INVALIDDATA;
> 
> Why not just let the line below return ret?

will change


> 
> > +}
> > +
> > +return ret;
> >  }
> >  
> >  AVInputFormat ff_aac_demuxer = {
> > 
> 
> LGTM either way.

will apply

thanks

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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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/h264_parse: Treat escaped and unescaped decoding error equal in decode_extradata_ps_mp4()

2017-11-25 Thread Carl Eugen Hoyos
2017-11-25 22:49 GMT+01:00 Michael Niedermayer :
> Fixes: lorex.mp4

Please mention ticket #6762 if it is related.

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


Re: [FFmpeg-devel] [PATCH] tests/checkasm/float_dsp: Increase allowed difference for float_dsp.vector_dmul

2017-11-25 Thread Michael Niedermayer
On Sun, Nov 26, 2017 at 12:10:38AM +0100, Michael Niedermayer wrote:
> On Fri, Nov 24, 2017 at 11:37:36PM -0300, James Almer wrote:
> > On 10/29/2017 11:57 AM, Michael Niedermayer wrote:
> > > The choosen value is the lowest power of 2 that allows 1000 iterations of 
> > > fate-checkasm-float_dsp
> > > to pass on x86-32
> > 
> > Ticket #6848 reports this value is still not enough. Maybe something
> > like 1.0e-12 or 1.0e-13 instead?
> 
> ok, ill push it with 1e-12

Or do people prefer this: (this should be more correct)

commit 67ba87a320faba623c0b35a0692adb916860ac40 (HEAD -> master)
Author: Michael Niedermayer 
Date:   Sun Oct 29 15:26:50 2017 +0100

tests/checkasm/float_dsp: Increase allowed difference for 
float_dsp.vector_dmul

Tested for 1 iterations on x86-32

Fixes: Ticket6848

Signed-off-by: Michael Niedermayer 

diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c
index 9b0a221c25..32cac45a17 100644
--- a/tests/checkasm/float_dsp.c
+++ b/tests/checkasm/float_dsp.c
@@ -165,7 +165,8 @@ static void test_vector_dmul_scalar(const double *src0, 
const double *src1)
 call_ref(cdst, src0, src1[0], LEN);
 call_new(odst, src0, src1[0], LEN);
 for (i = 0; i < LEN; i++) {
-if (!double_near_abs_eps(cdst[i], odst[i], DBL_EPSILON)) {
+double t = FFMAX3(fabs(src1[0]), fabs(src0[i]), fabs(src1[0] * 
src0[i]));
+if (!double_near_abs_eps(cdst[i], odst[i], FFMAX(t, 1.0) * 2 * 
DBL_EPSILON)) {
 fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", i,
 cdst[i], odst[i], cdst[i] - odst[i]);
 fail();


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



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


Re: [FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-11-25 Thread Steven Liu
2017-11-25 17:31 GMT+08:00 Rainer Hochecker :
> fate runs now without error, sorry for that
>
> ---
>  doc/demuxers.texi |   5 +
>  libavformat/hls.c | 302 
> --
>  2 files changed, 207 insertions(+), 100 deletions(-)
>
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index 73dc0feec1..634b122e10 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -316,6 +316,11 @@ segment index to start live streams at (negative values 
> are from the end).
>  @item max_reload
>  Maximum number of times a insufficient list is attempted to be reloaded.
>  Default value is 1000.
> +
> +@item load_all_variants
> +If 0, only the first variant/playlist is loaded on open. All other variants
> +get disabled and can be enabled by setting discard option in program.
> +Default value is 1.
>  @end table
>
>  @section image2
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 786934af03..c1c93f8067 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -112,6 +112,7 @@ struct playlist {
>  int n_segments;
>  struct segment **segments;
>  int needed, cur_needed;
> +int parsed;
>  int cur_seq_no;
>  int64_t cur_seg_offset;
>  int64_t last_load_time;
> @@ -206,6 +207,7 @@ typedef struct HLSContext {
>  int strict_std_compliance;
>  char *allowed_extensions;
>  int max_reload;
> +int load_all_variants;
>  } HLSContext;
>
>  static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
> @@ -314,6 +316,9 @@ static struct playlist *new_playlist(HLSContext *c, const 
> char *url,
>  pls->is_id3_timestamped = -1;
>  pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
>
> +pls->index = c->n_playlists;
> +pls->parsed = 0;
> +pls->needed = 0;
>  dynarray_add(>playlists, >n_playlists, pls);
>  return pls;
>  }
> @@ -721,6 +726,7 @@ static int parse_playlist(HLSContext *c, const char *url,
>  free_segment_list(pls);
>  pls->finished = 0;
>  pls->type = PLS_TYPE_UNSPECIFIED;
> +pls->parsed = 1;
>  }
>  while (!avio_feof(in)) {
>  read_chomp_line(in, line, sizeof(line));
> @@ -1377,23 +1383,41 @@ reload:
>  static void add_renditions_to_variant(HLSContext *c, struct variant *var,
>enum AVMediaType type, const char 
> *group_id)
>  {
> -int i;
> +int i, j;
> +int found;
>
>  for (i = 0; i < c->n_renditions; i++) {
>  struct rendition *rend = c->renditions[i];
>
>  if (rend->type == type && !strcmp(rend->group_id, group_id)) {
>
> -if (rend->playlist)
> +if (rend->playlist) {
>  /* rendition is an external playlist
>   * => add the playlist to the variant */
> -dynarray_add(>playlists, >n_playlists, 
> rend->playlist);
> -else
> +found = 0;
> +for (j = 0; j < var->n_playlists; j++) {
> +if (var->playlists[j] == rend->playlist) {
> +found = 1;
> +break;
> +}
> +}
> +if (!found)
> +dynarray_add(>playlists, >n_playlists, 
> rend->playlist);
> +} else {
>  /* rendition is part of the variant main Media Playlist
>   * => add the rendition to the main Media Playlist */
> -dynarray_add(>playlists[0]->renditions,
> - >playlists[0]->n_renditions,
> - rend);
> +found = 0;
> +for (j = 0; j < var->playlists[0]->n_renditions; j++) {
> +if (var->playlists[0]->renditions[j] == rend) {
> +found = 1;
> +break;
> +}
> +}
> +if (!found)
> +dynarray_add(>playlists[0]->renditions,
> + >playlists[0]->n_renditions,
> + rend);
> +}
>  }
>  }
>  }
> @@ -1631,6 +1655,122 @@ static int hls_close(AVFormatContext *s)
>  return 0;
>  }
>
> +static int init_playlist(HLSContext *c, struct playlist *pls)
> +{
> +AVInputFormat *in_fmt = NULL;
> +int highest_cur_seq_no = 0;
> +int ret;
> +int i;
> +
> +if (!(pls->ctx = avformat_alloc_context())) {
> +return AVERROR(ENOMEM);
> +}
> +
> +if (pls->n_segments == 0)
> +return 0;
> +
> +pls->needed = 1;
> +pls->parent = c->ctx;
> +
> +/*
> + * If this is a live stream and this playlist looks like it is one 
> segment
> + * behind, try to sync it up so that every substream starts at the same
> + * time position (so e.g. avformat_find_stream_info() will see packets 
> from
> + * all active streams within the first few seconds). This is not very 
> 

Re: [FFmpeg-devel] [PATCH] tests/checkasm/float_dsp: Increase allowed difference for float_dsp.vector_dmul

2017-11-25 Thread Michael Niedermayer
On Fri, Nov 24, 2017 at 11:37:36PM -0300, James Almer wrote:
> On 10/29/2017 11:57 AM, Michael Niedermayer wrote:
> > The choosen value is the lowest power of 2 that allows 1000 iterations of 
> > fate-checkasm-float_dsp
> > to pass on x86-32
> 
> Ticket #6848 reports this value is still not enough. Maybe something
> like 1.0e-12 or 1.0e-13 instead?

ok, ill push it with 1e-12

thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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/h264_parse: Treat escaped and unescaped decoding error equal in decode_extradata_ps_mp4()

2017-11-25 Thread Clément Bœsch
On Sat, Nov 25, 2017 at 10:49:09PM +0100, Michael Niedermayer wrote:
> Fixes: lorex.mp4
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/h264_parse.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> index a7c71d9bbb..9216d0bdbd 100644
> --- a/libavcodec/h264_parse.c
> +++ b/libavcodec/h264_parse.c
> @@ -427,8 +427,6 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, 
> int buf_size, H264ParamSe
>  
>  ret = decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
> logctx);
>  av_freep(_buf);
> -if (ret < 0)
> -return ret;

If you don't want the return code to be reintroduced differently 10x in
the future (like, someone deciding to return ret in the function instead
of 0), I'd suggest 2 things:

- use "(void)decode_extradata_ps(...)" to explicitly ignore the code
  return; it's a hint for the compiler and the developer, typically used
  in OpenBSD (I believe that's because they warn about unchecked return
  code by default)
- add a comment above about the why

No comment on the change itself.

-- 
Clément B.


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


[FFmpeg-devel] [PATCH] avcodec/h264_parse: Treat escaped and unescaped decoding error equal in decode_extradata_ps_mp4()

2017-11-25 Thread Michael Niedermayer
Fixes: lorex.mp4

Signed-off-by: Michael Niedermayer 
---
 libavcodec/h264_parse.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index a7c71d9bbb..9216d0bdbd 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -427,8 +427,6 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int 
buf_size, H264ParamSe
 
 ret = decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
logctx);
 av_freep(_buf);
-if (ret < 0)
-return ret;
 }
 
 return 0;
-- 
2.15.0

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


[FFmpeg-devel] avcodec/x86/lossless_videodsp : add_left_pred AVX2 v2

2017-11-25 Thread Martin Vignali
Hello,

New patchs in attach in order to add avx2 version for add_left_pred

Change since the v1 patch
- use ymm constant
- use 3 operandes mode

Check asm result

add_left_pred_rnd_acc_c: 1279.8
add_left_pred_rnd_acc_ssse3: 261.3
add_left_pred_rnd_acc_avx2: 209.8
add_left_pred_zero_c: 1284.8
add_left_pred_zero_ssse3: 260.8
add_left_pred_zero_avx2: 204.8


001 : add return check in the checkasm test
002/003 : add avx2 version

Martin


0001-checkasm-llviddsp-test-return-of-add_left_pred-16.patch
Description: Binary data


0002-avcodec-x86-lossless_videodsp.asm-make-macro-for.patch
Description: Binary data


0003-avcodec-x86-lossless_videodsp-add-avx2-version-for.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] avcodec/x86/bswapdsp : convert pb_bswap32 to ymm constant in order to simplify code

2017-11-25 Thread Martin Vignali
Hello,

In attach patch to convert pb_bswap32 to ymm constant
and remove the vbroadcasti128 part

Speed seems to be similar to me


Martin


0004-avcodec-x86-bswapdsp-convert-pb_bswap32-to-ymm.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mov: fix huge alloc in mov_read_ctts

2017-11-25 Thread John Stebbins
An invalid file may cause huge alloc.  Delay expansion of ctts entries
until the number of samples is known in mov_build_index.
---
 libavformat/mov.c | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ddb1e59b85..7a7fd13099 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2896,7 +2896,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 {
 AVStream *st;
 MOVStreamContext *sc;
-unsigned int i, j, entries, ctts_count = 0;
+unsigned int i, entries, ctts_count = 0;
 
 if (c->fc->nb_streams < 1)
 return 0;
@@ -2929,9 +2929,8 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 continue;
 }
 
-/* Expand entries such that we have a 1-1 mapping with samples. */
-for (j = 0; j < count; j++)
-add_ctts_entry(>ctts_data, _count, 
>ctts_allocated_size, 1, duration);
+add_ctts_entry(>ctts_data, _count, >ctts_allocated_size,
+   count, duration);
 
 av_log(c->fc, AV_LOG_TRACE, "count=%d, duration=%d\n",
 count, duration);
@@ -3580,6 +3579,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 unsigned int stps_index = 0;
 unsigned int i, j;
 uint64_t stream_size = 0;
+MOVStts *ctts_data_old = sc->ctts_data;
+unsigned int ctts_count_old = sc->ctts_count;
 
 if (sc->elst_count) {
 int i, edit_start_index = 0, multiple_edits = 0;
@@ -3648,6 +3649,28 @@ static void mov_build_index(MOVContext *mov, AVStream 
*st)
 }
 st->index_entries_allocated_size = (st->nb_index_entries + 
sc->sample_count) * sizeof(*st->index_entries);
 
+if (ctts_data_old) {
+// Expand ctts entries such that we have a 1-1 mapping with samples
+if (sc->sample_count >= UINT_MAX / sizeof(*sc->ctts_data))
+return;
+sc->ctts_count = 0;
+sc->ctts_allocated_size = 0;
+sc->ctts_data = av_fast_realloc(NULL, >ctts_allocated_size,
+sc->sample_count * sizeof(*sc->ctts_data));
+if (!sc->ctts_data) {
+av_free(ctts_data_old);
+return;
+}
+for (i = 0; i < ctts_count_old &&
+sc->ctts_count < sc->sample_count; i++)
+for (j = 0; j < ctts_data_old[i].count &&
+sc->ctts_count < sc->sample_count; j++)
+add_ctts_entry(>ctts_data, >ctts_count,
+   >ctts_allocated_size, 1,
+   ctts_data_old[i].duration);
+av_free(ctts_data_old);
+}
+
 for (i = 0; i < sc->chunk_count; i++) {
 int64_t next_offset = i+1 < sc->chunk_count ? 
sc->chunk_offsets[i+1] : INT64_MAX;
 current_offset = sc->chunk_offsets[i];
-- 
2.14.3

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


Re: [FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread Rostislav Pehlivanov
On 25 November 2017 at 18:40, James Almer  wrote:

> On 11/25/2017 2:01 PM, Rostislav Pehlivanov wrote:
> > Also makes it more robust than using volatiles.
> >
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/internal.h |  1 -
> >  libavcodec/utils.c| 12 ++--
> >  2 files changed, 6 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> > index d3310b6afe..1c54966f37 100644
> > --- a/libavcodec/internal.h
> > +++ b/libavcodec/internal.h
> > @@ -246,7 +246,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame
> *frame);
> >
> >  void ff_color_frame(AVFrame *frame, const int color[4]);
> >
> > -extern volatile int ff_avcodec_locked;
> >  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
> >  int ff_unlock_avcodec(const AVCodec *codec);
> >
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index 3a0f3c11f5..96bc9ff4a4 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -114,7 +114,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp
> op) = NULL;
> >  #endif
> >
> >
> > -volatile int ff_avcodec_locked;
> > +static atomic_bool ff_avcodec_locked;
> >  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
> >  static void *codec_mutex;
> >  static void *avformat_mutex;
> > @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex,
> enum AVLockOp op))
> >
> >  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
> >  {
> > +_Bool exp = 1;
> >  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE ||
> !codec->init)
> >  return 0;
> >
> > @@ -1952,22 +1953,21 @@ int ff_lock_avcodec(AVCodecContext *log_ctx,
> const AVCodec *codec)
> > atomic_load(_thread_counter));
> >  if (!lockmgr_cb)
> >  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set,
> please see av_lockmgr_register()\n");
> > -ff_avcodec_locked = 1;
> > +atomic_store(_avcodec_locked, 1);
> >  ff_unlock_avcodec(codec);
> >  return AVERROR(EINVAL);
> >  }
> > -av_assert0(!ff_avcodec_locked);
> > -ff_avcodec_locked = 1;
> > +av_assert0(atomic_compare_exchange_strong(_avcodec_locked,
> , 1));
>
> _Bool atomic_compare_exchange_strong( volatile A* obj,
>   C* expected, C desired );
>
> "Atomically compares the value pointed to by obj with the value pointed
> to by expected, and if those are equal, replaces the former with desired
> (performs read-modify-write operation).
> Return value: The result of the comparison: true if *obj was equal to
> *exp, false otherwise."
>
> exp should be 0. You need to assert that ff_avcodec_locked == 0, then
> set it to 1.
>

The whole experssion seems fine to me as-is and works as expected.


>
> >  return 0;
> >  }
> >
> >  int ff_unlock_avcodec(const AVCodec *codec)
> >  {
> > +_Bool exp = 0;
> >  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE ||
> !codec->init)
> >  return 0;
> >
> > -av_assert0(ff_avcodec_locked);
> > -ff_avcodec_locked = 0;
> > +av_assert0(atomic_compare_exchange_strong(_avcodec_locked,
> , 0));
>
> And here exp should be 1.
>
> >  atomic_fetch_add(_thread_counter, -1);
> >  if (lockmgr_cb) {
> >  if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
> >
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Seems like I sent an older version of the patch (had to rebase to fix older
commit), attached patch fixed both.
From e85ab6b0733e97e501dd24a02c921ed1b6394e3c Mon Sep 17 00:00:00 2001
From: Rostislav Pehlivanov 
Date: Sat, 25 Nov 2017 16:55:44 +
Subject: [PATCH] libavcodec/utils.c: simplify avcodec locking with atomics

Also makes it more robust than using volatiles.

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/internal.h |  1 -
 libavcodec/utils.c| 12 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index d3310b6afe..1c54966f37 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -246,7 +246,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
 
 void ff_color_frame(AVFrame *frame, const int color[4]);
 
-extern volatile int ff_avcodec_locked;
 int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
 int ff_unlock_avcodec(const AVCodec *codec);
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 3a0f3c11f5..c733709171 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -114,7 +114,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
 #endif
 
 
-volatile int ff_avcodec_locked;
+static atomic_bool ff_avcodec_locked;
 static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
 static void *codec_mutex;
 static 

Re: [FFmpeg-devel] fate/hapdec : add test for hap alpha only

2017-11-25 Thread Martin Vignali
>
> LGTM
>
> thx
>
>
>
> Pushed, thanks

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


Re: [FFmpeg-devel] avcodec/hapdec : use gray8 for HapAlphaOnly decoding instead of RGB0

2017-11-25 Thread Martin Vignali
2017-11-23 3:46 GMT+01:00 Carl Eugen Hoyos :

> 2017-11-16 23:41 GMT+01:00 Martin Vignali :
> > Hello,
> >
> > Following previous discussion
> > patch in attach change pix_fmt for hap alpha only decoding to use gray8
> > instead of RGB0
>
> Looks like what you suggested.
>
> Thank you, Carl Eugen
>
>
> Pushed, thanks

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


[FFmpeg-devel] [PATCH 2/2] avformat/mov_esds: check return value of ff_mp4_read_dec_config_descr

2017-11-25 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/mov_esds.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov_esds.c b/libavformat/mov_esds.c
index 2ecf03742f..a444d969c6 100644
--- a/libavformat/mov_esds.c
+++ b/libavformat/mov_esds.c
@@ -23,7 +23,7 @@
 int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
 {
 AVStream *st;
-int tag;
+int tag, ret = 0;
 
 if (fc->nb_streams < 1)
 return 0;
@@ -38,6 +38,7 @@ int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
 
 ff_mp4_read_descr(fc, pb, );
 if (tag == MP4DecConfigDescrTag)
-ff_mp4_read_dec_config_descr(fc, st, pb);
-return 0;
+ret = ff_mp4_read_dec_config_descr(fc, st, pb);
+
+return ret;
 }
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 1/2] avformat/isom: return proper error values in ff_mp4_read_dec_config_descr

2017-11-25 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/isom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 77983c5eaa..9d9f85885b 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -524,7 +524,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (tag == MP4DecSpecificDescrTag) {
 av_log(fc, AV_LOG_TRACE, "Specific MPEG-4 header len=%d\n", len);
 if (!len || (uint64_t)len > (1<<30))
-return -1;
+return AVERROR_INVALIDDATA;
 av_free(st->codecpar->extradata);
 if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0)
 return ret;
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread Rostislav Pehlivanov
On 25 November 2017 at 18:37, James Almer  wrote:

> On 11/25/2017 2:01 PM, Rostislav Pehlivanov wrote:
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/utils.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index e50de6e89b..3a0f3c11f5 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -56,6 +56,7 @@
> >  #include "version.h"
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #if CONFIG_ICONV
> > @@ -114,7 +115,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp
> op) = NULL;
> >
> >
> >  volatile int ff_avcodec_locked;
> > -static int volatile entangled_thread_counter = 0;
> > +static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
> >  static void *codec_mutex;
> >  static void *avformat_mutex;
> >
> > @@ -1944,11 +1945,11 @@ int ff_lock_avcodec(AVCodecContext *log_ctx,
> const AVCodec *codec)
> >  return -1;
> >  }
> >
> > -if (avpriv_atomic_int_add_and_fetch(_thread_counter, 1)
> != 1) {
> > +if (atomic_fetch_add(_thread_counter, 1)) {
> >  av_log(log_ctx, AV_LOG_ERROR,
> > "Insufficient thread locking. At least %d threads are "
> > "calling avcodec_open2() at the same time right now.\n",
> > -   entangled_thread_counter);
> > +   atomic_load(_thread_counter));
> >  if (!lockmgr_cb)
> >  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set,
> please see av_lockmgr_register()\n");
> >  ff_avcodec_locked = 1;
> > @@ -1967,7 +1968,7 @@ int ff_unlock_avcodec(const AVCodec *codec)
> >
> >  av_assert0(ff_avcodec_locked);
> >  ff_avcodec_locked = 0;
> > -avpriv_atomic_int_add_and_fetch(_thread_counter, -1);
> > +atomic_fetch_add(_thread_counter, -1);
>
> Nit: You could use atomic_fetch_sub() instead of adding -1.
>
> >  if (lockmgr_cb) {
> >  if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
> >  return -1;
> >
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH] avformat/aacdec: Fix leak in adts_aac_read_packet()

2017-11-25 Thread James Almer
On 11/25/2017 3:30 PM, Michael Niedermayer wrote:
> Fixes: chromium-773637/clusterfuzz-testcase-minimized-6418078673141760
> 
> Found-by: ossfuzz/chromium
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/aacdec.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index 364b33404f..101e8dbea5 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -139,7 +139,13 @@ static int adts_aac_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  return AVERROR_INVALIDDATA;
>  }
>  
> -return av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
> +ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
> +if (ret < 0) {
> +av_packet_unref(pkt);
> +return AVERROR_INVALIDDATA;

Why not just let the line below return ret?

> +}
> +
> +return ret;
>  }
>  
>  AVInputFormat ff_aac_demuxer = {
> 

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


Re: [FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread James Almer
On 11/25/2017 2:01 PM, Rostislav Pehlivanov wrote:
> Also makes it more robust than using volatiles.
> 
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/internal.h |  1 -
>  libavcodec/utils.c| 12 ++--
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index d3310b6afe..1c54966f37 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -246,7 +246,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame 
> *frame);
>  
>  void ff_color_frame(AVFrame *frame, const int color[4]);
>  
> -extern volatile int ff_avcodec_locked;
>  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
>  int ff_unlock_avcodec(const AVCodec *codec);
>  
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 3a0f3c11f5..96bc9ff4a4 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -114,7 +114,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) 
> = NULL;
>  #endif
>  
>  
> -volatile int ff_avcodec_locked;
> +static atomic_bool ff_avcodec_locked;
>  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>  static void *codec_mutex;
>  static void *avformat_mutex;
> @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum 
> AVLockOp op))
>  
>  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
>  {
> +_Bool exp = 1;
>  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
>  return 0;
>  
> @@ -1952,22 +1953,21 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const 
> AVCodec *codec)
> atomic_load(_thread_counter));
>  if (!lockmgr_cb)
>  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please 
> see av_lockmgr_register()\n");
> -ff_avcodec_locked = 1;
> +atomic_store(_avcodec_locked, 1);
>  ff_unlock_avcodec(codec);
>  return AVERROR(EINVAL);
>  }
> -av_assert0(!ff_avcodec_locked);
> -ff_avcodec_locked = 1;
> +av_assert0(atomic_compare_exchange_strong(_avcodec_locked, , 1));

_Bool atomic_compare_exchange_strong( volatile A* obj,
  C* expected, C desired );

"Atomically compares the value pointed to by obj with the value pointed
to by expected, and if those are equal, replaces the former with desired
(performs read-modify-write operation).
Return value: The result of the comparison: true if *obj was equal to
*exp, false otherwise."

exp should be 0. You need to assert that ff_avcodec_locked == 0, then
set it to 1.

>  return 0;
>  }
>  
>  int ff_unlock_avcodec(const AVCodec *codec)
>  {
> +_Bool exp = 0;
>  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
>  return 0;
>  
> -av_assert0(ff_avcodec_locked);
> -ff_avcodec_locked = 0;
> +av_assert0(atomic_compare_exchange_strong(_avcodec_locked, , 0));

And here exp should be 1.

>  atomic_fetch_add(_thread_counter, -1);
>  if (lockmgr_cb) {
>  if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
> 

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


Re: [FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread James Almer
On 11/25/2017 2:01 PM, Rostislav Pehlivanov wrote:
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/utils.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index e50de6e89b..3a0f3c11f5 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -56,6 +56,7 @@
>  #include "version.h"
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #if CONFIG_ICONV
> @@ -114,7 +115,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) 
> = NULL;
>  
>  
>  volatile int ff_avcodec_locked;
> -static int volatile entangled_thread_counter = 0;
> +static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>  static void *codec_mutex;
>  static void *avformat_mutex;
>  
> @@ -1944,11 +1945,11 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const 
> AVCodec *codec)
>  return -1;
>  }
>  
> -if (avpriv_atomic_int_add_and_fetch(_thread_counter, 1) != 1) {
> +if (atomic_fetch_add(_thread_counter, 1)) {
>  av_log(log_ctx, AV_LOG_ERROR,
> "Insufficient thread locking. At least %d threads are "
> "calling avcodec_open2() at the same time right now.\n",
> -   entangled_thread_counter);
> +   atomic_load(_thread_counter));
>  if (!lockmgr_cb)
>  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please 
> see av_lockmgr_register()\n");
>  ff_avcodec_locked = 1;
> @@ -1967,7 +1968,7 @@ int ff_unlock_avcodec(const AVCodec *codec)
>  
>  av_assert0(ff_avcodec_locked);
>  ff_avcodec_locked = 0;
> -avpriv_atomic_int_add_and_fetch(_thread_counter, -1);
> +atomic_fetch_add(_thread_counter, -1);

Nit: You could use atomic_fetch_sub() instead of adding -1.

>  if (lockmgr_cb) {
>  if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
>  return -1;
> 

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


[FFmpeg-devel] [PATCH] avformat/aacdec: Fix leak in adts_aac_read_packet()

2017-11-25 Thread Michael Niedermayer
Fixes: chromium-773637/clusterfuzz-testcase-minimized-6418078673141760

Found-by: ossfuzz/chromium
Signed-off-by: Michael Niedermayer 
---
 libavformat/aacdec.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 364b33404f..101e8dbea5 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -139,7 +139,13 @@ static int adts_aac_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 return AVERROR_INVALIDDATA;
 }
 
-return av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
+ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
+if (ret < 0) {
+av_packet_unref(pkt);
+return AVERROR_INVALIDDATA;
+}
+
+return ret;
 }
 
 AVInputFormat ff_aac_demuxer = {
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread James Almer
On 11/25/2017 3:07 PM, Clément Bœsch wrote:
> On Sat, Nov 25, 2017 at 05:01:56PM +, Rostislav Pehlivanov wrote:
> [...]
>> -volatile int ff_avcodec_locked;
>> +static atomic_bool ff_avcodec_locked;
>>  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>>  static void *codec_mutex;
>>  static void *avformat_mutex;
>> @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum 
>> AVLockOp op))
>>  
>>  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
>>  {
> 
>> +_Bool exp = 1;
> 
> why _Bool instead of atomic_bool?

See http://en.cppreference.com/w/c/atomic/atomic_compare_exchange

The variable passed as argument for *expected needs to be of the
non-atomic type of the variable passed for *obj.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread Clément Bœsch
On Sat, Nov 25, 2017 at 05:01:56PM +, Rostislav Pehlivanov wrote:
[...]
> -volatile int ff_avcodec_locked;
> +static atomic_bool ff_avcodec_locked;
>  static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
>  static void *codec_mutex;
>  static void *avformat_mutex;
> @@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum 
> AVLockOp op))
>  
>  int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
>  {

> +_Bool exp = 1;

why _Bool instead of atomic_bool?

-- 
Clément B.


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


[FFmpeg-devel] [PATCH] hls demuxer: add option to defer parsing of variants

2017-11-25 Thread Rainer Hochecker
fate runs now without error, sorry for that

---
 doc/demuxers.texi |   5 +
 libavformat/hls.c | 302 --
 2 files changed, 207 insertions(+), 100 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 73dc0feec1..634b122e10 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -316,6 +316,11 @@ segment index to start live streams at (negative values 
are from the end).
 @item max_reload
 Maximum number of times a insufficient list is attempted to be reloaded.
 Default value is 1000.
+
+@item load_all_variants
+If 0, only the first variant/playlist is loaded on open. All other variants
+get disabled and can be enabled by setting discard option in program.
+Default value is 1.
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 786934af03..c1c93f8067 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -112,6 +112,7 @@ struct playlist {
 int n_segments;
 struct segment **segments;
 int needed, cur_needed;
+int parsed;
 int cur_seq_no;
 int64_t cur_seg_offset;
 int64_t last_load_time;
@@ -206,6 +207,7 @@ typedef struct HLSContext {
 int strict_std_compliance;
 char *allowed_extensions;
 int max_reload;
+int load_all_variants;
 } HLSContext;
 
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
@@ -314,6 +316,9 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 pls->is_id3_timestamped = -1;
 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
+pls->index = c->n_playlists;
+pls->parsed = 0;
+pls->needed = 0;
 dynarray_add(>playlists, >n_playlists, pls);
 return pls;
 }
@@ -721,6 +726,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 free_segment_list(pls);
 pls->finished = 0;
 pls->type = PLS_TYPE_UNSPECIFIED;
+pls->parsed = 1;
 }
 while (!avio_feof(in)) {
 read_chomp_line(in, line, sizeof(line));
@@ -1377,23 +1383,41 @@ reload:
 static void add_renditions_to_variant(HLSContext *c, struct variant *var,
   enum AVMediaType type, const char 
*group_id)
 {
-int i;
+int i, j;
+int found;
 
 for (i = 0; i < c->n_renditions; i++) {
 struct rendition *rend = c->renditions[i];
 
 if (rend->type == type && !strcmp(rend->group_id, group_id)) {
 
-if (rend->playlist)
+if (rend->playlist) {
 /* rendition is an external playlist
  * => add the playlist to the variant */
-dynarray_add(>playlists, >n_playlists, 
rend->playlist);
-else
+found = 0;
+for (j = 0; j < var->n_playlists; j++) {
+if (var->playlists[j] == rend->playlist) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists, >n_playlists, 
rend->playlist);
+} else {
 /* rendition is part of the variant main Media Playlist
  * => add the rendition to the main Media Playlist */
-dynarray_add(>playlists[0]->renditions,
- >playlists[0]->n_renditions,
- rend);
+found = 0;
+for (j = 0; j < var->playlists[0]->n_renditions; j++) {
+if (var->playlists[0]->renditions[j] == rend) {
+found = 1;
+break;
+}
+}
+if (!found)
+dynarray_add(>playlists[0]->renditions,
+ >playlists[0]->n_renditions,
+ rend);
+}
 }
 }
 }
@@ -1631,6 +1655,122 @@ static int hls_close(AVFormatContext *s)
 return 0;
 }
 
+static int init_playlist(HLSContext *c, struct playlist *pls)
+{
+AVInputFormat *in_fmt = NULL;
+int highest_cur_seq_no = 0;
+int ret;
+int i;
+
+if (!(pls->ctx = avformat_alloc_context())) {
+return AVERROR(ENOMEM);
+}
+
+if (pls->n_segments == 0)
+return 0;
+
+pls->needed = 1;
+pls->parent = c->ctx;
+
+/*
+ * If this is a live stream and this playlist looks like it is one segment
+ * behind, try to sync it up so that every substream starts at the same
+ * time position (so e.g. avformat_find_stream_info() will see packets from
+ * all active streams within the first few seconds). This is not very 
generic,
+ * though, as the sequence numbers are technically independent.
+ */
+highest_cur_seq_no = 0;
+for (i = 0; i < c->n_playlists; i++) {
+struct playlist *pls = c->playlists[i];
+if (!pls->parsed)
+continue;
+if (pls->cur_seq_no > highest_cur_seq_no)
+highest_cur_seq_no = 

Re: [FFmpeg-devel] [PATCH] lavr: deprecate the entire library

2017-11-25 Thread Derek Buitenhuis
On 11/25/2017 2:40 PM, Clément Bœsch wrote:
> Maybe "libavresample is not maintained by the FFmpeg project and will be
> dropped at the next major bump. Please use libswresample instead."
> 
> And it probably needs a longer explanation somewhere (website/news/...)

All API functions should be properly marked as deprecated in the headers.

Relying on a stderr warning to help migrate API users is silly, who is
going to be watching stderr using a /library/?

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


[FFmpeg-devel] [PATCH v3 3/3] error_resilience: remove avpriv_atomic usage

2017-11-25 Thread Rostislav Pehlivanov
Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/error_resilience.c | 20 ++--
 libavcodec/error_resilience.h |  3 ++-
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 0c7f29d171..8f172beca6 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -807,7 +807,7 @@ void ff_er_frame_start(ERContext *s)
 
 memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END,
s->mb_stride * s->mb_height * sizeof(uint8_t));
-s->error_count= 3 * s->mb_num;
+atomic_init(>error_count, 3 * s->mb_num);
 s->error_occurred = 0;
 }
 
@@ -852,20 +852,20 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 mask &= ~VP_START;
 if (status & (ER_AC_ERROR | ER_AC_END)) {
 mask   &= ~(ER_AC_ERROR | ER_AC_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 if (status & (ER_DC_ERROR | ER_DC_END)) {
 mask   &= ~(ER_DC_ERROR | ER_DC_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 if (status & (ER_MV_ERROR | ER_MV_END)) {
 mask   &= ~(ER_MV_ERROR | ER_MV_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 
 if (status & ER_MB_ERROR) {
 s->error_occurred = 1;
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 }
 
 if (mask == ~0x7F) {
@@ -878,7 +878,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 }
 
 if (end_i == s->mb_num)
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 else {
 s->error_status_table[end_xy] &= mask;
 s->error_status_table[end_xy] |= status;
@@ -893,7 +893,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 prev_status &= ~ VP_START;
 if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
 s->error_occurred = 1;
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 }
 }
 }
@@ -910,10 +910,10 @@ void ff_er_frame_end(ERContext *s)
 
 /* We do not support ER of field pictures yet,
  * though it should not crash if enabled. */
-if (!s->avctx->error_concealment || s->error_count == 0||
+if (!s->avctx->error_concealment || !atomic_load(>error_count)  ||
 s->avctx->lowres   ||
 !er_supported(s)   ||
-s->error_count == 3 * s->mb_width *
+atomic_load(>error_count) == 3 * s->mb_width *
   (s->avctx->skip_top + s->avctx->skip_bottom)) {
 return;
 }
@@ -927,7 +927,7 @@ void ff_er_frame_end(ERContext *s)
 if (   mb_x == s->mb_width
 && s->avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
 && (FFALIGN(s->avctx->height, 16)&16)
-&& s->error_count == 3 * s->mb_width * (s->avctx->skip_top + 
s->avctx->skip_bottom + 1)
+&& atomic_load(>error_count) == 3 * s->mb_width * 
(s->avctx->skip_top + s->avctx->skip_bottom + 1)
 ) {
 av_log(s->avctx, AV_LOG_DEBUG, "ignoring last missing slice\n");
 return;
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index 27c2008694..664a765659 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -20,6 +20,7 @@
 #define AVCODEC_ERROR_RESILIENCE_H
 
 #include 
+#include 
 
 #include "avcodec.h"
 #include "me_cmp.h"
@@ -60,7 +61,7 @@ typedef struct ERContext {
 ptrdiff_t mb_stride;
 ptrdiff_t b8_stride;
 
-volatile int error_count;
+atomic_int error_count;
 int error_occurred;
 uint8_t *error_status_table;
 uint8_t *er_temp_buffer;
-- 
2.15.0.417.g466bffb3ac

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


[FFmpeg-devel] [PATCH v3 2/3] libavcodec/utils.c: simplify avcodec locking with atomics

2017-11-25 Thread Rostislav Pehlivanov
Also makes it more robust than using volatiles.

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/internal.h |  1 -
 libavcodec/utils.c| 12 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index d3310b6afe..1c54966f37 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -246,7 +246,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
 
 void ff_color_frame(AVFrame *frame, const int color[4]);
 
-extern volatile int ff_avcodec_locked;
 int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec);
 int ff_unlock_avcodec(const AVCodec *codec);
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 3a0f3c11f5..96bc9ff4a4 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -114,7 +114,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = 
NULL;
 #endif
 
 
-volatile int ff_avcodec_locked;
+static atomic_bool ff_avcodec_locked;
 static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
 static void *codec_mutex;
 static void *avformat_mutex;
@@ -1937,6 +1937,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum 
AVLockOp op))
 
 int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
 {
+_Bool exp = 1;
 if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
 return 0;
 
@@ -1952,22 +1953,21 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const 
AVCodec *codec)
atomic_load(_thread_counter));
 if (!lockmgr_cb)
 av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see 
av_lockmgr_register()\n");
-ff_avcodec_locked = 1;
+atomic_store(_avcodec_locked, 1);
 ff_unlock_avcodec(codec);
 return AVERROR(EINVAL);
 }
-av_assert0(!ff_avcodec_locked);
-ff_avcodec_locked = 1;
+av_assert0(atomic_compare_exchange_strong(_avcodec_locked, , 1));
 return 0;
 }
 
 int ff_unlock_avcodec(const AVCodec *codec)
 {
+_Bool exp = 0;
 if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
 return 0;
 
-av_assert0(ff_avcodec_locked);
-ff_avcodec_locked = 0;
+av_assert0(atomic_compare_exchange_strong(_avcodec_locked, , 0));
 atomic_fetch_add(_thread_counter, -1);
 if (lockmgr_cb) {
 if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
-- 
2.15.0.417.g466bffb3ac

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


[FFmpeg-devel] [PATCH v3 1/3] lavc/utils.c: use C11 atomics for entangled thread handling

2017-11-25 Thread Rostislav Pehlivanov
Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/utils.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e50de6e89b..3a0f3c11f5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -56,6 +56,7 @@
 #include "version.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #if CONFIG_ICONV
@@ -114,7 +115,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = 
NULL;
 
 
 volatile int ff_avcodec_locked;
-static int volatile entangled_thread_counter = 0;
+static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0);
 static void *codec_mutex;
 static void *avformat_mutex;
 
@@ -1944,11 +1945,11 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const 
AVCodec *codec)
 return -1;
 }
 
-if (avpriv_atomic_int_add_and_fetch(_thread_counter, 1) != 1) {
+if (atomic_fetch_add(_thread_counter, 1)) {
 av_log(log_ctx, AV_LOG_ERROR,
"Insufficient thread locking. At least %d threads are "
"calling avcodec_open2() at the same time right now.\n",
-   entangled_thread_counter);
+   atomic_load(_thread_counter));
 if (!lockmgr_cb)
 av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see 
av_lockmgr_register()\n");
 ff_avcodec_locked = 1;
@@ -1967,7 +1968,7 @@ int ff_unlock_avcodec(const AVCodec *codec)
 
 av_assert0(ff_avcodec_locked);
 ff_avcodec_locked = 0;
-avpriv_atomic_int_add_and_fetch(_thread_counter, -1);
+atomic_fetch_add(_thread_counter, -1);
 if (lockmgr_cb) {
 if ((*lockmgr_cb)(_mutex, AV_LOCK_RELEASE))
 return -1;
-- 
2.15.0.417.g466bffb3ac

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


Re: [FFmpeg-devel] [PATCH] hwcontext_d3d11va: properly reset values after release/close

2017-11-25 Thread Jan Ekström
On Sat, Nov 25, 2017 at 6:25 PM, Mark Thompson  wrote:
> LGTM, please apply.
>
> I checked the other hwcontext implementations for the same problem, and found 
> it only in OpenCL - it could also crash there, fixed in 
> .
>
> Thanks,
>
> - Mark

Thanks for the reviews, applied.

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


[FFmpeg-devel] [PATCH 2/2] error_resilience: remove avpriv_atomic usage

2017-11-25 Thread Rostislav Pehlivanov
Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/error_resilience.c | 18 +-
 libavcodec/error_resilience.h |  3 ++-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 0c7f29d171..abd001ed72 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -852,20 +852,20 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 mask &= ~VP_START;
 if (status & (ER_AC_ERROR | ER_AC_END)) {
 mask   &= ~(ER_AC_ERROR | ER_AC_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 if (status & (ER_DC_ERROR | ER_DC_END)) {
 mask   &= ~(ER_DC_ERROR | ER_DC_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 if (status & (ER_MV_ERROR | ER_MV_END)) {
 mask   &= ~(ER_MV_ERROR | ER_MV_END);
-avpriv_atomic_int_add_and_fetch(>error_count, start_i - end_i - 1);
+atomic_fetch_add(>error_count, start_i - end_i - 1);
 }
 
 if (status & ER_MB_ERROR) {
 s->error_occurred = 1;
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 }
 
 if (mask == ~0x7F) {
@@ -878,7 +878,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 }
 
 if (end_i == s->mb_num)
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 else {
 s->error_status_table[end_xy] &= mask;
 s->error_status_table[end_xy] |= status;
@@ -893,7 +893,7 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
 prev_status &= ~ VP_START;
 if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
 s->error_occurred = 1;
-avpriv_atomic_int_set(>error_count, INT_MAX);
+atomic_store(>error_count, INT_MAX);
 }
 }
 }
@@ -910,10 +910,10 @@ void ff_er_frame_end(ERContext *s)
 
 /* We do not support ER of field pictures yet,
  * though it should not crash if enabled. */
-if (!s->avctx->error_concealment || s->error_count == 0||
+if (!s->avctx->error_concealment || !atomic_load(>error_count)  ||
 s->avctx->lowres   ||
 !er_supported(s)   ||
-s->error_count == 3 * s->mb_width *
+atomic_load(>error_count) == 3 * s->mb_width *
   (s->avctx->skip_top + s->avctx->skip_bottom)) {
 return;
 }
@@ -927,7 +927,7 @@ void ff_er_frame_end(ERContext *s)
 if (   mb_x == s->mb_width
 && s->avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
 && (FFALIGN(s->avctx->height, 16)&16)
-&& s->error_count == 3 * s->mb_width * (s->avctx->skip_top + 
s->avctx->skip_bottom + 1)
+&& atomic_load(>error_count) == 3 * s->mb_width * 
(s->avctx->skip_top + s->avctx->skip_bottom + 1)
 ) {
 av_log(s->avctx, AV_LOG_DEBUG, "ignoring last missing slice\n");
 return;
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index 27c2008694..664a765659 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -20,6 +20,7 @@
 #define AVCODEC_ERROR_RESILIENCE_H
 
 #include 
+#include 
 
 #include "avcodec.h"
 #include "me_cmp.h"
@@ -60,7 +61,7 @@ typedef struct ERContext {
 ptrdiff_t mb_stride;
 ptrdiff_t b8_stride;
 
-volatile int error_count;
+atomic_int error_count;
 int error_occurred;
 uint8_t *error_status_table;
 uint8_t *er_temp_buffer;
-- 
2.15.0.417.g466bffb3ac

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


Re: [FFmpeg-devel] [PATCH] hwcontext_d3d11va: properly reset values after release/close

2017-11-25 Thread Mark Thompson
On 24/11/17 01:01, Jan Ekström wrote:
> Makes the uninit function re-entrable, which can be a common case
> when an API user first tries to initialize its context, fails, and
> then finally unrefs the AVHWDevice.
> 
> Fixes a crash reported by sm2345 on IRC.
> ---
>  libavutil/hwcontext_d3d11va.c | 21 -
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index 65dd6651fc..845a4a45fe 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -458,20 +458,31 @@ static void d3d11va_device_uninit(AVHWDeviceContext 
> *hwdev)
>  {
>  AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx;
>  
> -if (device_hwctx->device)
> +if (device_hwctx->device) {
>  ID3D11Device_Release(device_hwctx->device);
> +device_hwctx->device = NULL;
> +}
>  
> -if (device_hwctx->device_context)
> +if (device_hwctx->device_context) {
>  ID3D11DeviceContext_Release(device_hwctx->device_context);
> +device_hwctx->device_context = NULL;
> +}
>  
> -if (device_hwctx->video_device)
> +if (device_hwctx->video_device) {
>  ID3D11VideoDevice_Release(device_hwctx->video_device);
> +device_hwctx->video_device = NULL;
> +}
>  
> -if (device_hwctx->video_context)
> +if (device_hwctx->video_context) {
>  ID3D11VideoContext_Release(device_hwctx->video_context);
> +device_hwctx->video_context = NULL;
> +}
>  
> -if (device_hwctx->lock == d3d11va_default_lock)
> +if (device_hwctx->lock == d3d11va_default_lock) {
>  CloseHandle(device_hwctx->lock_ctx);
> +device_hwctx->lock_ctx = INVALID_HANDLE_VALUE;
> +device_hwctx->lock = NULL;
> +}
>  }
>  
>  static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
> 

LGTM, please apply.

I checked the other hwcontext implementations for the same problem, and found 
it only in OpenCL - it could also crash there, fixed in 
.

Thanks,

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


Re: [FFmpeg-devel] [PATCH] hwcontext_d3d11: Log adapter details on device creation

2017-11-25 Thread Mark Thompson
On 25/11/17 14:07, Jan Ekstrom wrote:
> On Tue, Nov 14, 2017 at 4:05 PM, Mark Thompson  wrote:
>> This is helpful to know what device has actually been used.
>> ---
> 
> Change looks alright, and especially in multi-GPU contexts like
> laptops this can be quite useful - as you would learn which device you
> have just tried to utilize.

Yeah, that's exactly the intent (it is not straightforward at all to find what 
the adapter index numbers actually are by any other route).

Applied.

Thanks,

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


Re: [FFmpeg-devel] [PATCH] ffmpeg fft: fix broken opus on 3dnow

2017-11-25 Thread James Almer
On 11/23/2017 4:12 PM, Mikulas Patocka wrote:
> The commit b7c16a3f2c4921f613319938b8ee0e3d6fa83e8d ("x86: fft: Port to
> cpuflags") breaks the opus decoder in ffmpeg when compiling for 3dnow. The
> output is audible, but there's a lot of noise.
> 
> This could be tested by disabling sse and compiling ffmpeg on a processor
> with 3dnow support:
> CC='gcc -m32' ./configure --disable-sse --disable-sse2 --disable-sse3
> 
> The reason for the breakage is that the commit unintentionally changed the 
> INTERL macro so that it is empty when compiling for 3dnow. This patch 
> fixes it.
> 
> Signed-off-by: Mikulas Patocka 
> 
> ---
>  libavcodec/x86/fft.asm |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: ffmpeg/libavcodec/x86/fft.asm
> ===
> --- mplayer.orig/libavcodec/x86/fft.asm
> +++ mplayer/libavcodec/x86/fft.asm
> @@ -199,7 +199,7 @@ SECTION .text
>  vextractf128  %4 %+ H(%5), %3, 0
>  vextractf128   %4(%5 + 1), %2, 1
>  vextractf128  %4 %+ H(%5 + 1), %3, 1
> -%elif cpuflag(sse)
> +%elif cpuflag(sse) || cpuflag(3dnow)
>  mova %3, %2
>  unpcklps %2, %1
>  unpckhps %3, %1

Confirmed and applied. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add lv2 wrapper filter

2017-11-25 Thread Paul B Mahol
On 11/24/17, Paul B Mahol  wrote:
> On 11/24/17, Derek Buitenhuis  wrote:
>> On 11/23/2017 9:16 PM, Paul B Mahol wrote:
>>
>>> +typedef struct LV2Context {
>>> +const AVClass *class;
>>> +char *plugin_uri;
>>> +char *options;
>>> +
>>> +unsigned long nb_inputs;
>>> +unsigned long nb_inputcontrols;
>>> +unsigned long nb_outputs;
>>
>> Why are you using longs instead of stdint?
>
> Fixed.
>
>>
>>> +table->uris = av_realloc(table->uris, ++table->n_uris *
>>> sizeof(char*));
>>> +table->uris[table->n_uris - 1] = av_malloc(len + 1);
>>
>> Every single allocation in this whole file is completely unchecked.
>> That's
>> not OK.
>
> Fixed.
>

If there are no more comments, I would like to apply this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] configure: remove superfluous cuvid and nvdec checks

2017-11-25 Thread James Almer
On 11/25/2017 12:27 PM, Philip Langdale wrote:
> On Fri, 24 Nov 2017 22:49:18 -0300
> James Almer  wrote:
> 
>> Both are autodetected, and their dependency on cuda is checked
>> elsewhere.
>>
>> Fixes ticket #6849.
>> ---
>>  configure | 4 
>>  1 file changed, 4 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 3ec6407fb2..7769427ffb 100755
>> --- a/configure
>> +++ b/configure
>> @@ -5816,10 +5816,6 @@ done
>>  
>>  # these are off by default, so fail if requested and not available
>>  enabled cuda_sdk  && require cuda_sdk cuda.h cuCtxCreate
>> -lcuda -enabled cuvid && { enabled cuda ||
>> -   die "ERROR: CUVID requires CUDA"; }
>> -enabled nvdec && { enabled cuda ||
>> -   die "ERROR: NVDEC hwaccel requires
>> CUDA"; } enabled chromaprint   && require chromaprint
>> chromaprint.h chromaprint_get_version -lchromaprint enabled
>> decklink  && { require_header DeckLinkAPI.h &&
>> { check_cpp_condition DeckLinkAPIVersion.h
>> "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR:
>> Decklink API version must be >= 10.6.1."; } }
> 
> LGTM
> 
> 
> --phil

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


Re: [FFmpeg-devel] [PATCH] configure: remove superfluous cuvid and nvdec checks

2017-11-25 Thread Philip Langdale
On Fri, 24 Nov 2017 22:49:18 -0300
James Almer  wrote:

> Both are autodetected, and their dependency on cuda is checked
> elsewhere.
> 
> Fixes ticket #6849.
> ---
>  configure | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/configure b/configure
> index 3ec6407fb2..7769427ffb 100755
> --- a/configure
> +++ b/configure
> @@ -5816,10 +5816,6 @@ done
>  
>  # these are off by default, so fail if requested and not available
>  enabled cuda_sdk  && require cuda_sdk cuda.h cuCtxCreate
> -lcuda -enabled cuvid && { enabled cuda ||
> -   die "ERROR: CUVID requires CUDA"; }
> -enabled nvdec && { enabled cuda ||
> -   die "ERROR: NVDEC hwaccel requires
> CUDA"; } enabled chromaprint   && require chromaprint
> chromaprint.h chromaprint_get_version -lchromaprint enabled
> decklink  && { require_header DeckLinkAPI.h &&
> { check_cpp_condition DeckLinkAPIVersion.h
> "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR:
> Decklink API version must be >= 10.6.1."; } }

LGTM


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


Re: [FFmpeg-devel] [PATCH] lavr: deprecate the entire library

2017-11-25 Thread Clément Bœsch
On Fri, Nov 17, 2017 at 03:58:16PM +, Rostislav Pehlivanov wrote:
[...]
> diff --git a/libavresample/utils.c b/libavresample/utils.c
> index b4fb906556..3e629fe901 100644
> --- a/libavresample/utils.c
> +++ b/libavresample/utils.c
> @@ -37,6 +37,9 @@ int avresample_open(AVAudioResampleContext *avr)
>  {
>  int ret;
>  
> +av_log(avr, AV_LOG_WARNING, "This library is being deprecated in favor 
> of libswresample, "
> +   "please migrate your program.");
> +

I'm fine with the patch but not so with this message.

Maybe "libavresample is not maintained by the FFmpeg project and will be
dropped at the next major bump. Please use libswresample instead."

And it probably needs a longer explanation somewhere (website/news/...)

Regards,

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH] hwcontext_d3d11: Log adapter details on device creation

2017-11-25 Thread Jan Ekstrom
On Tue, Nov 14, 2017 at 4:05 PM, Mark Thompson  wrote:
> This is helpful to know what device has actually been used.
> ---

Change looks alright, and especially in multi-GPU contexts like
laptops this can be quite useful - as you would learn which device you
have just tried to utilize.

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


Re: [FFmpeg-devel] [PATCH] web/index: add news entry for release 3.4

2017-11-25 Thread James Almer
On 11/25/2017 9:22 AM, Michael Niedermayer wrote:
> On Sat, Nov 25, 2017 at 12:59:50AM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> This was for some reason missed back in October.
>>
>>  src/index | 52 
>>  1 file changed, 52 insertions(+)
> 
> LGTM
> 
> thx

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


Re: [FFmpeg-devel] [PATCH] web/index: add news entry for release 3.4

2017-11-25 Thread Michael Niedermayer
On Sat, Nov 25, 2017 at 12:59:50AM -0300, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> This was for some reason missed back in October.
> 
>  src/index | 52 
>  1 file changed, 52 insertions(+)

LGTM

thx

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

Those who are best at talking, realize last or never when they are wrong.


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


Re: [FFmpeg-devel] [PATCH] 8-bit hevc decoding optimization on aarch64 with neon

2017-11-25 Thread Clément Bœsch
On Sat, Nov 18, 2017 at 06:35:48PM +0100, Rafal Dabrowa wrote:
> 
> This is a proposal of performance optimizations for 8-bit
> hevc video decoding on aarch64 platform with neon (simd) extension.
> 
> I'm testing my optimizations on NanoPi M3 device. I'm using
> mainly "Big Buck Bunny" video file in format 1280x720 for testing.
> The video file was pulled from libde265.org page, see
> http://www.libde265.org/hevc-bitstreams/bbb-1280x720-cfg06.mkv
> The movie duration is 00:10:34.53.
> 
> Overall performance gain is about 2x. Without optimizations the movie
> playback stops in practice after a few seconds. With
> optimizations the file is played smoothly 99% of the time.
> 
> For performance testing the following command was used:
> 
> time ./ffmpeg -hide_banner -i ~/bbb-1280x720-cfg06.mkv -f yuv4mpegpipe - 
> >/dev/null
> 
> The video file was pre-read before test to minimize disk reads during testing.
> Program execution time without optimization was as follows:
> 
> real  11m48.576s
> user  43m8.111s
> sys   0m12.469s
> 
> Execution time with optimizations:
> 
> real  6m17.046s
> user  21m19.792s
> sys   0m14.724s
> 

Can you post the results of checkasm --bench for hevc?

Did you run it to check for any calling convention violation?

> 
> The patch contains optimizations for most heavily used qpel, epel, sao and 
> idct
> functions.  Among the functions provided for optimization there are two
> intensively used, but not optimized in this patch: hevc_v_loop_filter_luma_8
> and hevc_h_loop_filter_luma_8. I have no idea how they could be optimized
> hence I leaved them without optimizations.
> 

You may want to check x86/hevc_deblock.asm then (no idea if these are
implemented).

[...]
> +function ff_hevc_put_hevc_pel_pixels4_8_neon, export=1
> +mov x7, 128
> +1:  ld1 { v0.s }[0], [x1], x2
> +ushll   v4.8h, v0.8b, 6

> +st1 { v4.d }[0], [x0], x7

using #128 not possible?

> +subsx3, x3, 1
> +b.ne1b
> +ret

here and below: no use of the x6 register?

A few comments on the style:

- please use a consistent spacing (current function mismatches with later
  code), preferably using a relatively large number of spaces as common
  ground (check the other sources)
- we use capitalized size suffixes (B, H, ...); and IIRC the lower case
  form are problematic with some assembler but don't quote me on that.
- we don't use spaces between {}

> +endfunc
> +
> +function ff_hevc_put_hevc_pel_pixels6_8_neon, export=1
> +mov x7, 120
> +1:  ld1 { v0.8b }, [x1], x2
> +ushll   v4.8h, v0.8b, 6

> +st1 { v4.d }[0], [x0], 8

I think you need to use # as prefix for the immediates

> +st1 { v4.s }[2], [x0], x7

I assume you can't use #120?

Have you checked if using #128 here and decrementing x0 afterward isn't
faster?

[...]
> +function ff_hevc_put_hevc_pel_bi_pixels32_8_neon, export=1
> +mov x10, 128
> +1:  ld1 { v0.16b, v1.16b }, [x2], x3// src
> +ushll   v16.8h, v0.8b, 6
> +ushll2  v17.8h, v0.16b, 6
> +ushll   v18.8h, v1.8b, 6
> +ushll2  v19.8h, v1.16b, 6
> +ld1 { v20.8h, v21.8h, v22.8h, v23.8h }, [x4], x10   // src2
> +sqadd   v16.8h, v16.8h, v20.8h
> +sqadd   v17.8h, v17.8h, v21.8h
> +sqadd   v18.8h, v18.8h, v22.8h
> +sqadd   v19.8h, v19.8h, v23.8h

> +sqrshrunv0.8b,  v16.8h, 7
> +sqrshrun2   v0.16b, v17.8h, 7
> +sqrshrunv1.8b,  v18.8h, 7
> +sqrshrun2   v1.16b, v19.8h, 7

does pairing helps here?

sqrshrunv0.8b,  v16.8h, 7
sqrshrunv1.8b,  v18.8h, 7
sqrshrun2   v0.16b, v17.8h, 7
sqrshrun2   v1.16b, v19.8h, 7

[...]
> +sqrshrunv0.8b,  v16.8h, 7
> +sqrshrun2   v0.16b, v17.8h, 7
> +sqrshrunv1.8b,  v18.8h, 7
> +sqrshrun2   v1.16b, v19.8h, 7
> +sqrshrunv2.8b,  v20.8h, 7
> +sqrshrun2   v2.16b, v21.8h, 7
> +sqrshrunv3.8b,  v22.8h, 7
> +sqrshrun2   v3.16b, v23.8h, 7

Again, this might be a good candidate for attempting to shuffle the
instructions and see if it helps (there are many other places, I picked
one randomly).

> +.Lepel_filters:

const/endconst + align might be better for all these labels

[...]
> +function ff_hevc_put_hevc_epel_hv12_8_neon, export=1
> +add x10, x3, 3
> +lsl x10, x10, 7
> +sub sp, sp, x10 // tmp_array
> +stp x0, x3, [sp, -16]!
> +stp x5, x30, [sp, -16]!
> +add x0, sp, 32
> +sub x1, x1, x2
> +add x3, x3, 3
> +bl  ff_hevc_put_hevc_epel_h12_8_neon
> +ldp x5, x30, [sp], 16
> +ldp x0, x3, [sp], 16
> +load_epel_filterh x5, x4
> +mov x5, 112
> +mov x10, 128
> +ld1 { v16.8h, v17.8h }, [sp], x10
> +ld1 { v18.8h, v19.8h }, [sp], x10
> +ld1 { v20.8h, v21.8h }, [sp], x10
> +1:  ld1 { v22.8h, v23.8h }, [sp], x10
> +calc_epelh  v4, v16,