Re: [FFmpeg-devel] [PATCH] configure: add host libm capability detection

2015-11-25 Thread Hendrik Leppkes
On Thu, Nov 26, 2015 at 6:04 AM, Ganesh Ajjanagadde
 wrote:
> This is needed in order to obtain what is available for hardcoded
> table generation.
>
> A minimal avutil/host_libm.h is also created.
>

I'm really not a fan of this change. configure is slow and complex
enough as it is, and host tools don't need to be micro-optimized,
since they are never run by a user.

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


Re: [FFmpeg-devel] [PATCH 1/2] aaccoder_twoloop: Mark sfdiff as av_unused

2015-11-25 Thread Claudio Freire
On Tue, Nov 10, 2015 at 1:41 AM, Timothy Gu  wrote:
> On Sun, Nov 8, 2015 at 9:28 AM Claudio Freire 
> wrote:
>>
>> This particular piece of code is going to disappear soon, so not sure
>> it's worth applying the patch.
>
>
> Oh, okay then.


Funny thing, in the end it's going to survive, so I'm going to apply
this soon :)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] ffprobe: Do not print profile names in -bitexact

2015-11-25 Thread Timothy Gu
---
 ffprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffprobe.c b/ffprobe.c
index c304a6d..216db379 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2148,7 +2148,7 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 }
 }
 
-if (dec && (profile = av_get_profile_name(dec, dec_ctx->profile)))
+if (!do_bitexact && dec && (profile = av_get_profile_name(dec, 
dec_ctx->profile)))
 print_str("profile", profile);
 else
 print_str_opt("profile", "unknown");
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 2/2] fate/concatdec: Use -bitexact

2015-11-25 Thread Timothy Gu
Fixes FATE failures on --enable-small builds.
---
 tests/fate-run.sh   | 4 ++--
 tests/ref/fate/concat-demuxer-extended-lavf-mxf | 2 +-
 tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +-
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf  | 4 ++--
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10  | 4 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts   | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 03fa898..16087cb 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -262,10 +262,10 @@ concat(){
 awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
 
 if [ "$mode" = "md5" ]; then
-run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -fflags 
keepside -safe 0 $extra_args $concatfile | tr -d '\r' > $packetfile
+run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 
-fflags keepside -safe 0 $extra_args $concatfile | tr -d '\r' > $packetfile
 do_md5sum $packetfile
 else
-run ffprobe${PROGSUF} -show_streams -show_packets -v 0 -of 
compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile
+run ffprobe${PROGSUF} -bitexact -show_streams -show_packets -v 0 -of 
compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile
 fi
 }
 
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index 536fba2..5a57f15 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-aa6477bcaef182919ac0c08ed74b32a1 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+378333d8de83abb900fdeb85ec73e81c 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
index ce68520..298db3a 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-651eca7722187ff6836f55826bb1d110 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
+2480da1b26899e17377e938b2cd9d6d7 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf 
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
index 754080e..6e5ba73 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
@@ -120,5 +120,5 @@ 
audio|1|65280|1.36|65280|1.36|1920|0.04|N/A|N/A|3840|206848|K|1
 Strings Metadata|8
 video|0|37|1.48|34|1.36|1|0.04|N/A|N/A|24786|211456|K|1
 Strings Metadata|8
-0|mpeg2video|MPEG-2 
video|Main|video|1/50|[0][0][0][0]|0x|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|00:00:00:00|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|104857200|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
-1|pcm_s16le|PCM signed 16-bit 
little-endian|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+0|mpeg2video|unknown|video|1/50|[0][0][0][0]|0x|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|00:00:00:00|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|104857200|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
index f573eae..60402b8 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
@@ -78,5 +78,5 @@ 
video|0|34|1.36|34|1.36|1|0.04|N/A|N/A|15|1923072|K|1
 Strings Metadata|8
 audio|1|65280|1.36|65280|1.36|1920|0.04|N/A|N/A|7680|2073600|K|1
 Strings Metadata|8
-0|mpeg2video|MPEG-2 
video|4:2:2|video|1/50|[0][0][0][0]|0x|720|608|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|00:00:00:00|1|N/A|25/1|25/1|1/25|0|0.00|N/A|N/A|3000|3000|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
-1|pcm_s16le|PCM signed 16-bit 
little-endian|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+0|mpeg2video|unknown|video|1/50|[0][0][0][0]|0x|720|608|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|00:00:00:00|1|N

[FFmpeg-devel] [PATCH] configure: add host libm capability detection

2015-11-25 Thread Ganesh Ajjanagadde
This is needed in order to obtain what is available for hardcoded
table generation.

A minimal avutil/host_libm.h is also created.

Signed-off-by: Ganesh Ajjanagadde 
---
 configure | 41 +
 libavutil/host_libm.h | 51 +++
 2 files changed, 92 insertions(+)
 create mode 100644 libavutil/host_libm.h

diff --git a/configure b/configure
index 0198b75..af411a3 100755
--- a/configure
+++ b/configure
@@ -926,6 +926,10 @@ ld_o(){
 eval printf '%s\\n' $LD_O
 }
 
