Re: [FFmpeg-devel] [PATCH 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Moritz Barsnick
On Tue, Oct 06, 2015 at 22:52:28 -0400, Ganesh Ajjanagadde wrote:
> ping: the reason I persist in this is because (long-term) the only 2
> compilers where we can reasonably reach a near "warning is regression"
> state and benefit from it are clang and gcc.

BTW, are the "remaining" (meaning: more than from gcc) warnings emitted
by the Intel C(++) Compiler redundant or false? The icc configuration
should then probably silence them.

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


[FFmpeg-devel] [PATCH] avfilter/vf_w3fdif: add x86 SIMD

2015-10-07 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_w3fdif.c  | 139 +++
 libavfilter/w3fdif.h |  61 +++
 libavfilter/x86/Makefile |   2 +
 libavfilter/x86/vf_w3fdif.asm| 230 +++
 libavfilter/x86/vf_w3fdif_init.c |  56 ++
 5 files changed, 441 insertions(+), 47 deletions(-)
 create mode 100644 libavfilter/w3fdif.h
 create mode 100644 libavfilter/x86/vf_w3fdif.asm
 create mode 100644 libavfilter/x86/vf_w3fdif_init.c

diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index 5b105f1..265443a 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -29,20 +29,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
-
-typedef struct W3FDIFContext {
-const AVClass *class;
-int filter;   ///< 0 is simple, 1 is more complex
-int deint;///< which frames to deinterlace
-int linesize[4];  ///< bytes of pixel data per line for each plane
-int planeheight[4];   ///< height of each plane
-int field;///< which field are we on, 0 or 1
-int eof;
-int nb_planes;
-AVFrame *prev, *cur, *next;  ///< previous, current, next frames
-int32_t **work_line;  ///< lines we are calculating
-int nb_threads;
-} W3FDIFContext;
+#include "w3fdif.h"
 
 #define OFFSET(x) offsetof(W3FDIFContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
@@ -81,6 +68,78 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, fmts_list);
 }
 
+static void filter_simple_low(int32_t *work_line,
+  uint8_t *in_lines_cur[2],
+  const int32_t *coef, int linesize)
+{
+int i;
+
+for (i = 0; i < linesize; i++) {
+*work_line   += *in_lines_cur[0]++ * coef[0];
+*work_line++ += *in_lines_cur[1]++ * coef[1];
+}
+}
+
+static void filter_complex_low(int32_t *work_line,
+   uint8_t *in_lines_cur[4],
+   const int32_t *coef, int linesize)
+{
+int i;
+
+for (i = 0; i < linesize; i++) {
+*work_line   += *in_lines_cur[0]++ * coef[0];
+*work_line   += *in_lines_cur[1]++ * coef[1];
+*work_line   += *in_lines_cur[2]++ * coef[2];
+*work_line++ += *in_lines_cur[3]++ * coef[3];
+}
+}
+
+static void filter_simple_high(int32_t *work_line,
+   uint8_t *in_lines_cur[3],
+   uint8_t *in_lines_adj[3],
+   const int32_t *coef, int linesize)
+{
+int i;
+
+for (i = 0; i < linesize; i++) {
+*work_line   += *in_lines_cur[0]++ * coef[0];
+*work_line   += *in_lines_adj[0]++ * coef[0];
+*work_line   += *in_lines_cur[1]++ * coef[1];
+*work_line   += *in_lines_adj[1]++ * coef[1];
+*work_line   += *in_lines_cur[2]++ * coef[2];
+*work_line++ += *in_lines_adj[2]++ * coef[2];
+}
+}
+
+static void filter_complex_high(int32_t *work_line,
+uint8_t *in_lines_cur[5],
+uint8_t *in_lines_adj[5],
+const int32_t *coef, int linesize)
+{
+int i;
+
+for (i = 0; i < linesize; i++) {
+*work_line   += *in_lines_cur[0]++ * coef[0];
+*work_line   += *in_lines_adj[0]++ * coef[0];
+*work_line   += *in_lines_cur[1]++ * coef[1];
+*work_line   += *in_lines_adj[1]++ * coef[1];
+*work_line   += *in_lines_cur[2]++ * coef[2];
+*work_line   += *in_lines_adj[2]++ * coef[2];
+*work_line   += *in_lines_cur[3]++ * coef[3];
+*work_line   += *in_lines_adj[3]++ * coef[3];
+*work_line   += *in_lines_cur[4]++ * coef[4];
+*work_line++ += *in_lines_adj[4]++ * coef[4];
+}
+}
+
+static void filter_scale(uint8_t *out_pixel, const int32_t *work_pixel, int 
linesize)
+{
+int j;
+
+for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
+*out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 256) >> 16;
+}
+
 static int config_input(AVFilterLink *inlink)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -106,6 +165,15 @@ static int config_input(AVFilterLink *inlink)
 return AVERROR(ENOMEM);
 }
 
+s->filter_simple_low = filter_simple_low;
+s->filter_complex_low = filter_complex_low;
+s->filter_simple_high = filter_simple_high;
+s->filter_complex_high = filter_complex_high;
+s->filter_scale = filter_scale;
+
+if (ARCH_X86)
+ff_w3fdif_init_x86(s);
+
 return 0;
 }
 
@@ -163,7 +231,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_
 const int dst_line_stride = out->linesize[plane];
 const int start = (height * jobnr) / nb_jobs;
 const int end = (height * (jobnr+1)) / nb_jobs;
-int i, j, y_in, y_out;
+int j, y_in, y_out;
 
 /* copy 

Re: [FFmpeg-devel] [PATCHv2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 3:34 PM, Michael Niedermayer
 wrote:
> On Wed, Oct 07, 2015 at 12:29:35PM -0400, Ganesh Ajjanagadde wrote:
>> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
>> The concept of av_uninit is inherently useful though. This patch silences a
>> bunch of warnings on clang e.g
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
>> Furthermore, it should be useful for general usage of av_uninit in future.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavutil/attributes.h | 6 ++
>>  1 file changed, 6 insertions(+)
>
> breaks gcc
> ./configure
> make
> CC  libavdevice/alldevices.o
> In file included from ./libavutil/common.h:42:0,
>  from ./libavutil/avutil.h:288,
>  from ./libavutil/log.h:25,
>  from libavdevice/avdevice.h:46,
>  from libavdevice/alldevices.c:22:
> ./libavutil/attributes.h:150:42: error: missing binary operator before token 
> "("
> make: *** [libavdevice/alldevices.o] Error 1

Wow, this works with GCC 5.2 (tested on Arch) but not on your gcc, and
(just checked) does not work either on Debian GCC 4.9.
Anyway, it seems to me that for whatever reason short circuit
evaluation is not respected by the GCC preprocessor (I lack the energy
or interest to investigate why, it seems ridiculous to me):
https://bugs.webkit.org/show_bug.cgi?id=133785

Apologies for the repeated failed attempts, but I have taken a new
stab at it (tested on debian clang 3.0, arch clang 3.7, debian gcc
4.9, arch gcc 5.2).

>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Many that live deserve death. And some that die deserve life. Can you give
> it to them? Then do not be too eager to deal out death in judgement. For
> even the very wise cannot see all ends. -- Gandalf
>
> ___
> 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 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Moritz Barsnick
On Wed, Oct 07, 2015 at 17:47:44 -0400, Ganesh Ajjanagadde wrote:
> Since I am currently in the warning suppression business, I can help
> out at least in some basic checking. Unfortunately, I believe the icc
> is not freely licensed, which means I can't test this stuff.

I'll get in touch "when I get around to it".

BTW, IANAL and haven't read all the fine print recently, but here's
(possibly) the "free" option:
https://software.intel.com/en-us/qualify-for-free-software/opensourcecontributor

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


Re: [FFmpeg-devel] [PATCH 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Moritz Barsnick
On Wed, Oct 07, 2015 at 16:07:53 -0400, Ronald S. Bultje wrote:
> > BTW, are the "remaining" (meaning: more than from gcc) warnings emitted
> > by the Intel C(++) Compiler redundant or false? The icc configuration
> > should then probably silence them.
> 
> I doubt anyone has ever investigated them...

configure creates a quite explicit list of warning suppressions for icc
already. Somebody did investigate at one point. My icc is a bit old
(14.0.3.174 is the newest I have a license for), but I can take a stab
sometime, or ask here what the point of the warnings could be, if noone
minds.

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


Re: [FFmpeg-devel] [PATCH 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 5:35 PM, Moritz Barsnick  wrote:
> On Wed, Oct 07, 2015 at 16:07:53 -0400, Ronald S. Bultje wrote:
>> > BTW, are the "remaining" (meaning: more than from gcc) warnings emitted
>> > by the Intel C(++) Compiler redundant or false? The icc configuration
>> > should then probably silence them.
>>
>> I doubt anyone has ever investigated them...
>
> configure creates a quite explicit list of warning suppressions for icc
> already. Somebody did investigate at one point. My icc is a bit old
> (14.0.3.174 is the newest I have a license for), but I can take a stab
> sometime, or ask here what the point of the warnings could be, if noone
> minds.

Since I am currently in the warning suppression business, I can help
out at least in some basic checking. Unfortunately, I believe the icc
is not freely licensed, which means I can't test this stuff.

>
> Thanks,
> 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/vf_w3fdif: add x86 SIMD

2015-10-07 Thread James Almer
On 10/7/2015 5:27 PM, Paul B Mahol wrote:
> +cglobal w3fdif_simple_high, 5, 10, 8, 0, work_line, in_lines_cur0, 
> in_lines_adj0, coef, linesize
[...]
> +cglobal w3fdif_complex_high, 5, 14, 8, 0, work_line, in_lines_cur0, 
> in_lines_adj0, coef, linesize

All the values in coeff_hf fit in words, so you should be able to get
these two functions working with pmaddwd instead of pmulld.
It will be faster and will also work on older CPUs.

You can probably also replace the pshufb with some punpk* instructions,
since (unless i'm reading this wrong) you're just doing a zero extend,
and effectively get these functions down to sse2.
If pshufb is measurably faster, then you can keep both sse2 and ssse3
versions and let the init code choose the best at runtime.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] dnxhddec: better support for 4:4:4

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 08:08:39PM +0200, Christophe Gisquet wrote:
> 2015-10-07 10:32 GMT+02:00 Christophe Gisquet :
> >> this would allow ctx->bit_depth to be set but without initializing the
> >> dsp contexts
> >> subsequent runs would also skip init due to
> >> " if (ctx->bit_depth != old_bit_depth) {"
> >
> > Actually, other changes could trigger the issue, like
> > 4:2:2 10 bits -> 4:4:4 8 bits (unknown, unsupported) -> 4:2:2 8 bits.
> >
> > Setting ctx->bit_depth should probably be delayed to when the idcts are set.
> 
> Here's an updated patch.
> 
> -- 
> Christophe

>  dnxhddec.c |  109 
> ++---
>  1 file changed, 76 insertions(+), 33 deletions(-)
> e4c57c9185aa008518f0a72947534785ec20823e  
> 0001-dnxhddec-better-support-for-4-4-4.patch
> From 9dbddfc7981312e1221c86e6399f716e6c3df972 Mon Sep 17 00:00:00 2001
> From: Christophe Gisquet 
> Date: Sun, 4 Oct 2015 10:06:28 +0200
> Subject: [PATCH 1/3] dnxhddec: better support for 4:4:4
> 
> Profiles 1256 & 1270 (currently) signal at the frame header and MB
> levels the colorspace used, either RGB or YUV. While a MB-level
> varying colorspace is not supported, whether it is constant can be
> tracked so as to determine the exact colorspace.
> 
> This requires having bitdepth and the ACT and 4:4:4 flags, in turn
> needing the CID. Because setting those before having validated
> enough things may result in invalid/unset DSP fucntions, setting
> the bitdepth in the context is delayed.
> 
> It is not tested against a true RGB sequence, though.
> ---
>  libavcodec/dnxhddec.c | 109 
> +++---
>  1 file changed, 76 insertions(+), 33 deletions(-)

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- 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 2/3] dnxhddata: introduce and use MBAFF flag

2015-10-07 Thread Michael Niedermayer
On Mon, Oct 05, 2015 at 08:44:45PM +0200, Christophe Gisquet wrote:
> MBAFF-like handling of interlaced content in CID 1260 is different from
> the other CIDs, and in particular doesn't use the same syntax.
> ---
>  libavcodec/dnxhddata.c | 2 +-
>  libavcodec/dnxhddata.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)

applied

thanks

[...]
-- 
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


[FFmpeg-devel] [PATCH] vp9: add 10/12bpp sse2 SIMD versions of iadst8x8.

2015-10-07 Thread Ronald S. Bultje
---
 libavcodec/x86/vp9dsp_init_16bpp_template.c |   4 +-
 libavcodec/x86/vp9itxfm_16bpp.asm   | 211 ++--
 2 files changed, 202 insertions(+), 13 deletions(-)

diff --git a/libavcodec/x86/vp9dsp_init_16bpp_template.c 
b/libavcodec/x86/vp9dsp_init_16bpp_template.c
index 6c8b0b1..55649df 100644
--- a/libavcodec/x86/vp9dsp_init_16bpp_template.c
+++ b/libavcodec/x86/vp9dsp_init_16bpp_template.c
@@ -134,7 +134,7 @@ decl_itxfm_func(idct,  idct,  4, BPC, sse2);
 decl_itxfm_func(idct,  iadst, 4, BPC, sse2);
 decl_itxfm_func(iadst, idct,  4, BPC, sse2);
 decl_itxfm_func(iadst, iadst, 4, BPC, sse2);
-decl_itxfm_func(idct, idct, 8, BPC, sse2);
+decl_itxfm_funcs(8, BPC, sse2);
 #endif /* HAVE_YASM */
 
 av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
@@ -205,7 +205,7 @@ av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
 #else
 init_itx_funcs(TX_4X4, 4, 12, sse2);
 #endif