+host_ld_o(){
+eval printf '%s\\n' $HOSTLD_O
+}
+
 check_ld(){
 log check_ld "$@"
 type=$1
@@ -938,6 +942,18 @@ check_ld(){
 check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
 }
 
+check_host_ld(){
+log check_host_ld "$@"
+type=$1
+shift 1
+flags=$(filter_out '-l*|*.so' $@)
+libs=$(filter '-l*|*.so' $@)
+check_$type $($host_cflags_filter $flags) || return
+flags=$($host_ldflags_filter $flags)
+libs=$($host_ldflags_filter $libs)
+check_cmd $host_ld $host_ldflags $flags $(host_ld_o $TMPE) $TMPO 
$host_libs $extralibs
+}
+
 print_include(){
 hdr=$1
 test "${hdr%.h}" = "${hdr}" &&
@@ -1061,6 +1077,20 @@ int main(void){ return (int) foo; }
 EOF
 }
 
+check_host_mathfunc(){
+log check_host_mathfunc "$@"
+func=$1
+narg=$2
+shift 2
+test $narg = 2 && args="f, g" || args="f"
+disable $(add_suffix _host $func)
+check_host_ld "host_cc" "$@" <
+float foo(float f, float g) { return $func($args); }
+int main(void){ return (int) foo; }
+EOF
+}
+
 check_func_headers(){
 log check_func_headers "$@"
 headers=$1
@@ -1762,6 +1792,12 @@ INTRINSICS_LIST="
 intrinsics_neon
 "
 
+HOST_MATH_FUNCS="
+cbrt
+llrint
+rint
+"
+
 MATH_FUNCS="
 atanf
 atan2f
@@ -1902,6 +1938,7 @@ HAVE_LIST="
 $HAVE_LIST_PUB
 $HEADERS_LIST
 $INTRINSICS_LIST
+$(add_suffix _host $HOST_MATH_FUNCS)
 $MATH_FUNCS
 $SYSTEM_FUNCS
 $THREADS_LIST
@@ -5317,6 +5354,10 @@ for func in $MATH_FUNCS; do
 eval check_mathfunc $func \${${func}_args:-1}
 done
 
+for func in $HOST_MATH_FUNCS; do
+eval check_host_mathfunc $func \${${func}_args:-1}
+done
+
 # these are off by default, so fail if requested and not available
 enabled avfoundation_indev && { check_header_oc AVFoundation/AVFoundation.h || 
disable avfoundation_indev; }
 enabled avfoundation_indev && { check_lib2 CoreGraphics/CoreGraphics.h 
CGGetActiveDisplayList -framework CoreGraphics ||
diff --git a/libavutil/host_libm.h b/libavutil/host_libm.h
new file mode 100644
index 000..927b93e
--- /dev/null
+++ b/libavutil/host_libm.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Replacements for frequently missing host libm functions
+ */
+
+#ifndef AVUTIL_HOST_LIBM_H
+#define AVUTIL_HOST_LIBM_H
+
+#include 
+#include "config.h"
+#include "attributes.h"
+#include "intfloat.h"
+
+#if !HAVE_CBRT_HOST
+static av_always_inline double cbrt(double x)
+{
+return x < 0 ? -pow(-x, 1.0 / 3.0) : pow(x, 1.0 / 3.0);
+}
+#endif
+
+#if !HAVE_LLRINT_HOST
+#undef llrint
+#define llrint(x) ((long long)rint(x))
+#endif /* HAVE_LLRINT_HOST */
+
+#if !HAVE_RINT_HOST
+static inline double rint(double x)
+{
+return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_RINT_HOST */
+
+#endif /* AVUTIL_LIBM_H */
-- 
2.6.2

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


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 10:13 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, Nov 25, 2015 at 8:48 PM, Ganesh Ajjanagadde 
> wrote:
>>
>> On Wed, Nov 25, 2015 at 8:29 PM, Ganesh Ajjanagadde 
>> wrote:
>> > On Wed, Nov 25, 2015 at 8:19 PM, Ronald S. Bultje 
>> > wrote:
>> >> Hi,
>> >>
>> >> On Wed, Nov 25, 2015 at 7:36 PM, Ganesh Ajjanagadde 
>> >> wrote:
>> >>
>> >>> On Wed, Nov 25, 2015 at 6:49 PM, James Almer 
>> >>> wrote:
>> >>> > On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
>> >>> >> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje
>> >>> >> 
>> >>> wrote:
>> >>> >>> Hi,
>> >>> >>>
>> >>> >>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde <
>> >>> gajjanaga...@gmail.com>
>> >>> >>> wrote:
>> >>> 
>> >>>  On systems having cbrt, there is no reason to use the slow pow
>> >>> function.
>> >>> 
>> >>>  Sample benchmark (x86-64, Haswell, GNU/Linux):
>> >>>  new:
>> >>>  5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>> >>> 
>> >>>  old:
>> >>>  12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>> >>> 
>> >>>  Signed-off-by: Ganesh Ajjanagadde 
>> >>> 
>> >>> 
>> >>>
>> >>> ---
>> >>>  What I wonder about is why --enable-hardcoded-tables is not the
>> >>> default
>> >>>  for
>> >>>  FFmpeg. Unless I am missing something, static storage is anyway
>> >>> allocated
>> >>>  even
>> >>>  if hardcoded tables are not used, and the cost is deferred to
>> >>>  runtime
>> >>>  instead of
>> >>>  build time. Thus binary size should not be affected, but users
>> >>>  burn
>> >>> cycles
>> >>>  unnecessarily for every codec having these kinds of tables. I
>> >>>  have
>> >>> these
>> >>>  patches,
>> >>>  simply because at the moment users are paying a price for the
>> >>>  typical
>> >>>  default.
>> >>>  ---
>> >>>   libavcodec/cbrt_tablegen.h | 6 +++---
>> >>>   1 file changed, 3 insertions(+), 3 deletions(-)
>> >>> >>>
>> >>> >>>
>> >>> >>> This has been discussed extensively in the past...
>> >>> >>
>> >>> >> Can you please give a link and/or timeframe to search for?
>> >>> >>
>> >>> >>>
>> >>> >>> As for the patch, don't forget that tablegen runs on the host
>> >>> >>> (build),
>> >>> not
>> >>> >>> target (runtime), whereas libm.h is for target (runtime) and may
>> >>> >>> not be
>> >>> >>> compatible. I believe that's why we don't use libm.h in tablegen
>> >>> >>> files.
>> >>> >>
>> >>> >> I don't understand this, it seems to me like any other code (at
>> >>> >> least
>> >>> >> in the default configure), it gets called, and like all other such
>> >>> >> things, we use libavutil/libm for hackery. This host/target
>> >>> >> business
>> >>> >> affects other things as well. What is the issue?
>> >>> >
>> >>> > libavutil/libm.h uses defines from config.h, which are based on the
>> >>> tests run
>> >>> > by configure for the target, and not the host where compilation
>> >>> > takes
>> >>> place.
>> >>> > The tablegen applications all run at compile time. What is available
>> >>> > on
>> >>> the
>> >>> > target may not be on the host.
>> >>>
>> >>> Ok. So I would like an answer to two simple questions that are outside
>> >>> my knowledge or interest.
>> >>>
>> >>> Is it possible with some hackery to get this change through, or not?
>> >>> If so, what is it?
>> >>
>> >>
>> >> You need to understand the issue before you can evaluate hacks.
>> >>
>> >> The issue is:
>> >> - I'm using a linux x86-64 machine using gcc as a compiler, with
>> >> libc=glibc
>> >> 2.18 (A);
>> >> - to build a binary that will run on a Windows Mobile ARMv7 machine,
>> >> with
>> >> libC=something-from-Microsoft (B).
>> >>
>> >> tablegen runs on A, but ffmpeg.exe runs on B. libavutil/libm.h only
>> >> works
>> >> for B. If you want a version of libm.h on A, you need to generate a
>> >> version
>> >> of libm.h that works on A. There is no relationship between A and B,
>> >> and
>> >> thus there can not possibly ever be any relationship between A's libm.h
>> >> and
>> >> B's libavutil/libm.h.
>> >>
>> >> It's probably possible to generate a version of libm.h for A, but
>> >> that's
>> >> not so much a coding issue, as it is an issue of understanding the
>> >> build
>> >> system and including detection for stuff on machine A, as opposed to
>> >> machine B (which is what most of configure does).
>> >
>> > Thanks a lot for the detail. So how about using a local
>> > #ifndef cbrt
>> > #define cbrt(x) pow(x, 1 / 3.0)
>> > code...
>> > #undef cbrt // at the very end of the file
>> > #endif
>>
>> Not that simple, something more like
>> #ifndef cbrt
>> #define ff_cbrt(x) pow(x, 1/3.0)
>> #else
>> #define ff_cbrt(x) cbrt(x)
>> code...
>> #undef ff_cbrt // at the very end of the file
>> #endif
>>
>> - this will resolve a glitch with the above in not undef'ing an
>> important symbol (all this is of course without includ

Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ronald S. Bultje
Hi,

On Wed, Nov 25, 2015 at 8:48 PM, Ganesh Ajjanagadde 
wrote:

> On Wed, Nov 25, 2015 at 8:29 PM, Ganesh Ajjanagadde 
> wrote:
> > On Wed, Nov 25, 2015 at 8:19 PM, Ronald S. Bultje 
> wrote:
> >> Hi,
> >>
> >> On Wed, Nov 25, 2015 at 7:36 PM, Ganesh Ajjanagadde 
> >> wrote:
> >>
> >>> On Wed, Nov 25, 2015 at 6:49 PM, James Almer 
> wrote:
> >>> > On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
> >>> >> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje <
> rsbul...@gmail.com>
> >>> wrote:
> >>> >>> Hi,
> >>> >>>
> >>> >>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde <
> >>> gajjanaga...@gmail.com>
> >>> >>> wrote:
> >>> 
> >>>  On systems having cbrt, there is no reason to use the slow pow
> >>> function.
> >>> 
> >>>  Sample benchmark (x86-64, Haswell, GNU/Linux):
> >>>  new:
> >>>  5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
> >>> 
> >>>  old:
> >>>  12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
> >>> 
> >>>  Signed-off-by: Ganesh Ajjanagadde 
> >>> 
> >>> 
> >>>
> ---
> >>>  What I wonder about is why --enable-hardcoded-tables is not the
> >>> default
> >>>  for
> >>>  FFmpeg. Unless I am missing something, static storage is anyway
> >>> allocated
> >>>  even
> >>>  if hardcoded tables are not used, and the cost is deferred to
> runtime
> >>>  instead of
> >>>  build time. Thus binary size should not be affected, but users
> burn
> >>> cycles
> >>>  unnecessarily for every codec having these kinds of tables. I have
> >>> these
> >>>  patches,
> >>>  simply because at the moment users are paying a price for the
> typical
> >>>  default.
> >>>  ---
> >>>   libavcodec/cbrt_tablegen.h | 6 +++---
> >>>   1 file changed, 3 insertions(+), 3 deletions(-)
> >>> >>>
> >>> >>>
> >>> >>> This has been discussed extensively in the past...
> >>> >>
> >>> >> Can you please give a link and/or timeframe to search for?
> >>> >>
> >>> >>>
> >>> >>> As for the patch, don't forget that tablegen runs on the host
> (build),
> >>> not
> >>> >>> target (runtime), whereas libm.h is for target (runtime) and may
> not be
> >>> >>> compatible. I believe that's why we don't use libm.h in tablegen
> files.
> >>> >>
> >>> >> I don't understand this, it seems to me like any other code (at
> least
> >>> >> in the default configure), it gets called, and like all other such
> >>> >> things, we use libavutil/libm for hackery. This host/target business
> >>> >> affects other things as well. What is the issue?
> >>> >
> >>> > libavutil/libm.h uses defines from config.h, which are based on the
> >>> tests run
> >>> > by configure for the target, and not the host where compilation takes
> >>> place.
> >>> > The tablegen applications all run at compile time. What is available
> on
> >>> the
> >>> > target may not be on the host.
> >>>
> >>> Ok. So I would like an answer to two simple questions that are outside
> >>> my knowledge or interest.
> >>>
> >>> Is it possible with some hackery to get this change through, or not?
> >>> If so, what is it?
> >>
> >>
> >> You need to understand the issue before you can evaluate hacks.
> >>
> >> The issue is:
> >> - I'm using a linux x86-64 machine using gcc as a compiler, with
> libc=glibc
> >> 2.18 (A);
> >> - to build a binary that will run on a Windows Mobile ARMv7 machine,
> with
> >> libC=something-from-Microsoft (B).
> >>
> >> tablegen runs on A, but ffmpeg.exe runs on B. libavutil/libm.h only
> works
> >> for B. If you want a version of libm.h on A, you need to generate a
> version
> >> of libm.h that works on A. There is no relationship between A and B, and
> >> thus there can not possibly ever be any relationship between A's libm.h
> and
> >> B's libavutil/libm.h.
> >>
> >> It's probably possible to generate a version of libm.h for A, but that's
> >> not so much a coding issue, as it is an issue of understanding the build
> >> system and including detection for stuff on machine A, as opposed to
> >> machine B (which is what most of configure does).
> >
> > Thanks a lot for the detail. So how about using a local
> > #ifndef cbrt
> > #define cbrt(x) pow(x, 1 / 3.0)
> > code...
> > #undef cbrt // at the very end of the file
> > #endif
>
> Not that simple, something more like
> #ifndef cbrt
> #define ff_cbrt(x) pow(x, 1/3.0)
> #else
> #define ff_cbrt(x) cbrt(x)
> code...
> #undef ff_cbrt // at the very end of the file
> #endif
>
> - this will resolve a glitch with the above in not undef'ing an
> important symbol (all this is of course without including
> libavutil/libm.h).


I don't think cbrt is a macro? But anyway, I don't think any of this is
meaningful, you're basically creating a crappy per-file libm.h for tablegen
files which will be duplicated all over the place. How about we do this
correctly, if we do it at all?

(Don't forget these table inits run once per proc

Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 6:32 PM, Ganesh Ajjanagadde
 wrote:
> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje  wrote:
>> Hi,
>>
>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde 
>> wrote:
>>>
>>> On systems having cbrt, there is no reason to use the slow pow function.
>>>
>>> Sample benchmark (x86-64, Haswell, GNU/Linux):
>>> new:
>>> 5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>>
>>> old:
>>> 12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>>
>>> Signed-off-by: Ganesh Ajjanagadde 
>>>
>>> ---
>>> What I wonder about is why --enable-hardcoded-tables is not the default
>>> for
>>> FFmpeg. Unless I am missing something, static storage is anyway allocated
>>> even
>>> if hardcoded tables are not used, and the cost is deferred to runtime
>>> instead of
>>> build time. Thus binary size should not be affected, but users burn cycles
>>> unnecessarily for every codec having these kinds of tables. I have these
>>> patches,
>>> simply because at the moment users are paying a price for the typical
>>> default.
>>> ---
>>>  libavcodec/cbrt_tablegen.h | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>>
>> This has been discussed extensively in the past...
>
> Can you please give a link and/or timeframe to search for?

For any interested, dug up at least one extensive thread on this:
https://ffmpeg.org/pipermail/ffmpeg-devel/2008-January/047111.html.

So I now see that static tables (even with array size explicitly
written down) do not neccesarily occupy memory until runtime. That was
the main source of my question. Now that I understand it, I realize
that picking a default is not easy and is very much environment
dependent - the cost of e.g a TLB miss/page fault due to a larger
binary can be a serious issue. As a practical example, servers with
beefed up hardware may prefer the extra memory footprint, but
lightweight devices may care a lot about memory requirements.
Ultimately, it is impossible to satisfy both simultaneously, and doing
e.g a configure time picking of a default heuristically is not
worthwhile.

Nevertheless, FFmpeg should IMHO do a best possible effort. For
clients who use hardcoded tables, there are no issues. For clients who
prefer a smaller binary, we should make the runtime
"loading/initialization" as fast as possible. Nevertheless, this is
not the kind of thing where micro-optimizations are worthwhile, but
nevertheless, simple, clear optimizations with obvious benefits are
certainly valuable IMHO. As such, I consider these patches worth
pursuing, especially since I have demonstrated > 50% in both cases
with minimal diffs.

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


Re: [FFmpeg-devel] [PATCH] avcodec/mpegaudio_tablegen: speed up table generation

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 9:22 PM, Timothy Gu  wrote:
> On Wed, Nov 25, 2015 at 6:03 PM Timothy Gu  wrote:
>
>> On Wed, Nov 25, 2015 at 05:17:29PM -0500, Ganesh Ajjanagadde wrote:
>> > +double f = value * cbrt_lut[value] * pow(2, (exponent -
>> 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
>>
>> While at it, you could change pow(2 to exp2(, which has a libm.h shim
>> and is easily 4 times faster than pow() on my machine (glibc 2.19,
>> Haswell).
>>
>
> In light of the comments made by Ronald and James in the other thread, it
> would probably be better if you look for instances of optimization
> opportunities in other files that matter rather than these tablegen files
> that will only be run once during the build process. A simple `git grep -E
> 'powf?\(2'` shows an awful lot.

That is not true, the default configure line generates these at
runtime (which was how I obtained the cycle numbers), translating to
cycles burnt. The Arch Linux package I know for a fact does not build
with "hardcoded tables". If it was just build time, I of course would
not have bothered.

Think of it this way: ~ 10^6 cycles is ~ 1 ms of running a CPU, and is
part of trivially avoidable latency. Why it is still being done at
runtime by default, I still don't understand why, and I requested for
an email thread/explanation.

I am working on all instances of pow, this was just one of them. For
me, the answer is simple: any runtime savings on the order of 10^5
cycles (and above) is worth it unless it causes a huge loss of
readability, even if it is in a init function that executes once.

>
> (BTW next time you send similar patches you c/should put them in a patch
> series so that it's easier to track on the ML. I missed the other thread
> before reading this one.)

Will keep in mind; I sent these as I did them.

>
> Timtohy
> ___
> 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] avcodec/mpegaudio_tablegen: speed up table generation

2015-11-25 Thread Timothy Gu
On Wed, Nov 25, 2015 at 6:03 PM Timothy Gu  wrote:

> On Wed, Nov 25, 2015 at 05:17:29PM -0500, Ganesh Ajjanagadde wrote:
> > +double f = value * cbrt_lut[value] * pow(2, (exponent -
> 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
>
> While at it, you could change pow(2 to exp2(, which has a libm.h shim
> and is easily 4 times faster than pow() on my machine (glibc 2.19,
> Haswell).
>

In light of the comments made by Ronald and James in the other thread, it
would probably be better if you look for instances of optimization
opportunities in other files that matter rather than these tablegen files
that will only be run once during the build process. A simple `git grep -E
'powf?\(2'` shows an awful lot.

(BTW next time you send similar patches you c/should put them in a patch
series so that it's easier to track on the ML. I missed the other thread
before reading this one.)

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


Re: [FFmpeg-devel] [PATCH] avcodec/mpegaudio_tablegen: speed up table generation

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 9:03 PM, Timothy Gu  wrote:
> On Wed, Nov 25, 2015 at 05:17:29PM -0500, Ganesh Ajjanagadde wrote:
>> +double f = value * cbrt_lut[value] * pow(2, (exponent - 400) * 
>> 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
>
> While at it, you could change pow(2 to exp2(, which has a libm.h shim
> and is easily 4 times faster than pow() on my machine (glibc 2.19, Haswell).

Thanks for the suggestion. However, this won't yield too great a gain,
since IIRC this second loop is only ~ 10% of the net cost with the
proposed patch. Furthermore, I had an even better way of doing this in
mind, that I might do in a separate patch (provided all the cross
compiling annoyances get resolved) - I wanted that to be cleared up
before proceeding on these things.

The better way I have in mind is notice that the pow is always 2^n  *
something from pow2_lut, where n is an integer, positive or negative.
Thus, this 2^n can be computed iteratively with likely no accuracy
issues since 2^n is exact in double precision, and depending on % 4,
accordingly multiplied with a thing from pow2_lut.

The shim issue is that we can't use avutil/libm IIUC, it needs some
other method, likely ifdefry. The above idea scores better in that
respect as well. As it is a little more tricky and not trivial like
the current changes which are low hanging, belongs in separate patch
IMHO. Feel free to try it out if interested :).

>
> 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] avcodec/mpegaudio_tablegen: speed up table generation

2015-11-25 Thread Timothy Gu
On Wed, Nov 25, 2015 at 05:17:29PM -0500, Ganesh Ajjanagadde wrote:
> +double f = value * cbrt_lut[value] * pow(2, (exponent - 400) * 
> 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;

While at it, you could change pow(2 to exp2(, which has a libm.h shim
and is easily 4 times faster than pow() on my machine (glibc 2.19, Haswell).

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


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 8:29 PM, Ganesh Ajjanagadde  wrote:
> On Wed, Nov 25, 2015 at 8:19 PM, Ronald S. Bultje  wrote:
>> Hi,
>>
>> On Wed, Nov 25, 2015 at 7:36 PM, Ganesh Ajjanagadde 
>> wrote:
>>
>>> On Wed, Nov 25, 2015 at 6:49 PM, James Almer  wrote:
>>> > On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
>>> >> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje 
>>> wrote:
>>> >>> Hi,
>>> >>>
>>> >>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde <
>>> gajjanaga...@gmail.com>
>>> >>> wrote:
>>> 
>>>  On systems having cbrt, there is no reason to use the slow pow
>>> function.
>>> 
>>>  Sample benchmark (x86-64, Haswell, GNU/Linux):
>>>  new:
>>>  5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>> 
>>>  old:
>>>  12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>> 
>>>  Signed-off-by: Ganesh Ajjanagadde 
>>> 
>>> 
>>> ---
>>>  What I wonder about is why --enable-hardcoded-tables is not the
>>> default
>>>  for
>>>  FFmpeg. Unless I am missing something, static storage is anyway
>>> allocated
>>>  even
>>>  if hardcoded tables are not used, and the cost is deferred to runtime
>>>  instead of
>>>  build time. Thus binary size should not be affected, but users burn
>>> cycles
>>>  unnecessarily for every codec having these kinds of tables. I have
>>> these
>>>  patches,
>>>  simply because at the moment users are paying a price for the typical
>>>  default.
>>>  ---
>>>   libavcodec/cbrt_tablegen.h | 6 +++---
>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>> >>>
>>> >>>
>>> >>> This has been discussed extensively in the past...
>>> >>
>>> >> Can you please give a link and/or timeframe to search for?
>>> >>
>>> >>>
>>> >>> As for the patch, don't forget that tablegen runs on the host (build),
>>> not
>>> >>> target (runtime), whereas libm.h is for target (runtime) and may not be
>>> >>> compatible. I believe that's why we don't use libm.h in tablegen files.
>>> >>
>>> >> I don't understand this, it seems to me like any other code (at least
>>> >> in the default configure), it gets called, and like all other such
>>> >> things, we use libavutil/libm for hackery. This host/target business
>>> >> affects other things as well. What is the issue?
>>> >
>>> > libavutil/libm.h uses defines from config.h, which are based on the
>>> tests run
>>> > by configure for the target, and not the host where compilation takes
>>> place.
>>> > The tablegen applications all run at compile time. What is available on
>>> the
>>> > target may not be on the host.
>>>
>>> Ok. So I would like an answer to two simple questions that are outside
>>> my knowledge or interest.
>>>
>>> Is it possible with some hackery to get this change through, or not?
>>> If so, what is it?
>>
>>
>> You need to understand the issue before you can evaluate hacks.
>>
>> The issue is:
>> - I'm using a linux x86-64 machine using gcc as a compiler, with libc=glibc
>> 2.18 (A);
>> - to build a binary that will run on a Windows Mobile ARMv7 machine, with
>> libC=something-from-Microsoft (B).
>>
>> tablegen runs on A, but ffmpeg.exe runs on B. libavutil/libm.h only works
>> for B. If you want a version of libm.h on A, you need to generate a version
>> of libm.h that works on A. There is no relationship between A and B, and
>> thus there can not possibly ever be any relationship between A's libm.h and
>> B's libavutil/libm.h.
>>
>> It's probably possible to generate a version of libm.h for A, but that's
>> not so much a coding issue, as it is an issue of understanding the build
>> system and including detection for stuff on machine A, as opposed to
>> machine B (which is what most of configure does).
>
> Thanks a lot for the detail. So how about using a local
> #ifndef cbrt
> #define cbrt(x) pow(x, 1 / 3.0)
> code...
> #undef cbrt // at the very end of the file
> #endif

Not that simple, something more like
#ifndef cbrt
#define ff_cbrt(x) pow(x, 1/3.0)
#else
#define ff_cbrt(x) cbrt(x)
code...
#undef ff_cbrt // at the very end of the file
#endif

- this will resolve a glitch with the above in not undef'ing an
important symbol (all this is of course without including
libavutil/libm.h).

>
>>
>> Ronald
>> ___
>> 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] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 8:19 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, Nov 25, 2015 at 7:36 PM, Ganesh Ajjanagadde 
> wrote:
>
>> On Wed, Nov 25, 2015 at 6:49 PM, James Almer  wrote:
>> > On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
>> >> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje 
>> wrote:
>> >>> Hi,
>> >>>
>> >>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde <
>> gajjanaga...@gmail.com>
>> >>> wrote:
>> 
>>  On systems having cbrt, there is no reason to use the slow pow
>> function.
>> 
>>  Sample benchmark (x86-64, Haswell, GNU/Linux):
>>  new:
>>  5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>> 
>>  old:
>>  12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>> 
>>  Signed-off-by: Ganesh Ajjanagadde 
>> 
>> 
>> ---
>>  What I wonder about is why --enable-hardcoded-tables is not the
>> default
>>  for
>>  FFmpeg. Unless I am missing something, static storage is anyway
>> allocated
>>  even
>>  if hardcoded tables are not used, and the cost is deferred to runtime
>>  instead of
>>  build time. Thus binary size should not be affected, but users burn
>> cycles
>>  unnecessarily for every codec having these kinds of tables. I have
>> these
>>  patches,
>>  simply because at the moment users are paying a price for the typical
>>  default.
>>  ---
>>   libavcodec/cbrt_tablegen.h | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>> >>>
>> >>>
>> >>> This has been discussed extensively in the past...
>> >>
>> >> Can you please give a link and/or timeframe to search for?
>> >>
>> >>>
>> >>> As for the patch, don't forget that tablegen runs on the host (build),
>> not
>> >>> target (runtime), whereas libm.h is for target (runtime) and may not be
>> >>> compatible. I believe that's why we don't use libm.h in tablegen files.
>> >>
>> >> I don't understand this, it seems to me like any other code (at least
>> >> in the default configure), it gets called, and like all other such
>> >> things, we use libavutil/libm for hackery. This host/target business
>> >> affects other things as well. What is the issue?
>> >
>> > libavutil/libm.h uses defines from config.h, which are based on the
>> tests run
>> > by configure for the target, and not the host where compilation takes
>> place.
>> > The tablegen applications all run at compile time. What is available on
>> the
>> > target may not be on the host.
>>
>> Ok. So I would like an answer to two simple questions that are outside
>> my knowledge or interest.
>>
>> Is it possible with some hackery to get this change through, or not?
>> If so, what is it?
>
>
> You need to understand the issue before you can evaluate hacks.
>
> The issue is:
> - I'm using a linux x86-64 machine using gcc as a compiler, with libc=glibc
> 2.18 (A);
> - to build a binary that will run on a Windows Mobile ARMv7 machine, with
> libC=something-from-Microsoft (B).
>
> tablegen runs on A, but ffmpeg.exe runs on B. libavutil/libm.h only works
> for B. If you want a version of libm.h on A, you need to generate a version
> of libm.h that works on A. There is no relationship between A and B, and
> thus there can not possibly ever be any relationship between A's libm.h and
> B's libavutil/libm.h.
>
> It's probably possible to generate a version of libm.h for A, but that's
> not so much a coding issue, as it is an issue of understanding the build
> system and including detection for stuff on machine A, as opposed to
> machine B (which is what most of configure does).

Thanks a lot for the detail. So how about using a local
#ifndef cbrt
#define cbrt(x) pow(x, 1 / 3.0)
code...
#undef cbrt // at the very end of the file
#endif

>
> Ronald
> ___
> 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] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ronald S. Bultje
Hi,

On Wed, Nov 25, 2015 at 7:36 PM, Ganesh Ajjanagadde 
wrote:

> On Wed, Nov 25, 2015 at 6:49 PM, James Almer  wrote:
> > On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
> >> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje 
> wrote:
> >>> Hi,
> >>>
> >>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde <
> gajjanaga...@gmail.com>
> >>> wrote:
> 
>  On systems having cbrt, there is no reason to use the slow pow
> function.
> 
>  Sample benchmark (x86-64, Haswell, GNU/Linux):
>  new:
>  5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
> 
>  old:
>  12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
> 
>  Signed-off-by: Ganesh Ajjanagadde 
> 
> 
> ---
>  What I wonder about is why --enable-hardcoded-tables is not the
> default
>  for
>  FFmpeg. Unless I am missing something, static storage is anyway
> allocated
>  even
>  if hardcoded tables are not used, and the cost is deferred to runtime
>  instead of
>  build time. Thus binary size should not be affected, but users burn
> cycles
>  unnecessarily for every codec having these kinds of tables. I have
> these
>  patches,
>  simply because at the moment users are paying a price for the typical
>  default.
>  ---
>   libavcodec/cbrt_tablegen.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> >>>
> >>>
> >>> This has been discussed extensively in the past...
> >>
> >> Can you please give a link and/or timeframe to search for?
> >>
> >>>
> >>> As for the patch, don't forget that tablegen runs on the host (build),
> not
> >>> target (runtime), whereas libm.h is for target (runtime) and may not be
> >>> compatible. I believe that's why we don't use libm.h in tablegen files.
> >>
> >> I don't understand this, it seems to me like any other code (at least
> >> in the default configure), it gets called, and like all other such
> >> things, we use libavutil/libm for hackery. This host/target business
> >> affects other things as well. What is the issue?
> >
> > libavutil/libm.h uses defines from config.h, which are based on the
> tests run
> > by configure for the target, and not the host where compilation takes
> place.
> > The tablegen applications all run at compile time. What is available on
> the
> > target may not be on the host.
>
> Ok. So I would like an answer to two simple questions that are outside
> my knowledge or interest.
>
> Is it possible with some hackery to get this change through, or not?
> If so, what is it?


You need to understand the issue before you can evaluate hacks.

The issue is:
- I'm using a linux x86-64 machine using gcc as a compiler, with libc=glibc
2.18 (A);
- to build a binary that will run on a Windows Mobile ARMv7 machine, with
libC=something-from-Microsoft (B).

tablegen runs on A, but ffmpeg.exe runs on B. libavutil/libm.h only works
for B. If you want a version of libm.h on A, you need to generate a version
of libm.h that works on A. There is no relationship between A and B, and
thus there can not possibly ever be any relationship between A's libm.h and
B's libavutil/libm.h.

It's probably possible to generate a version of libm.h for A, but that's
not so much a coding issue, as it is an issue of understanding the build
system and including detection for stuff on machine A, as opposed to
machine B (which is what most of configure does).

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


Re: [FFmpeg-devel] [PATCH] Fix sample_aspect_ratio computation for stereo matroska content.

2015-11-25 Thread Aaron Colwell
On Tue, Nov 24, 2015 at 10:43 AM Kirill Gavrilov 
wrote:

> On Mon, Nov 23, 2015 at 11:37 PM, Aaron Colwell 
> wrote:
>
> > matroskaenc.c applies divisors to the display width/height when
> generating
> > stereo content. This patch adds the corresponding multipliers to
> > matroskadec.c
> > so that the original sample aspect ratio can be recovered.
>
>
> Just to link this patch with Matroska Specification notes:
> http://www.matroska.org/technical/specs/notes.html#3D
>
> > The pixel count of the track (PixelWidth/PixelHeight) should be the raw
> > amount of pixels (for example 3840x1080 for full HD side by side)
> > and the DisplayWidth/Height in pixels should be the amount of pixels for
> > one plane (1920x1080 for that full HD stream).
> >
>

Is this intended to be a call to action or are you just adding information
to this particular thread? I'd like to get the change reviewed so I can
determine whether I need to make any other changes.

This change basically allows 'ffmpeg -i blah.mkv foo.mkv ; ffprobe foo.mkv'
to show that foo.mkv has the same SAR and DAR as blah.mkv when blah.mkv
contains stereo content. Without this patch the SAR & DAR get smaller based
on whichever dimension is halved by the stereo layout.

Hope this helps,
Aaron
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 6:49 PM, James Almer  wrote:
> On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
>> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje  wrote:
>>> Hi,
>>>
>>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde 
>>> wrote:

 On systems having cbrt, there is no reason to use the slow pow function.

 Sample benchmark (x86-64, Haswell, GNU/Linux):
 new:
 5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips

 old:
 12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips

 Signed-off-by: Ganesh Ajjanagadde 

 ---
 What I wonder about is why --enable-hardcoded-tables is not the default
 for
 FFmpeg. Unless I am missing something, static storage is anyway allocated
 even
 if hardcoded tables are not used, and the cost is deferred to runtime
 instead of
 build time. Thus binary size should not be affected, but users burn cycles
 unnecessarily for every codec having these kinds of tables. I have these
 patches,
 simply because at the moment users are paying a price for the typical
 default.
 ---
  libavcodec/cbrt_tablegen.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>>
>>> This has been discussed extensively in the past...
>>
>> Can you please give a link and/or timeframe to search for?
>>
>>>
>>> As for the patch, don't forget that tablegen runs on the host (build), not
>>> target (runtime), whereas libm.h is for target (runtime) and may not be
>>> compatible. I believe that's why we don't use libm.h in tablegen files.
>>
>> I don't understand this, it seems to me like any other code (at least
>> in the default configure), it gets called, and like all other such
>> things, we use libavutil/libm for hackery. This host/target business
>> affects other things as well. What is the issue?
>
> libavutil/libm.h uses defines from config.h, which are based on the tests run
> by configure for the target, and not the host where compilation takes place.
> The tablegen applications all run at compile time. What is available on the
> target may not be on the host.

Ok. So I would like an answer to two simple questions that are outside
my knowledge or interest.

Is it possible with some hackery to get this change through, or not?
If so, what is it?

>
>>
>>>
>>> It's fine to use pow or a compat wrapper, but then you need a build/host
>>> libm.h instead of using the target/runtime one.
>>>
>>> Ronald
>> ___
>> 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
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] fate: add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM tests

2015-11-25 Thread Michael Niedermayer
On Wed, Nov 25, 2015 at 09:14:48PM +0100, Matthieu Bouron wrote:
> On Wed, Nov 25, 2015 at 06:36:03PM +0100, Michael Niedermayer wrote:
> > On Wed, Nov 25, 2015 at 03:40:15PM +0100, Matthieu Bouron wrote:
> > > From: Matthieu Bouron 
[...]
> >
> > > +
> > > +static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket 
> > > *pkt, int decode)
> > > +{
> > > +int ret = 0;
> > > +int got_frame = 0;
> > > +AVFrame *frame = NULL;
> > > +int skip_frame = codec_ctx->skip_frame;
> > > +
> > > +if (!avcodec_is_open(codec_ctx)) {
> > > +const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
> > > +
> > > +ret = avcodec_open2(codec_ctx, codec, NULL);
> > > +if (ret < 0) {
> > > +av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");
> > > +goto end;
> > > +}
> > > +}
> > > +
> > > +frame = av_frame_alloc();
> > > +if (!frame) {
> > > +av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");
> > > +goto end;
> > > +}
> > > +
> > > +if (!decode && codec_ctx->codec->caps_internal & 
> > > FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
> > > +codec_ctx->skip_frame = AVDISCARD_ALL;
> > > +}
> > > +
> > > +do {
> > > +ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);
> > > +av_assert0(decode || (!decode && !got_frame));
> > > +if (ret < 0)
> > > +break;
> > > +pkt->data += ret;
> > > +pkt->size -= ret;
> > > +
> > > +if (got_frame) {
> > > +break;
> > > +}
> > > +} while (pkt->size > 0);
> > > +
> > > +end:
> > > +codec_ctx->skip_frame = skip_frame;
> > > +
> > > +av_frame_free(&frame);
> > > +return ret;
> > > +}
> > > +
> > > +static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
> > > +{
> > > +int ret = 0;
> > > +int i, done = 0;
> > > +AVPacket pkt;
> > > +
> > > +av_init_packet(&pkt);
> > > +
> > > +while (!done) {
> > > +AVCodecContext *codec_ctx = NULL;
> > > +AVStream *st;
> > > +
> > > +if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {
> > > +av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");
> > > +goto end;
> > > +}
> > > +
> > > +st = fmt_ctx->streams[pkt.stream_index];
> > > +codec_ctx = st->codec;
> > > +
> > > +if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||
> > 
> > > +st->codec_info_nb_frames++ > 0) {
> > 
> > writing into this is not ok, iam not sure it should be touched at
> > all from API users and tests/api/* could be used as example for
> > correct API use ...
> 
> This function intends to mimic avformat_find_stream_info which increments
> this field, if it's a blocker i'll use something else.

presonally iam fine if you document that this should not be used by
user applications and why it is used in this "regression test"


> 
> > 
> > 
> > > +av_packet_unref(&pkt);
> > > +continue;
> > > +}
> > > +
> > > +ret = try_decode_video_frame(codec_ctx, &pkt, decode);
> > > +if (ret < 0) {
> > > +av_log(fmt_ctx, AV_LOG_ERROR, "Failed to decode video 
> > > frame\n");
> > > +goto end;
> > > +}
> > > +
> > > +av_packet_unref(&pkt);
> > > +
> > > +/* check if all video streams have demuxed a packet */
> > > +done = 1;
> > > +for (i = 0; i < fmt_ctx->nb_streams; i++) {
> > > +st = fmt_ctx->streams[i];
> > > +codec_ctx = st->codec;
> > > +
> > > +if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO)
> > > +continue;
> > > +
> > > +done &= st->codec_info_nb_frames > 0;
> > > +}
> > > +}
> > > +
> > > +end:
> > > +av_packet_unref(&pkt);
> > > +
> > > +return ret < 0;
> > > +}
> > > +
> > > +static void dump_video_streams(const AVFormatContext *fmt_ctx, int 
> > > decode)
> > > +{
> > > +int i;
> > > +
> > > +for (i = 0; i < fmt_ctx->nb_streams; i++) {
> > > +const AVStream *st = fmt_ctx->streams[i];
> > > +const AVCodecContext *codec_ctx = st->codec;
> > > +const AVRational sar = codec_ctx->sample_aspect_ratio;
> > > +
> > > +printf("stream=%d, decode=%d\n", i, decode);
> > > +printf("width=%d\n", codec_ctx->width);
> > > +printf("height=%d\n", codec_ctx->height);
> > > +printf("pix_fmt=%s\n", 
> > > av_get_pix_fmt_name(codec_ctx->pix_fmt));
> > > +printf("sar=%d/%d\n", sar.num, sar.den);
> > > +printf("\n");
> > > +}
> > > +}
> > > +
> > > +static int open_and_probe_video_streams(AVFormatContext **fmt_ctx, const 
> > > char *filename, int decode)
> > > +{
> > > +int ret = 0;
> > > +
> > > +ret = avformat_open_input(fmt_ctx, filename, NULL, NULL);
> > > +if (ret < 0) {
> > > +av_log(NULL, AV_LOG_ERROR, "Failed to open input 

Re: [FFmpeg-devel] [PATCH] avcodec/pthread_slice: Remove rets_count

2015-11-25 Thread Michael Niedermayer
On Thu, Nov 19, 2015 at 12:58:35AM +0100, Michael Niedermayer wrote:
> From: Michael Niedermayer 
> 
> It appears rets_count is redundant
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/pthread_slice.c |5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)

applied

[...]
-- 
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]lavc/opusdec: Fix a memleak when reading invalid files

2015-11-25 Thread Carl Eugen Hoyos
On Friday 20 November 2015 02:59:34 am James Almer wrote:
> On 11/19/2015 10:05 PM, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch fixes a memleak with the sample from bug 909.

> >  /* find out the channel configuration */
> >  ret = ff_opus_parse_extradata(avctx, c);
> > -if (ret < 0)
> > +if (ret < 0) {
> > +av_freep(&c->fdsp);
> >  return ret;
>
> ff_opus_parse_extradata() can allocate s->channel_maps, so i think it
> should also be freed here.
>
> LGTM aside from that.

I have applied the patch with this change.

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


Re: [FFmpeg-devel] [PATCH]Recognize more extensions to encode raw hevc.

2015-11-25 Thread Carl Eugen Hoyos
On Tuesday 24 November 2015 02:16:11 am Michael Niedermayer wrote:
> On Tue, Nov 24, 2015 at 12:44:34AM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch allows more extensions for hevc, as requested 
> > on the user mailing list.
> >
> > Please comment, Carl Eugen
>
> should be ok

Patch applied.

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


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread James Almer
On 11/25/2015 8:32 PM, Ganesh Ajjanagadde wrote:
> On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje  wrote:
>> Hi,
>>
>> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde 
>> wrote:
>>>
>>> On systems having cbrt, there is no reason to use the slow pow function.
>>>
>>> Sample benchmark (x86-64, Haswell, GNU/Linux):
>>> new:
>>> 5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>>
>>> old:
>>> 12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>>
>>> Signed-off-by: Ganesh Ajjanagadde 
>>>
>>> ---
>>> What I wonder about is why --enable-hardcoded-tables is not the default
>>> for
>>> FFmpeg. Unless I am missing something, static storage is anyway allocated
>>> even
>>> if hardcoded tables are not used, and the cost is deferred to runtime
>>> instead of
>>> build time. Thus binary size should not be affected, but users burn cycles
>>> unnecessarily for every codec having these kinds of tables. I have these
>>> patches,
>>> simply because at the moment users are paying a price for the typical
>>> default.
>>> ---
>>>  libavcodec/cbrt_tablegen.h | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>>
>> This has been discussed extensively in the past...
> 
> Can you please give a link and/or timeframe to search for?
> 
>>
>> As for the patch, don't forget that tablegen runs on the host (build), not
>> target (runtime), whereas libm.h is for target (runtime) and may not be
>> compatible. I believe that's why we don't use libm.h in tablegen files.
> 
> I don't understand this, it seems to me like any other code (at least
> in the default configure), it gets called, and like all other such
> things, we use libavutil/libm for hackery. This host/target business
> affects other things as well. What is the issue?

libavutil/libm.h uses defines from config.h, which are based on the tests run
by configure for the target, and not the host where compilation takes place.
The tablegen applications all run at compile time. What is available on the
target may not be on the host.

> 
>>
>> It's fine to use pow or a compat wrapper, but then you need a build/host
>> libm.h instead of using the target/runtime one.
>>
>> Ronald
> ___
> 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]lavf/mxfdec: Set width to actual coded_width for AVCI50

2015-11-25 Thread Carl Eugen Hoyos
On Wednesday 25 November 2015 12:57:07 am Tomas Härdin wrote:
> On Tue, 2015-11-24 at 12:02 +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch fixes ticket #5029.
> >
> > Please comment, Carl Eugen
>
> Looks simple enough, but (ab)using MXFCodecUL like that 
> has a slight stink to it.

It was abused for pix_fmts before, and I added a usage for 
codec_tag in July. MXFCodecUL uses an int for the third 
parameter which is exactly what is needed for width.

> Can we perhaps rename the struct to something that signals 
> its more general use of mapping ULs to integers?

I will rename it if you make a suggestion...

> Another thing: don't we have some table like this for 
> H.264 in MXF already?

There are tables that contain H.263 as codec_id but the 
width is needed for this ticket.

Ok to apply?

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


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 6:19 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde 
> wrote:
>>
>> On systems having cbrt, there is no reason to use the slow pow function.
>>
>> Sample benchmark (x86-64, Haswell, GNU/Linux):
>> new:
>> 5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>
>> old:
>> 12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>>
>> ---
>> What I wonder about is why --enable-hardcoded-tables is not the default
>> for
>> FFmpeg. Unless I am missing something, static storage is anyway allocated
>> even
>> if hardcoded tables are not used, and the cost is deferred to runtime
>> instead of
>> build time. Thus binary size should not be affected, but users burn cycles
>> unnecessarily for every codec having these kinds of tables. I have these
>> patches,
>> simply because at the moment users are paying a price for the typical
>> default.
>> ---
>>  libavcodec/cbrt_tablegen.h | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>
>
> This has been discussed extensively in the past...

Can you please give a link and/or timeframe to search for?

>
> As for the patch, don't forget that tablegen runs on the host (build), not
> target (runtime), whereas libm.h is for target (runtime) and may not be
> compatible. I believe that's why we don't use libm.h in tablegen files.

I don't understand this, it seems to me like any other code (at least
in the default configure), it gets called, and like all other such
things, we use libavutil/libm for hackery. This host/target business
affects other things as well. What is the issue?

>
> It's fine to use pow or a compat wrapper, but then you need a build/host
> libm.h instead of using the target/runtime one.
>
> Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ronald S. Bultje
Hi,

On Wed, Nov 25, 2015 at 5:17 PM, Ganesh Ajjanagadde 
wrote:

> On systems having cbrt, there is no reason to use the slow pow function.
>
> Sample benchmark (x86-64, Haswell, GNU/Linux):
> new:
> 5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips
>
> old:
> 12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips
>
> Signed-off-by: Ganesh Ajjanagadde 
>
> ---
> What I wonder about is why --enable-hardcoded-tables is not the default for
> FFmpeg. Unless I am missing something, static storage is anyway allocated
> even
> if hardcoded tables are not used, and the cost is deferred to runtime
> instead of
> build time. Thus binary size should not be affected, but users burn cycles
> unnecessarily for every codec having these kinds of tables. I have these
> patches,
> simply because at the moment users are paying a price for the typical
> default.
> ---
>  libavcodec/cbrt_tablegen.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)


This has been discussed extensively in the past...

As for the patch, don't forget that tablegen runs on the host (build), not
target (runtime), whereas libm.h is for target (runtime) and may not be
compatible. I believe that's why we don't use libm.h in tablegen files.

It's fine to use pow or a compat wrapper, but then you need a build/host
libm.h instead of using the target/runtime one.

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


[FFmpeg-devel] [PATCH] avcodec/mpegaudio_tablegen: speed up table generation

2015-11-25 Thread Ganesh Ajjanagadde
This does some miscellaneous stuff mainly avoiding the usage of pow to
achieve significant speedups. This is not speed critical, but is
unnecessary latency and cycles wasted for a user.

All tables tested and are identical to the old ones
(bit-exact even in floating point case).

Sample benchmark (x86-64, Haswell, GNU/Linux):
old:
102329530 decicycles in mpegaudio_tableinit,   1 runs,  0 skips

new:
34111900 decicycles in mpegaudio_tableinit,   1 runs,  0 skips

Signed-off-by: Ganesh Ajjanagadde 
---
 libavcodec/mpegaudio_tablegen.h | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h
index 86b2cd3..cea466b 100644
--- a/libavcodec/mpegaudio_tablegen.h
+++ b/libavcodec/mpegaudio_tablegen.h
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include "libavutil/attributes.h"
+#include "libavutil/libm.h"
 
 #define TABLE_4_3_SIZE (8191 + 16)*4
 #if CONFIG_HARDCODED_TABLES
@@ -45,12 +46,21 @@ static float expval_table_float[512][16];
 static av_cold void mpegaudio_tableinit(void)
 {
 int i, value, exponent;
+double pow2_lut[4] = {
+1., /* 2 ^ (0 * 0.25) */
+1.18920711500272106672, /* 2 ^ (1 * 0.25) */
+M_SQRT2   , /* 2 ^ (2 * 0.25) */
+1.68179283050742908606, /* 2 ^ (3 * 0.25) */
+};
+double cbrt_lut[16];
+for (i = 0; i < 16; ++i)
+cbrt_lut[i] = cbrt(i);
+
 for (i = 1; i < TABLE_4_3_SIZE; i++) {
 double value = i / 4;
 double f, fm;
 int e, m;
-/* cbrtf() isn't available on all systems, so we use powf(). */
-f  = value / IMDCT_SCALAR * pow(value, 1.0 / 3.0) * pow(2, (i & 3) * 
0.25);
+f  = value / IMDCT_SCALAR * cbrt(value) * pow2_lut[i & 3];
 fm = frexp(f, &e);
 m  = (uint32_t)(fm * (1LL << 31) + 0.5);
 e += FRAC_BITS - 31 + 5 - 100;
@@ -61,10 +71,8 @@ static av_cold void mpegaudio_tableinit(void)
 }
 for (exponent = 0; exponent < 512; exponent++) {
 for (value = 0; value < 16; value++) {
-/* cbrtf() isn't available on all systems, so we use powf(). */
-double f = (double)value * pow(value, 1.0 / 3.0) * pow(2, 
(exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
-/* llrint() isn't always available, so round and cast manually. */
-expval_table_fixed[exponent][value] = (long long int) (f < 
0x ? floor(f + 0.5) : 0x);
+double f = value * cbrt_lut[value] * pow(2, (exponent - 400) * 
0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
+expval_table_fixed[exponent][value] = (f < 0x ? llrint(f) 
: 0x);
 expval_table_float[exponent][value] = f;
 }
 exp_table_fixed[exponent] = expval_table_fixed[exponent][1];
-- 
2.6.2

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


[FFmpeg-devel] [PATCH] avcodec/cbrt_tablegen: avoid pow and speed up cbrt_tableinit

2015-11-25 Thread Ganesh Ajjanagadde
On systems having cbrt, there is no reason to use the slow pow function.

Sample benchmark (x86-64, Haswell, GNU/Linux):
new:
5124920 decicycles in cbrt_tableinit,   1 runs,  0 skips

old:
12321680 decicycles in cbrt_tableinit,   1 runs,  0 skips

Signed-off-by: Ganesh Ajjanagadde 
---
What I wonder about is why --enable-hardcoded-tables is not the default for
FFmpeg. Unless I am missing something, static storage is anyway allocated even
if hardcoded tables are not used, and the cost is deferred to runtime instead of
build time. Thus binary size should not be affected, but users burn cycles
unnecessarily for every codec having these kinds of tables. I have these 
patches,
simply because at the moment users are paying a price for the typical default.
---
 libavcodec/cbrt_tablegen.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cbrt_tablegen.h b/libavcodec/cbrt_tablegen.h
index 27a3e3a..48d56b3 100644
--- a/libavcodec/cbrt_tablegen.h
+++ b/libavcodec/cbrt_tablegen.h
@@ -26,10 +26,11 @@
 #include 
 #include 
 #include "libavutil/attributes.h"
+#include "libavutil/libm.h"
 #include "libavcodec/aac_defines.h"
 
 #if USE_FIXED
-#define CBRT(x) (int)floor((x).f * 8192 + 0.5)
+#define CBRT(x) lrint((x).f * 8192)
 #else
 #define CBRT(x) x.i
 #endif
@@ -49,13 +50,12 @@ static av_cold void AAC_RENAME(cbrt_tableinit)(void)
 {
 if (!cbrt_tab[(1<<13) - 1]) {
 int i;
-/* cbrtf() isn't available on all systems, so we use powf(). */
 for (i = 0; i < 1<<13; i++) {
 union {
 float f;
 uint32_t i;
 } f;
-f.f = pow(i, 1.0 / 3.0) * i;
+f.f = cbrt(i) * i;
 cbrt_tab[i] = CBRT(f);
 }
 }
-- 
2.6.2

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


[FFmpeg-devel] [PATCH 6/6] lavf/matroska: add automatic bitstream filtering

2015-11-25 Thread Rodger Combs
---
 libavformat/matroskaenc.c | 43 +++
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 10cf0a0..41aa8e0 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -845,9 +845,6 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 int j, ret;
 AVDictionaryEntry *tag;
 
-// ms precision is the de-facto standard timescale for mkv files
-avpriv_set_pts_info(st, 64, 1, 1000);
-
 if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
 mkv->have_attachments = 1;
 return 0;
@@ -1388,11 +1385,6 @@ static int mkv_write_header(AVFormatContext *s)
 else
 mkv->mode = MODE_MATROSKAv2;
 
-if (s->avoid_negative_ts < 0) {
-s->avoid_negative_ts = 1;
-s->internal->avoid_negative_ts_use_pts = 1;
-}
-
 if (mkv->mode != MODE_WEBM ||
 av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
 av_dict_get(s->metadata, "alpha_mode", NULL, 0))
@@ -2098,6 +2090,35 @@ static int mkv_query_codec(enum AVCodecID codec_id, int 
std_compliance)
 return 0;
 }
 
+static int mkv_init(struct AVFormatContext *s)
+{
+int i;
+
+if (s->avoid_negative_ts < 0) {
+s->avoid_negative_ts = 1;
+s->internal->avoid_negative_ts_use_pts = 1;
+}
+
+for (i = 0; i < s->nb_streams; i++) {
+// ms precision is the de-facto standard timescale for mkv files
+avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
+}
+
+return 0;
+}
+
+static int mkv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+int ret = 1;
+AVStream *st = s->streams[pkt->stream_index];
+
+if (st->codec->codec_id == AV_CODEC_ID_AAC)
+if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
+ret = av_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
+
+return ret;
+}
+
 static const AVCodecTag additional_audio_tags[] = {
 { AV_CODEC_ID_ALAC,  0X },
 { AV_CODEC_ID_EAC3,  0X },
@@ -2160,6 +2181,7 @@ AVOutputFormat ff_matroska_muxer = {
  AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
 .video_codec   = CONFIG_LIBX264_ENCODER ?
  AV_CODEC_ID_H264 : AV_CODEC_ID_MPEG4,
+.init  = mkv_init,
 .write_header  = mkv_write_header,
 .write_packet  = mkv_write_flush_packet,
 .write_trailer = mkv_write_trailer,
@@ -2171,6 +2193,7 @@ AVOutputFormat ff_matroska_muxer = {
 },
 .subtitle_codec= AV_CODEC_ID_ASS,
 .query_codec   = mkv_query_codec,
+.check_bitstream   = mkv_check_bitstream,
 .priv_class= &matroska_class,
 };
 #endif
@@ -2192,9 +2215,11 @@ AVOutputFormat ff_webm_muxer = {
 .audio_codec   = CONFIG_LIBOPUS_ENCODER ? AV_CODEC_ID_OPUS : 
AV_CODEC_ID_VORBIS,
 .video_codec   = CONFIG_LIBVPX_VP9_ENCODER? AV_CODEC_ID_VP9 : 
AV_CODEC_ID_VP8,
 .subtitle_codec= AV_CODEC_ID_WEBVTT,
+.init  = mkv_init,
 .write_header  = mkv_write_header,
 .write_packet  = mkv_write_flush_packet,
 .write_trailer = mkv_write_trailer,
+.check_bitstream   = mkv_check_bitstream,
 .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
  AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH,
 .priv_class= &webm_class,
@@ -2217,9 +2242,11 @@ AVOutputFormat ff_matroska_audio_muxer = {
 .audio_codec   = CONFIG_LIBVORBIS_ENCODER ?
  AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3,
 .video_codec   = AV_CODEC_ID_NONE,
+.init  = mkv_init,
 .write_header  = mkv_write_header,
 .write_packet  = mkv_write_flush_packet,
 .write_trailer = mkv_write_trailer,
+.check_bitstream   = mkv_check_bitstream,
 .flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT |
  AVFMT_ALLOW_FLUSH,
 .codec_tag = (const AVCodecTag* const []){
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 5/6] lavf: add API to append a bsf to a stream's list

2015-11-25 Thread Rodger Combs
---
 libavformat/avformat.h | 12 
 libavformat/utils.c| 20 
 2 files changed, 32 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index bb3a674..33f6d28 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2799,6 +2799,18 @@ int avformat_match_stream_specifier(AVFormatContext *s, 
AVStream *st,
 int avformat_queue_attached_pictures(AVFormatContext *s);
 
 /**
+ * Add a bitstream filter to a stream.
+ *
+ * @param st output stream to add a filter to
+ * @param name the name of the filter to add
+ * @param args filter-specific argument string
+ * @return  >0 on success;
+ *  AVERROR code on failure
+ */
+int av_stream_add_bitstream_filter(AVStream *st, const char *name,
+   const char *args);
+
+/**
  * Apply a list of bitstream filters to a packet.
  *
  * @param codec AVCodecContext, usually from an AVStream
diff --git a/libavformat/utils.c b/libavformat/utils.c
index dcacf44..8f22c32 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4631,6 +4631,26 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum 
AVPacketSideDataType type,
 return data;
 }
 
+int av_stream_add_bitstream_filter(AVStream *st, const char *name,
+   const char *args)
+{
+AVBitStreamFilterContext *bsfc = NULL;
+AVBitStreamFilterContext **dest = &st->bsfc;
+while (*dest && (*dest)->next)
+dest = &(*dest)->next;
+
+if (!(bsfc = av_bitstream_filter_init(name))) {
+av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", name);
+return AVERROR(EINVAL);
+}
+if (args && !(bsfc->args = av_strdup(args))) {
+av_bitstream_filter_close(bsfc);
+return AVERROR(ENOMEM);
+}
+*dest = bsfc;
+return 1;
+}
+
 int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
AVBitStreamFilterContext *bsfc)
 {
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 4/6] lavf: add automatic bitstream filtering

2015-11-25 Thread Rodger Combs
This solves the problem discussed in 
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-September/179238.html
by allowing AVCodec::write_header to be delayed until after packets have been
run through required bitstream filters in order to generate global extradata.

It also provides a mechanism by which a muxer can add a bitstream filter to a
stream automatically, rather than prompting the user to do so.
---
 libavformat/avformat.h | 37 +
 libavformat/mux.c  | 47 +--
 2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d94191e..bb3a674 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -600,6 +600,29 @@ typedef struct AVOutputFormat {
  */
 int (*free_device_capabilities)(struct AVFormatContext *s, struct 
AVDeviceCapabilitiesQuery *caps);
 enum AVCodecID data_codec; /**< default data codec */
+/**
+ * Initialize format. May allocate data here, and set any AVFormatContext 
or
+ * AVStream parameters that need to be set before packets are sent.
+ * This method must not write output.
+ *
+ * Any allocations made here must be freed in deinit().
+ */
+int (*init)(struct AVFormatContext *);
+/**
+ * Deinitialize format. If present, this is called whenever the muxer is 
being
+ * destroyed, regardless of whether or not the header has been written.
+ *
+ * If a trailer is being written, this is called after write_trailer().
+ *
+ * This is called if init() fails as well.
+ */
+void (*deinit)(struct AVFormatContext *);
+/**
+ * Set up any necessary bitstream filtering and extract any extra data 
needed
+ * for the global header.
+ * Return 0 if more packets from this stream must be checked; 1 if not.
+ */
+int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt);
 } AVOutputFormat;
 /**
  * @}
@@ -1177,6 +1200,18 @@ typedef struct AVStream {
  * Must not be accessed in any way by callers.
  */
 AVStreamInternal *internal;
+
+/**
+ * bitstream filter to run on stream
+ * - encoding: Set by muxer or user using av_stream_add_bitstream_filter
+ * - decoding: unused
+ */
+AVBitStreamFilterContext *bsfc;
+
+/**
+ * internal check if check_bitstream should still be run on each packet
+ */
+int bitstream_checked;
 } AVStream;
 
 AVRational av_stream_get_r_frame_rate(const AVStream *s);
@@ -1792,6 +1827,8 @@ typedef struct AVFormatContext {
  * Demuxing: Set by user.
  */
 int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char 
*url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options);
+
+int header_written;
 } AVFormatContext;
 
 int av_format_get_probe_score(const AVFormatContext *s);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 05d4170..56ada97 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -405,6 +405,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
  *options = tmp;
 }
 
+if (s->oformat->init && (ret = s->oformat->init(s)) < 0) {
+s->oformat->deinit(s);
+goto fail;
+}
+
 return 0;
 
 fail:
@@ -456,7 +461,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary 
**options)
 if ((ret = init_muxer(s, options)) < 0)
 return ret;
 
-if (s->oformat->write_header) {
+if (s->oformat->write_header && !s->oformat->check_bitstream) {
 ret = s->oformat->write_header(s);
 if (ret >= 0 && s->pb && s->pb->error < 0)
 ret = s->pb->error;
@@ -464,6 +469,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary 
**options)
 return ret;
 if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & 
AVFMT_FLAG_FLUSH_PACKETS)
 avio_flush(s->pb);
+s->header_written = 1;
 }
 
 if ((ret = init_pts(s)) < 0)
@@ -1021,6 +1027,17 @@ int av_interleaved_write_frame(AVFormatContext *s, 
AVPacket *pkt)
 ret = AVERROR(EINVAL);
 goto fail;
 }
+
+if (s->oformat->check_bitstream) {
+if (!st->bitstream_checked) {
+if ((ret = s->oformat->check_bitstream(s, pkt)) < 0)
+goto fail;
+else if (ret == 1)
+st->bitstream_checked = 1;
+}
+}
+
+av_apply_bitstream_filters(st->codec, pkt, st->bsfc);
 } else {
 av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame FLUSH\n");
 flush = 1;
@@ -1037,10 +1054,22 @@ int av_interleaved_write_frame(AVFormatContext *s, 
AVPacket *pkt)
 if (ret <= 0) //FIXME cleanup needed for ret<0 ?
 return ret;
 
+if (!s->header_written && s->oformat->write_header) {
+ret = s->oformat->write_header(s);
+if (ret >= 0 && s->pb && s->pb->error < 0)
+ret = s->pb->error;
+ 

[FFmpeg-devel] [PATCH 3/6] lavf/tee: use lavf API for applying bitstream filters

2015-11-25 Thread Rodger Combs
---
 libavformat/tee.c | 44 +++-
 1 file changed, 3 insertions(+), 41 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index af52a49..8c54d32 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -405,45 +405,6 @@ fail:
 return ret;
 }
 
-static int filter_packet(void *log_ctx, AVPacket *pkt,
- AVFormatContext *fmt_ctx, AVBitStreamFilterContext 
*bsf_ctx)
-{
-AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
-int ret = 0;
-
-while (bsf_ctx) {
-AVPacket new_pkt = *pkt;
-ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL,
- &new_pkt.data, &new_pkt.size,
- pkt->data, pkt->size,
- pkt->flags & AV_PKT_FLAG_KEY);
-if (ret == 0 && new_pkt.data != pkt->data) {
-if ((ret = av_copy_packet(&new_pkt, pkt)) < 0)
-break;
-ret = 1;
-}
-
-if (ret > 0) {
-av_packet_unref(pkt);
-new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
-   av_buffer_default_free, NULL, 0);
-if (!new_pkt.buf)
-break;
-}
-if (ret < 0) {
-av_log(log_ctx, AV_LOG_ERROR,
-"Failed to filter bitstream with filter %s for stream %d in 
file '%s' with codec %s\n",
-bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename,
-avcodec_get_name(enc_ctx->codec_id));
-}
-*pkt = new_pkt;
-
-bsf_ctx = bsf_ctx->next;
-}
-
-return ret;
-}
-
 static int tee_write_trailer(AVFormatContext *avf)
 {
 TeeContext *tee = avf->priv_data;
@@ -496,8 +457,9 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 pkt2.duration = av_rescale_q(pkt->duration, tb, tb2);
 pkt2.stream_index = s2;
 
-filter_packet(avf2, &pkt2, avf2, tee->slaves[i].bsfs[s2]);
-if ((ret = av_interleaved_write_frame(avf2, &pkt2)) < 0)
+if ((ret = av_apply_bitstream_filters(avf2->streams[s2]->codec, &pkt2,
+  tee->slaves[i].bsfs[s2])) < 0 ||
+(ret = av_interleaved_write_frame(avf2, &pkt2)) < 0)
 if (!ret_all)
 ret_all = ret;
 }
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 2/6] ffmpeg: use lavf API for applying bitstream filters

2015-11-25 Thread Rodger Combs
---
 ffmpeg.c | 46 --
 ffmpeg.h |  1 -
 ffmpeg_opt.c |  6 +-
 3 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index bf5e983..c24c8ed 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -683,47 +683,10 @@ static void write_frame(AVFormatContext *s, AVPacket 
*pkt, OutputStream *ost)
 if (bsfc)
 av_packet_split_side_data(pkt);
 
-while (bsfc) {
-AVPacket new_pkt = *pkt;
-AVDictionaryEntry *bsf_arg = av_dict_get(ost->bsf_args,
- bsfc->filter->name,
- NULL, 0);
-int a = av_bitstream_filter_filter(bsfc, avctx,
-   bsf_arg ? bsf_arg->value : NULL,
-   &new_pkt.data, &new_pkt.size,
-   pkt->data, pkt->size,
-   pkt->flags & AV_PKT_FLAG_KEY);
-if(a == 0 && new_pkt.data != pkt->data) {
-uint8_t *t = av_malloc(new_pkt.size + 
AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so 
cannot overflow
-if(t) {
-memcpy(t, new_pkt.data, new_pkt.size);
-memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
-new_pkt.data = t;
-new_pkt.buf = NULL;
-a = 1;
-} else
-a = AVERROR(ENOMEM);
-}
-if (a > 0) {
-pkt->side_data = NULL;
-pkt->side_data_elems = 0;
-av_packet_unref(pkt);
-new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
-   av_buffer_default_free, NULL, 0);
-if (!new_pkt.buf)
-exit_program(1);
-} else if (a < 0) {
-new_pkt = *pkt;
-av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for 
stream %d with codec %s",
-   bsfc->filter->name, pkt->stream_index,
-   avctx->codec ? avctx->codec->name : "copy");
-print_error("", a);
-if (exit_on_error)
-exit_program(1);
-}
-*pkt = new_pkt;
-
-bsfc = bsfc->next;
+if ((ret = av_apply_bitstream_filters(avctx, pkt, bsfc)) < 0) {
+print_error("", ret);
+if (exit_on_error)
+exit_program(1);
 }
 
 if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