-init_itx_func(TX_8X8, DCT_DCT, idct, idct, 8, BPC, sse2);
+init_itx_funcs(TX_8X8, 8, BPC, sse2);
 }
 
 if (EXTERNAL_SSSE3(cpu_flags)) {
diff --git a/libavcodec/x86/vp9itxfm_16bpp.asm 
b/libavcodec/x86/vp9itxfm_16bpp.asm
index 3c66b8f..52389171 100644
--- a/libavcodec/x86/vp9itxfm_16bpp.asm
+++ b/libavcodec/x86/vp9itxfm_16bpp.asm
@@ -29,6 +29,8 @@ cextern pw_8
 cextern pw_1023
 cextern pw_2048
 cextern pw_4095
+cextern pw_m1
+cextern pd_1
 cextern pd_16
 cextern pd_8192
 
@@ -57,6 +59,17 @@ pw_m16069_3196: times 4 dw -16069, 3196
 pw_13623_9102: times 4 dw 13623, 9102
 pw_m9102_13623: times 4 dw -9102, 13623
 
+pw_1606_16305: times 4 dw 1606, 16305
+pw_m16305_1606: times 4 dw -16305, 1606
+pw_12665_10394: times 4 dw 12665, 10394
+pw_m10394_12665: times 4 dw -10394, 12665
+pw_7723_14449: times 4 dw 7723, 14449
+pw_m14449_7723: times 4 dw -14449, 7723
+pw_15679_4756: times 4 dw 15679, 4756
+pw_m4756_15679: times 4 dw -4756, 15679
+pw_15137_6270: times 4 dw 15137, 6270
+pw_m6270_15137: times 4 dw -6270, 15137
+
 SECTION .text
 
 %macro VP9_STORE_2X 6-7 dstq ; reg1, reg2, tmp1, tmp2, min, max, dst
@@ -523,7 +536,7 @@ IADST4_12BPP_FN iadst, IADST4, idct,  IDCT4
 IADST4_12BPP_FN iadst, IADST4, iadst, IADST4
 
 ; the following line has not been executed at the end of this macro:
-; UNSCRATCH7, 8, rsp+17*mmsize
+; UNSCRATCH6, 8, rsp+17*mmsize
 %macro IDCT8_1D 1 ; src
 movam0, [%1+ 0*mmsize]
 movam2, [%1+ 4*mmsize]
@@ -545,9 +558,9 @@ IADST4_12BPP_FN iadst, IADST4, iadst, IADST4
 SUMSUB_BA d, 1, 2, 4; m1=out1, m2=out6
 UNSCRATCH4, 8, rsp+17*mmsize
 UNSCRATCH6, 9, rsp+18*mmsize
-SCRATCH  0, 8, rsp+17*mmsize
-SUMSUB_BA d, 7, 4, 0; m7=out2, m4=out5
-SUMSUB_BA d, 3, 6, 0; m3=out3, m6=out4
+SCRATCH  2, 8, rsp+17*mmsize
+SUMSUB_BA d, 7, 4, 2; m7=out2, m4=out5
+SUMSUB_BA d, 3, 6, 2; m3=out3, m6=out4
 SWAP 0, 5, 4, 6, 2, 7
 %endmacro
 
@@ -627,12 +640,12 @@ cglobal vp9_idct_idct_8x8_add_10, 4, 6 + ARCH_X86_64, 10, 
\
 .loop_1:
 IDCT8_1Dblockq
 
-TRANSPOSE4x4D0, 1, 2, 3, 7
+TRANSPOSE4x4D0, 1, 2, 3, 6
 mova  [ptrq+ 0*mmsize], m0
 mova  [ptrq+ 2*mmsize], m1
 mova  [ptrq+ 4*mmsize], m2
 mova  [ptrq+ 6*mmsize], m3
-UNSCRATCH7, 8, rsp+17*mmsize
+UNSCRATCH6, 8, rsp+17*mmsize
 TRANSPOSE4x4D4, 5, 6, 7, 0
 mova  [ptrq+ 1*mmsize], m4
 mova  [ptrq+ 3*mmsize], m5
@@ -648,12 +661,12 @@ cglobal vp9_idct_idct_8x8_add_10, 4, 6 + ARCH_X86_64, 10, 
\
 .loop_2:
 IDCT8_1D  ptrq
 
-pxorm7, m7
+pxorm6, m6
 PRELOAD  9, rsp+16*mmsize, max
-ROUND_AND_STORE_4x4  0, 1, 2, 3, m7, reg_max, [pd_16], 5
+ROUND_AND_STORE_4x4  0, 1, 2, 3, m6, reg_max, [pd_16], 5
 lea   dstq, [dstq+strideq*4]
 UNSCRATCH0, 8, rsp+17*mmsize
-ROUND_AND_STORE_4x4  4, 5, 6, 0, m7, reg_max, [pd_16], 5
+ROUND_AND_STORE_4x4  4, 5, 0, 7, m6, reg_max, [pd_16], 5
 add   ptrq, 16
 %if ARCH_X86_64
 lea   dstq, [dstbakq+8]
@@ -664,8 +677,8 @@ cglobal vp9_idct_idct_8x8_add_10, 4, 6 + ARCH_X86_64, 10, \
 dec   cntd
 jg .loop_2
 
-; m7 is still zero
-ZERO_BLOCK blockq-2*mmsize, 32, 8, m7
+; m6 is still zero
+ZERO_BLOCK blockq-2*mmsize, 32, 8, m6
 RET
 
 INIT_XMM sse2
@@ -721,3 +734,179 @@ cglobal vp9_idct_idct_8x8_add_12, 4, 6 + ARCH_X86_64, 10, 
\
 dec   cntd
 jg .loop_dc
 RET
+
+; inputs and outputs are dwords, coefficients are words
+;
+; dst1[hi]:dst3[lo] = src1 * coef1 + src2 * coef2
+; dst2[hi]:dst4[lo] = src1 * coef2 - src2 * coef1
+%macro SUMSUB_MUL_D 6 ; src/dst 1-2, dst3-4, coef1-2
+pand   m%3, m%1, [pd_3fff]
+pand  

Re: [FFmpeg-devel] [PATCH 3/3 v3] h264: Run VLC init under pthread_once

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 12:28:51PM -0400, Derek Buitenhuis wrote:
> This makes the h.264 decoder threadsafe to initialize.

can you explain why it is not threadsafe currently ?
(assuming "done = 1" would be moved to the end of
ff_h264_decode_init_vlc())

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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


[FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
The concept of av_uninit is inherently useful though. This patch silences a
bunch of warnings on clang e.g
http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
Furthermore, it should be useful for general usage of av_uninit in future.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavutil/attributes.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index 5c6b9de..ceb9e29 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -147,6 +147,14 @@
 
 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
 #define av_uninit(x) x=x
+#elif defined(__clang__)
+#if __has_warning("-Wuninitialized")
+#define av_uninit(x) \
+_Pragma("clang diagnostic push") \
+_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
+x=x \
+_Pragma("clang diagnostic pop")
+#endif
 #else
 #define av_uninit(x) x
 #endif
-- 
2.6.1

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


Re: [FFmpeg-devel] [PATCH 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ronald S. Bultje
Hi,

On Wed, Oct 7, 2015 at 3:46 PM, Moritz Barsnick  wrote:

> On Tue, Oct 06, 2015 at 22:52:28 -0400, Ganesh Ajjanagadde wrote:
> > ping: the reason I persist in this is because (long-term) the only 2
> > compilers where we can reasonably reach a near "warning is regression"
> > state and benefit from it are clang and gcc.
>
> BTW, are the "remaining" (meaning: more than from gcc) warnings emitted
> by the Intel C(++) Compiler redundant or false? The icc configuration
> should then probably silence them.


I doubt anyone has ever investigated them...

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


Re: [FFmpeg-devel] [PATCH 3/3 v3] h264: Run VLC init under pthread_once

2015-10-07 Thread Hendrik Leppkes
On Wed, Oct 7, 2015 at 10:18 PM, Michael Niedermayer
 wrote:
> On Wed, Oct 07, 2015 at 12:28:51PM -0400, Derek Buitenhuis wrote:
>> This makes the h.264 decoder threadsafe to initialize.
>
> can you explain why it is not threadsafe currently ?
> (assuming "done = 1" would be moved to the end of
> ff_h264_decode_init_vlc())
>

Validating that a complex init function doesn't produce intermittently
incoherent states on all platforms (were reads/writes are not
necessarily atomic) is no easy feat. Global init should be protected
and only run once to avoid any and all unforseen issues.
Right now its protected by the lock in avcodec - but if we want to get
rid of that to avoid contention issues, we need new protection.

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


Re: [FFmpeg-devel] [PATCH 3/3] dnxhdenc: mark CID 1260 encoder experimental

2015-10-07 Thread Michael Niedermayer
On Mon, Oct 05, 2015 at 08:44:46PM +0200, Christophe Gisquet wrote:
> The MBAFF handling recently introduced on the decoder side shows that
> the encoder does not support it correctly. Therefore, make the related
> profile experimental.
> 
> Furthermore, current encoder logic treats it as unable to encode as
> progressive, which isn't the case.
> ---
>  libavcodec/dnxhddata.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
> index ffc8018..d8027b5 100644
> --- a/libavcodec/dnxhddata.c
> +++ b/libavcodec/dnxhddata.c
> @@ -1158,6 +1158,11 @@ int ff_dnxhd_find_cid(AVCodecContext *avctx, int 
> bit_depth)
>  if (cid->width == avctx->width && cid->height == avctx->height &&
>  interlaced == !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) &&
>  !(cid->flags & DNXHD_444) && cid->bit_depth == bit_depth) {
> +if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
> +cid->flags & DNXHD_MBAFF) {
> +av_log(avctx, AV_LOG_WARNING, "Profile selected is 
> experimental");

added a \n (otherwise it gets prepended without whitespace)

applied

thanks

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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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


Re: [FFmpeg-devel] [PATCH 1/3] dnxhddec: better support for 4:4:4

2015-10-07 Thread Christophe Gisquet
Hi,

> this would allow ctx->bit_depth to be set but without initializing the
> dsp contexts
> subsequent runs would also skip init due to
> " if (ctx->bit_depth != old_bit_depth) {"

Actually, other changes could trigger the issue, like
4:2:2 10 bits -> 4:4:4 8 bits (unknown, unsupported) -> 4:2:2 8 bits.

Setting ctx->bit_depth should probably be delayed to when the idcts are set.

I will send later an updated patch including the above fix.
-- 
Christophe
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter/delogo: Set default band to 1

2015-10-07 Thread Jean Delvare
The original interpolation algorithm behaved poorly on the borders and
did not even guarantee continuity at the borders. For this reason, a
second interpolation/blending pass was required on the borders to make
them seamless.

However, since the interpolation algorithm was improved in June 2013,
the border issues no longer exist. The new algorithm does guarantee
continuity at the borders, making the second pass useless. A larger
band always increases the cumulated interpolation error. In most cases
it also increases the average interpolation error, even though the
samples in the band are only partially interpolated.

For this reason I would like to get rid of the "band" parameter. As a
first step, let's change its default value from 4 to 1 and document it
as deprecated.

I have benchmarked this change on a combination of input sources and
realistic logo areas. Lowering the band value from 4 to 1 resulted in
8 to 39 % less interpolation error per frame (or 1 to 34 % less
interpolation error per luma sample.)

Signed-off-by: Jean Delvare 
---
 doc/filters.texi|4 +++-
 libavfilter/vf_delogo.c |   11 +--
 2 files changed, 12 insertions(+), 3 deletions(-)

--- ffmpeg.orig/doc/filters.texi2015-10-02 11:41:24.035943770 +0200
+++ ffmpeg/doc/filters.texi 2015-10-02 12:02:08.231484828 +0200
@@ -4590,7 +4590,9 @@ specified.
 
 @item band, t
 Specify the thickness of the fuzzy edge of the rectangle (added to
-@var{w} and @var{h}). The default value is 4.
+@var{w} and @var{h}). The default value is 1. This option is
+deprecated, setting higher values should no longer be necessary and
+is not recommended.
 
 @item show
 When set to 1, a green rectangle is drawn on the screen to simplify
--- ffmpeg.orig/libavfilter/vf_delogo.c 2015-10-02 11:41:24.035943770 +0200
+++ ffmpeg/libavfilter/vf_delogo.c  2015-10-07 08:45:39.037203764 +0200
@@ -165,8 +165,9 @@ static const AVOption delogo_options[]=
 { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
-{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  4 },  1, INT_MAX, FLAGS },
-{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  4 },  1, INT_MAX, FLAGS },
+/* Actual default value for band/t is 1, set in init */
+{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
+{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
 { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
.i64 =  0 },  0, 1,   FLAGS },
 { NULL }
 };
@@ -201,6 +202,12 @@ static av_cold int init(AVFilterContext
 CHECK_UNSET_OPT(w);
 CHECK_UNSET_OPT(h);
 
+if (s->band == 0) { /* Unset, use default */
+av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed from 
4 to 1.\n");
+s->band = 1;
+} else if (s->band != 1) {
+av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
+}
 av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
s->x, s->y, s->w, s->h, s->band, s->show);
 


-- 
Jean Delvare
SUSE L3 Support
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 8:21 PM, Michael Niedermayer
 wrote:
> On Wed, Oct 07, 2015 at 06:22:08PM -0400, Ganesh Ajjanagadde wrote:
>> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
>> The concept of av_uninit is inherently useful though. This patch silences a
>> bunch of warnings on clang e.g
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
>> Furthermore, it should be useful for general usage of av_uninit in future.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavutil/attributes.h | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
>> index 5c6b9de..ceb9e29 100644
>> --- a/libavutil/attributes.h
>> +++ b/libavutil/attributes.h
>> @@ -147,6 +147,14 @@
>>
>>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>>  #define av_uninit(x) x=x
>> +#elif defined(__clang__)
>> +#if __has_warning("-Wuninitialized")
>> +#define av_uninit(x) \
>> +_Pragma("clang diagnostic push") \
>> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
>> +x=x \
>> +_Pragma("clang diagnostic pop")
>> +#endif
>
> this breaks
> make distclean ; ./configure --cc='ccache clang' && make -j12
> it does not break clang alone and clearing the ccache cache does not
> help
> ccache version 3.1.6
>
> In file included from libavfilter/af_aecho.c:1:
> libavfilter/af_aecho.c:226:315: error: expected identifier or '('
> static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t **delayptrs, 
> uint8_t * const *src, uint8_t **dst, int nb_samples, int channels) { const 
> double out_gain = ctx->out_gain; const double in_gain = ctx->in_gain; const 
> int nb_echoes = ctx->nb_echoes; const int max_samples = ctx->max_samples; int 
> i, j, chan,#pragma clang diagnostic push#pragma clang diagnostic ignored 
> "-Wuninitialized" index=index#pragma clang diagnostic pop; ((void)0); for 
> (chan = 0; chan < channels; chan++) { const double *s = (double *)src[chan]; 
> double *d = (double *)dst[chan]; double *dbuf = (double *)delayptrs[chan]; 
> index = ctx->delay_index; for (i = 0; i < nb_samples; i++, s++, d++) { double 
> out, in; in = *s; out = in * in_gain; for (j = 0; j < nb_echoes; j++) { int 
> ix = index + max_samples - ctx->samples[j]; ix = (((ix) >= (max_samples)) ? 
> (ix) - (max_samples) : (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= 
> out_gain; *d = av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index 
> + 1) >= (max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } } 
> ctx->delay_index = index; }
>   
>   
>   
>   
>   ^
>
> [...]

ccache and clang have some weird interaction issues -for instance a
lot of -Warray-bounds are triggered for glibc functions like strcmp. I
vaguely recall some suggestion to use an environment variable to avoid
the breakage:
http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html

Anyway, this sounds like it needs to be fixed upstream with clang or
ccache or possibly both.
I drop this patch as infeasible at the moment; may revisit if this is
sorted out upstream.

> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- Plato
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 3/3 v3] h264: Run VLC init under pthread_once

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 10:46:50PM +0200, Hendrik Leppkes wrote:
> On Wed, Oct 7, 2015 at 10:18 PM, Michael Niedermayer
>  wrote:
> > On Wed, Oct 07, 2015 at 12:28:51PM -0400, Derek Buitenhuis wrote:
> >> This makes the h.264 decoder threadsafe to initialize.
> >
> > can you explain why it is not threadsafe currently ?
> > (assuming "done = 1" would be moved to the end of
> > ff_h264_decode_init_vlc())
> >
> 

> Validating that a complex init function doesn't produce intermittently
> incoherent states on all platforms (were reads/writes are not
> necessarily atomic) is no easy feat. Global init should be protected
> and only run once to avoid any and all unforseen issues.
> Right now its protected by the lock in avcodec - but if we want to get
> rid of that to avoid contention issues, we need new protection.

Please put this text or something similar in the commit message

thanks


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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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


Re: [FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ronald S. Bultje
Hi,

On Wed, Oct 7, 2015 at 6:22 PM, Ganesh Ajjanagadde 
wrote:

> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless
> warnings.
> The concept of av_uninit is inherently useful though. This patch silences a
> bunch of warnings on clang e.g
>
> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7
> .
> Furthermore, it should be useful for general usage of av_uninit in future.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/attributes.h | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
> index 5c6b9de..ceb9e29 100644
> --- a/libavutil/attributes.h
> +++ b/libavutil/attributes.h
> @@ -147,6 +147,14 @@
>
>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>  #define av_uninit(x) x=x
> +#elif defined(__clang__)
> +#if __has_warning("-Wuninitialized")
> +#define av_uninit(x) \
> +_Pragma("clang diagnostic push") \
> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
> +x=x \
> +_Pragma("clang diagnostic pop")
> +#endif
>  #else
>  #define av_uninit(x) x
>  #endif


Doesn't this leave av_uninit undefined if has_warning is false but clang is
true?

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


Re: [FFmpeg-devel] [PATCH 3/3][RFC] avfilter/vf_chromakey: Add OpenCL acceleration

2015-10-07 Thread highgod0401

From: Timo Rothenpieler
Date: 2015-09-30 19:27
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH 3/3][RFC] avfilter/vf_chromakey: Add OpenCL 
acceleration
>> ping once again
>>
>> Hi
> Could you describe how to verify it, and how can I test it?
> 
> Thanks
> Best regards
> 

Using this sample: https://btbn.de/files/chromakey_sample.mp4

ffmpeg -f lavfi -i color=c=black:s=1280x720 -i chromakey_sample.mp4 -an
-c:v libx264 -preset veryfast -crf 18 -shortest -filter_complex
"[1:v]chromakey=0x70de77:0.1:0.2:0:1[ckout];[0:v][ckout]overlay[out]"
-map "[out]" -y output.mkv

The last parameter to the chromakey filter enables opencl acceleration.

Hi,

Could you please send the patch as attachments? I merge the code, but some 
compile errors occur.

Thanks
Best regards




___
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] [PATCH] fix b frame n_quant_offset for nvenc

2015-10-07 Thread Agatha Hu
---
 libavcodec/nvenc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 18bcd96..0e6ef43 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -742,8 +742,6 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
 switch (avctx->codec->id) {
 case AV_CODEC_ID_H264:
 ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 
avctx->gop_size;
-
ctx->encode_config.encodeCodecConfig.h264Config.hierarchicalPFrames = 1;
-
ctx->encode_config.encodeCodecConfig.h264Config.hierarchicalBFrames = 1;
 break;
 case AV_CODEC_ID_H265:
 ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 
avctx->gop_size;
@@ -843,9 +841,9 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
 
 if(avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
 ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p * 
fabs(avctx->i_quant_factor);
-ctx->encode_config.rcParams.initialRCQP.qpIntra += qp_inter_p * 
avctx->i_quant_offset;
+ctx->encode_config.rcParams.initialRCQP.qpIntra += 
avctx->i_quant_offset;
 ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p * 
fabs(avctx->b_quant_factor);
-ctx->encode_config.rcParams.initialRCQP.qpInterB += qp_inter_p * 
avctx->b_quant_offset;
+ctx->encode_config.rcParams.initialRCQP.qpInterB += 
avctx->b_quant_offset;
 } else {
 ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p;
 ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p;
-- 
1.9.5.github.0

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


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

2015-10-07 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 e31a2c6..b9cde79 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -682,47 +682,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,
-   _pkt.data, _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_free_packet(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(s, pkt, bsfc) < 0) {
+print_error("", ret);
+if (exit_on_error)
+exit_program(1);
 }
 
 if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
@@ -4052,7 +4015,6 @@ static int transcode(void)
 av_dict_free(>sws_dict);
 av_dict_free(>swr_opts);
 av_dict_free(>resample_opts);
-av_dict_free(>bsf_args);
 }
 }
 }
diff --git a/ffmpeg.h b/ffmpeg.h
index 6544e6f..9d4f15b 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -436,7 +436,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 ded7e2e..76dbf32 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1227,7 +1227,11 @@ static OutputStream *new_output_stream(OptionsContext 
*o, AVFormatContext *oc, e
 bsfc_prev->next = bsfc;
 else
 ost->bitstream_filters = bsfc;
-av_dict_set(>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.0

___
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-10-07 Thread Rodger Combs
---
 libavformat/avformat.h |  8 
 libavformat/utils.c| 19 +++
 2 files changed, 27 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f3c8260..20759e3 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2758,6 +2758,14 @@ int avformat_match_stream_specifier(AVFormatContext *s, 
AVStream *st,
 int avformat_queue_attached_pictures(AVFormatContext *s);
 
 /**
+ * Add a bitstream filter to a stream.
+ *
+ * @return  >0 on success;
+ *  AVERROR code on failure
+ */
+int av_add_bitstream_filter(AVStream *st, const char *name, const char *args);
+
+/**
  * Apply a list of bitstream filters to a packet.
  *
  * @return  >=0 on success;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d4f8f12..d233dfd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4597,6 +4597,25 @@ uint8_t *ff_stream_new_side_data(AVStream *st, enum 
AVPacketSideDataType type,
 return data;
 }
 
+int av_add_bitstream_filter(AVStream *st, const char *name, const char *args)
+{
+AVBitStreamFilterContext *bsfc = NULL;
+AVBitStreamFilterContext **dest = >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(AVFormatContext *s, AVPacket *pkt,
AVBitStreamFilterContext *bsfc)
 {
-- 
2.6.0

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


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

2015-10-07 Thread Rodger Combs
---
 libavformat/avformat.h |  8 
 libavformat/utils.c| 48 
 2 files changed, 56 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e2a27d4..5226b0a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2728,6 +2728,14 @@ 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.
+ *
+ * @return  >=0 on success;
+ *  AVERROR code on failure
+ */
+int av_apply_bitstream_filters(AVFormatContext *s, AVPacket *pkt,
+   AVBitStreamFilterContext *bsfc);
 
 /**
  * @}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 689473e..d4f8f12 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4596,3 +4596,51 @@ uint8_t *ff_stream_new_side_data(AVStream *st, enum 
AVPacketSideDataType type,
 sd->size = size;
 return data;
 }
+
+int av_apply_bitstream_filters(AVFormatContext *s, AVPacket *pkt,
+   AVBitStreamFilterContext *bsfc)
+{
+int ret = 0;
+AVStream *st = s->streams[pkt->stream_index];
+while (bsfc) {
+AVPacket new_pkt = *pkt;
+int a = av_bitstream_filter_filter(bsfc, st->codec, NULL,
+   _pkt.data, _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_free_packet(pkt);
+} else {
+a = AVERROR(ENOMEM);
+}
+}
+if (a < 0) {
+av_log(s, AV_LOG_ERROR, "Failed to open bitstream filter %s for 
stream %d with codec %s",
+   bsfc->filter->name, pkt->stream_index,
+   st->codec->codec ? st->codec->codec->name : "copy");
+ret = a;
+break;
+}
+*pkt = new_pkt;
+
+bsfc = bsfc->next;
+}
+return ret;
+}
-- 
2.6.0

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


Re: [FFmpeg-devel] [PATCH 0/9] Initial support for DNxHR, v2

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 08:11:21PM +0200, Christophe Gisquet wrote:
> 2015-10-05 14:03 GMT+02:00 Christophe Gisquet :
> > Hi,
> >
> > 2015-10-05 13:18 GMT+02:00 Michael Niedermayer :
> >> do you have any testcases you can share for these ?
> >
> > I was provided some but that I assume not redistributable. I asked the
> > same question but got no reply.
> >
> > There's this one sequence here that I assume to be redistributable:
> > https://trac.ffmpeg.org/ticket/4581
> > which is CID1270
> > but according to the little info here:
> > http://avid.force.com/pkb/articles/en_US/White_Paper/DNxHR-Codec-Bandwidth-Specifications
> > it might be out of specs (but we do support it), so not the best example.
> >
> > https://trac.ffmpeg.org/ticket/4876
> > might be interesting because it exposed a previously unsupported
> > feature (MBAFF like) in profile CID 1260. Not HR, but still useful.
> 
> So I have made a fate test on 1 frame for each sequence (total around 1.8MB).
> 
> Is it ok?

ok

thanks

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

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


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


Re: [FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 06:22:08PM -0400, Ganesh Ajjanagadde wrote:
> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
> The concept of av_uninit is inherently useful though. This patch silences a
> bunch of warnings on clang e.g
> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
> Furthermore, it should be useful for general usage of av_uninit in future.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/attributes.h | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
> index 5c6b9de..ceb9e29 100644
> --- a/libavutil/attributes.h
> +++ b/libavutil/attributes.h
> @@ -147,6 +147,14 @@
>  
>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>  #define av_uninit(x) x=x
> +#elif defined(__clang__)
> +#if __has_warning("-Wuninitialized")
> +#define av_uninit(x) \
> +_Pragma("clang diagnostic push") \
> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
> +x=x \
> +_Pragma("clang diagnostic pop")
> +#endif

this breaks
make distclean ; ./configure --cc='ccache clang' && make -j12
it does not break clang alone and clearing the ccache cache does not
help
ccache version 3.1.6

In file included from libavfilter/af_aecho.c:1:
libavfilter/af_aecho.c:226:315: error: expected identifier or '('
static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t **delayptrs, 
uint8_t * const *src, uint8_t **dst, int nb_samples, int channels) { const 
double out_gain = ctx->out_gain; const double in_gain = ctx->in_gain; const int 
nb_echoes = ctx->nb_echoes; const int max_samples = ctx->max_samples; int i, j, 
chan,#pragma clang diagnostic push#pragma clang diagnostic ignored 
"-Wuninitialized" index=index#pragma clang diagnostic pop; ((void)0); for (chan 
= 0; chan < channels; chan++) { const double *s = (double *)src[chan]; double 
*d = (double *)dst[chan]; double *dbuf = (double *)delayptrs[chan]; index = 
ctx->delay_index; for (i = 0; i < nb_samples; i++, s++, d++) { double out, in; 
in = *s; out = in * in_gain; for (j = 0; j < nb_echoes; j++) { int ix = index + 
max_samples - ctx->samples[j]; ix = (((ix) >= (max_samples)) ? (ix) - 
(max_samples) : (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= out_gain; *d = 
av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index + 1) >= 
(max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } } 
ctx->delay_index = index; }



  ^

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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


Re: [FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 8:44 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, Oct 7, 2015 at 6:22 PM, Ganesh Ajjanagadde 
> wrote:
>>
>> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless
>> warnings.
>> The concept of av_uninit is inherently useful though. This patch silences
>> a
>> bunch of warnings on clang e.g
>>
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
>> Furthermore, it should be useful for general usage of av_uninit in future.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavutil/attributes.h | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
>> index 5c6b9de..ceb9e29 100644
>> --- a/libavutil/attributes.h
>> +++ b/libavutil/attributes.h
>> @@ -147,6 +147,14 @@
>>
>>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) &&
>> !defined(__clang__)
>>  #define av_uninit(x) x=x
>> +#elif defined(__clang__)
>> +#if __has_warning("-Wuninitialized")
>> +#define av_uninit(x) \
>> +_Pragma("clang diagnostic push") \
>> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
>> +x=x \
>> +_Pragma("clang diagnostic pop")
>> +#endif
>>  #else
>>  #define av_uninit(x) x
>>  #endif
>
>
> Doesn't this leave av_uninit undefined if has_warning is false but clang is
> true?

Indeed you are right. Michael clarified that the issue is with the
ccache and clang interaction.
Consider this patch dropped; thanks all for the testing - at least we
now know where things need to be addressed.

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


[FFmpeg-devel] [PATCH] doc/faq: use https instead of http

2015-10-07 Thread Ganesh Ajjanagadde
Change to https for FFmpeg websites.

Signed-off-by: Ganesh Ajjanagadde 
---
 doc/faq.texi | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/doc/faq.texi b/doc/faq.texi
index 5fe716b..ef111c7 100644
--- a/doc/faq.texi
+++ b/doc/faq.texi
@@ -147,7 +147,7 @@ exec /usr/bin/pkg-config "$@@"
 
 Try a @code{make distclean} in the ffmpeg source directory before the build.
 If this does not help see
-(@url{http://ffmpeg.org/bugreports.html}).
+(@url{https://ffmpeg.org/bugreports.html}).
 
 @section How do I encode single pictures into movies?
 
@@ -311,18 +311,18 @@ invoking ffmpeg with several @option{-i} options.
 For audio, to put all channels together in a single stream (example: two
 mono streams into one stereo stream): this is sometimes called to
 @emph{merge} them, and can be done using the
-@url{http://ffmpeg.org/ffmpeg-filters.html#amerge, @code{amerge}} filter.
+@url{https://ffmpeg.org/ffmpeg-filters.html#amerge, @code{amerge}} filter.
 
 @item
 For audio, to play one on top of the other: this is called to @emph{mix}
 them, and can be done by first merging them into a single stream and then
-using the @url{http://ffmpeg.org/ffmpeg-filters.html#pan, @code{pan}} filter 
to mix
+using the @url{https://ffmpeg.org/ffmpeg-filters.html#pan, @code{pan}} filter 
to mix
 the channels at will.
 
 @item
 For video, to display both together, side by side or one on top of a part of
 the other; it can be done using the
-@url{http://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video 
filter.
+@url{https://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video 
filter.
 
 @end itemize
 
@@ -333,19 +333,19 @@ There are several solutions, depending on the exact 
circumstances.
 
 @subsection Concatenating using the concat @emph{filter}
 
-FFmpeg has a @url{http://ffmpeg.org/ffmpeg-filters.html#concat,
+FFmpeg has a @url{https://ffmpeg.org/ffmpeg-filters.html#concat,
 @code{concat}} filter designed specifically for that, with examples in the
 documentation. This operation is recommended if you need to re-encode.
 
 @subsection Concatenating using the concat @emph{demuxer}
 
-FFmpeg has a @url{http://www.ffmpeg.org/ffmpeg-formats.html#concat,
+FFmpeg has a @url{https://www.ffmpeg.org/ffmpeg-formats.html#concat,
 @code{concat}} demuxer which you can use when you want to avoid a re-encode and
 your format doesn't support file level concatenation.
 
 @subsection Concatenating using the concat @emph{protocol} (file level)
 
-FFmpeg has a @url{http://ffmpeg.org/ffmpeg-protocols.html#concat,
+FFmpeg has a @url{https://ffmpeg.org/ffmpeg-protocols.html#concat,
 @code{concat}} protocol designed specifically for that, with examples in the
 documentation.
 
@@ -485,7 +485,7 @@ scaling adjusts the SAR to keep the DAR constant.
 
 If you want to stretch, or “unstretch”, the image, you need to override the
 information with the
-@url{http://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or 
setsar filters}}.
+@url{https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar, @code{setdar 
or setsar filters}}.
 
 Do not forget to examine carefully the original video to check whether the
 stretching comes from the image or from the aspect ratio information.
@@ -589,7 +589,7 @@ see @file{libavformat/aviobuf.c} in FFmpeg and 
@file{libmpdemux/demux_lavf.c} in
 
 @section Where is the documentation about ffv1, msmpeg4, asv1, 4xm?
 
-see @url{http://www.ffmpeg.org/~michael/}
+see @url{https://www.ffmpeg.org/~michael/}
 
 @section How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?
 
-- 
2.6.1

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


[FFmpeg-devel] [PATCH 1/6] lavc: move bitstream filter args to the bsf ctx

2015-10-07 Thread Rodger Combs
---
 libavcodec/avcodec.h  | 1 +
 libavcodec/bitstream_filter.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ff70d25..ce42e57 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5026,6 +5026,7 @@ typedef struct AVBitStreamFilterContext {
 struct AVBitStreamFilter *filter;
 AVCodecParserContext *parser;
 struct AVBitStreamFilterContext *next;
+char *args;
 } AVBitStreamFilterContext;
 
 
diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c
index a4e437d..fb690b6 100644
--- a/libavcodec/bitstream_filter.c
+++ b/libavcodec/bitstream_filter.c
@@ -73,6 +73,7 @@ void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc)
 if (bsfc->filter->close)
 bsfc->filter->close(bsfc);
 av_freep(>priv_data);
+av_freep(>args);
 av_parser_close(bsfc->parser);
 av_free(bsfc);
 }
@@ -84,6 +85,6 @@ int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
 {
 *poutbuf  = (uint8_t *)buf;
 *poutbuf_size = buf_size;
-return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size,
-buf, buf_size, keyframe);
+return bsfc->filter->filter(bsfc, avctx, args ? args : bsfc->args,
+poutbuf, poutbuf_size, buf, buf_size, 
keyframe);
 }
-- 
2.6.0

___
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-10-07 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 1fb39fe..81e859f 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))
@@ -2106,6 +2098,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_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 },
@@ -2168,6 +2189,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,
@@ -2179,6 +2201,7 @@ AVOutputFormat ff_matroska_muxer = {
 },
 .subtitle_codec= AV_CODEC_ID_ASS,
 .query_codec   = mkv_query_codec,
+.check_bitstream   = mkv_check_bitstream,
 .priv_class= _class,
 };
 #endif
@@ -2200,9 +2223,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= _class,
@@ -2225,9 +2250,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.0

___
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-10-07 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 | 29 +
 libavformat/mux.c  | 31 ---
 2 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5226b0a..f3c8260 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -598,6 +598,21 @@ 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.
+ * Must not write output.
+ *
+ * FIXME: Data allocated here would be leaked if there's a failure before
+ * write_header is called. Ban allocations? Add a `deinit` cleanup 
function?
+ */
+int (*init)(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;
 /**
  * @}
@@ -1167,6 +1182,18 @@ typedef struct AVStream {
 AVRational display_aspect_ratio;
 
 struct FFFrac *priv_pts;
+
+/**
+ * bitstream filter to run on stream
+ * - encoding: Set by muxer or user using av_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);
@@ -1782,6 +1809,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 c9ef490..b5b2c8a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -400,7 +400,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
  *options = tmp;
 }
 
-return 0;
+return s->oformat->init ? s->oformat->init(s) : 0;
 
 fail:
 av_dict_free();
@@ -451,7 +451,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;
@@ -459,6 +459,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)
@@ -951,6 +952,18 @@ 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;
+}
+}
+
+if ((ret = av_apply_bitstream_filters(s, pkt, st->bsfc)) < 0)
+goto fail;
 } else {
 av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame FLUSH\n");
 flush = 1;
@@ -967,10 +980,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;
+if (ret < 0)
+goto fail2;
+if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & 
AVFMT_FLAG_FLUSH_PACKETS)
+avio_flush(s->pb);
+s->header_written = 1;
+}
+
 ret = write_packet(s, );
 if (ret >= 0)
 s->streams[opkt.stream_index]->nb_frames++;
 

Re: [FFmpeg-devel] [PATCH 0/9] Initial support for DNxHR, v2

2015-10-07 Thread Christophe Gisquet
Hi,

2015-10-08 1:38 GMT+02:00 Michael Niedermayer :
>> So I have made a fate test on 1 frame for each sequence (total around 1.8MB).
>>
>> Is it ok?
>
> ok

Here you go. Hendrik has kindly volunteered to upload the 2 samples for me.

-- 
Christophe
From 332b92d977ae04db0080973426ddc019d93a040b Mon Sep 17 00:00:00 2001
From: Christophe Gisquet 
Date: Mon, 5 Oct 2015 17:37:38 +0200
Subject: [PATCH] fate: add DNxHD/HR tests

Currently only 2 profiles are evaluated because they are the only 2
with distributed test sequences.
- CID 1260: YUV 4:2:2 10 bits with block-adaptive interlace coding,
  from ticket 4876;
- CID 1270: YUV 4:4:4 10 bits (HR), 1920x839, from ticket 4581.

They were generated from the ticket sequences by running the
following kind of command-line;
ffmpeg -i $INPUT -an -sn -vcodec copy -vframes 1 -y $OUTPUT.mov
---
 tests/Makefile | 1 +
 tests/fate/dnxhd.mak   | 8 
 tests/ref/fate/dnxhd-mbaff | 2 ++
 tests/ref/fate/dnxhr-444   | 2 ++
 4 files changed, 13 insertions(+)
 create mode 100644 tests/fate/dnxhd.mak
 create mode 100644 tests/ref/fate/dnxhd-mbaff
 create mode 100644 tests/ref/fate/dnxhr-444

diff --git a/tests/Makefile b/tests/Makefile
index c4a16c3..c0c1958 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -113,6 +113,7 @@ include $(SRC_PATH)/tests/fate/checkasm.mak
 include $(SRC_PATH)/tests/fate/cover-art.mak
 include $(SRC_PATH)/tests/fate/demux.mak
 include $(SRC_PATH)/tests/fate/dfa.mak
+include $(SRC_PATH)/tests/fate/dnxhd.mak
 include $(SRC_PATH)/tests/fate/dpcm.mak
 include $(SRC_PATH)/tests/fate/ea.mak
 include $(SRC_PATH)/tests/fate/exif.mak
diff --git a/tests/fate/dnxhd.mak b/tests/fate/dnxhd.mak
new file mode 100644
index 000..6d79f3b
--- /dev/null
+++ b/tests/fate/dnxhd.mak
@@ -0,0 +1,8 @@
+FATE_DNXHD = fate-dnxhd-mbaff \
+ fate-dnxhr-444
+
+FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, DNXHD) += $(FATE_DNXHD)
+fate-dnxhd: $(FATE_DNXHD) $(FATE_VCODEC_DNXHD)
+
+fate-dnxhd-mbaff: CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/dnxhd/dnxhd100_cid1260.mov -pix_fmt yuv422p10le
+fate-dnxhr-444:   CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/dnxhd/dnxhr444_cid1270.mov -pix_fmt yuv444p10le
diff --git a/tests/ref/fate/dnxhd-mbaff b/tests/ref/fate/dnxhd-mbaff
new file mode 100644
index 000..171c244
--- /dev/null
+++ b/tests/ref/fate/dnxhd-mbaff
@@ -0,0 +1,2 @@
+#tb 0: 1001/3
+0,  0,  0,1,  6220800, 0xe78198c0
diff --git a/tests/ref/fate/dnxhr-444 b/tests/ref/fate/dnxhr-444
new file mode 100644
index 000..743067d
--- /dev/null
+++ b/tests/ref/fate/dnxhr-444
@@ -0,0 +1,2 @@
+#tb 0: 1/24
+0,  0,  0,1,  9665280, 0x238a023e
-- 
2.6.0

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


Re: [FFmpeg-devel] [PATCHv2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 12:29:35PM -0400, Ganesh Ajjanagadde wrote:
> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
> The concept of av_uninit is inherently useful though. This patch silences a
> bunch of warnings on clang e.g
> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
> Furthermore, it should be useful for general usage of av_uninit in future.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/attributes.h | 6 ++
>  1 file changed, 6 insertions(+)

breaks gcc
./configure
make
CC  libavdevice/alldevices.o
In file included from ./libavutil/common.h:42:0,
 from ./libavutil/avutil.h:288,
 from ./libavutil/log.h:25,
 from libavdevice/avdevice.h:46,
 from libavdevice/alldevices.c:22:
./libavutil/attributes.h:150:42: error: missing binary operator before token "("
make: *** [libavdevice/alldevices.o] Error 1

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


Re: [FFmpeg-devel] [PATCHv2] avcodec/libx264: silence -Waddress

2015-10-07 Thread Ronald S. Bultje
Hi,

On Tue, Oct 6, 2015 at 10:48 PM, Ganesh Ajjanagadde 
wrote:

> This patch moves the pointer validity check outside the macro,
> and silences the -Waddress observed with GCC 5.2.
>
> Note that this changes the error message slightly, from:
> "bad option..." to "Error parsing option...".
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavcodec/libx264.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 75b5a5f..cc79250 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -399,7 +399,7 @@ static av_cold int X264_close(AVCodecContext *avctx)
>  #define OPT_STR(opt, param)
>  \
>  do {
> \
>  int ret;
> \
> -if (param && (ret = x264_param_parse(>params, opt, param)) <
> 0) { \
> +if ((ret = x264_param_parse(>params, opt, param)) < 0) { \
>  if(ret == X264_PARAM_BAD_NAME)
> \
>  av_log(avctx, AV_LOG_ERROR,
>  \
>  "bad option '%s': '%s'\n", opt, param);
>  \
> @@ -490,7 +490,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  x4->params.i_log_level  = X264_LOG_DEBUG;
>  x4->params.i_csp= convert_pix_fmt(avctx->pix_fmt);
>
> -OPT_STR("weightp", x4->wpredp);
> +PARSE_X264_OPT("weightp", wpredp);
>
>  if (avctx->bit_rate) {
>  x4->params.rc.i_bitrate   = avctx->bit_rate / 1000;
> @@ -520,7 +520,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  (float)avctx->rc_initial_buffer_occupancy /
> avctx->rc_buffer_size;
>  }
>
> -OPT_STR("level", x4->level);
> +PARSE_X264_OPT("level", level);
>
>  if (avctx->i_quant_factor > 0)
>  x4->params.rc.f_ip_factor = 1 /
> fabs(avctx->i_quant_factor);
> --
> 2.6.1


lgtm - I'll commit this later today if nobody does it before me.

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


Re: [FFmpeg-devel] [PATCH] RFC: Automatic bitstream filtering

2015-10-07 Thread Michael Niedermayer
On Tue, Oct 06, 2015 at 08:07:08PM -0500, Rodger Combs wrote:
> 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.
> 
> I'd like to split this into 4 commits:
> - Moving av_apply_bitstream_filters from ffmpeg.c to its own API function
> - Other lavf API changes
> - Use of the new API in matroskaenc
> - The minor style tweak in matroskaenc
> 
> There are a few other changes I think should be made before this is applied:
> - Adding BSF arguments to AVBitStreamFilterContext rather than passing them
> manually on each packet
> - Providing an API to add a bitstream filter to an AVStream, rather than doing
> so manually, and using it in check_bitstream
> - Using said API in ffmpeg_opt.c and removing ffmpeg.c's own BSF handling
> - Adding check_bitstream to other muxers that currently prompt the user to add
> bitstream filters (such as aac_adtstoasc and h264_mpeg4toannexb). It could 
> also
> be used by e.g. movenc for generating the EAC3-specific atom.
> ---
>  ffmpeg.c  | 45 --
>  libavformat/avformat.h| 16 +++
>  libavformat/matroskaenc.c | 22 -
>  libavformat/mux.c | 25 +++-
>  libavformat/utils.c   | 50 
> +++
>  5 files changed, 115 insertions(+), 43 deletions(-)

i know its just a RFC but as i tested it ... it fails fate
make: *** [fate-binsub-mksenc] Error 1
make: *** [fate-acodec-tta] Error 1
make: *** [fate-seek-lavf-mkv] Error 1

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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


Re: [FFmpeg-devel] [PATCH] RFC: Automatic bitstream filtering

2015-10-07 Thread wm4
On Tue,  6 Oct 2015 20:07:08 -0500
Rodger Combs  wrote:

> 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.
> 
> I'd like to split this into 4 commits:
> - Moving av_apply_bitstream_filters from ffmpeg.c to its own API function
> - Other lavf API changes
> - Use of the new API in matroskaenc
> - The minor style tweak in matroskaenc
> 
> There are a few other changes I think should be made before this is applied:
> - Adding BSF arguments to AVBitStreamFilterContext rather than passing them
> manually on each packet
> - Providing an API to add a bitstream filter to an AVStream, rather than doing
> so manually, and using it in check_bitstream
> - Using said API in ffmpeg_opt.c and removing ffmpeg.c's own BSF handling
> - Adding check_bitstream to other muxers that currently prompt the user to add
> bitstream filters (such as aac_adtstoasc and h264_mpeg4toannexb). It could 
> also
> be used by e.g. movenc for generating the EAC3-specific atom.
> ---

Seems like a good idea. As far as I can see, all added fields are
explicitly marked as internal, so that's fine with me.

I just wonder why av_apply_bitstream_filters() is public, and ffmpeg.c
accesses an internal AVStream field (which it shouldn't be allowed to
access).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/delogo: Set default band to 1

2015-10-07 Thread Jean Delvare
Hi Stefano,

On Wed, 7 Oct 2015 11:21:45 +0200, Stefano Sabatini wrote:
> On date Wednesday 2015-10-07 08:54:59 +0200, Jean Delvare encoded:
> > The original interpolation algorithm behaved poorly on the borders and
> > did not even guarantee continuity at the borders. For this reason, a
> > second interpolation/blending pass was required on the borders to make
> > them seamless.
> > 
> > However, since the interpolation algorithm was improved in June 2013,
> > the border issues no longer exist. The new algorithm does guarantee
> > continuity at the borders, making the second pass useless. A larger
> > band always increases the cumulated interpolation error. In most cases
> > it also increases the average interpolation error, even though the
> > samples in the band are only partially interpolated.
> > 
> > For this reason I would like to get rid of the "band" parameter. As a
> > first step, let's change its default value from 4 to 1 and document it
> > as deprecated.
> > 
> > I have benchmarked this change on a combination of input sources and
> > realistic logo areas. Lowering the band value from 4 to 1 resulted in
> > 8 to 39 % less interpolation error per frame (or 1 to 34 % less
> > interpolation error per luma sample.)
> > 
> > Signed-off-by: Jean Delvare 
> > ---
> >  doc/filters.texi|4 +++-
> >  libavfilter/vf_delogo.c |   11 +--
> >  2 files changed, 12 insertions(+), 3 deletions(-)
> > 
> > --- ffmpeg.orig/doc/filters.texi2015-10-02 11:41:24.035943770 +0200
> > +++ ffmpeg/doc/filters.texi 2015-10-02 12:02:08.231484828 +0200
> > @@ -4590,7 +4590,9 @@ specified.
> >  
> >  @item band, t
> >  Specify the thickness of the fuzzy edge of the rectangle (added to
> > -@var{w} and @var{h}). The default value is 4.
> > +@var{w} and @var{h}). The default value is 1. This option is
> > +deprecated, setting higher values should no longer be necessary and
> > +is not recommended.
> >  
> >  @item show
> >  When set to 1, a green rectangle is drawn on the screen to simplify
> > --- ffmpeg.orig/libavfilter/vf_delogo.c 2015-10-02 11:41:24.035943770 
> > +0200
> > +++ ffmpeg/libavfilter/vf_delogo.c  2015-10-07 08:45:39.037203764 +0200
> > @@ -165,8 +165,9 @@ static const AVOption delogo_options[]=
> >  { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> >  { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> >  { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> > -{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  4 },  1, INT_MAX, FLAGS },
> > -{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  4 },  1, INT_MAX, FLAGS },
> > +/* Actual default value for band/t is 1, set in init */
> > +{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  0 },  0, INT_MAX, FLAGS },
> > +{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  0 },  0, INT_MAX, FLAGS },
> >  { "show", "show delogo area",  OFFSET(show), 
> > AV_OPT_TYPE_BOOL,{ .i64 =  0 },  0, 1,   FLAGS },
> >  { NULL }
> >  };
> > @@ -201,6 +202,12 @@ static av_cold int init(AVFilterContext
> >  CHECK_UNSET_OPT(w);
> >  CHECK_UNSET_OPT(h);
> >  
> > +if (s->band == 0) { /* Unset, use default */
> > +av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed 
> > from 4 to 1.\n");
> > +s->band = 1;
> > +} else if (s->band != 1) {
> > +av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
> > +}
> >  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
> > s->x, s->y, s->w, s->h, s->band, s->show);
> 
> LGTM. BTW, if you want to drop the band option, you could ifdef it so
> that it will be dropt at the next lavfi major bump.

Good idea. Something like this?

---
 libavfilter/vf_delogo.c |6 ++
 1 file changed, 6 insertions(+)

--- ffmpeg.orig/libavfilter/vf_delogo.c 2015-10-07 08:45:39.037203764 +0200
+++ ffmpeg/libavfilter/vf_delogo.c  2015-10-07 13:52:43.716487733 +0200
@@ -165,9 +165,11 @@ static const AVOption delogo_options[]=
 { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
+#if LIBAVFILTER_VERSION_MAJOR < 7
 /* Actual default value for band/t is 1, set in init */
 { "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
 { "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, 

Re: [FFmpeg-devel] [PATCH] avfilter/delogo: Set default band to 1

2015-10-07 Thread Stefano Sabatini
On date Wednesday 2015-10-07 08:54:59 +0200, Jean Delvare encoded:
> The original interpolation algorithm behaved poorly on the borders and
> did not even guarantee continuity at the borders. For this reason, a
> second interpolation/blending pass was required on the borders to make
> them seamless.
> 
> However, since the interpolation algorithm was improved in June 2013,
> the border issues no longer exist. The new algorithm does guarantee
> continuity at the borders, making the second pass useless. A larger
> band always increases the cumulated interpolation error. In most cases
> it also increases the average interpolation error, even though the
> samples in the band are only partially interpolated.
> 
> For this reason I would like to get rid of the "band" parameter. As a
> first step, let's change its default value from 4 to 1 and document it
> as deprecated.
> 
> I have benchmarked this change on a combination of input sources and
> realistic logo areas. Lowering the band value from 4 to 1 resulted in
> 8 to 39 % less interpolation error per frame (or 1 to 34 % less
> interpolation error per luma sample.)
> 
> Signed-off-by: Jean Delvare 
> ---
>  doc/filters.texi|4 +++-
>  libavfilter/vf_delogo.c |   11 +--
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> --- ffmpeg.orig/doc/filters.texi  2015-10-02 11:41:24.035943770 +0200
> +++ ffmpeg/doc/filters.texi   2015-10-02 12:02:08.231484828 +0200
> @@ -4590,7 +4590,9 @@ specified.
>  
>  @item band, t
>  Specify the thickness of the fuzzy edge of the rectangle (added to
> -@var{w} and @var{h}). The default value is 4.
> +@var{w} and @var{h}). The default value is 1. This option is
> +deprecated, setting higher values should no longer be necessary and
> +is not recommended.
>  
>  @item show
>  When set to 1, a green rectangle is drawn on the screen to simplify
> --- ffmpeg.orig/libavfilter/vf_delogo.c   2015-10-02 11:41:24.035943770 
> +0200
> +++ ffmpeg/libavfilter/vf_delogo.c2015-10-07 08:45:39.037203764 +0200
> @@ -165,8 +165,9 @@ static const AVOption delogo_options[]=
>  { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
>  { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
>  { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
> -{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  4 },  1, INT_MAX, FLAGS },
> -{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  4 },  1, INT_MAX, FLAGS },
> +/* Actual default value for band/t is 1, set in init */
> +{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  0 },  0, INT_MAX, FLAGS },
> +{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  0 },  0, INT_MAX, FLAGS },
>  { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
> .i64 =  0 },  0, 1,   FLAGS },
>  { NULL }
>  };
> @@ -201,6 +202,12 @@ static av_cold int init(AVFilterContext
>  CHECK_UNSET_OPT(w);
>  CHECK_UNSET_OPT(h);
>  
> +if (s->band == 0) { /* Unset, use default */
> +av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed 
> from 4 to 1.\n");
> +s->band = 1;
> +} else if (s->band != 1) {
> +av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
> +}
>  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
> s->x, s->y, s->w, s->h, s->band, s->show);

LGTM. BTW, if you want to drop the band option, you could ifdef it so
that it will be dropt at the next lavfi major bump.
-- 
FFmpeg = Friendly and Fundamental Meaningless Programmable Enlightened God
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/x86/vf_blend.asm: add hardmix and phoenix sse2 SIMD

2015-10-07 Thread Ronald S. Bultje
Hi,

On Wed, Oct 7, 2015 at 5:38 AM, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/x86/vf_blend.asm| 62
> +
>  libavfilter/x86/vf_blend_init.c | 14 ++
>  2 files changed, 76 insertions(+)
>
> diff --git a/libavfilter/x86/vf_blend.asm b/libavfilter/x86/vf_blend.asm
> index 167e72b..7180817 100644
> --- a/libavfilter/x86/vf_blend.asm
> +++ b/libavfilter/x86/vf_blend.asm
> @@ -27,6 +27,8 @@ SECTION_RODATA
>
>  pw_128: times 8 dw 128
>  pw_255: times 8 dw 255
> +pb_128: times 16 db 128
> +pb_255: times 16 db 255
>
>  SECTION .text
>
> @@ -273,6 +275,36 @@ cglobal blend_darken, 9, 10, 2, 0, top, top_linesize,
> bottom, bottom_linesize, d
>  jg .nextrow
>  REP_RET
>
> +cglobal blend_hardmix, 9, 10, 3, 0, top, top_linesize, bottom,
> bottom_linesize, dst, dst_linesize, width, start, end
> +add  topq, widthq
> +add   bottomq, widthq
> +add  dstq, widthq
> +sub  endq, startq
> +negwidthq
> +.nextrow:
> +mov   r10q, widthq
> +%define  x  r10q
>

You're saying that you use 10 regs, but you're using r10, which is the
11th. Use r9 here, or specify that you use 11.

Now, more generally, you're using a lot of regs in all your simd, and some
aren't necessary, so some lessons about arguments: most arguments come on
stack. On x86-64, the first 4 (win64) or 6 (unix64) come in registers, but
the rest (width, start, end) come on stack. On x86-32, all arguments come
on stack. So, if you get 9 arguments, you have 3 arguments at least on
stack, including width. That means you don't have to move width into r10q;
you can move widthmp (the stack version of this argument) into widthq at
the start of each row, since the system already put width on stack for you.
x86inc.asm moves it from stack into a register for you when you say cglobal
name, %d and %d >= 7 (where width is the 7th argument).

Then, you can also sub startmp from endq, which you can then store back
into endmp on x86-32, and suddenly on x86-32 you only need 7 regs (for
x86-64, you keep using endd since that's faster). And now, your simd works
on 32bit systems as well.

+.loop:
> +movum0, [topq + x]
> +movum1, [bottomq + x]
> +movam2, [pb_255]
> +psubusb m2, m1


pxor m1, [pb_255] should be the same as mova reg, [pb_255] and psubusb reg,
m1

Now, you're using pb_255 a lot inside your inner loop, and with pxor, you
only use it non-destructively, so why not move it into a register (m3)
outside the loop so you only load it from mem once?

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


[FFmpeg-devel] [PATCH] avfilter/x86/vf_blend.asm: add hardmix and phoenix sse2 SIMD

2015-10-07 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/x86/vf_blend.asm| 62 +
 libavfilter/x86/vf_blend_init.c | 14 ++
 2 files changed, 76 insertions(+)

diff --git a/libavfilter/x86/vf_blend.asm b/libavfilter/x86/vf_blend.asm
index 167e72b..7180817 100644
--- a/libavfilter/x86/vf_blend.asm
+++ b/libavfilter/x86/vf_blend.asm
@@ -27,6 +27,8 @@ SECTION_RODATA
 
 pw_128: times 8 dw 128
 pw_255: times 8 dw 255
+pb_128: times 16 db 128
+pb_255: times 16 db 255
 
 SECTION .text
 
@@ -273,6 +275,36 @@ cglobal blend_darken, 9, 10, 2, 0, top, top_linesize, 
bottom, bottom_linesize, d
 jg .nextrow
 REP_RET
 
+cglobal blend_hardmix, 9, 10, 3, 0, top, top_linesize, bottom, 
bottom_linesize, dst, dst_linesize, width, start, end
+add  topq, widthq
+add   bottomq, widthq
+add  dstq, widthq
+sub  endq, startq
+negwidthq
+.nextrow:
+mov   r10q, widthq
+%define  x  r10q
+
+.loop:
+movum0, [topq + x]
+movum1, [bottomq + x]
+movam2, [pb_255]
+psubusb m2, m1
+pxorm0, [pb_128]
+pxorm2, [pb_128]
+pcmpgtb m2, m0
+pxorm2, [pb_255]
+mova[dstq + x], m2
+add   r10q, mmsize
+jl .loop
+
+add  topq, top_linesizeq
+add   bottomq, bottom_linesizeq
+add  dstq, dst_linesizeq
+sub  endd, 1
+jg .nextrow
+REP_RET
+
 cglobal blend_lighten, 9, 10, 2, 0, top, top_linesize, bottom, 
bottom_linesize, dst, dst_linesize, width, start, end
 add  topq, widthq
 add   bottomq, widthq
@@ -298,6 +330,36 @@ cglobal blend_lighten, 9, 10, 2, 0, top, top_linesize, 
bottom, bottom_linesize,
 jg .nextrow
 REP_RET
 
+cglobal blend_phoenix, 9, 10, 3, 0, top, top_linesize, bottom, 
bottom_linesize, dst, dst_linesize, width, start, end
+add  topq, widthq
+add   bottomq, widthq
+add  dstq, widthq
+sub  endq, startq
+negwidthq
+.nextrow:
+mov   r10q, widthq
+%define  x  r10q
+
+.loop:
+movum0, [topq + x]
+movum1, [bottomq + x]
+movam2, m0
+pminub  m0, m1
+pmaxub  m1, m2
+movam2, [pb_255]
+psubusb m2, m1
+paddusb m2, m0
+mova[dstq + x], m2
+add   r10q, mmsize
+jl .loop
+
+add  topq, top_linesizeq
+add   bottomq, bottom_linesizeq
+add  dstq, dst_linesizeq
+sub  endd, 1
+jg .nextrow
+REP_RET
+
 INIT_XMM ssse3
 cglobal blend_difference, 9, 10, 3, 0, top, top_linesize, bottom, 
bottom_linesize, dst, dst_linesize, width, start, end
 add  topq, widthq
diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c
index 61e90f8..454d030 100644
--- a/libavfilter/x86/vf_blend_init.c
+++ b/libavfilter/x86/vf_blend_init.c
@@ -59,6 +59,12 @@ void ff_blend_difference128_sse2(const uint8_t *top, 
ptrdiff_t top_linesize,
  ptrdiff_t width, ptrdiff_t start, ptrdiff_t 
end,
  struct FilterParams *param, double *values);
 
+void ff_blend_hardmix_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+   const uint8_t *bottom, ptrdiff_t bottom_linesize,
+   uint8_t *dst, ptrdiff_t dst_linesize,
+   ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+   struct FilterParams *param, double *values);
+
 void ff_blend_lighten_sse2(const uint8_t *top, ptrdiff_t top_linesize,
const uint8_t *bottom, ptrdiff_t bottom_linesize,
uint8_t *dst, ptrdiff_t dst_linesize,
@@ -71,6 +77,12 @@ void ff_blend_or_sse2(const uint8_t *top, ptrdiff_t 
top_linesize,
   ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
   struct FilterParams *param, double *values);
 
+void ff_blend_phoenix_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+   const uint8_t *bottom, ptrdiff_t bottom_linesize,
+   uint8_t *dst, ptrdiff_t dst_linesize,
+   ptrdiff_t width, ptrdiff_t start, ptrdiff_t end,
+   struct FilterParams *param, double *values);
+
 void ff_blend_subtract_sse2(const uint8_t *top, ptrdiff_t top_linesize,
 const uint8_t *bottom, ptrdiff_t bottom_linesize,
 uint8_t *dst, ptrdiff_t dst_linesize,
@@ -107,8 +119,10 @@ av_cold void ff_blend_init_x86(FilterParams *param, int 
is_16bit)
 case BLEND_AVERAGE:  param->blend = ff_blend_average_sse2;  break;
 case BLEND_DARKEN:   param->blend = ff_blend_darken_sse2;   break;
 case 

Re: [FFmpeg-devel] [PATCH] doc/developer: use https instead of http

2015-10-07 Thread Michael Niedermayer
On Tue, Oct 06, 2015 at 11:15:49PM -0400, Ganesh Ajjanagadde wrote:
> Change to https for FFmpeg websites.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  doc/developer.texi | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

applied

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH v2 0/8] libkvazaar improvements

2015-10-07 Thread Arttu Ylä-Outinen

On 2015-09-29 16:29, Arttu Ylä-Outinen wrote:

These patches fix some problems in libkvazaar encoder and update it to work
with the latest git version of Kvazaar. Most notable changes are setting
pts, dts and keyframe flag on the output packets and fixing the calculation
of the framerate.

v2: Add libkvazaar version check and fix descriptions of patches
 "libkvazaar: Fix setting target bitrate" and
 "doc/encoders: Fix libkvazaar documentation."

Thanks for the comments!

Arttu Ylä-Outinen (8):
   libkvazaar: Update to work with the latest version
   configure: Add version check for libkvazaar
   libkvazaar: Remove unnecessary NULL checks
   libkvazaar: Replace asserts with proper errors
   libkvazaar: Set pts and dts
   libkvazaar: Use av_image_copy for copying pixels
   libkvazaar: Fix setting framerate
   doc/encoders: Fix libkvazaar documentation

  configure   |2 ++
  doc/encoders.texi   |3 --
  libavcodec/libkvazaar.c |   80 ++-
  3 files changed, 60 insertions(+), 25 deletions(-)



Is it OK if I push these (with the v3 of the second patch)?

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


[FFmpeg-devel] [PATCH 1/2] avcodec/mips: build fix for MSA

2015-10-07 Thread shivraj.patil
From: Shivraj Patil 

Modified sps and pps access from old HEVCContext(s) structure to newly 
introduced HEVCParamSets(ps)

Signed-off-by: Shivraj Patil 
---
 libavcodec/mips/hevcpred_msa.c |  282 
 1 file changed, 141 insertions(+), 141 deletions(-)

diff --git a/libavcodec/mips/hevcpred_msa.c b/libavcodec/mips/hevcpred_msa.c
index 5d9299f..6a3b281 100644
--- a/libavcodec/mips/hevcpred_msa.c
+++ b/libavcodec/mips/hevcpred_msa.c
@@ -1915,24 +1915,24 @@ void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, 
int y0, int c_idx)
 v16u8 vec0;
 HEVCLocalContext *lc = s->HEVClc;
 int i;