@@ -4190,7 +4153,6 @@ static int transcode(void)
 av_dict_free(&ost->sws_dict);
 av_dict_free(&ost->swr_opts);
 av_dict_free(&ost->resample_opts);
-av_dict_free(&ost->bsf_args);
 }
 }
 }
diff --git a/ffmpeg.h b/ffmpeg.h
index 82ab1ee..6eeb152 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -452,7 +452,6 @@ typedef struct OutputStream {
 AVDictionary *sws_dict;
 AVDictionary *swr_opts;
 AVDictionary *resample_opts;
-AVDictionary *bsf_args;
 char *apad;
 OSTFinished finished;/* no more packets should be written for this 
stream */
 int unavailable; /* true if the steram is unavailable 
(possibly temporarily) */
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 131dd89..ca1640c 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1255,7 +1255,11 @@ static OutputStream *new_output_stream(OptionsContext 
*o, AVFormatContext *oc, e
 bsfc_prev->next = bsfc;
 else
 ost->bitstream_filters = bsfc;
-av_dict_set(&ost->bsf_args, bsfc->filter->name, arg, 0);
+if (arg)
+if (!(bsfc->args = av_strdup(arg))) {
+av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation 
failed\n");
+exit_program(1);
+}
 
 bsfc_prev = bsfc;
 bsf   = next;
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 1/6] lavf: add API to apply a list of bsfs to a packet

2015-11-25 Thread Rodger Combs
---
 libavformat/avformat.h | 11 +++
 libavformat/utils.c| 49 +
 2 files changed, 60 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 36f9d02..d94191e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2761,6 +2761,17 @@ int avformat_match_stream_specifier(AVFormatContext *s, 
AVStream *st,
 
 int avformat_queue_attached_pictures(AVFormatContext *s);
 
+/**
+ * Apply a list of bitstream filters to a packet.
+ *
+ * @param codec AVCodecContext, usually from an AVStream
+ * @param pkt the packet to apply filters to
+ * @param bsfc a NULL-terminated list of filters to apply
+ * @return  >=0 on success;
+ *  AVERROR code on failure
+ */
+int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
+   AVBitStreamFilterContext *bsfc);
 
 /**
  * @}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f33f2f5..dcacf44 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4630,3 +4630,52 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum 
AVPacketSideDataType type,
 sd->size = size;
 return data;
 }
+
+int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
+   AVBitStreamFilterContext *bsfc)
+{
+int ret = 0;
+while (bsfc) {
+AVPacket new_pkt = *pkt;
+int a = av_bitstream_filter_filter(bsfc, codec, NULL,
+   &new_pkt.data, &new_pkt.size,
+   pkt->data, pkt->size,
+   pkt->flags & AV_PKT_FLAG_KEY);
+if(a == 0 && new_pkt.data != pkt->data) {
+uint8_t *t = av_malloc(new_pkt.size + 
AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so 
cannot overflow
+if (t) {
+memcpy(t, new_pkt.data, new_pkt.size);
+memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+new_pkt.data = t;
+new_pkt.buf = NULL;
+a = 1;
+} else {
+a = AVERROR(ENOMEM);
+}
+}
+if (a > 0) {
+new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
+   av_buffer_default_free, NULL, 0);
+if (new_pkt.buf) {
+pkt->side_data = NULL;
+pkt->side_data_elems = 0;
+av_packet_unref(pkt);
+} else {
+av_freep(&new_pkt.data);
+a = AVERROR(ENOMEM);
+}
+}
+if (a < 0) {
+av_log(codec, AV_LOG_ERROR,
+   "Failed to open bitstream filter %s for stream %d with 
codec %s",
+   bsfc->filter->name, pkt->stream_index,
+   codec->codec ? codec->codec->name : "copy");
+ret = a;
+break;
+}
+*pkt = new_pkt;
+
+bsfc = bsfc->next;
+}
+return ret;
+}
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 2/2] lavc/aac_ac3_parser: reindent

2015-11-25 Thread Rodger Combs
---
 libavcodec/aac_ac3_parser.c | 45 +++--
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 6a76eb8..c9ba6bf 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -79,31 +79,32 @@ get_next:
 avctx->codec_id = s->codec_id;
 
 if (got_frame) {
-/* Due to backwards compatible HE-AAC the sample rate, channel count,
-   and total number of samples found in an AAC ADTS header are not
-   reliable. Bit rate is still accurate because the total frame duration in
-   seconds is still correct (as is the number of bits in the frame). */
-if (avctx->codec_id != AV_CODEC_ID_AAC) {
-avctx->sample_rate = s->sample_rate;
+/* Due to backwards compatible HE-AAC the sample rate, channel count,
+   and total number of samples found in an AAC ADTS header are not
+   reliable. Bit rate is still accurate because the total frame
+   duration in seconds is still correct (as is the number of bits in
+   the frame). */
+if (avctx->codec_id != AV_CODEC_ID_AAC) {
+avctx->sample_rate = s->sample_rate;
 
-/* (E-)AC-3: allow downmixing to stereo or mono */
-if (s->channels > 1 &&
-avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
-avctx->channels   = 1;
-avctx->channel_layout = AV_CH_LAYOUT_MONO;
-} else if (s->channels > 2 &&
-   avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
-avctx->channels   = 2;
-avctx->channel_layout = AV_CH_LAYOUT_STEREO;
-} else {
-avctx->channels = s->channels;
-avctx->channel_layout = s->channel_layout;
+/* (E-)AC-3: allow downmixing to stereo or mono */
+if (s->channels > 1 &&
+avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
+avctx->channels   = 1;
+avctx->channel_layout = AV_CH_LAYOUT_MONO;
+} else if (s->channels > 2 &&
+   avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
+avctx->channels   = 2;
+avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+} else {
+avctx->channels = s->channels;
+avctx->channel_layout = s->channel_layout;
+}
+s1->duration = s->samples;
+avctx->audio_service_type = s->service_type;
 }
-s1->duration = s->samples;
-avctx->audio_service_type = s->service_type;
-}
 
-avctx->bit_rate = s->bit_rate;
+avctx->bit_rate = s->bit_rate;
 }
 
 return i;
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 1/2] lavc/aac_ac3_parser: avoid zeroing codec parameters if we haven't read a frame