-int hshift = s->sps->hshift[c_idx];
-int vshift = s->sps->vshift[c_idx];
+int hshift = s->ps.sps->hshift[c_idx];
+int vshift = s->ps.sps->vshift[c_idx];
 int size_in_luma_h = 16 << hshift;
-int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size;
+int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
 int size_in_luma_v = 16 << vshift;
-int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size;
+int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
 int x = x0 >> hshift;
 int y = y0 >> vshift;
-int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
-int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
+int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
+int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
 
 int cur_tb_addr =
-s->pps->min_tb_addr_zs[(y_tb) * (s->sps->tb_mask + 2) + (x_tb)];
+s->ps.pps->min_tb_addr_zs[(y_tb) * (s->ps.sps->tb_mask + 2) + (x_tb)];
 
 ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(uint8_t);
 uint8_t *src = (uint8_t *) s->frame->data[c_idx] + x + y * stride;
 
-int min_pu_width = s->sps->min_pu_width;
+int min_pu_width = s->ps.sps->min_pu_width;
 
 enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
 lc->tu.intra_pred_mode;
@@ -1948,41 +1948,41 @@ void ff_intra_pred_8_16x16_msa(HEVCContext *s, int x0, 
int y0, int c_idx)
 uint8_t *filtered_top = filtered_top_array + 1;
 int cand_bottom_left = lc->na.cand_bottom_left
 && cur_tb_addr >
-s->pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & s->sps->tb_mask) *
-   (s->sps->tb_mask + 2) + (x_tb - 1)];
+s->ps.pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & 
s->ps.sps->tb_mask) *
+   (s->ps.sps->tb_mask + 2) + (x_tb - 1)];
 int cand_left = lc->na.cand_left;
 int cand_up_left = lc->na.cand_up_left;
 int cand_up = lc->na.cand_up;
 int cand_up_right = lc->na.cand_up_right
 && cur_tb_addr >
-s->pps->min_tb_addr_zs[(y_tb - 1) * (s->sps->tb_mask + 2) +
-   ((x_tb + size_in_tbs_h) & s->sps->tb_mask)];
+s->ps.pps->min_tb_addr_zs[(y_tb - 1) * (s->ps.sps->tb_mask + 2) +
+   ((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask)];
 
 int bottom_left_size =
 (((y0 + 2 * size_in_luma_v) >
-  (s->sps->height) ? (s->sps->height) : (y0 +
+  (s->ps.sps->height) ? (s->ps.sps->height) : (y0 +
  2 * size_in_luma_v)) -
  (y0 + size_in_luma_v)) >> vshift;
 int top_right_size =
 (((x0 + 2 * size_in_luma_h) >
-  (s->sps->width) ? (s->sps->width) : (x0 + 2 * size_in_luma_h)) -
+  (s->ps.sps->width) ? (s->ps.sps->width) : (x0 + 2 * size_in_luma_h)) 
-
  (x0 + size_in_luma_h)) >> hshift;
 
-if (s->pps->constrained_intra_pred_flag == 1) {
-int size_in_luma_pu_v = ((size_in_luma_v) >> s->sps->log2_min_pu_size);
-int size_in_luma_pu_h = ((size_in_luma_h) >> s->sps->log2_min_pu_size);
-int on_pu_edge_x = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));
-int on_pu_edge_y = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));
+if (s->ps.pps->constrained_intra_pred_flag == 1) {
+int size_in_luma_pu_v = ((size_in_luma_v) >> 
s->ps.sps->log2_min_pu_size);
+int size_in_luma_pu_h = ((size_in_luma_h) >> 
s->ps.sps->log2_min_pu_size);
+int on_pu_edge_x = !(x0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
+int on_pu_edge_y = !(y0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
 if (!size_in_luma_pu_h)
 size_in_luma_pu_h++;
 if (cand_bottom_left == 1 && on_pu_edge_x) {
-int x_left_pu = ((x0 - 1) >> s->sps->log2_min_pu_size);
+int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
 int y_bottom_pu =
-((y0 + size_in_luma_v) >> s->sps->log2_min_pu_size);
+((y0 + size_in_luma_v) >> s->ps.sps->log2_min_pu_size);
 int max =
 ((size_in_luma_pu_v) >
- (s->sps->min_pu_height -
-  y_bottom_pu) 

Re: [FFmpeg-devel] [PATCHv2] avfilter/buffersrc: add av_warn_unused_result attributes

2015-10-07 Thread Clément Bœsch
On Wed, Oct 07, 2015 at 09:31:49AM -0400, Ganesh Ajjanagadde wrote:
> On Wed, Oct 7, 2015 at 8:59 AM, Clément Bœsch  wrote:
> > On Tue, Oct 06, 2015 at 06:53:47PM -0400, Ganesh Ajjanagadde wrote:
> >> This adds av_warn_unused_result whenever it is relevant.
> >>
> >> Signed-off-by: Ganesh Ajjanagadde 
> >> ---
> >>  libavfilter/buffersrc.h | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
> >> index cd3d95f..847c093 100644
> >> --- a/libavfilter/buffersrc.h
> >> +++ b/libavfilter/buffersrc.h
> >> @@ -78,6 +78,7 @@ unsigned 
> >> av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
> >>   * This function is equivalent to av_buffersrc_add_frame_flags() with the
> >>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
> >>   */
> >> +av_warn_unused_result
> >>  int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
> >>
> >>  /**
> >> @@ -98,6 +99,7 @@ int av_buffersrc_write_frame(AVFilterContext *ctx, const 
> >> AVFrame *frame);
> >>   * This function is equivalent to av_buffersrc_add_frame_flags() without 
> >> the
> >>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
> >>   */
> >> +av_warn_unused_result
> >>  int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
> >>
> >>  /**
> >> @@ -115,6 +117,7 @@ int av_buffersrc_add_frame(AVFilterContext *ctx, 
> >> AVFrame *frame);
> >>   * @return>= 0 in case of success, a negative AVERROR code
> >>   *in case of failure
> >>   */
> >> +av_warn_unused_result
> >>  int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
> >>   AVFrame *frame, int flags);
> >>
> >
> > Aren't you just supposed to (void)-prefix the call in the caller when you
> > explicitly don't care about the result?
> >
> > These functions certainly looks like you actually want to check for the
> > result most of the time.
> 
> Exactly - this addition to the declaration in the header will trigger
> a warning whenever this function is used without obtaining the return
> value.
> 

Oh, my bad, I misunderstood, sounds indeed saner than what I had in mind.

Thanks for the clarification.

-- 
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/delogo: Set default band to 1

2015-10-07 Thread Stefano Sabatini
On date Wednesday 2015-10-07 13:57:46 +0200, Jean Delvare encoded:
> Hi Stefano,
> 
> On Wed, 7 Oct 2015 11:21:45 +0200, Stefano Sabatini wrote:
> > On date Wednesday 2015-10-07 08:54:59 +0200, Jean Delvare encoded:
> > > The original interpolation algorithm behaved poorly on the borders and
> > > did not even guarantee continuity at the borders. For this reason, a
> > > second interpolation/blending pass was required on the borders to make
> > > them seamless.
> > > 
> > > However, since the interpolation algorithm was improved in June 2013,
> > > the border issues no longer exist. The new algorithm does guarantee
> > > continuity at the borders, making the second pass useless. A larger
> > > band always increases the cumulated interpolation error. In most cases
> > > it also increases the average interpolation error, even though the
> > > samples in the band are only partially interpolated.
> > > 
> > > For this reason I would like to get rid of the "band" parameter. As a
> > > first step, let's change its default value from 4 to 1 and document it
> > > as deprecated.
> > > 
> > > I have benchmarked this change on a combination of input sources and
> > > realistic logo areas. Lowering the band value from 4 to 1 resulted in
> > > 8 to 39 % less interpolation error per frame (or 1 to 34 % less
> > > interpolation error per luma sample.)
> > > 
> > > Signed-off-by: Jean Delvare 
> > > ---
> > >  doc/filters.texi|4 +++-
> > >  libavfilter/vf_delogo.c |   11 +--
> > >  2 files changed, 12 insertions(+), 3 deletions(-)
> > > 
> > > --- ffmpeg.orig/doc/filters.texi  2015-10-02 11:41:24.035943770 +0200
> > > +++ ffmpeg/doc/filters.texi   2015-10-02 12:02:08.231484828 +0200
> > > @@ -4590,7 +4590,9 @@ specified.
> > >  
> > >  @item band, t
> > >  Specify the thickness of the fuzzy edge of the rectangle (added to
> > > -@var{w} and @var{h}). The default value is 4.
> > > +@var{w} and @var{h}). The default value is 1. This option is
> > > +deprecated, setting higher values should no longer be necessary and
> > > +is not recommended.
> > >  
> > >  @item show
> > >  When set to 1, a green rectangle is drawn on the screen to simplify
> > > --- ffmpeg.orig/libavfilter/vf_delogo.c   2015-10-02 11:41:24.035943770 
> > > +0200
> > > +++ ffmpeg/libavfilter/vf_delogo.c2015-10-07 08:45:39.037203764 
> > > +0200
> > > @@ -165,8 +165,9 @@ static const AVOption delogo_options[]=
> > >  { "y","set logo y position",   OFFSET(y),
> > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
> > >  { "w","set logo width",OFFSET(w),
> > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
> > >  { "h","set logo height",   OFFSET(h),
> > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
> > > -{ "band", "set delogo area band size", OFFSET(band), 
> > > AV_OPT_TYPE_INT, { .i64 =  4 },  1, INT_MAX, FLAGS },
> > > -{ "t","set delogo area band size", OFFSET(band), 
> > > AV_OPT_TYPE_INT, { .i64 =  4 },  1, INT_MAX, FLAGS },
> > > +/* Actual default value for band/t is 1, set in init */
> > > +{ "band", "set delogo area band size", OFFSET(band), 
> > > AV_OPT_TYPE_INT, { .i64 =  0 },  0, INT_MAX, FLAGS },
> > > +{ "t","set delogo area band size", OFFSET(band), 
> > > AV_OPT_TYPE_INT, { .i64 =  0 },  0, INT_MAX, FLAGS },
> > >  { "show", "show delogo area",  OFFSET(show), 
> > > AV_OPT_TYPE_BOOL,{ .i64 =  0 },  0, 1,   FLAGS },
> > >  { NULL }
> > >  };
> > > @@ -201,6 +202,12 @@ static av_cold int init(AVFilterContext
> > >  CHECK_UNSET_OPT(w);
> > >  CHECK_UNSET_OPT(h);
> > >  
> > > +if (s->band == 0) { /* Unset, use default */
> > > +av_log(ctx, AV_LOG_WARNING, "Note: default band value was 
> > > changed from 4 to 1.\n");
> > > +s->band = 1;
> > > +} else if (s->band != 1) {
> > > +av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
> > > +}
> > >  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
> > > s->x, s->y, s->w, s->h, s->band, s->show);
> > 
> > LGTM. BTW, if you want to drop the band option, you could ifdef it so
> > that it will be dropt at the next lavfi major bump.
> 
> Good idea. Something like this?
> 
> ---
>  libavfilter/vf_delogo.c |6 ++
>  1 file changed, 6 insertions(+)
> 
> --- ffmpeg.orig/libavfilter/vf_delogo.c   2015-10-07 08:45:39.037203764 
> +0200
> +++ ffmpeg/libavfilter/vf_delogo.c2015-10-07 13:52:43.716487733 +0200
> @@ -165,9 +165,11 @@ static const AVOption delogo_options[]=
>  { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
>  { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
>  { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, { 
> .i64 = -1 }, -1, INT_MAX, FLAGS },
> +#if 

Re: [FFmpeg-devel] [PATCH] avfilter/delogo: Set default band to 1

2015-10-07 Thread Jean Delvare
On Wed, 7 Oct 2015 14:19:58 +0200, Stefano Sabatini wrote:
> > > LGTM. BTW, if you want to drop the band option, you could ifdef it so
> > > that it will be dropt at the next lavfi major bump.
> > 
> > Good idea. Something like this?
> > 
> > ---
> >  libavfilter/vf_delogo.c |6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > --- ffmpeg.orig/libavfilter/vf_delogo.c 2015-10-07 08:45:39.037203764 
> > +0200
> > +++ ffmpeg/libavfilter/vf_delogo.c  2015-10-07 13:52:43.716487733 +0200
> > @@ -165,9 +165,11 @@ static const AVOption delogo_options[]=
> >  { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> >  { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> >  { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, 
> > { .i64 = -1 }, -1, INT_MAX, FLAGS },
> > +#if LIBAVFILTER_VERSION_MAJOR < 7
> >  /* Actual default value for band/t is 1, set in init */
> >  { "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  0 },  0, INT_MAX, FLAGS },
> >  { "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, 
> > { .i64 =  0 },  0, INT_MAX, FLAGS },
> > +#endif
> >  { "show", "show delogo area",  OFFSET(show), 
> > AV_OPT_TYPE_BOOL,{ .i64 =  0 },  0, 1,   FLAGS },
> >  { NULL }
> >  };
> > @@ -202,12 +204,16 @@ static av_cold int init(AVFilterContext
> >  CHECK_UNSET_OPT(w);
> >  CHECK_UNSET_OPT(h);
> >  
> > +#if LIBAVFILTER_VERSION_MAJOR < 7
> >  if (s->band == 0) { /* Unset, use default */
> >  av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed 
> > from 4 to 1.\n");
> >  s->band = 1;
> >  } else if (s->band != 1) {
> >  av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
> >  }
> > +#else
> > +s->band = 1;
> > +#endif
> >  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
> > s->x, s->y, s->w, s->h, s->band, s->show);
> 
> Looks fine to me.

Great.

> > Or should I use FF_API_OLD_FILTER_OPTS?
> 
> No, I think that's related to another issue.

I thought so but wasn't sure.

> > Assuming this is what you had in mind, would it go as a separate patch,
> > or should this be folded in the patch I just sent?
> 
> Use a single patch since it involves less work, unless you prefer to
> do it with a separate patch.

I'm fine either way so if a single patch is easier for you, I'll do
that. I'll send a v2 of the patch in a minute.

Thanks for the review,
-- 
Jean Delvare
SUSE L3 Support
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Michael Niedermayer
On Sat, Sep 19, 2015 at 01:00:17AM -0400, Ganesh Ajjanagadde wrote:
> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
> The concept of av_uninit is inherently useful though. This patch silences a
> bunch of warnings on clang e.g
> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
> Furthermore, it should be useful for general usage of av_uninit in future.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/attributes.h | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
> index 50e8eb3..b4b5f13 100644
> --- a/libavutil/attributes.h
> +++ b/libavutil/attributes.h
> @@ -141,6 +141,12 @@
>  
>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>  #define av_uninit(x) x=x
> +#elif defined(__clang__)
> +#define av_uninit(x) \
> +_Pragma("clang diagnostic push") \
> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
> +x=x \
> +_Pragma("clang diagnostic pop")
>  #else

this fails with clang version 3.1 (trunk 144800)

AR  libavdevice/libavdevice.a
CC  libavfilter/af_aecho.o
In file included from libavfilter/af_aecho.c:1:
libavfilter/af_aecho.c:226:315: error: expected identifier or '('
static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t **delayptrs, 
uint8_t * const *src, uint8_t **dst, int nb_samples, int channels) { const 
double out_gain = ctx->out_gain; const double in_gain = ctx->in_gain; const int 
nb_echoes = ctx->nb_echoes; const int max_samples = ctx->max_samples; int i, j, 
chan,#pragma clang diagnostic push#pragma clang diagnostic ignored 
"-Wuninitialized" index=index#pragma clang diagnostic pop; ((void)0); for (chan 
= 0; chan < channels; chan++) { const double *s = (double *)src[chan]; double 
*d = (double *)dst[chan]; double *dbuf = (double *)delayptrs[chan]; index = 
ctx->delay_index; for (i = 0; i < nb_samples; i++, s++, d++) { double out, in; 
in = *s; out = in * in_gain; for (j = 0; j < nb_echoes; j++) { int ix = index + 
max_samples - ctx->samples[j]; ix = (((ix) >= (max_samples)) ? (ix) - 
(max_samples) : (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= out_gain; *d = 
av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index + 1) >= 
(max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } } 
ctx->delay_index = index; }



  ^
...

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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


[FFmpeg-devel] [PATCH v2] avfilter/delogo: Set default band to 1

2015-10-07 Thread Jean Delvare
The original interpolation algorithm behaved poorly on the borders and
did not even guarantee continuity at the borders. For this reason, a
second interpolation/blending pass was required on the borders to make
them seamless.

However, since the interpolation algorithm was improved in June 2013,
the border issues no longer exist. The new algorithm does guarantee
continuity at the borders, making the second pass useless. A larger
band always increases the cumulated interpolation error. In most cases
it also increases the average interpolation error, even though the
samples in the band are only partially interpolated.

For this reason I would like to get rid of the "band" parameter. As a
first step, let's change its default value from 4 to 1 and document it
as deprecated.

I have benchmarked this change on a combination of input sources and
realistic logo areas. Lowering the band value from 4 to 1 resulted in
8 to 39 % less interpolation error per frame (or 1 to 34 % less
interpolation error per luma sample.)

Signed-off-by: Jean Delvare 
---
Changes since v1:
 * Added #ifs so that the deprecated options are dropped automatically
   on next major version of libavfilter (suggested by Stefano Sabatini)

 doc/filters.texi|4 +++-
 libavfilter/vf_delogo.c |   17 +++--
 2 files changed, 18 insertions(+), 3 deletions(-)

--- ffmpeg.orig/doc/filters.texi2015-10-02 11:41:24.035943770 +0200
+++ ffmpeg/doc/filters.texi 2015-10-02 12:02:08.231484828 +0200
@@ -4590,7 +4590,9 @@ specified.
 
 @item band, t
 Specify the thickness of the fuzzy edge of the rectangle (added to
-@var{w} and @var{h}). The default value is 4.
+@var{w} and @var{h}). The default value is 1. This option is
+deprecated, setting higher values should no longer be necessary and
+is not recommended.
 
 @item show
 When set to 1, a green rectangle is drawn on the screen to simplify
--- ffmpeg.orig/libavfilter/vf_delogo.c 2015-10-02 11:41:24.035943770 +0200
+++ ffmpeg/libavfilter/vf_delogo.c  2015-10-07 14:56:43.521386501 +0200
@@ -165,8 +165,11 @@ static const AVOption delogo_options[]=
 { "y","set logo y position",   OFFSET(y),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "w","set logo width",OFFSET(w),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
 { "h","set logo height",   OFFSET(h),AV_OPT_TYPE_INT, { 
.i64 = -1 }, -1, INT_MAX, FLAGS },
-{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  4 },  1, INT_MAX, FLAGS },
-{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  4 },  1, INT_MAX, FLAGS },
+#if LIBAVFILTER_VERSION_MAJOR < 7
+/* Actual default value for band/t is 1, set in init */
+{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
+{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
+#endif
 { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
.i64 =  0 },  0, 1,   FLAGS },
 { NULL }
 };
@@ -201,6 +204,16 @@ static av_cold int init(AVFilterContext
 CHECK_UNSET_OPT(w);
 CHECK_UNSET_OPT(h);
 
+#if LIBAVFILTER_VERSION_MAJOR < 7
+if (s->band == 0) { /* Unset, use default */
+av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed from 
4 to 1.\n");
+s->band = 1;
+} else if (s->band != 1) {
+av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
+}
+#else
+s->band = 1;
+#endif
 av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
s->x, s->y, s->w, s->h, s->band, s->show);
 


-- 
Jean Delvare
SUSE L3 Support
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCHv2] avfilter/buffersrc: add av_warn_unused_result attributes

2015-10-07 Thread Clément Bœsch
On Tue, Oct 06, 2015 at 06:53:47PM -0400, Ganesh Ajjanagadde wrote:
> This adds av_warn_unused_result whenever it is relevant.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavfilter/buffersrc.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
> index cd3d95f..847c093 100644
> --- a/libavfilter/buffersrc.h
> +++ b/libavfilter/buffersrc.h
> @@ -78,6 +78,7 @@ unsigned 
> av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
>   * This function is equivalent to av_buffersrc_add_frame_flags() with the
>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
>   */
> +av_warn_unused_result
>  int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
>  
>  /**
> @@ -98,6 +99,7 @@ int av_buffersrc_write_frame(AVFilterContext *ctx, const 
> AVFrame *frame);
>   * This function is equivalent to av_buffersrc_add_frame_flags() without the
>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
>   */
> +av_warn_unused_result
>  int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
>  
>  /**
> @@ -115,6 +117,7 @@ int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame 
> *frame);
>   * @return>= 0 in case of success, a negative AVERROR code
>   *in case of failure
>   */
> +av_warn_unused_result
>  int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
>   AVFrame *frame, int flags);
>  

Aren't you just supposed to (void)-prefix the call in the caller when you
explicitly don't care about the result?

These functions certainly looks like you actually want to check for the
result most of the time.

-- 
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 1/2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 8:56 AM, Michael Niedermayer
 wrote:
> On Sat, Sep 19, 2015 at 01:00:17AM -0400, Ganesh Ajjanagadde wrote:
>> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
>> The concept of av_uninit is inherently useful though. This patch silences a
>> bunch of warnings on clang e.g
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
>> Furthermore, it should be useful for general usage of av_uninit in future.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavutil/attributes.h | 6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
>> index 50e8eb3..b4b5f13 100644
>> --- a/libavutil/attributes.h
>> +++ b/libavutil/attributes.h
>> @@ -141,6 +141,12 @@
>>
>>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>>  #define av_uninit(x) x=x
>> +#elif defined(__clang__)
>> +#define av_uninit(x) \
>> +_Pragma("clang diagnostic push") \
>> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
>> +x=x \
>> +_Pragma("clang diagnostic pop")
>>  #else
>
> this fails with clang version 3.1 (trunk 144800)
>
> AR  libavdevice/libavdevice.a
> CC  libavfilter/af_aecho.o
> In file included from libavfilter/af_aecho.c:1:
> libavfilter/af_aecho.c:226:315: error: expected identifier or '('
> static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t **delayptrs, 
> uint8_t * const *src, uint8_t **dst, int nb_samples, int channels) { const 
> double out_gain = ctx->out_gain; const double in_gain = ctx->in_gain; const 
> int nb_echoes = ctx->nb_echoes; const int max_samples = ctx->max_samples; int 
> i, j, chan,#pragma clang diagnostic push#pragma clang diagnostic ignored 
> "-Wuninitialized" index=index#pragma clang diagnostic pop; ((void)0); for 
> (chan = 0; chan < channels; chan++) { const double *s = (double *)src[chan]; 
> double *d = (double *)dst[chan]; double *dbuf = (double *)delayptrs[chan]; 
> index = ctx->delay_index; for (i = 0; i < nb_samples; i++, s++, d++) { double 
> out, in; in = *s; out = in * in_gain; for (j = 0; j < nb_echoes; j++) { int 
> ix = index + max_samples - ctx->samples[j]; ix = (((ix) >= (max_samples)) ? 
> (ix) - (max_samples) : (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= 
> out_gain; *d = av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index 
> + 1) >= (max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } } 
> ctx->delay_index = index; }
>   
>   
>   
>   
>   ^
> ...
>
> [...]

Thanks for checking this. Guess I need to find out which clang version
introduced this and accordingly enable.

>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When you are offended at any man's fault, turn to yourself and study your
> own failings. Then you will forget your anger. -- Epictetus
>
> ___
> 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/alac: also use a temp buffer for 24bit samples

2015-10-07 Thread wm4
On Tue, 6 Oct 2015 20:13:58 -0300
James Almer  wrote:

> On 10/6/2015 5:33 PM, Paul B Mahol wrote:
> > you set aligned number of samples before calling get_buffer and after
> > that changes
> > frame->nb_samples to actual number of samples.
> > 
> > Alternatively IIRC default 16 byte alignment could be increased.
> 
> Nevermind, looks like avframe does pad the buffer after all, so patch
> dropped.

AFAIK this actually depends on the get_buffer2 implementation?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avcodec/mips: build fix for MSA 64bit

2015-10-07 Thread shivraj.patil
From: Shivraj Patil 

Modified datatype of function argument (pitch from int32_t to ptrdiff_t)

Signed-off-by: Shivraj Patil 
---
 libavcodec/mips/vp9_lpf_msa.c |   42 -
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavcodec/mips/vp9_lpf_msa.c b/libavcodec/mips/vp9_lpf_msa.c
index 63e538e..eef8afc 100644
--- a/libavcodec/mips/vp9_lpf_msa.c
+++ b/libavcodec/mips/vp9_lpf_msa.c
@@ -259,7 +259,7 @@
 mask_out = __msa_xori_b(mask_out, 0xff);   \
 }
 
-void ff_loop_filter_v_4_8_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_4_8_msa(uint8_t *src, ptrdiff_t pitch,
   int32_t b_limit_ptr,
   int32_t limit_ptr,
   int32_t thresh_ptr)
@@ -288,7 +288,7 @@ void ff_loop_filter_v_4_8_msa(uint8_t *src, int32_t pitch,
 }
 
 
-void ff_loop_filter_v_44_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_44_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
 int32_t thresh_ptr)
@@ -318,7 +318,7 @@ void ff_loop_filter_v_44_16_msa(uint8_t *src, int32_t pitch,
 ST_UB4(p1, p0, q0, q1, (src - 2 * pitch), pitch);
 }
 
-void ff_loop_filter_v_8_8_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_8_8_msa(uint8_t *src, ptrdiff_t pitch,
   int32_t b_limit_ptr,
   int32_t limit_ptr,
   int32_t thresh_ptr)
@@ -392,7 +392,7 @@ void ff_loop_filter_v_8_8_msa(uint8_t *src, int32_t pitch,
 }
 }
 
-void ff_loop_filter_v_88_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_88_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
 int32_t thresh_ptr)
@@ -471,7 +471,7 @@ void ff_loop_filter_v_88_16_msa(uint8_t *src, int32_t pitch,
 }
 }
 
-void ff_loop_filter_v_84_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_84_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
 int32_t thresh_ptr)
@@ -542,7 +542,7 @@ void ff_loop_filter_v_84_16_msa(uint8_t *src, int32_t pitch,
 }
 }
 
-void ff_loop_filter_v_48_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_48_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
 int32_t thresh_ptr)
@@ -614,7 +614,7 @@ void ff_loop_filter_v_48_16_msa(uint8_t *src, int32_t pitch,
 }
 }
 