2015-11-25 Thread Rodger Combs
This caused issues when seeking in some unusual MPEGTS files
---
 libavcodec/aac_ac3_parser.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 2f7d568..6a76eb8 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -34,6 +34,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
 ParseContext *pc = &s->pc;
 int len, i;
 int new_frame_start;
+int got_frame = 0;
 
 get_next:
 i=END_NOT_FOUND;
@@ -51,6 +52,7 @@ get_next:
 if(len<=0){
 i=END_NOT_FOUND;
 }else{
+got_frame = 1;
 s->state=0;
 i-= s->header_size -1;
 s->remaining_size = len;
@@ -76,6 +78,7 @@ get_next:
 if(s->codec_id)
 avctx->codec_id = s->codec_id;
 
+if (got_frame) {
 /* Due to backwards compatible HE-AAC the sample rate, channel count,
and total number of samples found in an AAC ADTS header are not
reliable. Bit rate is still accurate because the total frame duration in
@@ -101,6 +104,7 @@ get_next:
 }
 
 avctx->bit_rate = s->bit_rate;
+}
 
 return i;
 }
-- 
2.6.3

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


[FFmpeg-devel] [PATCH 1/2] lavc/ac3_parser: avoid zeroing codec parameters if we haven't parsed a frame

2015-11-25 Thread Rodger Combs
This caused issues when seeking in some unusual MPEGTS files
---
 libavcodec/aac_ac3_parser.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 2f7d568..6a76eb8 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -34,6 +34,7 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
 ParseContext *pc = &s->pc;
 int len, i;
 int new_frame_start;
+int got_frame = 0;
 
 get_next:
 i=END_NOT_FOUND;
@@ -51,6 +52,7 @@ get_next:
 if(len<=0){
 i=END_NOT_FOUND;
 }else{
+got_frame = 1;
 s->state=0;
 i-= s->header_size -1;
 s->remaining_size = len;
@@ -76,6 +78,7 @@ get_next:
 if(s->codec_id)
 avctx->codec_id = s->codec_id;
 
+if (got_frame) {
 /* Due to backwards compatible HE-AAC the sample rate, channel count,
and total number of samples found in an AAC ADTS header are not
reliable. Bit rate is still accurate because the total frame duration in
@@ -101,6 +104,7 @@ get_next:
 }
 
 avctx->bit_rate = s->bit_rate;
+}
 
 return i;
 }
-- 
2.6.3

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


Re: [FFmpeg-devel] [PATCH] fate: add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM tests

2015-11-25 Thread Matthieu Bouron
On Wed, Nov 25, 2015 at 06:36:03PM +0100, Michael Niedermayer wrote:
> On Wed, Nov 25, 2015 at 03:40:15PM +0100, Matthieu Bouron wrote:
> > From: Matthieu Bouron 
> > 
> > ---
> >  tests/api/Makefile  |   1 +
> >  tests/api/api-codec-param-test.c| 223 
> > 
> >  tests/fate/api.mak  |   8 ++
> >  tests/ref/fate/api-jpeg-codec-param |  12 ++
> >  tests/ref/fate/api-png-codec-param  |  12 ++
> >  5 files changed, 256 insertions(+)
> >  create mode 100644 tests/api/api-codec-param-test.c
> >  create mode 100644 tests/ref/fate/api-jpeg-codec-param
> >  create mode 100644 tests/ref/fate/api-png-codec-param
> > 
> > diff --git a/tests/api/Makefile b/tests/api/Makefile
> > index 27f499f..c48c34a 100644
> > --- a/tests/api/Makefile
> > +++ b/tests/api/Makefile
> > @@ -1,6 +1,7 @@
> >  APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
> >  APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
> >  APITESTPROGS-yes += api-seek
> > +APITESTPROGS-yes += api-codec-param
> >  APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
> >  APITESTPROGS += $(APITESTPROGS-yes)
> >  
> > diff --git a/tests/api/api-codec-param-test.c 
> > b/tests/api/api-codec-param-test.c
> > new file mode 100644
> > index 000..48aced9
> > --- /dev/null
> > +++ b/tests/api/api-codec-param-test.c
> > @@ -0,0 +1,223 @@
> > +/*
> > + * Copyright (c) 2015 Matthieu Bouron 
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a 
> > copy
> > + * of this software and associated documentation files (the "Software"), 
> > to deal
> > + * in the Software without restriction, including without limitation the 
> > rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or 
> > sell
> > + * copies of the Software, and to permit persons to whom the Software is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be included 
> > in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
> > OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
> > OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> > FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
> > IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> did you intend to use #include <> instead of "" ?

Nope (fixed locally).

> 
> 
> > +
> > +static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket 
> > *pkt, int decode)
> > +{
> > +int ret = 0;
> > +int got_frame = 0;
> > +AVFrame *frame = NULL;
> > +int skip_frame = codec_ctx->skip_frame;
> > +
> > +if (!avcodec_is_open(codec_ctx)) {
> > +const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
> > +
> > +ret = avcodec_open2(codec_ctx, codec, NULL);
> > +if (ret < 0) {
> > +av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");
> > +goto end;
> > +}
> > +}
> > +
> > +frame = av_frame_alloc();
> > +if (!frame) {
> > +av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");
> > +goto end;
> > +}
> > +
> > +if (!decode && codec_ctx->codec->caps_internal & 
> > FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
> > +codec_ctx->skip_frame = AVDISCARD_ALL;
> > +}
> > +
> > +do {
> > +ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);
> > +av_assert0(decode || (!decode && !got_frame));
> > +if (ret < 0)
> > +break;
> > +pkt->data += ret;
> > +pkt->size -= ret;
> > +
> > +if (got_frame) {
> > +break;
> > +}
> > +} while (pkt->size > 0);
> > +
> > +end:
> > +codec_ctx->skip_frame = skip_frame;
> > +
> > +av_frame_free(&frame);
> > +return ret;
> > +}
> > +
> > +static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
> > +{
> > +int ret = 0;
> > +int i, done = 0;
> > +AVPacket pkt;
> > +
> > +av_init_packet(&pkt);
> > +
> > +while (!done) {
> > +AVCodecContext *codec_ctx = NULL;
> > +AVStream *st;
> > +
> > +if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {
> > +av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");
> > +goto end;
> > +}
> > +
> > +st = fmt_ctx->streams[pkt.stream_index];
> > +codec_ctx = st->codec;
> > +
> > +if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||
> 
> > +st->codec_info_nb_frames++ > 0) {
> 
> writing into this is not ok, iam not sure i

Re: [FFmpeg-devel] VS 2015 patch

2015-11-25 Thread Bruce Dawson
I tracked down the source of the confusion. The Chromium team has a repo
that sits between Chromium and the main ffmpeg repo. This repo is discussed
here:

https://chromium.googlesource.com/chromium/third_party/ffmpeg.git

The trouble is that this page shows README instead of README.chromium, so
it shows contributing instructions that are applicable to git://
source.ffmpeg.org/ffmpeg.git ffmpeg, but aren't applicable to the repo it
links to.

I'm mentioning this just in case some other lost soul shows up trying to
contribute a patch to a Chromium only file. I'll get my patch landed in the
right place.

Thanks for the help.

On Wed, Nov 25, 2015 at 5:46 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 11/25/2015 12:05 AM, Bruce Dawson wrote:
> > This would make ffmpeg fail on VS versions prior to VS 2013, for those
> > using the BUILD.gn file, which I assume is not many. It would be easy to
> > add additional conditionals for earlier versions, but if it's just for
> > Chromium then 2013/2015 is sufficient.
>
> If directed to the Chromium team, as noted elsewhere, I doubt this is an
> issue,
> since they only ever support a single compiler for Windows, at once, as far
> as I know.
>
> - Derek
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>



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


Re: [FFmpeg-devel] [PATCH v2 01/10] Added VideoToolbox H.264 encoder.

2015-11-25 Thread Michael Niedermayer
On Wed, Nov 18, 2015 at 01:49:49PM -0500, ker...@gmail.com wrote:
> From: Rick Kern 
> 
> Enable with configure --enable-vtenc and encode using -codec:v vtenc_h264.
> 
> Signed-off-by: Rick Kern 
> ---
>  MAINTAINERS|1 +
>  configure  |   14 +
>  libavcodec/Makefile|1 +
>  libavcodec/allcodecs.c |1 +
>  libavcodec/vtenc.c | 1089 
> 
>  5 files changed, 1106 insertions(+)
>  create mode 100644 libavcodec/vtenc.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3735742..28782d2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -286,6 +286,7 @@ Codecs:
>vp8   David Conrad, Jason Garrett-Glaser, 
> Ronald Bultje
>vp9   Ronald Bultje, Clément Bœsch
>vqavideo.cMike Melanson
> +  vtenc.c   Rick Kern
>wavpack.c Kostya Shishkov
>wmaprodec.c   Sascha Sommer
>wmavoice.cRonald S. Bultje
> diff --git a/configure b/configure
> index 9a736ce..e465424 100755
> --- a/configure
> +++ b/configure
> @@ -286,6 +286,7 @@ External library support:
>--disable-sdldisable sdl [autodetect]
>--disable-securetransport disable Secure Transport, needed for TLS support
> on OSX if openssl and gnutls are not used 
> [autodetect]
> +  --enable-vtenc   enable VideoToolbox encoding support [no]
>--enable-x11grab enable X11 grabbing (legacy) [no]
>--disable-xlib   disable xlib [autodetect]
>--disable-zlib   disable zlib [autodetect]
> @@ -1473,6 +1474,7 @@ EXTERNAL_LIBRARY_LIST="
>  schannel
>  sdl
>  securetransport
> +vtenc
>  x11grab
>  xlib
>  zlib
> @@ -2609,6 +2611,7 @@ libzvbi_teletext_decoder_deps="libzvbi"
>  nvenc_encoder_deps="nvenc"
>  nvenc_h264_encoder_deps="nvenc"
>  nvenc_hevc_encoder_deps="nvenc"
> +vtenc_h264_encoder_deps="vtenc"
>  
>  # demuxers / muxers
>  ac3_demuxer_select="ac3_parser"
> @@ -5471,6 +5474,17 @@ enabled openssl   && { check_lib openssl/ssl.h 
> SSL_library_init -lssl -l
> check_lib openssl/ssl.h SSL_library_init 
> -lssl32 -leay32 ||
> check_lib openssl/ssl.h SSL_library_init 
> -lssl -lcrypto -lws2_32 -lgdi32 ||
> die "ERROR: openssl not found"; }
> +enabled vtenc && { { check_header VideoToolbox/VideoToolbox.h ||
> + die "ERROR: VideoToolbox/VideoToolbox.h not 
> found."
> +   } &&
> +   { check_header "Availability.h" &&
> + { check_cpp_condition "Availability.h" 
> "defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0" ||
> +   check_cpp_condition "Availability.h" 
> "defined(__MAC_10_9) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9"
> +  } ||
> +  die "VideoToolbox requires Mac OSX 10.9+ 
> or iOS 8.0+"
> +   }
> + }
> +
>  enabled qtkit_indev  && { check_header_oc QTKit/QTKit.h || disable 
> qtkit_indev; }
>  
>  if enabled gnutls; then
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 68a573f..afb38e4 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -116,6 +116,7 @@ OBJS-$(CONFIG_TEXTUREDSP)  += texturedsp.o
>  OBJS-$(CONFIG_TEXTUREDSPENC)   += texturedspenc.o
>  OBJS-$(CONFIG_TPELDSP) += tpeldsp.o
>  OBJS-$(CONFIG_VIDEODSP)+= videodsp.o
> +OBJS-$(CONFIG_VTENC)   += vtenc.o
>  OBJS-$(CONFIG_VP3DSP)  += vp3dsp.o
>  OBJS-$(CONFIG_VP56DSP) += vp56dsp.o
>  OBJS-$(CONFIG_VP8DSP)  += vp8dsp.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 9f60d7c..6465df0 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -605,6 +605,7 @@ void avcodec_register_all(void)
>  REGISTER_ENCODER(HEVC_QSV,  hevc_qsv);
>  REGISTER_ENCODER(LIBKVAZAAR,libkvazaar);
>  REGISTER_ENCODER(MPEG2_QSV, mpeg2_qsv);
> +REGISTER_ENCODER(VTENC_H264,vtenc_h264);
>  
>  /* parsers */
>  REGISTER_PARSER(AAC,aac);
> diff --git a/libavcodec/vtenc.c b/libavcodec/vtenc.c
> new file mode 100644
> index 000..06c5360
> --- /dev/null
> +++ b/libavcodec/vtenc.c
> @@ -0,0 +1,1089 @@
> +/*
> + * copyright (c) 2015 Rick Kern 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundat

Re: [FFmpeg-devel] [PATCH v2 03/10] vtenc: Removed trailing whitespace.

2015-11-25 Thread Michael Niedermayer
On Wed, Nov 18, 2015 at 01:49:51PM -0500, ker...@gmail.com wrote:
> From: Rick Kern 
> 
> Signed-off-by: Rick Kern 
> ---
>  libavcodec/vtenc.c | 308 
> ++---
>  1 file changed, 154 insertions(+), 154 deletions(-)

it is not possible to push changes with trailing whitespaces
(with some exceptions like Makefiles and merges)

so this patchset cannot be pushed, it would be rejected by the
git hooks

also any fixes should be stashed with the changes that add the bugs
it makes no sense to commit a bug and then seperatly a bugfix
unless thats a merge from a public repository

[...]
-- 
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 2/5] avfilter: use AV_OPT_TYPE_BOOL in a bunch of places

2015-11-25 Thread Michael Niedermayer
On Sat, Nov 21, 2015 at 10:17:51PM +0100, Clément Bœsch wrote:
> From: Clément Bœsch 
> 
> ---
>  libavfilter/avf_showwaves.c | 2 +-
>  libavfilter/vf_pullup.c | 2 +-
>  libavfilter/vf_scale.c  | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

LGTM

also wont review the other 2, so dont wait for a review from me

thx


[...]
-- 
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 10/10] avfilter/vsrc_mptestsrc: use hypot()

2015-11-25 Thread Michael Niedermayer
On Sun, Nov 22, 2015 at 12:05:50PM -0500, Ganesh Ajjanagadde wrote:
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavfilter/vsrc_mptestsrc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

should be ok

thx

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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


Re: [FFmpeg-devel] [PATCH] fate: add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM tests

2015-11-25 Thread Michael Niedermayer
On Wed, Nov 25, 2015 at 03:40:15PM +0100, Matthieu Bouron wrote:
> From: Matthieu Bouron 
> 
> ---
>  tests/api/Makefile  |   1 +
>  tests/api/api-codec-param-test.c| 223 
> 
>  tests/fate/api.mak  |   8 ++
>  tests/ref/fate/api-jpeg-codec-param |  12 ++
>  tests/ref/fate/api-png-codec-param  |  12 ++
>  5 files changed, 256 insertions(+)
>  create mode 100644 tests/api/api-codec-param-test.c
>  create mode 100644 tests/ref/fate/api-jpeg-codec-param
>  create mode 100644 tests/ref/fate/api-png-codec-param
> 
> diff --git a/tests/api/Makefile b/tests/api/Makefile
> index 27f499f..c48c34a 100644
> --- a/tests/api/Makefile
> +++ b/tests/api/Makefile
> @@ -1,6 +1,7 @@
>  APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
>  APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
>  APITESTPROGS-yes += api-seek
> +APITESTPROGS-yes += api-codec-param
>  APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
>  APITESTPROGS += $(APITESTPROGS-yes)
>  
> diff --git a/tests/api/api-codec-param-test.c 
> b/tests/api/api-codec-param-test.c
> new file mode 100644
> index 000..48aced9
> --- /dev/null
> +++ b/tests/api/api-codec-param-test.c
> @@ -0,0 +1,223 @@
> +/*
> + * Copyright (c) 2015 Matthieu Bouron 
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

did you intend to use #include <> instead of "" ?


> +
> +static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, 
> int decode)
> +{
> +int ret = 0;
> +int got_frame = 0;
> +AVFrame *frame = NULL;
> +int skip_frame = codec_ctx->skip_frame;
> +
> +if (!avcodec_is_open(codec_ctx)) {
> +const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
> +
> +ret = avcodec_open2(codec_ctx, codec, NULL);
> +if (ret < 0) {
> +av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");
> +goto end;
> +}
> +}
> +
> +frame = av_frame_alloc();
> +if (!frame) {
> +av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");
> +goto end;
> +}
> +
> +if (!decode && codec_ctx->codec->caps_internal & 
> FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
> +codec_ctx->skip_frame = AVDISCARD_ALL;
> +}
> +
> +do {
> +ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);
> +av_assert0(decode || (!decode && !got_frame));
> +if (ret < 0)
> +break;
> +pkt->data += ret;
> +pkt->size -= ret;
> +
> +if (got_frame) {
> +break;
> +}
> +} while (pkt->size > 0);
> +
> +end:
> +codec_ctx->skip_frame = skip_frame;
> +
> +av_frame_free(&frame);
> +return ret;
> +}
> +
> +static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
> +{
> +int ret = 0;
> +int i, done = 0;
> +AVPacket pkt;
> +
> +av_init_packet(&pkt);
> +
> +while (!done) {
> +AVCodecContext *codec_ctx = NULL;
> +AVStream *st;
> +
> +if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {
> +av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");
> +goto end;
> +}
> +
> +st = fmt_ctx->streams[pkt.stream_index];
> +codec_ctx = st->codec;
> +
> +if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||

> +st->codec_info_nb_frames++ > 0) {

writing into this is not ok, iam not sure it should be touched at
all from API users and tests/api/* could be used as example for
correct API use ...


> +av_packet_unref(&pkt);
> +continue;
> +}
> +
> +ret = try_decode_video_frame(codec_ctx, &pkt, decode);
> +if (ret < 0) {
> +av_log(fmt_ctx, AV_LOG_ERROR, "Failed to decode video frame\n");
> +goto end;
> +}
> +
> +

Re: [FFmpeg-devel] [PATCH] avfilter: add compensationdelay filter

2015-11-25 Thread Paul B Mahol
On 11/25/15, Moritz Barsnick  wrote:
> On Wed, Nov 25, 2015 at 09:48:36 +0100, Paul B Mahol wrote:
>> Patch attached.
>
>> +For example, you have recorded guitar with two microphones placed in
>> +different location. Because the front of sound wave has fixed speed in
>> +normal conditions, the phasing of microphones can vary and depends on
>> +their location and interposition. The best sound mix you will get when
>> +these microphones are in phase (synchronized). Note that distance of
>> +~30 cm between microphones makes one microphone to capture signal in
>> +antiphase to another microphone. That makes the final mix sounding moody.
>> +This filter helps to solve phasing problems by adding different delays
>> +to each microphone track and make them synchronized.
>
>   For example, you have recorded a guitar with two microphones placed
>   in different locations.
>
> This part I don't actually understand (is the fixed speed really the
> reason?), but I fixed the grammar anyway:
>
>   Because the front of sound wave travels at fixed speed in normal
>   conditions, the phasing of microphones can vary and depends on their
>   location and interposition.
>
>   The best sound mix can be achieved when these microphones are in
>   phase (synchronized). Note that a difference of ~30 cm in the
>   distances between source and microphones leads to one microphone
>   capturing its signal in antiphase to the other.
>
>   That makes the final mix sound moody. This filter helps to solve
>   phasing problems by adding different delays to each microphone track
>   and make them synchronized.

You changed logic here, I changed only first part.

>
> I'm not sure "synchronized" is the correct term though, but I'm no
> expert.
>
> Here, I might avoid the "you" form in favor of passive, but I guess
> it's okay as it is:
>
>   The best results can be achieved when you take one track as base and
>   synchronize other tracks one by one with it.
>
>
>> +@item mm
>> +Set millimeters distance. This is compensation distance for fine tuning.
>> +
>> +@item cm
>> +Set cm distance. This is compensation distance for tighten distance
>> setup.
>
> for tightening

Changed.

>
>> +@item m
>> +Set meters distance. This is compensation distance for hard distance
>> setup.
>> +
>> +@item dry
>> +Set dry amount. Amount of unprocessed (dry) signal.
>> +
>> +@item wet
>> +Set wet amount. Amount of processed (wet) signal.
>> +
>> +@item temp
>> +Set temperature degree in Celzius. This is the temperature of the
>> environment.
>
> Celsius

Changed.

>
>> +@end table
>
> Would you like to document the defaults?

Done.

>
> Moritz
> ___
> 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] avfilter: add compensationdelay filter

2015-11-25 Thread Ganesh Ajjanagadde
On Wed, Nov 25, 2015 at 9:50 AM, Moritz Barsnick  wrote:
> On Wed, Nov 25, 2015 at 09:48:36 +0100, Paul B Mahol wrote:
>> Patch attached.
>
>> +For example, you have recorded guitar with two microphones placed in
>> +different location. Because the front of sound wave has fixed speed in
>> +normal conditions, the phasing of microphones can vary and depends on
>> +their location and interposition. The best sound mix you will get when
>> +these microphones are in phase (synchronized). Note that distance of
>> +~30 cm between microphones makes one microphone to capture signal in
>> +antiphase to another microphone. That makes the final mix sounding moody.
>> +This filter helps to solve phasing problems by adding different delays
>> +to each microphone track and make them synchronized.
>
>   For example, you have recorded a guitar with two microphones placed
>   in different locations.
>
> This part I don't actually understand (is the fixed speed really the
> reason?), but I fixed the grammar anyway:
>
>   Because the front of sound wave travels at fixed speed in normal
>   conditions, the phasing of microphones can vary and depends on their
>   location and interposition.
>
>   The best sound mix can be achieved when these microphones are in
>   phase (synchronized). Note that a difference of ~30 cm in the
>   distances between source and microphones leads to one microphone
>   capturing its signal in antiphase to the other.
>
>   That makes the final mix sound moody. This filter helps to solve
>   phasing problems by adding different delays to each microphone track
>   and make them synchronized.
>
> I'm not sure "synchronized" is the correct term though, but I'm no
> expert.

Synchronized should be fine, for a more technical audience who desire
precise terms, above paragraph has a "in phase (synchronized)"
clarifying the colloquialism.

BTW, last line could be better as "and thus making them synchronized".

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


Re: [FFmpeg-devel] [PATCH] avfilter/af_dynaudnorm: remove pow2

2015-11-25 Thread Ronald S. Bultje
Hi,

On Wed, Nov 25, 2015 at 8:00 AM, Ganesh Ajjanagadde 
wrote:

> pow2 is being used for trivial squaring. Its name is not good: is this
> 2^x or x^2?


2^x is exp2, not pow2. (I have no opinion on the patch itself.)

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


Re: [FFmpeg-devel] [PATCH] Allow mpjpeg demuxer to process MIME parts which do not include Content-Length header.

2015-11-25 Thread Alex Agranovsky

On November 24, 2015 at 6:06:36 PM, Michael Niedermayer (michae...@gmx.at) 
wrote:

On Tue, Nov 24, 2015 at 03:01:28PM -0500, Alex Agranovsky wrote: 
[...] 

> From 2c253d7978a6c9c2dc701d393eb5b9d68e831c98 Mon Sep 17 00:00:00 2001 
> From: Alex Agranovsky  
> Date: Tue, 24 Nov 2015 00:07:34 -0500 
> Subject: [PATCH 2/2] If available, use the actual boundary in HTTP response's 
> Content-Type header, to separate MIME parts in mpjpeg stream 
> 
> This code is disabled by default so not to break some fragile endpoints 
> sending invalid MIME, but can be enabled via AVOption 'strict_mime_boundary' 
> 
> Signed-off-by: Alex Agranovsky  
> --- 
> libavformat/mpjpegdec.c | 75 
> +++-- 
> 1 file changed, 72 insertions(+), 3 deletions(-) 
> 
> diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c 
> index b9093ea..b89f128 100644 
> --- a/libavformat/mpjpegdec.c 
> +++ b/libavformat/mpjpegdec.c 
> @@ -20,6 +20,7 @@ 
> */ 
>  
> #include "libavutil/avstring.h" 
> +#include "libavutil/opt.h" 
>  
> #include "avformat.h" 
> #include "internal.h" 
> @@ -28,9 +29,11 @@ 
>  
>  
> typedef struct MPJPEGDemuxContext { 
> + const AVClass *class; 
> char* boundary; 
> char* searchstr; 
> int searchstr_len; 
> + int strict_mime_boundary; 
> } MPJPEGDemuxContext; 
>  
>  
> @@ -245,6 +248,43 @@ static int parse_multipart_header(AVIOContext *pb, 
> } 
>  
>  
> +static char* mpjpeg_get_boundary(AVIOContext* pb) 
> +{ 
> + uint8_t *mime_type = NULL; 
> + uint8_t *start; 
> + uint8_t *end; 
> + uint8_t *res = NULL; 
> + int len; 
> + 
> + /* get MIME type, and skip to the first parameter */ 
> + av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type); 
> + start = mime_type; 
> + while (start != NULL && *start != '\0') { 
> + start = strchr(start, ';'); 
> + if (start) 
> + start = start+1; 
> + 
> + while (av_isspace(*start)) 
> + start++; 
> + 
> + if (!av_strncasecmp(start, "boundary=", 9)) { 
> + start += 9; 
> + 
> + end = strchr(start, ';'); 
> + if (end) 
> + len = end - start - 1; 
> + else 
> + len = strlen(start); 
> + res = av_strndup(start, len); 
> + break; 
> + } 
> + } 
> + 
> + av_freep(&mime_type); 
> + return res; 
> +} 
> + 
> + 
> static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) 
> { 
> int size; 
> @@ -252,8 +292,18 @@ static int mpjpeg_read_packet(AVFormatContext *s, 
> AVPacket *pkt) 
>  
> MPJPEGDemuxContext *mpjpeg = s->priv_data; 
> if (mpjpeg->boundary == NULL) { 
> - mpjpeg->boundary = av_strdup("--"); 
> - mpjpeg->searchstr = av_strdup("\r\n--"); 
> + uint8_t* boundary = NULL; 
> + if (mpjpeg->strict_mime_boundary) { 
> + boundary = mpjpeg_get_boundary(s->pb); 
> + } 
> + if (boundary != NULL) { 
> + mpjpeg->boundary = boundary; 
> + mpjpeg->searchstr = av_malloc(4+strlen(boundary)+1); 

> + sprintf( mpjpeg->searchstr, "\r\n%s\r\n", boundary ); 

please use snprintf() 


> + } else { 
> + mpjpeg->boundary = av_strdup("--"); 
> + mpjpeg->searchstr = av_strdup("\r\n--"); 
> + } 
> mpjpeg->searchstr_len = strlen(mpjpeg->searchstr); 
> if (!mpjpeg->boundary || !mpjpeg->searchstr) { 
> av_freep(&mpjpeg->boundary); 
> @@ -315,6 +365,22 @@ static int mpjpeg_read_packet(AVFormatContext *s, 
> AVPacket *pkt) 
> return ret; 
> } 
>  
> +#define OFFSET(x) offsetof(MPJPEGDemuxContext, x) 
> + 
> +#define DEC AV_OPT_FLAG_DECODING_PARAM 
> +const AVOption mpjpeg_options[] = { 
> + { "strict_mime_boundary", "require MIME boundaries match", 
> OFFSET(strict_mime_boundary), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC }, 
> + { NULL } 
> +}; 
> + 
> + 

> +static const AVClass ff_mpjpeg_demuxer_class = { 

there should be no ff_ as its static 


> + .class_name = "MPJPEG demuxer", 
> + .item_name = av_default_item_name, 
> + .option = mpjpeg_options, 
> + .version = LIBAVUTIL_VERSION_INT, 
> +}; 
> + 
> AVInputFormat ff_mpjpeg_demuxer = { 
> .name = "mpjpeg", 
> .long_name = NULL_IF_CONFIG_SMALL("MIME multipart JPEG"), 
> @@ -324,5 +390,8 @@ AVInputFormat ff_mpjpeg_demuxer = { 
> .read_probe = mpjpeg_read_probe, 
> .read_header = mpjpeg_read_header, 
> .read_packet = mpjpeg_read_packet, 
> - .read_close = mpjpeg_read_close 
> + .read_close = mpjpeg_read_close, 
> + .priv_class = &ff_mpjpeg_demuxer_class 
> }; 
> + 
> + 
> -- 
> 2.4.9 (Apple Git-60) 
> 

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


-- 
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. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Please find the patches attached. First one is unc

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

2015-11-25 Thread Paul B Mahol
Patch attached.
From db6a900bbe6a20afc44d3bc7b5416a2093d0c95f Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Wed, 25 Nov 2015 11:36:45 +0100
Subject: [PATCH] avfilter: add audio compressor filter

Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  72 +
 libavfilter/Makefile   |   1 +
 libavfilter/af_sidechaincompress.c | 157 ++---
 libavfilter/allfilters.c   |   1 +
 4 files changed, 202 insertions(+), 29 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index eedd02f..7b3773e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -318,6 +318,78 @@ build.
 
 Below is a description of the currently available audio filters.
 
+@section acompressor
+
+A compressor is mainly used to reduce the dynamic of a signal.
+Especially modern music is mostly compressed at a high ratio to
+improve the overall loudness. It's done to get the highest attention
+of a listener, "fatten" the sound and bring more "power" to the track.
+If a signal is compressed too much it may sound dull or "dead"
+afterwards or it may start to "pump" (which could be a powerful effect
+but can also destroy a track completely).
+The right compression is the key to reach a professional sound and is
+the high art of mixing and mastering. Because of it's complex settings
+it may take a long time to get the right feeling for this kind of effect.
+
+Compression is done by detecting the volume above a chosen level
+@code{threshold} and divide it by the factor set with @code{ratio}.
+So if you set the threshold to -12dB and your signal reaches -6dB a ratio
+of 2:1 will result in a signal at -9dB. Because an exact manipulation of
+the signal would cause distrotion of the waveform the reduction can be
+levelled over the time. This is done by setting "Attack" and "Release".
+@code{attack} determines how long the signal has to rise above the threshold
+before any reduction will occur and @code{release} sets the time the signal
+has to fall below the threshold to reduce the reduction again. Shorter signals
+than the chosen attack time will be left untouched.
+The overall reduction of the signal can be made up afterwards with the
+@code{makeup} setting. So compressing the peaks of a signal about 6dB and
+rising the makeup to this level results in a signal two times louder than the
+source. To gain a softer entry in the compression the @code{knee} flattens the
+hard edge at the threshold in the range of the chosen decibels.
+
+The filter accepts the following options:
+
+@table @option
+@item threshold
+If a signal of second stream raises above this level it will affect the gain
+reduction of first stream.
+By default is 0.125. Range is between 0.00097563 and 1.
+
+@item ratio
+Set a ratio about which the signal is reduced. 1:2 means that if the level
+raised 4dB above the threshold, it will be only 2dB above after the reduction.
+Default is 2. Range is between 1 and 20.
+
+@item attack
+Amount of milliseconds the signal has to rise above the threshold before gain
+reduction starts. Default is 20. Range is between 0.01 and 2000.
+
+@item release
+Amount of milliseconds the signal has to fall below the threshold before
+reduction is decreased again. Default is 250. Range is between 0.01 and 9000.
+
+@item makeup
+Set the amount by how much signal will be amplified after processing.
+Default is 2. Range is from 1 and 64.
+
+@item knee
+Curve the sharp knee around the threshold to enter gain reduction more softly.
+Default is 2.82843. Range is between 1 and 8.
+
+@item link
+Choose if the @code{average} level between all channels of input stream
+or the louder(@code{maximum}) channel of input stream affects the
+reduction. Default is @code{average}.
+
+@item detection
+Should the exact signal be taken in case of @code{peak} or an RMS one in case
+of @code{rms}. Default is @code{rms} which is mainly smoother.
+
+@item mix
+How much to use compressed signal in output. Default is 1.
+Range is between 0 and 1.
+@end table
+
 @section acrossfade
 
 Apply cross fade from one input audio stream to another input audio stream.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index c896374..e31bdaa 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -23,6 +23,7 @@ OBJS = allfilters.o \
transform.o  \
video.o  \
 
+OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
 OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
 OBJS-$(CONFIG_ADELAY_FILTER) += af_adelay.o
 OBJS-$(CONFIG_AECHO_FILTER)  += af_aecho.o
diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c
index 25f3fd1..1dce1c0 100644
--- a/libavfilter/af_sidechaincompress.c
+++ b/libavfilter/af_sidechaincompress.c
@@ -21,7 +21,7 @@
 

Re: [FFmpeg-devel] [PATCH] avfilter: add compensationdelay filter

2015-11-25 Thread Moritz Barsnick
On Wed, Nov 25, 2015 at 09:48:36 +0100, Paul B Mahol wrote:
> Patch attached.

> +For example, you have recorded guitar with two microphones placed in
> +different location. Because the front of sound wave has fixed speed in
> +normal conditions, the phasing of microphones can vary and depends on
> +their location and interposition. The best sound mix you will get when
> +these microphones are in phase (synchronized). Note that distance of
> +~30 cm between microphones makes one microphone to capture signal in
> +antiphase to another microphone. That makes the final mix sounding moody.
> +This filter helps to solve phasing problems by adding different delays
> +to each microphone track and make them synchronized.

  For example, you have recorded a guitar with two microphones placed
  in different locations.

This part I don't actually understand (is the fixed speed really the
reason?), but I fixed the grammar anyway:

  Because the front of sound wave travels at fixed speed in normal
  conditions, the phasing of microphones can vary and depends on their
  location and interposition.

  The best sound mix can be achieved when these microphones are in
  phase (synchronized). Note that a difference of ~30 cm in the
  distances between source and microphones leads to one microphone
  capturing its signal in antiphase to the other.

  That makes the final mix sound moody. This filter helps to solve
  phasing problems by adding different delays to each microphone track
  and make them synchronized.

I'm not sure "synchronized" is the correct term though, but I'm no
expert.

Here, I might avoid the "you" form in favor of passive, but I guess
it's okay as it is:

  The best results can be achieved when you take one track as base and
  synchronize other tracks one by one with it.


> +@item mm
> +Set millimeters distance. This is compensation distance for fine tuning.
> +
> +@item cm
> +Set cm distance. This is compensation distance for tighten distance setup.

for tightening

> +@item m
> +Set meters distance. This is compensation distance for hard distance setup.
> +
> +@item dry
> +Set dry amount. Amount of unprocessed (dry) signal.
> +
> +@item wet
> +Set wet amount. Amount of processed (wet) signal.
> +
> +@item temp
> +Set temperature degree in Celzius. This is the temperature of the 
> environment.

Celsius

> +@end table

Would you like to document the defaults?

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


[FFmpeg-devel] [PATCH] fate: add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM tests

2015-11-25 Thread Matthieu Bouron
From: Matthieu Bouron 

---
 tests/api/Makefile  |   1 +
 tests/api/api-codec-param-test.c| 223 
 tests/fate/api.mak  |   8 ++
 tests/ref/fate/api-jpeg-codec-param |  12 ++
 tests/ref/fate/api-png-codec-param  |  12 ++
 5 files changed, 256 insertions(+)
 create mode 100644 tests/api/api-codec-param-test.c
 create mode 100644 tests/ref/fate/api-jpeg-codec-param
 create mode 100644 tests/ref/fate/api-png-codec-param

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 27f499f..c48c34a 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,6 +1,7 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
 APITESTPROGS-yes += api-seek
+APITESTPROGS-yes += api-codec-param
 APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
 APITESTPROGS += $(APITESTPROGS-yes)
 
diff --git a/tests/api/api-codec-param-test.c b/tests/api/api-codec-param-test.c
new file mode 100644
index 000..48aced9
--- /dev/null
+++ b/tests/api/api-codec-param-test.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2015 Matthieu Bouron 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, 
int decode)
+{
+int ret = 0;
+int got_frame = 0;
+AVFrame *frame = NULL;
+int skip_frame = codec_ctx->skip_frame;
+
+if (!avcodec_is_open(codec_ctx)) {
+const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
+
+ret = avcodec_open2(codec_ctx, codec, NULL);
+if (ret < 0) {
+av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");
+goto end;
+}
+}
+
+frame = av_frame_alloc();
+if (!frame) {
+av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");
+goto end;
+}
+
+if (!decode && codec_ctx->codec->caps_internal & 
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
+codec_ctx->skip_frame = AVDISCARD_ALL;
+}
+
+do {
+ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);
+av_assert0(decode || (!decode && !got_frame));
+if (ret < 0)
+break;
+pkt->data += ret;
+pkt->size -= ret;
+
+if (got_frame) {
+break;
+}
+} while (pkt->size > 0);
+
+end:
+codec_ctx->skip_frame = skip_frame;
+
+av_frame_free(&frame);
+return ret;
+}
+
+static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
+{
+int ret = 0;
+int i, done = 0;
+AVPacket pkt;
+
+av_init_packet(&pkt);
+
+while (!done) {
+AVCodecContext *codec_ctx = NULL;
+AVStream *st;
+
+if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {
+av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");
+goto end;
+}
+
+st = fmt_ctx->streams[pkt.stream_index];
+codec_ctx = st->codec;
+
+if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||
+st->codec_info_nb_frames++ > 0) {
+av_packet_unref(&pkt);
+continue;
+}
+
+ret = try_decode_video_frame(codec_ctx, &pkt, decode);
+if (ret < 0) {
+av_log(fmt_ctx, AV_LOG_ERROR, "Failed to decode video frame\n");
+goto end;
+}
+
+av_packet_unref(&pkt);
+
+/* check if all video streams have demuxed a packet */
+done = 1;
+for (i = 0; i < fmt_ctx->nb_streams; i++) {
+st = fmt_ctx->streams[i];
+codec_ctx = st->codec;
+
+if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO)
+continue;
+
+done &= st->codec_info_nb_frames > 0;
+}
+}
+
+end:
+av_packet_unref(&pkt);
+
+return ret < 0;
+}
+
+static void dump_video_streams(const AVFormatContext *fmt_ctx, int decode)
+{
+int i;
+
+fo

Re: [FFmpeg-devel] VS 2015 patch

2015-11-25 Thread Derek Buitenhuis
On 11/25/2015 12:05 AM, Bruce Dawson wrote:
> This would make ffmpeg fail on VS versions prior to VS 2013, for those
> using the BUILD.gn file, which I assume is not many. It would be easy to
> add additional conditionals for earlier versions, but if it's just for
> Chromium then 2013/2015 is sufficient.

If directed to the Chromium team, as noted elsewhere, I doubt this is an issue,
since they only ever support a single compiler for Windows, at once, as far
as I know.

- Derek

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


[FFmpeg-devel] [PATCH] avfilter/af_dynaudnorm: remove pow2

2015-11-25 Thread Ganesh Ajjanagadde
pow2 is being used for trivial squaring. Its name is not good: is this
2^x or x^2? In any case, using x * x is IMHO more readable in this
context.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavfilter/af_dynaudnorm.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 5f412f5..72e3ce8 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -309,11 +309,6 @@ static inline double fade(double prev, double next, int 
pos,
 return fade_factors[0][pos] * prev + fade_factors[1][pos] * next;
 }
 
-static inline double pow2(const double value)
-{
-return value * value;
-}
-
 static inline double bound(const double threshold, const double val)
 {
 const double CONST = 
0.8862269254527580136490837416705725913987747280611935; //sqrt(PI) / 2.0
@@ -352,7 +347,7 @@ static double compute_frame_rms(AVFrame *frame, int channel)
 const double *data_ptr = (double *)frame->extended_data[c];
 
 for (i = 0; i < frame->nb_samples; i++) {
-rms_value += pow2(data_ptr[i]);
+rms_value += data_ptr[i] * data_ptr[i];
 }
 }
 
@@ -360,7 +355,7 @@ static double compute_frame_rms(AVFrame *frame, int channel)
 } else {
 const double *data_ptr = (double *)frame->extended_data[channel];
 for (i = 0; i < frame->nb_samples; i++) {
-rms_value += pow2(data_ptr[i]);
+rms_value += data_ptr[i] * data_ptr[i];
 }
 
 rms_value /= frame->nb_samples;
@@ -503,7 +498,7 @@ static double 
compute_frame_std_dev(DynamicAudioNormalizerContext *s,
 const double *data_ptr = (double *)frame->extended_data[c];
 
 for (i = 0; i < frame->nb_samples; i++) {
-variance += pow2(data_ptr[i]);  // Assume that MEAN is *zero*
+variance += data_ptr[i] * data_ptr[i];  // Assume that MEAN is 
*zero*
 }
 }
 variance /= (s->channels * frame->nb_samples) - 1;
@@ -511,7 +506,7 @@ static double 
compute_frame_std_dev(DynamicAudioNormalizerContext *s,
 const double *data_ptr = (double *)frame->extended_data[channel];
 
 for (i = 0; i < frame->nb_samples; i++) {
-variance += pow2(data_ptr[i]);  // Assume that MEAN is *zero*
+variance += data_ptr[i] * data_ptr[i];  // Assume that MEAN is 
*zero*
 }
 variance /= frame->nb_samples - 1;
 }
-- 
2.6.2

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


Re: [FFmpeg-devel] [PATCHv2] avutil/lls: speed up performance of solve_lls

2015-11-25 Thread Michael Niedermayer
On Tue, Nov 24, 2015 at 10:13:22PM -0500, Ganesh Ajjanagadde wrote:
> This is a trivial rewrite of the loops that results in better
> prefetching and associated cache efficiency. Essentially, the problem is
> that modern prefetching logic is based on finite state Markov memory, a 
> reasonable
> assumption that is used elsewhere in CPU's in for instance branch
> predictors.
> 
> Surrounding loops all iterate forward through the array, making the
> predictor think of prefetching in the forward direction, but the
> intermediate loop is unnecessarily in the backward direction.
> 
> Speedup is nontrivial. Benchmarks obtained by 10^6 iterations within
> solve_lls, with START/STOP_TIMER. File is 
> tests/data/fate/flac-16-lpc-cholesky.err.
> Hardware: x86-64, Haswell, GNU/Linux.
> 
> new:
>   17291 decicycles in solve_lls, 2096706 runs,446 skips
>   17255 decicycles in solve_lls, 4193657 runs,647 skips
>   17231 decicycles in solve_lls, 8384997 runs,   3611 skips
>   17189 decicycles in solve_lls,16771010 runs,   6206 skips
>   17132 decicycles in solve_lls,33544757 runs,   9675 skips
>   17092 decicycles in solve_lls,67092404 runs,  16460 skips
>   17058 decicycles in solve_lls,134188213 runs,  29515 skips
> 
> old:
>   18009 decicycles in solve_lls, 2096665 runs,487 skips
>   17805 decicycles in solve_lls, 4193320 runs,984 skips
>   17779 decicycles in solve_lls, 8386855 runs,   1753 skips
>   18289 decicycles in solve_lls,16774280 runs,   2936 skips
>   18158 decicycles in solve_lls,33548104 runs,   6328 skips
>   18420 decicycles in solve_lls,67091793 runs,  17071 skips
>   18310 decicycles in solve_lls,134187219 runs,  30509 skips
> 
> Reviewed-by: Michael Niedermayer 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/lls.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

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] VS 2015 patch