-static int32_t vp9_hz_lpf_t4_and_t8_16w(uint8_t *src, int32_t pitch,
+static int32_t vp9_hz_lpf_t4_and_t8_16w(uint8_t *src, ptrdiff_t pitch,
 uint8_t *filter48,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
@@ -689,7 +689,7 @@ static int32_t vp9_hz_lpf_t4_and_t8_16w(uint8_t *src, 
int32_t pitch,
 }
 }
 
-static void vp9_hz_lpf_t16_16w(uint8_t *src, int32_t pitch, uint8_t *filter48)
+static void vp9_hz_lpf_t16_16w(uint8_t *src, ptrdiff_t pitch, uint8_t 
*filter48)
 {
 v16u8 flat, flat2, filter8;
 v16i8 zero = { 0 };
@@ -1021,7 +1021,7 @@ static void vp9_hz_lpf_t16_16w(uint8_t *src, int32_t 
pitch, uint8_t *filter48)
 }
 }
 
-void ff_loop_filter_v_16_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_16_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
 int32_t limit_ptr,
 int32_t thresh_ptr)
@@ -1037,7 +1037,7 @@ void ff_loop_filter_v_16_16_msa(uint8_t *src, int32_t 
pitch,
 }
 }
 
-void ff_loop_filter_v_16_8_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_v_16_8_msa(uint8_t *src, ptrdiff_t pitch,
int32_t b_limit_ptr,
int32_t limit_ptr,
int32_t thresh_ptr)
@@ -1261,7 +1261,7 @@ void ff_loop_filter_v_16_8_msa(uint8_t *src, int32_t 
pitch,
 }
 }
 
-void ff_loop_filter_h_4_8_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_h_4_8_msa(uint8_t *src, ptrdiff_t pitch,
   int32_t b_limit_ptr,
   int32_t limit_ptr,
   int32_t thresh_ptr)
@@ -1290,7 +1290,7 @@ void ff_loop_filter_h_4_8_msa(uint8_t *src, int32_t pitch,
 ST4x4_UB(vec3, vec3, 0, 1, 2, 3, src, pitch);
 }
 