2015-11-25 Thread Hendrik Leppkes
On Wed, Nov 25, 2015 at 1:38 AM, Bruce Dawson  wrote:
> Yes - the modifications to BUILD.gn seem to all be done by Google/Chromium
> engineers.
>
> When Chromium pulls in a third party dependency they sometimes but the
> build files just outside of the copy of the third party repo, and this time
> the build files got checked in to the upstream repo. I'm not sure why -
> perhaps there were other gn based projects using ffmpeg.
>

BUILD.gn does not even exist in ffmpeg, so its something Chromium
invented in their local fork of ffmpeg.
You should direct the patch there.

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


[FFmpeg-devel] [PATCH] Makefile: add cleanup of pkg-config files created by configure to distclean

2015-11-25 Thread Tobias Rapp
When creating a fresh working copy I noticed that the 
"doc/examples/pc-uninstalled" folder which is created by ./configure is 
not cleaned up when running "make distclean".


Attached patch adds the removal of "doc/examples/pc-uninstalled" folder 
to "make distclean".


Regards,
Tobias
>From 166a9ca8c6e446d4430eb26691d4e23810855dc7 Mon Sep 17 00:00:00 2001
From: Tobias Rapp 
Date: Wed, 25 Nov 2015 11:47:14 +0100
Subject: [PATCH] Makefile: add cleanup of pkg-config files created by
 configure to distclean

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 306f060..58f1a3a 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,7 @@ clean::
 distclean::
 	$(RM) $(DISTCLEANSUFFIXES)
 	$(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h
+	$(RM) -rf doc/examples/pc-uninstalled
 
 config:
 	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 1/5] avcodec: use AV_OPT_TYPE_BOOL in a bunch of places

2015-11-25 Thread Clément Bœsch
On Sat, Nov 21, 2015 at 10:17:50PM +0100, Clément Bœsch wrote:
> From: Clément Bœsch 
> 
> ---
>  libavcodec/ac3dec_fixed.c |  2 +-
>  libavcodec/ac3dec_float.c |  2 +-
>  libavcodec/ac3enc_opts_template.c |  4 ++--
>  libavcodec/alac.c |  2 +-
>  libavcodec/cinepakenc.c   |  2 +-
>  libavcodec/dcadec.c   |  4 ++--
>  libavcodec/dnxhdenc.c |  2 +-
>  libavcodec/dvbsubdec.c|  4 ++--
>  libavcodec/dvdsubdec.c|  2 +-
>  libavcodec/dvdsubenc.c|  2 +-
>  libavcodec/evrcdec.c  |  2 +-
>  libavcodec/ffv1enc.c  |  2 +-
>  libavcodec/fic.c  |  2 +-
>  libavcodec/flacdec.c  |  2 +-
>  libavcodec/flacenc.c  |  4 ++--
>  libavcodec/frwu.c |  2 +-
>  libavcodec/g723_1.c   |  2 +-
>  libavcodec/h264.c |  2 +-
>  libavcodec/hevc.c |  4 ++--
>  libavcodec/libvpxenc.c|  4 ++--
>  libavcodec/libx264.c  | 22 +++---
>  libavcodec/libxavs.c  |  8 
>  libavcodec/mjpegdec.c |  2 +-
>  libavcodec/mpeg12enc.c| 10 +-
>  libavcodec/mpeg4videodec.c|  4 ++--
>  libavcodec/mpeg4videoenc.c|  4 ++--
>  libavcodec/mpegvideo_enc.c| 12 ++--
>  libavcodec/rawdec.c   |  2 +-
>  libavcodec/snowenc.c  |  4 ++--
>  29 files changed, 60 insertions(+), 60 deletions(-)
> 