-void ff_loop_filter_h_44_16_msa(uint8_t *src, int32_t pitch,
+void ff_loop_filter_h_44_16_msa(uint8_t *src, ptrdiff_t pitch,
 int32_t b_limit_ptr,
  

Re: [FFmpeg-devel] [PATCH v2 0/8] libkvazaar improvements

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 01:33:58PM +0300, Arttu Ylä-Outinen wrote:
> On 2015-09-29 16:29, Arttu Ylä-Outinen wrote:
> >These patches fix some problems in libkvazaar encoder and update it to work
> >with the latest git version of Kvazaar. Most notable changes are setting
> >pts, dts and keyframe flag on the output packets and fixing the calculation
> >of the framerate.
> >
> >v2: Add libkvazaar version check and fix descriptions of patches
> > "libkvazaar: Fix setting target bitrate" and
> > "doc/encoders: Fix libkvazaar documentation."
> >
> >Thanks for the comments!
> >
> >Arttu Ylä-Outinen (8):
> >   libkvazaar: Update to work with the latest version
> >   configure: Add version check for libkvazaar
> >   libkvazaar: Remove unnecessary NULL checks
> >   libkvazaar: Replace asserts with proper errors
> >   libkvazaar: Set pts and dts
> >   libkvazaar: Use av_image_copy for copying pixels
> >   libkvazaar: Fix setting framerate
> >   doc/encoders: Fix libkvazaar documentation
> >
> >  configure   |2 ++
> >  doc/encoders.texi   |3 --
> >  libavcodec/libkvazaar.c |   80 
> > ++-
> >  3 files changed, 60 insertions(+), 25 deletions(-)
> >
> 
> Is it OK if I push these (with the v3 of the second patch)?

sure, you are the maintainer of the code

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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


Re: [FFmpeg-devel] [PATCHv2] avcodec/libx264: silence -Waddress

2015-10-07 Thread Ronald S. Bultje
Hi,

On Tue, Oct 6, 2015 at 10:48 PM, Ganesh Ajjanagadde 
wrote:

> This patch moves the pointer validity check outside the macro,
> and silences the -Waddress observed with GCC 5.2.
>
> Note that this changes the error message slightly, from:
> "bad option..." to "Error parsing option...".
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavcodec/libx264.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 75b5a5f..cc79250 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -399,7 +399,7 @@ static av_cold int X264_close(AVCodecContext *avctx)
>  #define OPT_STR(opt, param)
>  \
>  do {
> \
>  int ret;
> \
> -if (param && (ret = x264_param_parse(>params, opt, param)) <
> 0) { \
> +if ((ret = x264_param_parse(>params, opt, param)) < 0) { \
>  if(ret == X264_PARAM_BAD_NAME)
> \
>  av_log(avctx, AV_LOG_ERROR,
>  \
>  "bad option '%s': '%s'\n", opt, param);
>  \
> @@ -490,7 +490,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  x4->params.i_log_level  = X264_LOG_DEBUG;
>  x4->params.i_csp= convert_pix_fmt(avctx->pix_fmt);
>
> -OPT_STR("weightp", x4->wpredp);
> +PARSE_X264_OPT("weightp", wpredp);
>
>  if (avctx->bit_rate) {
>  x4->params.rc.i_bitrate   = avctx->bit_rate / 1000;
> @@ -520,7 +520,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  (float)avctx->rc_initial_buffer_occupancy /
> avctx->rc_buffer_size;
>  }
>
> -OPT_STR("level", x4->level);
> +PARSE_X264_OPT("level", level);
>
>  if (avctx->i_quant_factor > 0)
>  x4->params.rc.f_ip_factor = 1 /
> fabs(avctx->i_quant_factor);
> --
> 2.6.1


And pushed.

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


Re: [FFmpeg-devel] [PATCHv2] avfilter/buffersrc: add av_warn_unused_result attributes

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 8:59 AM, Clément Bœsch  wrote:
> On Tue, Oct 06, 2015 at 06:53:47PM -0400, Ganesh Ajjanagadde wrote:
>> This adds av_warn_unused_result whenever it is relevant.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavfilter/buffersrc.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
>> index cd3d95f..847c093 100644
>> --- a/libavfilter/buffersrc.h
>> +++ b/libavfilter/buffersrc.h
>> @@ -78,6 +78,7 @@ unsigned 
>> av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
>>   * This function is equivalent to av_buffersrc_add_frame_flags() with the
>>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
>>   */
>> +av_warn_unused_result
>>  int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
>>
>>  /**
>> @@ -98,6 +99,7 @@ int av_buffersrc_write_frame(AVFilterContext *ctx, const 
>> AVFrame *frame);
>>   * This function is equivalent to av_buffersrc_add_frame_flags() without the
>>   * AV_BUFFERSRC_FLAG_KEEP_REF flag.
>>   */
>> +av_warn_unused_result
>>  int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
>>
>>  /**
>> @@ -115,6 +117,7 @@ int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame 
>> *frame);
>>   * @return>= 0 in case of success, a negative AVERROR code
>>   *in case of failure
>>   */
>> +av_warn_unused_result
>>  int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
>>   AVFrame *frame, int flags);
>>
>
> Aren't you just supposed to (void)-prefix the call in the caller when you
> explicitly don't care about the result?
>
> These functions certainly looks like you actually want to check for the
> result most of the time.

Exactly - this addition to the declaration in the header will trigger
a warning whenever this function is used without obtaining the return
value.

>
> --
> Clément B.
>
> ___
> 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 2/2] avcodec/mips: build fix for MSA 64bit

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 06:21:59PM +0530, shivraj.pa...@imgtec.com wrote:
> From: Shivraj Patil 
> 
> Modified datatype of function argument (pitch from int32_t to ptrdiff_t)
> 
> Signed-off-by: Shivraj Patil 
> ---
>  libavcodec/mips/vp9_lpf_msa.c |   42 
> -
>  1 file changed, 21 insertions(+), 21 deletions(-)

applied

thanks

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

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


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


[FFmpeg-devel] [PATCH] libavcodec/qsv.c: Re-design session control and internal allocation

2015-10-07 Thread Ivan Uskov
Hello All,

The attached patch represents new design for qsv session control and internal
allocation.  All qsv modules now uses instance of AVQSVContext so now session
allocates by external application and session allocates internally by ffmpeg
itself handles by unified way.
For  the  case  of  internal  session  allocation  now one global instance of
AVQSVContext   creates,   I.e. one common session uses for all qsv components
in  processing  chain   (decoder,   vpp,  encoder).   This   opens  a  way to
implement a complex video processing into the GPU without system memory using.

-- 
Best regards,
 Ivan  mailto:ivan.us...@nablet.com

0001-libavcodec-qsv.c-Re-design-session-control-and-inter.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] vp9: add 12bpp sse2 versions of iadst4.

2015-10-07 Thread Henrik Gramner
On Wed, Oct 7, 2015 at 3:59 AM, Ronald S. Bultje  wrote:
> diff --git a/libavcodec/x86/vp9itxfm_16bpp.asm 
> b/libavcodec/x86/vp9itxfm_16bpp.asm

> +%macro IADST4_12BPP_1D 0
> +pandm4, m0, [pd_3fff]
> +pandm5, m1, [pd_3fff]
> +psrad   m0, 14
> +psrad   m1, 14
> +packssdwm5, m1
> +packssdwm4, m0
> +punpckhwd   m1, m4, m5
> +punpcklwd   m4, m5
> +pandm5, m2, [pd_3fff]
> +pandm6, m3, [pd_3fff]

mova m6, [pd_3fff]

> +pmaddwd m7, m5, [pw_15212_9929]
> +pmaddwd m6, m4, [pw_5283_13377]
> +pmaddwd m2, m3, [pw_15212_9929]
> +pmaddwd m0, m1, [pw_5283_13377]

mova m2, [pw_15212_9929]
mova m0, [pw_5283_13377]

> +pmaddwd m7, m5, [pw_m13377_13377]
> +pmaddwd m2, m4, [pw_13377_0]
> +pmaddwd m8, m3, [pw_m13377_13377]
> +pmaddwd m9, m1, [pw_13377_0]

mova m8, [pw_m13377_13377]
mova m9, [pw_13377_0]

> +pmaddwd m7, m5, [pw_m5283_m15212]
> +pmaddwd m6, m4, [pw_9929_13377]
> +pmaddwd m8, m3, [pw_m5283_m15212]
> +pmaddwd m9, m1, [pw_9929_13377]

mova m8, [pw_m5283_m15212]
mova m9, [pw_9929_13377]

> +%macro IADST4_12BPP_FN 4
> +INIT_XMM sse2

I'd use INIT_* when invoking the macro instead unless there's a reason not to

> +cglobal vp9_%1_%3_4x4_add_12, 3, 3, 10, dst, stride, block, eob
[...]
> +paddd   m0, [pd_8]
> +paddd   m1, [pd_8]
> +paddd   m2, [pd_8]
> +paddd   m3, [pd_8]
> +psrad   m0, 4
> +psrad   m1, 4
> +psrad   m2, 4
> +psrad   m3, 4

Store [pd_8] in a register.

In general SIMD code is usually not load-bound (and modern CPUs has
two load units) so having redundant loads of the same value multiple
times is fine, but it's often a good idea to only do a single load to
a register when doing so reduces code size.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavcodec/qsv.c: Re-design session control and internal allocation

2015-10-07 Thread Hendrik Leppkes
On Wed, Oct 7, 2015 at 4:41 PM, Ivan Uskov  wrote:
> Hello All,
>
> The attached patch represents new design for qsv session control and internal
> allocation.  All qsv modules now uses instance of AVQSVContext so now session
> allocates by external application and session allocates internally by ffmpeg
> itself handles by unified way.
> For  the  case  of  internal  session  allocation  now one global instance of
> AVQSVContext   creates,   I.e. one common session uses for all qsv components
> in  processing  chain   (decoder,   vpp,  encoder).   This   opens  a  way to
> implement a complex video processing into the GPU without system memory using.
>
> index 4c8e6b0..6ced294 100644
>--- a/libavcodec/qsv.c
>+++ b/libavcodec/qsv.c
>@@ -30,6 +30,8 @@
> #include "avcodec.h"
> #include "qsv_internal.h"
>
>+static AVQSVContext* g_av_qsv = NULL;
>+
> int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
> {

Global static variables are not acceptable, sorry.
You'll have to find another way to solve your problem, but global
state is not the way to go.

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mips: build fix for MSA

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 06:20:53PM +0530, shivraj.pa...@imgtec.com wrote:
> From: Shivraj Patil 
> 
> Modified sps and pps access from old HEVCContext(s) structure to newly 
> introduced HEVCParamSets(ps)
> 
> Signed-off-by: Shivraj Patil 
> ---
>  libavcodec/mips/hevcpred_msa.c |  282 
> 
>  1 file changed, 141 insertions(+), 141 deletions(-)

applied

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH 01/15] lavfi/af_aresample: remove looping on request_frame().

2015-10-07 Thread Nicolas George
Le tridi 13 vendémiaire, an CCXXIV, Michael Niedermayer a écrit :
> whole patchset should be ok

Thanks. Warnings fixed (sorry about that) and series pushed.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] w32pthreads: add pthread_once emulation

2015-10-07 Thread Hendrik Leppkes
On Wed, Oct 7, 2015 at 7:06 PM, Matt Oliver  wrote:
> On 8 October 2015 at 03:29, Hendrik Leppkes  wrote:
>
>> On Wed, Oct 7, 2015 at 6:23 PM, Matt Oliver  wrote:
>> > On 6 October 2015 at 21:36, Hendrik Leppkes  wrote:
>> >
>> >> The emulation uses native InitOnce* APIs on Windows Vista+, and a
>> >> lock-free/allocation-free approach using atomics and spinning for
>> Windows
>> >> XP.
>> >> ---
>> >>
>> >> This is in preparation to use pthread_once for global static init
>> >> functions,
>> >> and eventually removing the global lock in avcodec_open2
>> >>
>> >> compat/w32pthreads.h | 68
>> >> 
>> >>  1 file changed, 68 insertions(+)
>> >>
>> >> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
>> >> index deb1c53..8523976 100644
>> >> --- a/compat/w32pthreads.h
>> >> +++ b/compat/w32pthreads.h
>> >> @@ -154,6 +154,19 @@ static inline int
>> pthread_cond_signal(pthread_cond_t
>> >> *cond)
>> >>  return 0;
>> >>  }
>> >>
>> >> +typedef INIT_ONCE pthread_once_t;
>> >> +#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
>> >> +
>> >> +static av_unused int pthread_once(pthread_once_t *once_control, void
>> >> (*init_routine)(void))
>> >> +{
>> >> +BOOL pending = FALSE;
>> >> +InitOnceBeginInitialize(once_control, 0, , NULL);
>> >> +if (pending)
>> >> +init_routine();
>> >> +InitOnceComplete(once_control, 0, NULL);
>> >> +return 0;
>> >> +}
>> >> +
>> >>  #else // _WIN32_WINNT < 0x0600
>> >>  /* for pre-Windows 6.0 platforms we need to define and use our own
>> >> condition
>> >>   * variable and api */
>> >> @@ -304,6 +317,57 @@ static av_unused int
>> >> pthread_cond_signal(pthread_cond_t *cond)
>> >>  pthread_mutex_unlock(_cond->mtx_broadcast);
>> >>  return 0;
>> >>  }
>> >> +
>> >> +/* for pre-Windows 6.0 platforms, define INIT_ONCE struct,
>> >> + * compatible to the one used in the native API */
>> >> +
>> >> +typedef union pthread_once_t  {
>> >> +void * Ptr;///< For the Windows 6.0+ native functions
>> >> +LONG state;///< For the pre-Windows 6.0 compat code
>> >> +} pthread_once_t;
>> >> +
>> >> +#define PTHREAD_ONCE_INIT {0}
>> >> +
>> >> +/* function pointers to init once API on windows 6.0+ kernels */
>> >> +static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD
>> >> dwFlags, BOOL *fPending, void **lpContext);
>> >> +static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce,
>> DWORD
>> >> dwFlags, void *lpContext);
>> >> +
>> >> +static av_unused int pthread_once(pthread_once_t *once_control, void
>> >> (*init_routine)(void))
>> >> +{
>> >> +/* Use native functions on Windows 6.0+ */
>> >> +if (initonce_begin && initonce_complete)
>> >> +{
>> >> +BOOL pending = FALSE;
>> >> +initonce_begin(once_control, 0, , NULL);
>> >> +if (pending)
>> >> +init_routine();
>> >> +initonce_complete(once_control, 0, NULL);
>> >> +return 0;
>> >> +}
>> >> +
>> >> +/* pre-Windows 6.0 compat using a spin-lock */
>> >> +switch (InterlockedCompareExchange(_control->state, 1, 0))
>> >> +{
>> >> +/* Initial run */
>> >> +case 0:
>> >> +init_routine();
>> >> +InterlockedExchange(_control->state, 2);
>> >> +break;
>> >> +/* Another thread is running init */
>> >> +case 1:
>> >> +while (1) {
>> >> +MemoryBarrier();
>> >> +if (once_control->state == 2)
>> >> +break;
>> >> +Sleep(0);
>> >> +}
>> >> +break;
>> >> +/* Initialization complete */
>> >> +case 2:
>> >> +break;
>> >> +}
>> >> +return 0;
>> >> +}
>> >>  #endif
>> >>
>> >>  static av_unused void w32thread_init(void)
>> >> @@ -319,6 +383,10 @@ static av_unused void w32thread_init(void)
>> >>  (void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
>> >>  cond_wait  =
>> >>  (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
>> >> +initonce_begin =
>> >> +(void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize");
>> >> +initonce_complete =
>> >> +(void*)GetProcAddress(kernel_dll, "InitOnceComplete");
>> >>  #endif
>> >>
>> >>  }
>> >> --
>> >> 2.5.3.windows.1
>> >
>> >
>> > LGTM
>>
>> There is a new version of the patch which also solves the
>> w32thread_init mess, so this one isn't the final version anymore.
>> Current working version is here:
>> https://github.com/Nevcairiel/FFmpeg/commits/pthread_once
>>
>>
> This looks better.
> So by win32thread_init mess im assuming your referring to a need to have
> called it before hand. Given that youve added it to the only 2 functions
> that need it then doesnt that mean that win32thread_init be completely
> removed from all other code and only used locally 

[FFmpeg-devel] [PATCH 1/3] Revert "cabac: Allow hardcoding CABAC table."

2015-10-07 Thread Derek Buitenhuis
This becomes unuseful in the following commit.

This reverts commit 092d1977cc7146f20c8db2155e7d648afb300de7.

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/Makefile  |   4 +-
 libavcodec/cabac.c   |  74 -
 libavcodec/cabac.h   |   7 +--
 libavcodec/cabac_functions.h |   8 ++--
 libavcodec/cabac_tablegen.c  |  41 
 libavcodec/cabac_tablegen.h  | 108 ---
 6 files changed, 78 insertions(+), 164 deletions(-)
 delete mode 100644 libavcodec/cabac_tablegen.c
 delete mode 100644 libavcodec/cabac_tablegen.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9075077..71f66d4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -957,7 +957,6 @@ HOSTPROGS = aac_tablegen
\
 aacps_fixed_tablegen\
 aacsbr_tablegen \
 aacsbr_fixed_tablegen   \
-cabac_tablegen  \
 cbrt_tablegen   \
 cbrt_fixed_tablegen \
 cos_tablegen\
@@ -987,7 +986,7 @@ else
 $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
 endif
 
-GEN_HEADERS = cabac_tables.h cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h 
aacps_fixed_tables.h aacsbr_tables.h \
+GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h 
aacps_fixed_tables.h aacsbr_tables.h \
   aacsbr_fixed_tables.h aac_tables.h dsd_tables.h dv_tables.h \
   sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h 
motionpixels_tables.h \
   pcm_tables.h qdm2_tables.h
@@ -1005,7 +1004,6 @@ $(SUBDIR)aacsbr.o: $(SUBDIR)aacsbr_tables.h
 $(SUBDIR)aacsbr_fixed.o: $(SUBDIR)aacsbr_fixed_tables.h
 $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h
 $(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h
-$(SUBDIR)cabac.o: $(SUBDIR)cabac_tables.h
 $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h
 $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
 $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 8cc9333..bc0d8ac 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -32,7 +32,55 @@
 #include "cabac.h"
 #include "cabac_functions.h"
 
-#include "cabac_tablegen.h"
+uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
+
+static const uint8_t lps_range[64][4]= {
+{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
+{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
+{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
+{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
+{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
+{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
+{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
+{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
+{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
+{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
+{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
+{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
+{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
+{ 10, 12, 14, 16}, {  9, 11, 13, 15}, {  9, 11, 12, 14}, {  8, 10, 12, 14},
+{  8,  9, 11, 13}, {  7,  9, 11, 12}, {  7,  9, 10, 12}, {  7,  8, 10, 11},
+{  6,  8,  9, 11}, {  6,  7,  9, 10}, {  6,  7,  8,  9}, {  2,  2,  2,  2},
+};
+
+static const uint8_t mps_state[64]= {
+  1, 2, 3, 4, 5, 6, 7, 8,
+  9,10,11,12,13,14,15,16,
+ 17,18,19,20,21,22,23,24,
+ 25,26,27,28,29,30,31,32,
+ 33,34,35,36,37,38,39,40,
+ 41,42,43,44,45,46,47,48,
+ 49,50,51,52,53,54,55,56,
+ 57,58,59,60,61,62,62,63,
+};
+
+static const uint8_t lps_state[64]= {
+  0, 0, 1, 2, 2, 4, 4, 5,
+  6, 7, 8, 9, 9,11,11,12,
+ 13,13,15,15,16,16,18,18,
+ 19,19,21,21,22,22,23,24,
+ 24,25,26,26,27,27,28,29,
+ 29,30,30,30,31,32,32,33,
+ 33,33,34,34,35,35,35,36,
+ 36,36,37,37,37,38,38,63,
+};
+
+static const uint8_t last_coeff_flag_offset_8x8[63] = {
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
+};
 
 /**
  *
@@ -68,12 +116,34 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t 
*buf, int buf_size){
 
 void ff_init_cabac_states(void)
 {
+int i, j;
 static int initialized = 0;
 
 if (initialized)
 return;
 
-cabac_tableinit();
+for (i = 0; i < 512; i++)
+

Re: [FFmpeg-devel] [PATCH 3/3] h264: Run VLC init under pthread_once

2015-10-07 Thread wm4
On Wed,  7 Oct 2015 11:39:47 -0400
Derek Buitenhuis  wrote:

> This makes the h.264 decoder threadsafe to initialize.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavcodec/h264.c |  7 ++-
>  libavcodec/h264.h | 10 ++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 3209c9c..27a1d32 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -657,7 +657,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
>  if (!avctx->has_b_frames)
>  h->low_delay = 1;
>  
> -ff_h264_decode_init_vlc();
> +ret = pthread_once(_h264_vlc_init, _h264_decode_init_vlc);
> +if (ret != 0) {
> +av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
> +return AVERROR_UNKNOWN;
> +}
>  
>  if (avctx->codec_id == AV_CODEC_ID_H264) {
>  if (avctx->ticks_per_frame == 1) {
> @@ -1993,6 +1997,7 @@ AVCodec ff_h264_decoder = {
>  .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
> AV_CODEC_CAP_DR1 |
>   AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS 
> |
>   AV_CODEC_CAP_FRAME_THREADS,
> +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
>  .flush = flush_dpb,
>  .init_thread_copy  = 
> ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
>  .update_thread_context = 
> ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index 769abda..c5119f9 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -43,6 +43,14 @@
>  #include "rectangle.h"
>  #include "videodsp.h"
>  
> +#if HAVE_PTHREADS
> +#   include 
> +#elif HAVE_OS2THREADS
> +#   include "compat/os2threads.h"
> +#elif HAVE_W32THREADS
> +#   include "compat/w32pthreads.h"
> +#endif
> +
>  #define H264_MAX_PICTURE_COUNT 36
>  #define H264_MAX_THREADS   32
>  
> @@ -931,6 +939,8 @@ int ff_h264_check_intra_pred_mode(const H264Context *h, 
> H264SliceContext *sl,
>  void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
>  int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size);
>  int ff_h264_decode_init(AVCodecContext *avctx);
> +
> +static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;
>  void ff_h264_decode_init_vlc(void);
>  
>  /**

A static variable in a header file? This doesn't look right. You should
define it in h264.c instead.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] h264: Run VLC init under pthread_once

2015-10-07 Thread Derek Buitenhuis
On 10/7/2015 5:05 PM, Matt Oliver wrote:
> Couldnt all the above if/includes be simplified by just using a single
> include libavutil/thread.h (which has all the above checks in it.

So, I included "thread.h", which is from avcodec, and it failed. I think it's
pretty non-obvious I need the thread.h from libavutil.

I based this off of vp8.h, which has this exact block of code.

We can fix this before or after.

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


Re: [FFmpeg-devel] [PATCH] w32pthreads: add pthread_once emulation

2015-10-07 Thread Matt Oliver
On 6 October 2015 at 21:36, Hendrik Leppkes  wrote:

> The emulation uses native InitOnce* APIs on Windows Vista+, and a
> lock-free/allocation-free approach using atomics and spinning for Windows
> XP.
> ---
>
> This is in preparation to use pthread_once for global static init
> functions,
> and eventually removing the global lock in avcodec_open2
>
> compat/w32pthreads.h | 68
> 
>  1 file changed, 68 insertions(+)
>
> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> index deb1c53..8523976 100644
> --- a/compat/w32pthreads.h
> +++ b/compat/w32pthreads.h
> @@ -154,6 +154,19 @@ static inline int pthread_cond_signal(pthread_cond_t
> *cond)
>  return 0;
>  }
>
> +typedef INIT_ONCE pthread_once_t;
> +#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
> +
> +static av_unused int pthread_once(pthread_once_t *once_control, void
> (*init_routine)(void))
> +{
> +BOOL pending = FALSE;
> +InitOnceBeginInitialize(once_control, 0, , NULL);
> +if (pending)
> +init_routine();
> +InitOnceComplete(once_control, 0, NULL);
> +return 0;
> +}
> +
>  #else // _WIN32_WINNT < 0x0600
>  /* for pre-Windows 6.0 platforms we need to define and use our own
> condition
>   * variable and api */
> @@ -304,6 +317,57 @@ static av_unused int
> pthread_cond_signal(pthread_cond_t *cond)
>  pthread_mutex_unlock(_cond->mtx_broadcast);
>  return 0;
>  }
> +
> +/* for pre-Windows 6.0 platforms, define INIT_ONCE struct,
> + * compatible to the one used in the native API */
> +
> +typedef union pthread_once_t  {
> +void * Ptr;///< For the Windows 6.0+ native functions
> +LONG state;///< For the pre-Windows 6.0 compat code
> +} pthread_once_t;
> +
> +#define PTHREAD_ONCE_INIT {0}
> +
> +/* function pointers to init once API on windows 6.0+ kernels */
> +static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD
> dwFlags, BOOL *fPending, void **lpContext);
> +static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD
> dwFlags, void *lpContext);
> +
> +static av_unused int pthread_once(pthread_once_t *once_control, void
> (*init_routine)(void))
> +{
> +/* Use native functions on Windows 6.0+ */
> +if (initonce_begin && initonce_complete)
> +{
> +BOOL pending = FALSE;
> +initonce_begin(once_control, 0, , NULL);
> +if (pending)
> +init_routine();
> +initonce_complete(once_control, 0, NULL);
> +return 0;
> +}
> +
> +/* pre-Windows 6.0 compat using a spin-lock */
> +switch (InterlockedCompareExchange(_control->state, 1, 0))
> +{
> +/* Initial run */
> +case 0:
> +init_routine();
> +InterlockedExchange(_control->state, 2);
> +break;
> +/* Another thread is running init */
> +case 1:
> +while (1) {
> +MemoryBarrier();
> +if (once_control->state == 2)
> +break;
> +Sleep(0);
> +}
> +break;
> +/* Initialization complete */
> +case 2:
> +break;
> +}
> +return 0;
> +}
>  #endif
>
>  static av_unused void w32thread_init(void)
> @@ -319,6 +383,10 @@ static av_unused void w32thread_init(void)
>  (void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
>  cond_wait  =
>  (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
> +initonce_begin =
> +(void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize");
> +initonce_complete =
> +(void*)GetProcAddress(kernel_dll, "InitOnceComplete");
>  #endif
>
>  }
> --
> 2.5.3.windows.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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


[FFmpeg-devel] [PATCH 3/3 v2] h264: Run VLC init under pthread_once

2015-10-07 Thread Derek Buitenhuis
This makes the h.264 decoder threadsafe to initialize.

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/h264.c | 9 -
 libavcodec/h264.h | 7 +++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 3209c9c..1abdc4b 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -644,6 +644,8 @@ static int h264_init_context(AVCodecContext *avctx, 
H264Context *h)
 return 0;
 }
 
+static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;
+
 av_cold int ff_h264_decode_init(AVCodecContext *avctx)
 {
 H264Context *h = avctx->priv_data;
@@ -657,7 +659,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
 if (!avctx->has_b_frames)
 h->low_delay = 1;
 
-ff_h264_decode_init_vlc();
+ret = pthread_once(_h264_vlc_init, _h264_decode_init_vlc);
+if (ret != 0) {
+av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
+return AVERROR_UNKNOWN;
+}
 
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 if (avctx->ticks_per_frame == 1) {
@@ -1993,6 +1999,7 @@ AVCodec ff_h264_decoder = {
 .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
  AV_CODEC_CAP_FRAME_THREADS,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 .flush = flush_dpb,
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 769abda..f8a58a6 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -29,6 +29,7 @@
 #define AVCODEC_H264_H
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "cabac.h"
 #include "error_resilience.h"
 #include "get_bits.h"
@@ -43,6 +44,12 @@
 #include "rectangle.h"
 #include "videodsp.h"
 
+#if HAVE_PTHREADS
+#   include 
+#elif HAVE_W32THREADS
+#   include "compat/w32pthreads.h"
+#endif
+
 #define H264_MAX_PICTURE_COUNT 36
 #define H264_MAX_THREADS   32
 
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH 2/3] cabac: Make cabac starts hardcoded

2015-10-07 Thread Derek Buitenhuis
From: Anton Khirnov 

There's not much reason to generate such a small table at runtime.

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/cabac.c   | 207 ++-
 libavcodec/cabac.h   |   3 +-
 libavcodec/cabac_functions.h |   8 +-
 libavcodec/h264.c|   2 -
 libavcodec/hevc.c|   2 -
 5 files changed, 129 insertions(+), 93 deletions(-)

diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index bc0d8ac..598c942 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -32,54 +32,130 @@
 #include "cabac.h"
 #include "cabac_functions.h"
 
-uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
-
-static const uint8_t lps_range[64][4]= {
-{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
-{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
-{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
-{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
-{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
-{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
-{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
-{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
-{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
-{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
-{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
-{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
-{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
-{ 10, 12, 14, 16}, {  9, 11, 13, 15}, {  9, 11, 12, 14}, {  8, 10, 12, 14},
-{  8,  9, 11, 13}, {  7,  9, 11, 12}, {  7,  9, 10, 12}, {  7,  8, 10, 11},
-{  6,  8,  9, 11}, {  6,  7,  9, 10}, {  6,  7,  8,  9}, {  2,  2,  2,  2},
-};
-
-static const uint8_t mps_state[64]= {
-  1, 2, 3, 4, 5, 6, 7, 8,
-  9,10,11,12,13,14,15,16,
- 17,18,19,20,21,22,23,24,
- 25,26,27,28,29,30,31,32,
- 33,34,35,36,37,38,39,40,
- 41,42,43,44,45,46,47,48,
- 49,50,51,52,53,54,55,56,
- 57,58,59,60,61,62,62,63,
-};
-
-static const uint8_t lps_state[64]= {
-  0, 0, 1, 2, 2, 4, 4, 5,
-  6, 7, 8, 9, 9,11,11,12,
- 13,13,15,15,16,16,18,18,
- 19,19,21,21,22,22,23,24,
- 24,25,26,26,27,27,28,29,
- 29,30,30,30,31,32,32,33,
- 33,33,34,34,35,35,35,36,
- 36,36,37,37,37,38,38,63,
-};
-
-static const uint8_t last_coeff_flag_offset_8x8[63] = {
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
+const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63] = {
+9,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5,
+4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+// LPS range
+-128,-128,-128,-128,-128,-128,123, 123,
+116, 116, 111, 111, 105, 105, 100, 100,
+95,  95,  90,  90,  85,  85,  81,  81,
+77,  77,  73,  73,  69,  69,  66,  66,
+62,  62,  59,  59,  56,  56,  53,  53,
+51,  51,  48,  48,  46,  46,  43,  43,
+41,  41,  39,  39,  37,  37,  35,  35,
+33,  33,  32,  32,  30,  30,  29,  29,
+27,  27,  26,  26,  24,  24,  23,  23,
+22,  22,  21,  21,  20,  20,  19,  19,
+18,  18,  17,  17,  16,  16,  15,  15,
+14,  14,  14,  14,  13,  13,  12,  12,
+12,  12,  11,  11,  11,  11,  10,  10,
+10,  10,  9,   9,   9,   

[FFmpeg-devel] [PATCH] vp9: add 10/12bpp sse2 SIMD for idct_idct_8x8.

2015-10-07 Thread Ronald S. Bultje
---
 libavcodec/x86/vp9dsp_init_16bpp_template.c |   4 +-
 libavcodec/x86/vp9itxfm_16bpp.asm   | 299 +---
 2 files changed, 234 insertions(+), 69 deletions(-)

diff --git a/libavcodec/x86/vp9dsp_init_16bpp_template.c 
b/libavcodec/x86/vp9dsp_init_16bpp_template.c
index 13f2f39..6c8b0b1 100644
--- a/libavcodec/x86/vp9dsp_init_16bpp_template.c
+++ b/libavcodec/x86/vp9dsp_init_16bpp_template.c
@@ -134,6 +134,7 @@ decl_itxfm_func(idct,  idct,  4, BPC, sse2);
 decl_itxfm_func(idct,  iadst, 4, BPC, sse2);
 decl_itxfm_func(iadst, idct,  4, BPC, sse2);
 decl_itxfm_func(iadst, iadst, 4, BPC, sse2);
+decl_itxfm_func(idct, idct, 8, BPC, sse2);
 #endif /* HAVE_YASM */
 
 av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
@@ -168,7 +169,7 @@ av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
 
 #define init_itx_func(idxa, idxb, typea, typeb, size, bpp, opt) \
 dsp->itxfm_add[idxa][idxb] = \
-ff_vp9_##typea##_##typeb##_##size##x##size##_add_##bpp##_##opt;
+cat(ff_vp9_##typea##_##typeb##_##size##x##size##_add_, bpp, _##opt);
 #define init_itx_func_one(idx, typea, typeb, size, bpp, opt) \
 init_itx_func(idx, DCT_DCT,   typea, typeb, size, bpp, opt); \
 init_itx_func(idx, ADST_DCT,  typea, typeb, size, bpp, opt); \
@@ -204,6 +205,7 @@ av_cold void INIT_FUNC(VP9DSPContext *dsp, int bitexact)
 #else
 init_itx_funcs(TX_4X4, 4, 12, sse2);
 #endif
+init_itx_func(TX_8X8, DCT_DCT, idct, idct, 8, BPC, sse2);
 }
 
 if (EXTERNAL_SSSE3(cpu_flags)) {
diff --git a/libavcodec/x86/vp9itxfm_16bpp.asm 
b/libavcodec/x86/vp9itxfm_16bpp.asm
index c7bf6dd..1c58caa 100644
--- a/libavcodec/x86/vp9itxfm_16bpp.asm
+++ b/libavcodec/x86/vp9itxfm_16bpp.asm
@@ -32,6 +32,7 @@ cextern pw_4095
 cextern pd_8192
 
 pd_8: times 4 dd 8
+pd_16: times 4 dd 16
 pd_3fff: times 4 dd 0x3fff
 
 ; FIXME these should probably be shared between 8bpp and 10/12bpp
@@ -51,6 +52,11 @@ pw_m13377_13377: times 4 dw -13377, 13377
 pw_13377_0: times 4 dw 13377, 0
 pw_9929_m5283: times 4 dw 9929, -5283
 
+pw_3196_16069: times 4 dw 3196, 16069
+pw_m16069_3196: times 4 dw -16069, 3196
+pw_13623_9102: times 4 dw 13623, 9102
+pw_m9102_13623: times 4 dw -9102, 13623
+
 SECTION .text
 
 %macro VP9_STORE_2X 6-7 dstq ; reg1, reg2, tmp1, tmp2, min, max, dst
@@ -303,12 +309,43 @@ IADST4_FN iadst, IADST4, iadst, IADST4
 paddd  m%2, m%4
 %endmacro
 
-%macro IDCT4_12BPP_1D 0
-SUMSUB_MUL   0, 2, 4, 5, 11585, 11585
-SUMSUB_MUL   1, 3, 4, 5, 15137,  6270
-SUMSUB_BA d, 1, 0, 4
-SUMSUB_BA d, 3, 2, 4
-SWAP 1, 3, 0
+%macro IDCT4_12BPP_1D 0-6 0, 1, 2, 3, 4, 5
+SUMSUB_MUL  %1, %3, %5, %6, 11585, 11585
+SUMSUB_MUL  %2, %4, %5, %6, 15137,  6270
+SUMSUB_BAd, %2, %1, %5
+SUMSUB_BAd, %4, %3, %5
+SWAP%2, %4, %1
+%endmacro
+
+%macro STORE_4x4 6 ; tmp1-2, reg1-2, min, max
+movh   m%1, [dstq+strideq*0]
+movh   m%2, [dstq+strideq*2]
+movhps m%1, [dstq+strideq*1]
+movhps m%2, [dstq+stride3q ]
+paddw  m%1, m%3
+paddw  m%2, m%4
+pmaxsw m%1, %5
+pmaxsw m%2, %5
+pminsw m%1, %6
+pminsw m%2, %6
+movh   [dstq+strideq*0], m%1
+movhps [dstq+strideq*1], m%1
+movh   [dstq+strideq*2], m%2
+movhps [dstq+stride3q ], m%2
+%endmacro
+
+%macro ROUND_AND_STORE_4x4 8 ; reg1-4, min, max, rnd, shift
+paddd  m%1, %7
+paddd  m%2, %7
+paddd  m%3, %7
+paddd  m%4, %7
+psrad  m%1, %8
+psrad  m%2, %8
+psrad  m%3, %8
+psrad  m%4, %8
+packssdw   m%1, m%2
+packssdw   m%3, m%4
+STORE_4x4   %2, %4, %1, %3, %5, %6
 %endmacro
 
 INIT_XMM sse2
@@ -337,20 +374,7 @@ cglobal vp9_idct_idct_4x4_add_12, 4, 4, 6, dst, stride, 
block, eob
 movd  [blockq], m4
 DEFINE_ARGS dst, stride, stride3
 lea   stride3q, [strideq*3]
-movhm1, [dstq+strideq*0]
-movhm3, [dstq+strideq*2]
-movhps  m1, [dstq+strideq*1]
-movhps  m3, [dstq+stride3q ]
-paddw   m1, m0
-paddw   m3, m0
-pmaxsw  m1, m4
-pmaxsw  m3, m4
-pminsw  m1, m5
-pminsw  m3, m5
-movh   [dstq+strideq*0], m1
-movhps [dstq+strideq*1], m1
-movh   [dstq+strideq*2], m3
-movhps [dstq+stride3q ], m3
+STORE_4x41, 3, 0, 0, m4, m5
 RET
 
 .idctfull:
@@ -370,31 +394,8 @@ cglobal vp9_idct_idct_4x4_add_12, 4, 4, 6, dst, stride, 
block, eob
 ; writeout
 DEFINE_ARGS dst, stride, stride3
 lea   stride3q, [strideq*3]
-paddd   m0, [pd_8]
-paddd   m1, [pd_8]
-paddd   

Re: [FFmpeg-devel] [PATCH] winrt: multithreading support

2015-10-07 Thread Matt Oliver
On 2 October 2015 at 05:14, Hendrik Leppkes  wrote:

> On Thu, Oct 1, 2015 at 9:05 PM, wm4  wrote:
> > On Fri, 2 Oct 2015 02:58:52 +0800
> > Wang Bin  wrote:
> >
> >> From b8b5ad2d6510778111c2a03ae5cfbe727ee6 Mon Sep 17 00:00:00 2001
> >> From: wang-bin 
> >> Date: Tue, 29 Sep 2015 18:11:03 +0800
> >> Subject: [PATCH] winrt: multithreading support
> >>
> >> _beginthreadex is for desktop only. CreateThread is available for
> windows store apps on windows (and phone) 8.1 and later.
> http://msdn.microsoft.com/en-us/library/ms682453%28VS.85%29.aspx
> >> ---
> >>  compat/w32pthreads.h | 14 ++
> >>  configure|  4 
> >>  libavutil/cpu.c  | 14 +-
> >>  3 files changed, 31 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> >> index deb1c53..7491cab 100644
> >> --- a/compat/w32pthreads.h
> >> +++ b/compat/w32pthreads.h
> >> @@ -37,7 +37,16 @@
> >>
> >>  #define WIN32_LEAN_AND_MEAN
> >>  #include 
> >> +#ifdef WINAPI_FAMILY
> >> +#include 
> >> +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
> >> +#define TARGET_OS_WINRT
> >> +#endif
> >> +#endif
> >> +#ifndef TARGET_OS_WINRT
> >>  #include 
> >> +#endif
> >> +
> >>
> >>  #include "libavutil/attributes.h"
> >>  #include "libavutil/common.h"
> >> @@ -82,8 +91,13 @@ static av_unused int pthread_create(pthread_t
> *thread, const void *unused_attr,
> >>  {
> >>  thread->func   = start_routine;
> >>  thread->arg= arg;
> >> +#ifndef TARGET_OS_WINRT
> >>  thread->handle = (void*)_beginthreadex(NULL, 0,
> win32thread_worker, thread,
> >> 0, NULL);
> >> +#else
> >> +thread->handle = (void*)CreateThread(NULL, 0, win32thread_worker,
> thread,
> >> +   0, NULL);
> >> +#endif
> >
> > Why can't it always use CreateThread? This looks very suspicious.
>
> MSDN warns about using CreateThread with C code, something with the
> CRT init, and recommend _beginthreadex instead.
> Using CreateThread on WinRT seems a bit fishy for the same reason.
>

CreateThread is just a Win32 call. _beginthreadex is better as it adds
additional setup for the C runtime as well as wrapping a call to
CreateThread. Without the C runtime initialisation then standard CRT
functions can mem-leak and otherwise misbehave. So _beginthreadex is
definitely the correct option most of the time. However when creating
windows store/phone apps _beginthreadex is not available and CreateThread
is the only other option. The above issues are overcome by ensuring that
you link against the dynamic release microsoft c runtime dll, which is also
a requirement for windows store/phone apps (but not one you want to require
any other time) so it should work itself out.

So the above check for WINAPI_PARTITION_DESKTOP will only enable
CreateThread when building a store/phone app which is I think is the only
way to go (blame microsoft for annoying requirements).


>
>
>
> >>  return !thread->handle;
> >>  }
> >>
> >> diff --git a/configure b/configure
> >> index 361c024..08d0d5d 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -5189,6 +5189,10 @@ check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
> >>  if ! disabled w32threads && ! enabled pthreads; then
> >>  check_func_headers "windows.h process.h" _beginthreadex &&
> >>  enable w32threads || disable w32threads
> >> +if ! enabled w32threads; then
> >> +check_func_headers "windows.h" CreateThread &&
> >> +enable w32threads || disable w32threads
> >> +fi
> >>  fi
> >>
>

This is a little ambiguous. The assumption that the only time
_beginthreadex is not available and CreateThread is available is when
building a store/phone app may not always be correct. If for some obscure
reason _beginthreadex is not available and its not an app build then the
w32pthread code will fail. For clarity you should probably add to this a
check !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) and CreateThread
before enabling.

Also the big pile of ifdefary that is added to w32pthread.h and cpu.c can
probably be avoided by adding another option to configure (something like
HAVE_WINRT) that is enabled with a check of !WINAPI_FAMILY_PARTITION(
WINAPI_PARTITION_DESKTOP). Then this should be used above so the check for
CreateThread is only when using WinRT. Having this available will also help
in the future as any additional WinRT changes are required.


> >>  # check for some common methods of building with pthread support
> >> diff --git a/libavutil/cpu.c b/libavutil/cpu.c
> >> index 780368d..c562e86 100644
> >> --- a/libavutil/cpu.c
> >> +++ b/libavutil/cpu.c
> >> @@ -30,8 +30,14 @@
> >>  #endif
> >>  #include 
> >>  #endif
> >> -#if HAVE_GETPROCESSAFFINITYMASK
> >> +#if HAVE_WINDOWS_H
> >>  #include 
> >> +#ifdef WINAPI_FAMILY
> >> +#include 
> >> +#if 

Re: [FFmpeg-devel] [PATCH 3/3] h264: Run VLC init under pthread_once

2015-10-07 Thread Matt Oliver
On 8 October 2015 at 02:39, Derek Buitenhuis 
wrote:

> This makes the h.264 decoder threadsafe to initialize.
>
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavcodec/h264.c |  7 ++-
>  libavcodec/h264.h | 10 ++
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 3209c9c..27a1d32 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -657,7 +657,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
>  if (!avctx->has_b_frames)
>  h->low_delay = 1;
>
> -ff_h264_decode_init_vlc();
> +ret = pthread_once(_h264_vlc_init, _h264_decode_init_vlc);
> +if (ret != 0) {
> +av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
> +return AVERROR_UNKNOWN;
> +}
>
>  if (avctx->codec_id == AV_CODEC_ID_H264) {
>  if (avctx->ticks_per_frame == 1) {
> @@ -1993,6 +1997,7 @@ AVCodec ff_h264_decoder = {
>  .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/
> AV_CODEC_CAP_DR1 |
>   AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_SLICE_THREADS |
>   AV_CODEC_CAP_FRAME_THREADS,
> +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
>  .flush = flush_dpb,
>  .init_thread_copy  =
> ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
>  .update_thread_context =
> ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index 769abda..c5119f9 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -43,6 +43,14 @@
>  #include "rectangle.h"
>  #include "videodsp.h"
>
> +#if HAVE_PTHREADS
> +#   include 
> +#elif HAVE_OS2THREADS
> +#   include "compat/os2threads.h"
> +#elif HAVE_W32THREADS
> +#   include "compat/w32pthreads.h"
> +#endif
> +
>

Couldnt all the above if/includes be simplified by just using a single
include libavutil/thread.h (which has all the above checks in it.


>  #define H264_MAX_PICTURE_COUNT 36
>  #define H264_MAX_THREADS   32
>
> @@ -931,6 +939,8 @@ int ff_h264_check_intra_pred_mode(const H264Context
> *h, H264SliceContext *sl,
>  void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl);
>  int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int
> size);
>  int ff_h264_decode_init(AVCodecContext *avctx);
> +
> +static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;
>  void ff_h264_decode_init_vlc(void);
>
>  /**
> --
> 1.8.3.1
>
> ___
> 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] libavcodec/qsv.c: Re-design session control and internal allocation

2015-10-07 Thread Ivan Uskov
Hello Hendrik,

Wednesday, October 7, 2015, 5:58:25 PM, you wrote:

HL> On Wed, Oct 7, 2015 at 4:41 PM, Ivan Uskov  wrote:

HL> Global static variables are not acceptable, sorry.
HL> You'll have to find another way to solve your problem, but global
HL> state is not the way to go.
Unfortunately   I   do   not   have   ideas  how to provide single and common
memory  block  for  separatemodules   by  another  way.   Memory  mapping
files  looks not too portable and much more bulky solution then one global 
variable.
I  do  not  see  the  way to use appropriate field of AVCodecContext to share
global data.
Has anybody any ideas?
Is  me  missed  something?  There is really the necessary to have a global 
common
structure shared between decoder, vpp and decoder. 

-- 
Best regards,
 Ivanmailto:ivan.us...@nablet.com

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


[FFmpeg-devel] [PATCH 0/3] h264: Threadsafe initialization

2015-10-07 Thread Derek Buitenhuis
Towards a glorious non-locking future.

Obviously requires Hendrik's phread_once patch.

Anton Khirnov (1):
  cabac: Make cabac starts hardcoded

Derek Buitenhuis (2):
  Revert "cabac: Allow hardcoding CABAC table."
  h264: Run VLC init under pthread_once

 libavcodec/Makefile  |   4 +-
 libavcodec/cabac.c   | 139 ++-
 libavcodec/cabac.h   |   8 +--
 libavcodec/cabac_functions.h |   8 +--
 libavcodec/cabac_tablegen.c  |  41 -
 libavcodec/cabac_tablegen.h  | 108 -
 libavcodec/h264.c|   9 ++-
 libavcodec/h264.h|  10 
 libavcodec/hevc.c|   2 -
 9 files changed, 147 insertions(+), 182 deletions(-)
 delete mode 100644 libavcodec/cabac_tablegen.c
 delete mode 100644 libavcodec/cabac_tablegen.h

-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH 3/3] h264: Run VLC init under pthread_once

2015-10-07 Thread Derek Buitenhuis
On 10/7/2015 4:39 PM, Derek Buitenhuis wrote:
> +static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;

I've added av_unused here locally.

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mips: build fix for MSA

2015-10-07 Thread Michael Niedermayer
On Wed, Oct 07, 2015 at 06:20:53PM +0530, shivraj.pa...@imgtec.com wrote:
> From: Shivraj Patil 
> 
> Modified sps and pps access from old HEVCContext(s) structure to newly 
> introduced HEVCParamSets(ps)
> 
> Signed-off-by: Shivraj Patil 
> ---
>  libavcodec/mips/hevcpred_msa.c |  282 
> 
>  1 file changed, 141 insertions(+), 141 deletions(-)

does this or any other patch need to be backported to release/2.8 ?

if so please backport them (assuming its not just a cherry pick
without conflicts)

thanks

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH 1/3] dnxhddec: better support for 4:4:4

2015-10-07 Thread Christophe Gisquet
2015-10-07 10:32 GMT+02:00 Christophe Gisquet :
>> this would allow ctx->bit_depth to be set but without initializing the
>> dsp contexts
>> subsequent runs would also skip init due to
>> " if (ctx->bit_depth != old_bit_depth) {"
>
> Actually, other changes could trigger the issue, like
> 4:2:2 10 bits -> 4:4:4 8 bits (unknown, unsupported) -> 4:2:2 8 bits.
>
> Setting ctx->bit_depth should probably be delayed to when the idcts are set.

Here's an updated patch.

-- 
Christophe
From 9dbddfc7981312e1221c86e6399f716e6c3df972 Mon Sep 17 00:00:00 2001
From: Christophe Gisquet 
Date: Sun, 4 Oct 2015 10:06:28 +0200
Subject: [PATCH 1/3] dnxhddec: better support for 4:4:4

Profiles 1256 & 1270 (currently) signal at the frame header and MB
levels the colorspace used, either RGB or YUV. While a MB-level
varying colorspace is not supported, whether it is constant can be
tracked so as to determine the exact colorspace.

This requires having bitdepth and the ACT and 4:4:4 flags, in turn
needing the CID. Because setting those before having validated
enough things may result in invalid/unset DSP fucntions, setting
the bitdepth in the context is delayed.

It is not tested against a true RGB sequence, though.
---
 libavcodec/dnxhddec.c | 109 +++---
 1 file changed, 76 insertions(+), 33 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index fec9aac..3b1fbdb 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -43,6 +43,8 @@ typedef struct RowContext {
 int last_dc[3];
 int last_qscale;
 int errors;
+/** -1:not set yet  0:off=RGB  1:on=YUV  2:variable */
+int format;
 } RowContext;
 
 typedef struct DNXHDContext {
@@ -102,7 +104,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
 return 0;
 }
 
-static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
+static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
 {
 if (cid != ctx->cid) {
 int index;
@@ -111,9 +113,9 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
 av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
 return AVERROR(ENOSYS);
 }
-if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth &&
+if (ff_dnxhd_cid_table[index].bit_depth != bitdepth &&
 ff_dnxhd_cid_table[index].bit_depth != DNXHD_VARIABLE) {
-av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, ctx->bit_depth);
+av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, bitdepth);
 return AVERROR_INVALIDDATA;
 }
 ctx->cid_table = _dnxhd_cid_table[index];
@@ -126,7 +128,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid)
 init_vlc(>ac_vlc, DNXHD_VLC_BITS, 257,
  ctx->cid_table->ac_bits, 1, 1,
  ctx->cid_table->ac_codes, 2, 2, 0);
-init_vlc(>dc_vlc, DNXHD_DC_VLC_BITS, ctx->bit_depth + 4,
+init_vlc(>dc_vlc, DNXHD_DC_VLC_BITS, bitdepth + 4,
  ctx->cid_table->dc_bits, 1, 1,
  ctx->cid_table->dc_codes, 1, 1, 0);
 init_vlc(>run_vlc, DNXHD_VLC_BITS, 62,
@@ -161,7 +163,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
 static const uint8_t header_prefixhr1[] = { 0x00, 0x00, 0x02, 0x80, 0x03 };
 static const uint8_t header_prefixhr2[] = { 0x00, 0x00, 0x03, 0x8C, 0x03 };
 int i, cid, ret;
-int old_bit_depth = ctx->bit_depth;
+int old_bit_depth = ctx->bit_depth, bitdepth;
 int old_mb_height = ctx->mb_height;
 
 if (buf_size < 0x280) {
@@ -192,38 +194,53 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
 ctx->width  = AV_RB16(buf + 0x1a);
 
 switch(buf[0x21] >> 5) {
-case 1: ctx->bit_depth = 8; break;
-case 2: ctx->bit_depth = 10; break;
-case 3: ctx->bit_depth = 12; break;
+case 1: bitdepth = 8; break;
+case 2: bitdepth = 10; break;
+case 3: bitdepth = 12; break;
 default:
 av_log(ctx->avctx, AV_LOG_ERROR,
"Unknown bitdepth indicator (%d)\n", buf[0x21] >> 5);
 return AVERROR_INVALIDDATA;
 }
-ctx->avctx->bits_per_raw_sample = ctx->bit_depth;
+
+cid = AV_RB32(buf + 0x28);
+if ((ret = dnxhd_init_vlc(ctx, cid, bitdepth)) < 0)
+return ret;
+if (ctx->mbaff && ctx->cid_table->cid != 1260)
+av_log(ctx->avctx, AV_LOG_WARNING,
+   "Adaptive MB interlace flag in an unsupported profile.\n");
+
+ctx->act = buf[0x2C] & 7;
+if (ctx->act && ctx->cid_table->cid != 1256 && ctx->cid_table->cid != 1270)
+av_log(ctx->avctx, AV_LOG_WARNING,
+   "Adaptive color transform in an unsupported profile.\n");
 
 ctx->is_444 = (buf[0x2C] >> 6) & 1;
 if (ctx->is_444) {
-if 

Re: [FFmpeg-devel] [PATCH 0/9] Initial support for DNxHR, v2

2015-10-07 Thread Christophe Gisquet
2015-10-05 14:03 GMT+02:00 Christophe Gisquet :
> Hi,
>
> 2015-10-05 13:18 GMT+02:00 Michael Niedermayer :
>> do you have any testcases you can share for these ?
>
> I was provided some but that I assume not redistributable. I asked the
> same question but got no reply.
>
> There's this one sequence here that I assume to be redistributable:
> https://trac.ffmpeg.org/ticket/4581
> which is CID1270
> but according to the little info here:
> http://avid.force.com/pkb/articles/en_US/White_Paper/DNxHR-Codec-Bandwidth-Specifications
> it might be out of specs (but we do support it), so not the best example.
>
> https://trac.ffmpeg.org/ticket/4876
> might be interesting because it exposed a previously unsupported
> feature (MBAFF like) in profile CID 1260. Not HR, but still useful.

So I have made a fate test on 1 frame for each sequence (total around 1.8MB).

Is it ok?

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


Re: [FFmpeg-devel] [PATCHv2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
On Wed, Oct 7, 2015 at 12:29 PM, Ganesh Ajjanagadde
 wrote:
> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
> The concept of av_uninit is inherently useful though. This patch silences a
> bunch of warnings on clang e.g
> http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
> Furthermore, it should be useful for general usage of av_uninit in future.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/attributes.h | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
> index 5c6b9de..32b60e7 100644
> --- a/libavutil/attributes.h
> +++ b/libavutil/attributes.h
> @@ -147,6 +147,12 @@
>
>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
>  #define av_uninit(x) x=x
> +#elif defined(__clang__) && __has_warning("-Wuninitialized")
> +#define av_uninit(x) \
> +_Pragma("clang diagnostic push") \
> +_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
> +x=x \
> +_Pragma("clang diagnostic pop")
>  #else
>  #define av_uninit(x) x
>  #endif
> --
> 2.1.4
>

Can't guarantee that this will work, as I am unable to reproduce
Michael's build failure on clang 3.1. I have tested this with Debian
clang 3.0 and clang 3.7 on Arch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3 v2] h264: Run VLC init under pthread_once

2015-10-07 Thread wm4
On Wed,  7 Oct 2015 12:24:32 -0400
Derek Buitenhuis  wrote:

> This makes the h.264 decoder threadsafe to initialize.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavcodec/h264.c | 9 -
>  libavcodec/h264.h | 7 +++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 3209c9c..1abdc4b 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -644,6 +644,8 @@ static int h264_init_context(AVCodecContext *avctx, 
> H264Context *h)
>  return 0;
>  }
>  
> +static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;
> +
>  av_cold int ff_h264_decode_init(AVCodecContext *avctx)
>  {
>  H264Context *h = avctx->priv_data;
> @@ -657,7 +659,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
>  if (!avctx->has_b_frames)
>  h->low_delay = 1;
>  
> -ff_h264_decode_init_vlc();
> +ret = pthread_once(_h264_vlc_init, _h264_decode_init_vlc);
> +if (ret != 0) {
> +av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
> +return AVERROR_UNKNOWN;
> +}
>  
>  if (avctx->codec_id == AV_CODEC_ID_H264) {
>  if (avctx->ticks_per_frame == 1) {
> @@ -1993,6 +1999,7 @@ AVCodec ff_h264_decoder = {
>  .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
> AV_CODEC_CAP_DR1 |
>   AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS 
> |
>   AV_CODEC_CAP_FRAME_THREADS,
> +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
>  .flush = flush_dpb,
>  .init_thread_copy  = 
> ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
>  .update_thread_context = 
> ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index 769abda..f8a58a6 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -29,6 +29,7 @@
>  #define AVCODEC_H264_H
>  
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/thread.h"
>  #include "cabac.h"
>  #include "error_resilience.h"
>  #include "get_bits.h"
> @@ -43,6 +44,12 @@
>  #include "rectangle.h"
>  #include "videodsp.h"
>  
> +#if HAVE_PTHREADS
> +#   include 
> +#elif HAVE_W32THREADS
> +#   include "compat/w32pthreads.h"
> +#endif
> +
>  #define H264_MAX_PICTURE_COUNT 36
>  #define H264_MAX_THREADS   32
>  

I think you forgot to remove the second chunk? It's unnecessary with
thread.h included.

Other than that LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3 v2] h264: Run VLC init under pthread_once

2015-10-07 Thread Derek Buitenhuis
On 10/7/2015 5:24 PM, Derek Buitenhuis wrote:
> This makes the h.264 decoder threadsafe to initialize.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavcodec/h264.c | 9 -
>  libavcodec/h264.h | 7 +++
>  2 files changed, 15 insertions(+), 1 deletion(-)

Disregard this one, wrong ver sent.

- Derek

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


Re: [FFmpeg-devel] [PATCH] w32pthreads: add pthread_once emulation

2015-10-07 Thread Matt Oliver
On 8 October 2015 at 03:29, Hendrik Leppkes  wrote:

> On Wed, Oct 7, 2015 at 6:23 PM, Matt Oliver  wrote:
> > On 6 October 2015 at 21:36, Hendrik Leppkes  wrote:
> >
> >> The emulation uses native InitOnce* APIs on Windows Vista+, and a
> >> lock-free/allocation-free approach using atomics and spinning for
> Windows
> >> XP.
> >> ---
> >>
> >> This is in preparation to use pthread_once for global static init
> >> functions,
> >> and eventually removing the global lock in avcodec_open2
> >>
> >> compat/w32pthreads.h | 68
> >> 
> >>  1 file changed, 68 insertions(+)
> >>
> >> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> >> index deb1c53..8523976 100644
> >> --- a/compat/w32pthreads.h
> >> +++ b/compat/w32pthreads.h
> >> @@ -154,6 +154,19 @@ static inline int
> pthread_cond_signal(pthread_cond_t
> >> *cond)
> >>  return 0;
> >>  }
> >>
> >> +typedef INIT_ONCE pthread_once_t;
> >> +#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
> >> +
> >> +static av_unused int pthread_once(pthread_once_t *once_control, void
> >> (*init_routine)(void))
> >> +{
> >> +BOOL pending = FALSE;
> >> +InitOnceBeginInitialize(once_control, 0, , NULL);
> >> +if (pending)
> >> +init_routine();
> >> +InitOnceComplete(once_control, 0, NULL);
> >> +return 0;
> >> +}
> >> +
> >>  #else // _WIN32_WINNT < 0x0600
> >>  /* for pre-Windows 6.0 platforms we need to define and use our own
> >> condition
> >>   * variable and api */
> >> @@ -304,6 +317,57 @@ static av_unused int
> >> pthread_cond_signal(pthread_cond_t *cond)
> >>  pthread_mutex_unlock(_cond->mtx_broadcast);
> >>  return 0;
> >>  }
> >> +
> >> +/* for pre-Windows 6.0 platforms, define INIT_ONCE struct,
> >> + * compatible to the one used in the native API */
> >> +
> >> +typedef union pthread_once_t  {
> >> +void * Ptr;///< For the Windows 6.0+ native functions
> >> +LONG state;///< For the pre-Windows 6.0 compat code
> >> +} pthread_once_t;
> >> +
> >> +#define PTHREAD_ONCE_INIT {0}
> >> +
> >> +/* function pointers to init once API on windows 6.0+ kernels */
> >> +static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD
> >> dwFlags, BOOL *fPending, void **lpContext);
> >> +static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce,
> DWORD
> >> dwFlags, void *lpContext);
> >> +
> >> +static av_unused int pthread_once(pthread_once_t *once_control, void
> >> (*init_routine)(void))
> >> +{
> >> +/* Use native functions on Windows 6.0+ */
> >> +if (initonce_begin && initonce_complete)
> >> +{
> >> +BOOL pending = FALSE;
> >> +initonce_begin(once_control, 0, , NULL);
> >> +if (pending)
> >> +init_routine();
> >> +initonce_complete(once_control, 0, NULL);
> >> +return 0;
> >> +}
> >> +
> >> +/* pre-Windows 6.0 compat using a spin-lock */
> >> +switch (InterlockedCompareExchange(_control->state, 1, 0))
> >> +{
> >> +/* Initial run */
> >> +case 0:
> >> +init_routine();
> >> +InterlockedExchange(_control->state, 2);
> >> +break;
> >> +/* Another thread is running init */
> >> +case 1:
> >> +while (1) {
> >> +MemoryBarrier();
> >> +if (once_control->state == 2)
> >> +break;
> >> +Sleep(0);
> >> +}
> >> +break;
> >> +/* Initialization complete */
> >> +case 2:
> >> +break;
> >> +}
> >> +return 0;
> >> +}
> >>  #endif
> >>
> >>  static av_unused void w32thread_init(void)
> >> @@ -319,6 +383,10 @@ static av_unused void w32thread_init(void)
> >>  (void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
> >>  cond_wait  =
> >>  (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
> >> +initonce_begin =
> >> +(void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize");
> >> +initonce_complete =
> >> +(void*)GetProcAddress(kernel_dll, "InitOnceComplete");
> >>  #endif
> >>
> >>  }
> >> --
> >> 2.5.3.windows.1
> >
> >
> > LGTM
>
> There is a new version of the patch which also solves the
> w32thread_init mess, so this one isn't the final version anymore.
> Current working version is here:
> https://github.com/Nevcairiel/FFmpeg/commits/pthread_once
>
>
This looks better.
So by win32thread_init mess im assuming your referring to a need to have
called it before hand. Given that youve added it to the only 2 functions
that need it then doesnt that mean that win32thread_init be completely
removed from all other code and only used locally in w32pthread.h and only
when WIN32_WINNT<0x600.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] h264: Run VLC init under pthread_once

2015-10-07 Thread Hendrik Leppkes
On Wed, Oct 7, 2015 at 6:10 PM, Derek Buitenhuis
 wrote:
> On 10/7/2015 4:57 PM, wm4 wrote:
>> A static variable in a header file? This doesn't look right. You should
>> define it in h264.c instead.
>
> [17:03] <+wm4> Daemon404: what exactly is the point of declaring the 
> init_once in the .h file?
> [17:03] <@Daemon404> i didnt know the right place to put it
> [17:03] <+wm4> h264.c
> [17:03] <@Daemon404> there's no obviously correct place
> [17:04]  * Daemon404 will send the libav patchset once rsync actually 
> finishes and he can run fate
> [17:06] <+wm4> there needs to be exactly one instance of this variable, so it 
> should be in h264.c, unless
>h264.c is somehow used for freaky preprocessor template stuff 
> (which I think it isn't)
> [17:07] <@Daemon404> and the function it uses isnt from h264.c, which is why 
> i had put it in the .h
> [17:07] <@Daemon404> i have no strong opinion
>
> Currently moved to h264.c locally.
>

You could put it right above the pthread_once call, inside the
function even, as long as there is only one place its ever called.
But we should probably come to a more general consensus for functions
that may be called in more than one place, where the variable may even
need to be referenced in a header somewhere so  two files can
reference it - or you create a new wrapper that wraps the pthread_once
for those cases.

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


[FFmpeg-devel] [PATCHv2] avutil/attributes: extend av_uninit to clang

2015-10-07 Thread Ganesh Ajjanagadde
Commit 6dac8c8327 disabled av_uninit for clang, due to some useless warnings.
The concept of av_uninit is inherently useful though. This patch silences a
bunch of warnings on clang e.g
http://fate.ffmpeg.org/log.cgi?time=20150918181527=compile=x86_64-darwin-clang-polly-vectorize-stripmine-3.7.
Furthermore, it should be useful for general usage of av_uninit in future.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavutil/attributes.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index 5c6b9de..32b60e7 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -147,6 +147,12 @@
 
 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
 #define av_uninit(x) x=x
+#elif defined(__clang__) && __has_warning("-Wuninitialized")
+#define av_uninit(x) \
+_Pragma("clang diagnostic push") \
+_Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
+x=x \
+_Pragma("clang diagnostic pop")
 #else
 #define av_uninit(x) x
 #endif
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 3/3 v3] h264: Run VLC init under pthread_once

2015-10-07 Thread Derek Buitenhuis
This makes the h.264 decoder threadsafe to initialize.

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/h264.c | 9 -
 libavcodec/h264.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 3209c9c..1abdc4b 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -644,6 +644,8 @@ static int h264_init_context(AVCodecContext *avctx, 
H264Context *h)
 return 0;
 }
 
+static pthread_once_t ff_h264_vlc_init = PTHREAD_ONCE_INIT;
+
 av_cold int ff_h264_decode_init(AVCodecContext *avctx)
 {
 H264Context *h = avctx->priv_data;
@@ -657,7 +659,11 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
 if (!avctx->has_b_frames)
 h->low_delay = 1;
 
-ff_h264_decode_init_vlc();
+ret = pthread_once(_h264_vlc_init, _h264_decode_init_vlc);
+if (ret != 0) {
+av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
+return AVERROR_UNKNOWN;
+}
 
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 if (avctx->ticks_per_frame == 1) {
@@ -1993,6 +1999,7 @@ AVCodec ff_h264_decoder = {
 .capabilities  = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ 
AV_CODEC_CAP_DR1 |
  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
  AV_CODEC_CAP_FRAME_THREADS,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 .flush = flush_dpb,
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 769abda..b3d08c3 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -29,6 +29,7 @@
 #define AVCODEC_H264_H
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "cabac.h"
 #include "error_resilience.h"
 #include "get_bits.h"
-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH] libavcodec/qsv.c: Re-design session control and internal allocation

2015-10-07 Thread Ivan Uskov
Hello wm4,

Wednesday, October 7, 2015, 7:40:45 PM, you wrote:

w> There's no automagic way to get this done.

w> Hardware accelerators like vaapi and vdpau need the same thing. These
w> have special APIs to set an API context on the decoder. Some APIs use
w> hwaccel_context, vdpau uses av_vdpau_bind_context().

w> The hwaccel_context pointer is untyped (just a void*), and what it means
w> is implicit to the hwaccel or the decoder that is used. It could point
w> to some sort of qsv state, which will have to be explicitly allocated
w> and set by the API user (which might be ffmpeg.c).
So  if  I will implement something like ffmpeg_qsv.c (using ffmpeg_vdpau.c as
example)   and   extend  the  hwaccels[]  into  ffmpeg_opt.c  by corresponded
qsv entries it  would  be the acceptable solution, correct?

w> For filters there is no such thing yet. New API would have to be
w> created. For filters in particular, we will have to make sure that the
w> API isn't overly qsv-specific, and that it is extendable to other APIs
w> (like for example vaapi or vdpau).
Ok,   if   VPP  could be the  issue  I  would  like  to  get  working  direct
link qsv_decoder-qsv_encoder first.

-- 
Best regards,
 Ivanmailto:ivan.us...@nablet.com

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