ping

I know this patchset is boring but it's relatively easy to review. I'll
push soon if I see no comment.

[...]

-- 
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] avfilter/af_dynaudnorm: remove wasteful pow

2015-11-25 Thread Paul B Mahol
On 11/25/15, Ganesh Ajjanagadde  wrote:
> This removes wasteful pow(x, 2.0) that although not terribly important
> for speed, is still useless.
>
> Signed-off-by: Ganesh Ajjanagadde 
> --
> Observed while auditing the codebase for wasteful pow calls.
>
> ---
>  libavfilter/af_dynaudnorm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
> index 62a2653..5f412f5 100644
> --- a/libavfilter/af_dynaudnorm.c
> +++ b/libavfilter/af_dynaudnorm.c
> @@ -237,13 +237,13 @@ static void
> init_gaussian_filter(DynamicAudioNormalizerContext *s)
>  // Pre-compute constants
>  const int offset = s->filter_size / 2;
>  const double c1 = 1.0 / (sigma * sqrt(2.0 * M_PI));
> -const double c2 = 2.0 * pow(sigma, 2.0);
> +const double c2 = 2.0 * sigma * sigma;
>
>  // Compute weights
>  for (i = 0; i < s->filter_size; i++) {
>  const int x = i - offset;
>
> -s->weights[i] = c1 * exp(-(pow(x, 2.0) / c2));
> +s->weights[i] = c1 * exp(-x * x / c2);
>  total_weight += s->weights[i];
>  }
>
> --
> 2.6.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH] avfilter/af_afade: improve accuracy and speed of gain computation

2015-11-25 Thread Paul B Mahol
On 11/25/15, Ganesh Ajjanagadde  wrote:
> Gain computation for various curves was being done in a needlessly
> inaccurate fashion. Of course these are all subjective curves, but when
> a curve is advertised to the user, it should be matched as closely as
> possible within the limitations of libm. In particular, the constants
> kept here were pretty inaccurate for double precision.
>
> Speed improvements are mainly due to the avoidance of pow, the most
> notorious of the libm functions in terms of performance. To be fair, it
> is the GNU libm that is among the worst, but it is not really GNU libm's
> fault
> since others simply yield a higher error as measured in ULP.
>
> "Magic" constants are also accordingly documented, since they take at
> least a minute of thought for a casual reader.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavfilter/af_afade.c | 20 
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c
> index ca9f2c4..c8b6ed8 100644
> --- a/libavfilter/af_afade.c
> +++ b/libavfilter/af_afade.c
> @@ -92,6 +92,7 @@ static int query_formats(AVFilterContext *ctx)
>
>  static double fade_gain(int curve, int64_t index, int range)
>  {
> +#define CUBE(a) ((a)*(a)*(a))
>  double gain;
>
>  gain = av_clipd(1.0 * index / range, 0, 1.0);
> @@ -101,22 +102,25 @@ static double fade_gain(int curve, int64_t index, int
> range)
>  gain = sin(gain * M_PI / 2.0);
>  break;
>  case IQSIN:
> -gain = 0.636943 * asin(gain);
> +/* 0.6... = 2 / M_PI */
> +gain = 0.6366197723675814 * asin(gain);
>  break;
>  case ESIN:
> -gain = 1.0 - cos(M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1));
> +gain = 1.0 - cos(M_PI / 4.0 * (CUBE(2.0*gain - 1) + 1));
>  break;
>  case HSIN:
>  gain = (1.0 - cos(gain * M_PI)) / 2.0;
>  break;
>  case IHSIN:
> -gain = 0.318471 * acos(1 - 2 * gain);
> +/* 0.3... = 1 / M_PI */
> +gain = 0.3183098861837907 * acos(1 - 2 * gain);
>  break;
>  case EXP:
> -gain = pow(0.1, (1 - gain) * 5.0);
> +/* -11.5... = 5*ln(0.1) */
> +gain = exp(-11.512925464970227 * (1 - gain));
>  break;
>  case LOG:
> -gain = av_clipd(0.0868589 * log(10 * gain), 0, 1.0);
> +gain = av_clipd(1 + 0.2 * log10(gain), 0, 1.0);
>  break;
>  case PAR:
>  gain = 1 - sqrt(1 - gain);
> @@ -128,7 +132,7 @@ static double fade_gain(int curve, int64_t index, int
> range)
>  gain *= gain;
>  break;
>  case CUB:
> -gain = gain * gain * gain;
> +gain = CUBE(gain);
>  break;
>  case SQU:
>  gain = sqrt(gain);
> @@ -137,10 +141,10 @@ static double fade_gain(int curve, int64_t index, int
> range)
>  gain = cbrt(gain);
>  break;
>  case DESE:
> -gain = gain <= 0.5 ? pow(2 * gain, 1/3.) / 2: 1 - pow(2 * (1 -
> gain), 1/3.) / 2;
> +gain = gain <= 0.5 ? cbrt(2 * gain) / 2: 1 - cbrt(2 * (1 - gain)) /
> 2;
>  break;
>  case DESI:
> -gain = gain <= 0.5 ? pow(2 * gain, 3) / 2: 1 - pow(2 * (1 - gain),
> 3) / 2;
> +gain = gain <= 0.5 ? CUBE(2 * gain) / 2: 1 - CUBE(2 * (1 - gain)) /
> 2;
>  break;
>  }
>
> --
> 2.6.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH] avfilter: add compensationdelay filter

2015-11-25 Thread Paul B Mahol
Patch attached.
From bda6d56599de5b0e1359d3244222e31ff6790007 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Tue, 24 Nov 2015 11:14:36 +0100
Subject: [PATCH] avfilter: add compensation delay line filter

Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  42 
 libavfilter/Makefile   |   1 +
 libavfilter/af_compensationdelay.c | 198 +
 libavfilter/allfilters.c   |   1 +
 4 files changed, 242 insertions(+)
 create mode 100644 libavfilter/af_compensationdelay.c

diff --git a/doc/filters.texi b/doc/filters.texi
index f351390..d8b2fb5 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1628,6 +1628,48 @@ compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
 @end example
 @end itemize
 
+@section compensationdelay
+
+Compensation Delay Line is a metric based delay to compensate differing
+positions of microphones or speakers.
+
+For example, you have recorded guitar with two microphones placed in
+different location. Because the front of sound wave has fixed speed in
+normal conditions, the phasing of microphones can vary and depends on
+their location and interposition. The best sound mix you will get when
+these microphones are in phase (synchronized). Note that distance of
+~30 cm between microphones makes one microphone to capture signal in
+antiphase to another microphone. That makes the final mix sounding moody.
+This filter helps to solve phasing problems by adding different delays
+to each microphone track and make them synchronized.
+
+The best result can be reached when you take one track as base and
+synchronize other tracks one by one with it.
+Remember that synchronization/delay tolerance depends on sample rate, too.
+Higher sample rates will give more tolerance.
+
+It accepts the following parameters:
+
+@table @option
+@item mm
+Set millimeters distance. This is compensation distance for fine tuning.
+
+@item cm
+Set cm distance. This is compensation distance for tighten distance setup.
+
+@item m
+Set meters distance. This is compensation distance for hard distance setup.
+
+@item dry
+Set dry amount. Amount of unprocessed (dry) signal.
+
+@item wet
+Set wet amount. Amount of processed (wet) signal.
+
+@item temp
+Set temperature degree in Celzius. This is the temperature of the environment.
+@end table
+
 @section dcshift
 Apply a DC shift to the audio.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1f4abeb..c896374 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -64,6 +64,7 @@ OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o
 OBJS-$(CONFIG_CHANNELSPLIT_FILTER)   += af_channelsplit.o
 OBJS-$(CONFIG_CHORUS_FILTER) += af_chorus.o generate_wave_table.o
 OBJS-$(CONFIG_COMPAND_FILTER)+= af_compand.o
+OBJS-$(CONFIG_COMPENSATIONDELAY_FILTER)  += af_compensationdelay.o
 OBJS-$(CONFIG_DCSHIFT_FILTER)+= af_dcshift.o
 OBJS-$(CONFIG_DYNAUDNORM_FILTER) += af_dynaudnorm.o
 OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o
diff --git a/libavfilter/af_compensationdelay.c b/libavfilter/af_compensationdelay.c
new file mode 100644
index 000..17e8b63
--- /dev/null
+++ b/libavfilter/af_compensationdelay.c
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen, Vladimir Sadovnikov and others
+ * Copyright (c) 2015 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/opt.h"
+#include "libavutil/samplefmt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+
+typedef struct CompensationDelayContext {
+const AVClass *class;
+int distance_mm;
+int distance_cm;
+int distance_m;
+double dry, wet;
+int temp;
+
+unsigned delay;
+unsigned w_ptr;
+unsigned buf_size;
+AVFrame *delay_frame;
+} CompensationDelayContext;
+
+#define OFFSET(x) offsetof(CompensationDelayContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption compensationdelay_options[] = {
+{ "mm",   "set mm distance",OFFSET(distance_mm), AV_OPT_TYPE_INT,{.i64=0},   0,  10, A },
+{ "cm",   "set cm