Re: [libav-devel] [PATCHES] scalarproduct_and_madd_int16 and wma lossless

2014-02-10 Thread Kostya Shishkov
On Mon, Feb 10, 2014 at 08:39:59AM +0100, Christophe Gisquet wrote:
 Hi,
 
 2014-02-10 6:42 GMT+01:00 Kostya Shishkov kostya.shish...@gmail.com:
  On Sun, Feb 09, 2014 at 11:21:33PM +0100, Christophe Gisquet wrote:
  +if(s-cdlms[c][i].order  8) {
  +static int warned;
  +if(!warned)
  +avpriv_request_sample(s-avctx, CDLMS of order %d,
  +  s-cdlms[c][i].order);
  +warned = 1;
  +}
 
   7 maybe ?
 
 You can't see that in the diff, but just above, we have:
 s-cdlms[c][i].order = (get_bits(s-gb, 7) + 1) * 8;
 
 What you suggest is still valid, and would catch things even if they
 changed, though.

Maybe it's not worth warning about it at all.
 
  +for (i = 0; i  s-cdlms_ttl[c]; i++) {
  +memset(s-cdlms[c][i].coefs + s-cdlms[c][i].order, 0,
  +   (s-cdlms[c][i].order  (WMALL_COEFF_PAD_SIZE-1))
 
  wouldn't that be too much on large orders (e.g. order = 15)?
  I'd simply zero to the end of coefs array.
 
 Hum right, these lines are wrong on so many levels... Strange it
 didn't trigger any crash, actually.
 
 Seeing the conditions for this to trigger, I'm tempted then to just write:
 // pad the coeff buffers with 0s up to a 16-aligned position
 for (i = 0; i  s-cdlms_ttl[c]; i++)
 if(s-cdlms[c][i].order  8)
 AV_ZERO128(s-cdlms[c][i].coefs + s-cdlms[c][i].order);
 
 
 That's the problem when there's no sample that may trigger it (except
 crafted ones).

I'd simply zero all coeffs before decoding but that's me.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] lavf: always unref the packet passed to av_interleaved_write_frame() on error

2014-02-10 Thread Martin Storsjö

On Tue, 4 Feb 2014, Anton Khirnov wrote:


---
libavformat/avformat.h |3 ++-
libavformat/mux.c  |   25 ++---
2 files changed, 20 insertions(+), 8 deletions(-)


The change in general looks nice, but won't this lead to double frees for 
all those callers that have made sure to free these packets in case of 
error before? Not sure if anybody actually did that though.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/1] build: fix make examples when EXESUF is not empty

2014-02-10 Thread Diego Biurrun
build: fix examples compilation when EXESUF is not empty

On Mon, Feb 10, 2014 at 12:47:17AM +0100, Janne Grunau wrote:
 From: Christophe Gisquet christophe.gisq...@gmail.com
 
 Due to a wrong substitution doc/examples is not added as prerequisite

as a

 for the objects of the example programs. This results in compiler error
 due to the non existing output directory.

non-existing

OK and thanks.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/5] wip: fate: FFv1 testcases

2014-02-10 Thread Diego Biurrun
On Sun, Feb 09, 2014 at 07:28:17PM +0100, Luca Barbato wrote:
 From: Peter B p...@das-werkstatt.com
 
 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---

I'm assuming this is not meant to be pushed right now?

 --- /dev/null
 +++ b/tests/fate/ffv1.mak
 @@ -0,0 +1,314 @@
 +# This Makefile checks for $(CONFIG_...) variables being set, so we can
 +# include/exclude tests accordingly:
 +ifdef CONFIG_AVCONV
 +FLAGS_FFV1_V3 = -strict experimental
 +else
 +FLAGS_FFV1_V3 =
 +endif

This needs to go along with all the related ifdeffery below.

 +DEC_SRC = $(TARGET_PATH)/tests/data/fate
 +
 +fate-ffv1-enc-%: CODEC = $(word 2, $(subst -, ,$(@)))
 +fate-ffv1-enc-%: FMT = avi
 +fate-ffv1-enc-%: SRC = tests/data/vsynth1.yuv
 +# Limit the duration of test videos to 4 frames at 25fps:
 +fate-ffv1-enc-%: DUR = 0:00:00.160
 +fate-ffv1-enc-%: CMD = enc_dec rawvideo -s 352x288 -pix_fmt yuv420p 
 $(RAWDECOPTS) $(SRC) $(FMT) -t $(DUR) -c $(CODEC) $(ENCOPTS) rawvideo -s 
 352x288 -pix_fmt yuv420p -vsync 0 $(DECOPTS) -keep $(DECINOPTS)
 +
 +
 +FATE_FFV1_LEVEL1 = v1-defaults \
 +   v1-gray \
 +   v1-rgb32 \
 +   v1-yuv410p \
 +   v1-yuv411p \
 +   v1-yuv420p \
 +   v1-yuv422p \
 +   v1-yuv444p \
 +   v1-bgra \
 +   v1-tff \
 +   v1-bff

Aligned \ would be a plus.

 +FATE_FFV1 = $(FATE_FFV1_LEVEL1) \
 +$(FATE_FFV1_LEVEL3)

nit: no need to break lines here

 +###
 +#  Decoding:
 +###
 +#  YUV (8bit)
 +fate-ffv1-dec-v1-defaults:   ${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-defaults.avi} fate-ffv1-enc-v1-defaults
 +fate-ffv1-dec-v1-yuv410p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv410p.avi} fate-ffv1-enc-v1-yuv410p
 +fate-ffv1-dec-v1-yuv411p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv411p.avi} fate-ffv1-enc-v1-yuv411p
 +fate-ffv1-dec-v1-yuv420p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv420p.avi} fate-ffv1-enc-v1-yuv420p
 +fate-ffv1-dec-v1-yuv422p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv422p.avi} fate-ffv1-enc-v1-yuv422p
 +fate-ffv1-dec-v1-yuv444p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv444p.avi} fate-ffv1-enc-v1-yuv444p
 +fate-ffv1-dec-v1-yuv440p:${CMD = framecrc -i 
 $(DEC_SRC)/ffv1-enc-v1-yuv440p.avi} fate-ffv1-enc-v1-yuv440p

Generally $() is preferred over ${}.

 +#  YUV (8bit)
 +#  - This also iterates through all coder/context combinations.
 +fate-ffv1-enc-v3-yuv410p:ENCOPTS = -level 3 -g 1 -coder 0 -context 0 
 -slices 4 -slicecrc 0 -pix_fmt yuv410p $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv420p:ENCOPTS = -level 3 -g 1 -coder 0 -context 1 
 -slices 12 -slicecrc 0 -pix_fmt yuv420p $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv422p:ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt yuv422p $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv444p:ENCOPTS = -level 3 -g 1 -coder 1 -context 1 
 -slices 30 -slicecrc 0 -pix_fmt yuv444p $(FLAGS_FFV1_V3)
 +#  YUV (9bit)
 +fate-ffv1-enc-v3-yuv420p9:   ENCOPTS = -level 3 -g 1 -coder -1 -context 
 1 -slices 24 -slicecrc 0 -pix_fmt yuv420p9 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv422p9:   ENCOPTS = -level 3 -g 1 -coder 2 -context 0 
 -slices 30 -slicecrc 0 -pix_fmt yuv422p9 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv444p9:   ENCOPTS = -level 3 -g 1 -coder 1 -context 1 
 -slices 4  -slicecrc 0 -pix_fmt yuv444p9 $(FLAGS_FFV1_V3)
 +#  Gray
 +fate-ffv1-enc-v3-gray:   ENCOPTS = -level 3 -g 1 -coder 0 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gray $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-gray16: ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gray16 $(FLAGS_FFV1_V3)
 +#  RGB
 +fate-ffv1-enc-v3-rgb32:  ENCOPTS = -level 3 -g 1 -coder 0 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt rgb32 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-bgr0:   ENCOPTS = -level 3 -g 1 -coder 0 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt bgr0 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-gbrp9:  ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gbrp9 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-gbrp10: ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gbrp10 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-gbrp12: ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gbrp12 $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-gbrp14: ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 24 -slicecrc 0 -pix_fmt gbrp14 $(FLAGS_FFV1_V3)
 +
 +# Slice CRC: On
 +fate-ffv1-enc-v3-yuv422p_crc:ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 -slices 30 -slicecrc 1 -pix_fmt yuv422p $(FLAGS_FFV1_V3)
 +fate-ffv1-enc-v3-yuv422p9_crc:   ENCOPTS = -level 3 -g 1 -coder 1 -context 0 
 

Re: [libav-devel] [PATCH 2/5] lavf: always unref the packet passed to av_interleaved_write_frame() on error

2014-02-10 Thread Anton Khirnov

On Mon, 10 Feb 2014 13:05:42 +0200 (EET), Martin Storsjö mar...@martin.st 
wrote:
 On Tue, 4 Feb 2014, Anton Khirnov wrote:
 
  ---
  libavformat/avformat.h |3 ++-
  libavformat/mux.c  |   25 ++---
  2 files changed, 20 insertions(+), 8 deletions(-)
 
 The change in general looks nice, but won't this lead to double frees for 
 all those callers that have made sure to free these packets in case of 
 error before? Not sure if anybody actually did that though.
 

av_packet_unref() clears the packet, so unless the caller is keeping an extra
copy then it shouldn't break anything.

Besides, the alternative of not touching the packet on error would be quite
ugly, since the error may happen after we've passed the packet onward.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 5/5] wip: fate: FFv1 testcases

2014-02-10 Thread Luca Barbato
On 10/02/14 12:17, Diego Biurrun wrote:
 On Sun, Feb 09, 2014 at 07:28:17PM +0100, Luca Barbato wrote:
 From: Peter B p...@das-werkstatt.com

 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---
 
 I'm assuming this is not meant to be pushed right now?
 

right, it is a wip since I want a second opinion.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] lavf: always unref the packet passed to av_interleaved_write_frame() on error

2014-02-10 Thread Martin Storsjö

On Mon, 10 Feb 2014, Anton Khirnov wrote:



On Mon, 10 Feb 2014 13:05:42 +0200 (EET), Martin Storsjö mar...@martin.st 
wrote:

On Tue, 4 Feb 2014, Anton Khirnov wrote:


---
libavformat/avformat.h |3 ++-
libavformat/mux.c  |   25 ++---
2 files changed, 20 insertions(+), 8 deletions(-)


The change in general looks nice, but won't this lead to double frees for
all those callers that have made sure to free these packets in case of
error before? Not sure if anybody actually did that though.



av_packet_unref() clears the packet, so unless the caller is keeping an extra
copy then it shouldn't break anything.

Besides, the alternative of not touching the packet on error would be quite
ugly, since the error may happen after we've passed the packet onward.


Right, so I guess it's ok then.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] dcadsp: move test out of loop and dspize

2014-02-10 Thread Diego Biurrun
On Sun, Feb 09, 2014 at 02:33:42PM +0100, Christophe Gisquet wrote:
 --- a/libavcodec/arm/dcadsp_init_arm.c
 +++ b/libavcodec/arm/dcadsp_init_arm.c
 @@ -53,6 +53,45 @@ void ff_synth_filter_float_neon(FFTContext *imdct,
  
 +#if HAVE_NEON_INLINE  HAVE_ASM_MOD_Y
 +
 +static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
 + float *dst, const int8_t *src, int 
 scale)
 +{
 +}
 +
 +static void decode_hf_neon(float dst[DCA_SUBBANDS][8],
 +   const int32_t vq_num[DCA_SUBBANDS],
 +   const int8_t hf_vq[1024][32], intptr_t vq_offset,
 +   int32_t scale[DCA_SUBBANDS][2],
 +   intptr_t start, intptr_t end)
 +{
 +}
 +
 +#endif

Please comment the #endif.

 --- a/libavcodec/dcadec.c
 +++ b/libavcodec/dcadec.c
 @@ -50,14 +50,11 @@
  #if ARCH_ARM
  #   include arm/dca.h
  #endif
 -#if ARCH_X86
 -#   include x86/dca.h
 -#endif
  
  //#define TRACE
  
  #define DCA_PRIM_CHANNELS_MAX  (7)
 -#define DCA_SUBBANDS  (32)
 +// DCA_SUBBANDS defined in dcadsp.h

Drop this comment.

 --- a/libavcodec/dcadsp.h
 +++ b/libavcodec/dcadsp.h
 @@ -22,6 +22,8 @@
  
 +#define DCA_SUBBANDS  (32)

The spacing looks slightly off, the () are redundant.

 --- a/libavcodec/x86/dca.h
 +++ /dev/null
 @@ -1,55 +0,0 @@
 -
 -#if ARCH_X86_64  HAVE_SSE2_INLINE
 -# include libavutil/x86/asm.h
 -# include libavutil/mem.h
 -#include libavcodec/dcadsp.h
 -
 -# define int8x8_fmul_int32 int8x8_fmul_int32
 -static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
 - float *dst, const int8_t *src, int 
 scale)
 -{
 -DECLARE_ALIGNED(16, static const uint32_t, inverse16) = 0x3D80;
 -__asm__ volatile (
 -cvtsi2ss%2, %%xmm0 \n\t
 -mulss   %3, %%xmm0 \n\t
 -movq  (%1), %%xmm1 \n\t
 -punpcklbw   %%xmm1, %%xmm1 \n\t
 -movaps  %%xmm1, %%xmm2 \n\t
 -punpcklwd   %%xmm1, %%xmm1 \n\t
 -punpckhwd   %%xmm2, %%xmm2 \n\t
 -psrad  $24, %%xmm1 \n\t
 -psrad  $24, %%xmm2 \n\t
 -shufps  $0, %%xmm0, %%xmm0 \n\t
 -cvtdq2ps%%xmm1, %%xmm1 \n\t
 -cvtdq2ps%%xmm2, %%xmm2 \n\t
 -mulps   %%xmm0, %%xmm1 \n\t
 -mulps   %%xmm0, %%xmm2 \n\t
 -movaps  %%xmm1,  0(%0) \n\t
 -movaps  %%xmm2, 16(%0) \n\t
 -:: r(dst), r(src), m(scale), m(inverse16)
 -XMM_CLOBBERS_ONLY(xmm0, xmm1, xmm2)
 -);
 -}
 -
 -#endif /* ARCH_X86_64  HAVE_SSE2_INLINE */
 --- a/libavcodec/x86/dcadsp.asm
 +++ b/libavcodec/x86/dcadsp.asm
 @@ -26,18 +26,37 @@ pf_inv16:  times 4 dd 0x3D80 ; 1/16
  
 -; void int8x8_fmul_int32_sse2(float *dst, const int8_t *src, int scale)
 -%macro INT8X8_FMUL_INT32 0
 -cglobal int8x8_fmul_int32, 3,3,5, dst, src, scale
 -cvtsi2ssm0, scalem
 +; decode_hf(float dst[DCA_SUBBANDS][8], const int32_t vq_num[DCA_SUBBANDS],
 +; const int8_t hf_vq[1024][32], intptr_t vq_offset,
 +; int32_t scale[DCA_SUBBANDS][2],
 +; intptr_t start, intptr_t end)

Indentation is off.

 +%macro DECODE_HF 0
 +cglobal decode_hf, 6,6,5, dst, num, src, offset, scale, start, end

I owe you a beer for eliminating the inline assembly :)

 @@ -67,27 +86,33 @@ cglobal int8x8_fmul_int32, 3,3,5, dst, src, scale
  mulps   m1, m0
  mulps   m2, m0
 -mova [dstq+ 0], m1
 -mova [dstq+16], m2
 +mova [dstq + 8*startq +  0], m1
 +mova [dstq + 8*startq + 16], m2
 +add startq, 4
 +cmp startq, endm
 +jl   .loop
 +.end:
 +%if cpuflag(sse2) == 0

notcpuflag?

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 4/5] ffv1: frame threading

2014-02-10 Thread Diego Biurrun
On Sun, Feb 09, 2014 at 07:28:16PM +0100, Luca Barbato wrote:
 --- a/libavcodec/ffv1dec.c
 +++ b/libavcodec/ffv1dec.c
 @@ -353,6 +354,43 @@ static int decode_slice(AVCodecContext *c, void *arg)
 +memcpy(pdst, psrc, sizeof(*pdst));
 +pdst-state = NULL;
 +pdst-vlc_state = NULL;

nit: align

 +if (fssrc-ac) {
 +pdst-state = av_malloc(CONTEXT_SIZE * psrc-context_count);
 +memcpy(pdst-state, psrc-state,
 +   CONTEXT_SIZE * psrc-context_count);
 +} else {
 +pdst-vlc_state = av_malloc(sizeof(*pdst-vlc_state) *
 +psrc-context_count);
 +memcpy(pdst-vlc_state, psrc-vlc_state,
 +   sizeof(*pdst-vlc_state) * psrc-context_count);
 +}

unchecked av_malloc

 @@ -905,44 +977,135 @@ static int ffv1_decode_frame(AVCodecContext *avctx, 
 void *data,
  
 -av_frame_free(s-last_picture);
 +f-picture.f  = NULL;
 +f-last_picture.f = NULL;
 +f-sample_buffer  = NULL;
 +f-slice_count = 0;

align

 +f-picture.f  = av_frame_alloc();
 +f-last_picture.f = av_frame_alloc();

unchecked allocations

 +static void copy_fields(FFV1Context *fsdst, FFV1Context *fssrc, FFV1Context 
 *fsrc)
 +{
 +fsdst-version = fsrc-version;
 +fsdst-minor_version   = fsrc-minor_version;
 +fsdst-chroma_planes   = fsrc-chroma_planes;
 +fsdst-chroma_h_shift  = fsrc-chroma_h_shift;
 +fsdst-chroma_v_shift  = fsrc-chroma_v_shift;
 +fsdst-transparency= fsrc-transparency;
 +fsdst-plane_count = fsrc-plane_count;
 +fsdst-ac  = fsrc-ac;
 +fsdst-colorspace  = fsrc-colorspace;
 +
 +fsdst-ec  = fsrc-ec;
 +fsdst-slice_damaged   = fssrc-slice_damaged;
 +fsdst-key_frame_ok= fsrc-key_frame_ok;
 +
 +fsdst-bits_per_raw_sample = fsrc-bits_per_raw_sample;
 +fsdst-packed_at_lsb   = fsrc-packed_at_lsb;
 +fsdst-slice_count = fsrc-slice_count;
 +if (fsrc-version3){

spacing

 +static int update_thread_context(AVCodecContext *dst, const AVCodecContext 
 *src)
 +{
 +FFV1Context *fsrc = src-priv_data;
 +FFV1Context *fdst = dst-priv_data;
 +int i, ret;
 +
 +if (dst == src)
 +return 0;
 +
 +{
 +FFV1Context bak = *fdst;
 +memcpy(fdst, fsrc, sizeof(*fdst));
 +memcpy(fdst-initial_states, bak.initial_states, 
 sizeof(fdst-initial_states));
 +memcpy(fdst-slice_context,  bak.slice_context , 
 sizeof(fdst-slice_context));

odd comma spacing

 +fdst-picture  = bak.picture;
 +fdst-last_picture = bak.last_picture;
 +for (i = 0; ifdst-num_h_slices * fdst-num_v_slices; i++) {

spacing

 +FFV1Context *fssrc = fsrc-slice_context[i];
 +FFV1Context *fsdst = fdst-slice_context[i];
 +copy_fields(fsdst, fssrc, fsrc);
 +}
 +}

This extra block seems unnecessary, just move the variable declaration.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] g2meet: factor out seeking to the chunk end

2014-02-10 Thread Luca Barbato
On 08/02/14 14:36, Kostya Shishkov wrote:
 From: Maxim Poliakovski max_p...@gmx.de
 Signed-off-by: Kostya Shishkov kostya.shish...@gmail.com
 ---
  libavcodec/g2meet.c |   21 -
  1 file changed, 8 insertions(+), 13 deletions(-)
 

Seems ok.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/5] g2meet: make JPEG tile decoder operate on 8x8 block mask

2014-02-10 Thread Luca Barbato
On 08/02/14 14:36, Kostya Shishkov wrote:
 This is needed for upcoming Go2Meeting (G2M2/G2M3) decoder.
 ---
  libavcodec/g2meet.c |   23 ---
  1 file changed, 16 insertions(+), 7 deletions(-)
 

mask is surely large enough?

Beside that possibly ok.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/5] g2meet: make JPEG tile decoder operate on 8x8 block mask

2014-02-10 Thread Kostya Shishkov
On Mon, Feb 10, 2014 at 12:57:45PM +0100, Luca Barbato wrote:
 On 08/02/14 14:36, Kostya Shishkov wrote:
  This is needed for upcoming Go2Meeting (G2M2/G2M3) decoder.
  ---
   libavcodec/g2meet.c |   23 ---
   1 file changed, 16 insertions(+), 7 deletions(-)
  
 
 mask is surely large enough?

yes
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavfi: add compand audio filter

2014-02-10 Thread Diego Biurrun
On Sat, Feb 08, 2014 at 08:59:33PM -0500, Andrew Kelley wrote:
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -467,6 +467,80 @@ To fix a 5.1 WAV improperly encoded in AAC's native 
 channel order
 +
 +@item attacks
 +@item decays
 +Set list of times in seconds for each channel over which the instantaneous 
 level
 +of the input signal is averaged to determine its volume. @var{attacks} 
 refers to

What is an instantaneous level?  A current level?

 +@item points
 +Set list of points for transfer function, specified in dB relative to maximum
 +possible signal amplitude. Each key points list need to be defined using the
 +following syntax: @code{x0/y0 x1/y1 x2/y2 }

needS

 +@item soft-knee
 +Set amount for which the points at where adjacent line segments on the 
 transfer
 +function meet will be rounded. Defaults is 0.01.

This sentence is highly confusing.  I have trouble extracting a valid
interpretation from it.

 +@item gain
 +Set additional gain in dB to be applied at all points on the transfer 
 function
 +and allows easy adjustment of the overall gain. Default is 0.

allow_

 +@item delay
 +Set delay in seconds. Default is 0. The input audio is analysed immediately,

AnalyZed, let's stick to American English.

 +@item
 +Noise-gate for when the noise is at a lower level than the signal:
 +
 +@item
 +Here is another noise-gate, this time for when the noise is at a higher level

noise gate

 --- a/libavfilter/Makefile
 +++ b/libavfilter/Makefile
 @@ -37,6 +37,7 @@ OBJS-$(CONFIG_CHANNELSPLIT_FILTER)   += 
 af_channelsplit.o
  OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
  OBJS-$(CONFIG_RESAMPLE_FILTER)   += af_resample.o
  OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o
 +OBJS-$(CONFIG_COMPAND_FILTER)+= af_compand.o

order

 --- /dev/null
 +++ b/libavfilter/af_compand.c
 @@ -0,0 +1,595 @@
 +
 +#include libavutil/mem.h
 +#include libavutil/avassert.h
 +#include libavutil/mathematics.h
 +#include libavutil/channel_layout.h
 +#include libavutil/opt.h
 +#include libavutil/common.h
 +#include audio.h
 +#include avfilter.h
 +#include formats.h
 +#include internal.h

We order includes nowadays.

 +layouts = ff_all_channel_layouts();
 +if (!layouts)
 +return AVERROR(ENOMEM);
 +ff_set_common_channel_layouts(ctx, layouts);
 +
 +formats = ff_make_format_list(sample_fmts);
 +if (!formats)
 +return AVERROR(ENOMEM);
 +ff_set_common_formats(ctx, formats);
 +
 +formats = ff_all_samplerates();
 +if (!formats)
 +return AVERROR(ENOMEM);
 +ff_set_common_samplerates(ctx, formats);

This looks like you leak memory if the second or third allocation fails
and you return early.

 +/**
 + * Clip a double value into the amin-amax range.
 + * @param a value to clip
 + * @param amin minimum value of the clip range
 + * @param amax maximum value of the clip range

Vertically aligning the parameter descriptions would make this more
readable.

 +static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
 +{
 +CompandContext *s = ctx-priv;
 +AVFilterLink *inlink = ctx-inputs[0];
 +const int channels = 
 av_get_channel_layout_nb_channels(inlink-channel_layout);
 +const int nb_samples = frame-nb_samples;
 +int chan, i, av_uninit(dindex), oindex, av_uninit(count);

The av_uninit look fishy.  Why are they necessary?

 +static char *av_strtok(char *s, const char *delim, char **saveptr)

What's the problem with just using strtok()?

 +static int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int 
 *linesize, int nb_channels,
 +   int nb_samples, enum AVSampleFormat 
 sample_fmt, int align)

indentation, long lines

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] pcmdec: replace a reachable assert with an error check

2014-02-10 Thread Tim Walker
On 10 Feb 2014, at 07:48, Anton Khirnov an...@khirnov.net wrote:

 Libavformat should not make any assumptions about values returned from
 other libraries. This assert is easily reachable by using a non-raw
 codec id.
 ---
 libavformat/pcmdec.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

LGTM.

Tim
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/5] wip: fate: FFv1 testcases

2014-02-10 Thread Janne Grunau
On 2014-02-10 12:17:30 +0100, Diego Biurrun wrote:
 On Sun, Feb 09, 2014 at 07:28:17PM +0100, Luca Barbato wrote:
  From: Peter B p...@das-werkstatt.com
  
  Signed-off-by: Luca Barbato lu_z...@gentoo.org
  ---
  +###
  +#  Decoding:
  +###
  +#  YUV (8bit)
  +fate-ffv1-dec-v1-defaults:   ${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-defaults.avi} fate-ffv1-enc-v1-defaults
  +fate-ffv1-dec-v1-yuv410p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv410p.avi} fate-ffv1-enc-v1-yuv410p
  +fate-ffv1-dec-v1-yuv411p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv411p.avi} fate-ffv1-enc-v1-yuv411p
  +fate-ffv1-dec-v1-yuv420p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv420p.avi} fate-ffv1-enc-v1-yuv420p
  +fate-ffv1-dec-v1-yuv422p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv422p.avi} fate-ffv1-enc-v1-yuv422p
  +fate-ffv1-dec-v1-yuv444p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv444p.avi} fate-ffv1-enc-v1-yuv444p
  +fate-ffv1-dec-v1-yuv440p:${CMD = framecrc -i 
  $(DEC_SRC)/ffv1-enc-v1-yuv440p.avi} fate-ffv1-enc-v1-yuv440p
 
 Generally $() is preferred over ${}.

cleaner and more in sync with the rest to add
'fate-ffv1-dec-v1-%: fate-ffv1-enc-v1-%'
and drop the ${}

  +# Requires generating vsynth1.yuv as input source:
  +$(FATE_FFV1-yes): tests/data/vsynth1.yuv

missing $(TARGET_PATH)

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/5] ffv1: Make sure to clean up on error

2014-02-10 Thread Janne Grunau
On 2014-02-09 19:28:15 +0100, Luca Barbato wrote:
 Plug some leaks and free on non-allocated pointers.
 ---
  libavcodec/ffv1.c| 29 +
  libavcodec/ffv1dec.c | 14 +-
  2 files changed, 34 insertions(+), 9 deletions(-)
 
 diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
 index 9e7ba2e..1bc4273 100644
 --- a/libavcodec/ffv1.c
 +++ b/libavcodec/ffv1.c
 @@ -189,7 +189,7 @@ int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
  
  av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  {
 -int i;
 +int i, j;
  
  f-slice_count = f-num_h_slices * f-num_v_slices;
  if (f-slice_count = 0) {

since I found it nowhere else this needs a check for f-slice_count 
MAX_SLICES

 @@ -205,6 +205,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  int sxe = f-avctx-width  * (sx + 1) / f-num_h_slices;
  int sys = f-avctx-height *  sy  / f-num_v_slices;
  int sye = f-avctx-height * (sy + 1) / f-num_v_slices;
 +
 +if (!fs)
 +goto fail;
 +
  f-slice_context[i] = fs;
  memcpy(fs, f, sizeof(*fs));
  memset(fs-rc_stat2, 0, sizeof(fs-rc_stat2));
 @@ -216,10 +220,21 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  
  fs-sample_buffer = av_malloc(3 * MAX_PLANES * (fs-width + 6) *
sizeof(*fs-sample_buffer));
 -if (!fs-sample_buffer)
 -return AVERROR(ENOMEM);
 +if (!fs-sample_buffer) {
 +av_freep(f-slice_context + i);
 +goto fail;
 +}
  }
  return 0;
 +
 +fail:
 +for (j = 0; j  i; j++) {
 +av_free(f-slice_context[i]-sample_buffer);
 +av_freep(f-slice_context + j);
 +}
 +for (; i  f-slice_count; i++)
 +f-slice_context[i] = NULL;

is there a reason to believe that these could be not null?

The error handling looks imho too complex while technically correct.
I would just go over all f-slice_count contexts free
f-slice_context[i]-sample_buffer if (f-slice_context[i]) and
av_freep() the slice context then.

and while identical f-slice_context[i] is probably easier to read

 +return AVERROR(ENOMEM);
  }
  
  int ffv1_allocate_initial_states(FFV1Context *f)
 @@ -229,8 +244,14 @@ int ffv1_allocate_initial_states(FFV1Context *f)
  for (i = 0; i  f-quant_table_count; i++) {
  f-initial_states[i] = av_malloc(f-context_count[i] *
   sizeof(*f-initial_states[i]));
 -if (!f-initial_states[i])
 +if (!f-initial_states[i]) {
 +int j;
 +for (j = 0; j  i; j++)
 +av_freep(f-initial_states + j);
 +for (; i  f-quant_table_count; i++)
 + f-initial_states[i] = NULL;

same, is there any reason to believe one of those is not NULL?

  return AVERROR(ENOMEM);
 +}
  memset(f-initial_states[i], 128,
 f-context_count[i] * sizeof(*f-initial_states[i]));
  }
 diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
 index 98fd9d8..dd31d89 100644
 --- a/libavcodec/ffv1dec.c
 +++ b/libavcodec/ffv1dec.c
 @@ -805,15 +805,19 @@ static av_cold int ffv1_decode_init(AVCodecContext 
 *avctx)
  
  ffv1_common_init(avctx);
  
 -f-last_picture = av_frame_alloc();
 -if (!f-last_picture)
 -return AVERROR(ENOMEM);
 -
  if (avctx-extradata  (ret = read_extra_header(f))  0)

read_extra_header() might have already allocate memory so this needs
ffv1_close() too.

  return ret;
  
 -if ((ret = ffv1_init_slice_contexts(f))  0)
 +if ((ret = ffv1_init_slice_contexts(f))  0) {
 +ffv1_close(avctx);
  return ret;
 +}
 +
 +f-last_picture = av_frame_alloc();
 +if (!f-last_picture) {
 +ffv1_close(avctx);
 +return AVERROR(ENOMEM);
 +}

no need to change the allocation order

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/5] ffv1: Make sure to clean up on error

2014-02-10 Thread Luca Barbato
On 10/02/14 14:03, Janne Grunau wrote:
 On 2014-02-09 19:28:15 +0100, Luca Barbato wrote:
 Plug some leaks and free on non-allocated pointers.
 ---
  libavcodec/ffv1.c| 29 +
  libavcodec/ffv1dec.c | 14 +-
  2 files changed, 34 insertions(+), 9 deletions(-)

 diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
 index 9e7ba2e..1bc4273 100644
 --- a/libavcodec/ffv1.c
 +++ b/libavcodec/ffv1.c
 @@ -189,7 +189,7 @@ int ffv1_init_slice_state(FFV1Context *f, FFV1Context 
 *fs)
  
  av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  {
 -int i;
 +int i, j;
  
  f-slice_count = f-num_h_slices * f-num_v_slices;
  if (f-slice_count = 0) {
 
 since I found it nowhere else this needs a check for f-slice_count 
 MAX_SLICES

Thanks for spotting.

 @@ -205,6 +205,10 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  int sxe = f-avctx-width  * (sx + 1) / f-num_h_slices;
  int sys = f-avctx-height *  sy  / f-num_v_slices;
  int sye = f-avctx-height * (sy + 1) / f-num_v_slices;
 +
 +if (!fs)
 +goto fail;
 +
  f-slice_context[i] = fs;
  memcpy(fs, f, sizeof(*fs));
  memset(fs-rc_stat2, 0, sizeof(fs-rc_stat2));
 @@ -216,10 +220,21 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
  
  fs-sample_buffer = av_malloc(3 * MAX_PLANES * (fs-width + 6) *
sizeof(*fs-sample_buffer));
 -if (!fs-sample_buffer)
 -return AVERROR(ENOMEM);
 +if (!fs-sample_buffer) {
 +av_freep(f-slice_context + i);
 +goto fail;
 +}
  }
  return 0;
 +
 +fail:
 +for (j = 0; j  i; j++) {
 +av_free(f-slice_context[i]-sample_buffer);
 +av_freep(f-slice_context + j);
 +}
 +for (; i  f-slice_count; i++)
 +f-slice_context[i] = NULL;
 
 is there a reason to believe that these could be not null?

Probably we could zero it from start.

 The error handling looks imho too complex while technically correct.
 I would just go over all f-slice_count contexts free
 f-slice_context[i]-sample_buffer if (f-slice_context[i]) and
 av_freep() the slice context then.

I prefer be sure than sorry.

 and while identical f-slice_context[i] is probably easier to read

I prefer not use foo[i] when possible because it is less easier to read
and  could be typoed away too easily.

 +return AVERROR(ENOMEM);
  }
  
  int ffv1_allocate_initial_states(FFV1Context *f)
 @@ -229,8 +244,14 @@ int ffv1_allocate_initial_states(FFV1Context *f)
  for (i = 0; i  f-quant_table_count; i++) {
  f-initial_states[i] = av_malloc(f-context_count[i] *
   sizeof(*f-initial_states[i]));
 -if (!f-initial_states[i])
 +if (!f-initial_states[i]) {
 +int j;
 +for (j = 0; j  i; j++)
 +av_freep(f-initial_states + j);
 +for (; i  f-quant_table_count; i++)
 + f-initial_states[i] = NULL;
 
 same, is there any reason to believe one of those is not NULL?

As above.


  return AVERROR(ENOMEM);
 +}
  memset(f-initial_states[i], 128,
 f-context_count[i] * sizeof(*f-initial_states[i]));
  }
 diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
 index 98fd9d8..dd31d89 100644
 --- a/libavcodec/ffv1dec.c
 +++ b/libavcodec/ffv1dec.c
 @@ -805,15 +805,19 @@ static av_cold int ffv1_decode_init(AVCodecContext 
 *avctx)
  
  ffv1_common_init(avctx);
  
 -f-last_picture = av_frame_alloc();
 -if (!f-last_picture)
 -return AVERROR(ENOMEM);
 -
  if (avctx-extradata  (ret = read_extra_header(f))  0)
 
 read_extra_header() might have already allocate memory so this needs
 ffv1_close() too.

right.


lu


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/5] ffv1: Make sure to clean up on error

2014-02-10 Thread Janne Grunau
On 2014-02-10 14:09:14 +0100, Luca Barbato wrote:
 On 10/02/14 14:03, Janne Grunau wrote:
  On 2014-02-09 19:28:15 +0100, Luca Barbato wrote:
  Plug some leaks and free on non-allocated pointers.
  ---
  @@ -216,10 +220,21 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
   
   fs-sample_buffer = av_malloc(3 * MAX_PLANES * (fs-width + 6) *
 sizeof(*fs-sample_buffer));
  -if (!fs-sample_buffer)
  -return AVERROR(ENOMEM);
  +if (!fs-sample_buffer) {
  +av_freep(f-slice_context + i);
  +goto fail;
  +}
   }
   return 0;
  +
  +fail:
  +for (j = 0; j  i; j++) {
  +av_free(f-slice_context[i]-sample_buffer);
  +av_freep(f-slice_context + j);
  +}
  +for (; i  f-slice_count; i++)
  +f-slice_context[i] = NULL;
  
  is there a reason to believe that these could be not null?
 
 Probably we could zero it from start.

it's zero from the start, avctx.priv_data is allocated with av_mallocz

  The error handling looks imho too complex while technically correct.
  I would just go over all f-slice_count contexts free
  f-slice_context[i]-sample_buffer if (f-slice_context[i]) and
  av_freep() the slice context then.
 
 I prefer be sure than sorry.

I would say the simpler approach is safer

  and while identical f-slice_context[i] is probably easier to read
 
 I prefer not use foo[i] when possible because it is less easier to read
 and  could be typoed away too easily.

I disagree but do as you prefer

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] aacdec: set AVFrame sample_rate

2014-02-10 Thread Janne Grunau
On 2014-02-08 21:24:00 -0500, Justin Ruggles wrote:
 On 02/08/2014 09:19 PM, John Stebbins wrote:
  AVFrame.sample_rate is set in ff_get_buffer, but aacdec calls
  ff_get_buffer before the samplerate is known. So it needs to be
  set again before returning the frame.
  ---
   libavcodec/aacdec.c | 11 +++
   1 file changed, 7 insertions(+), 4 deletions(-)
 
 LGTM

queued

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavc: set AVFrame pkt_pts and reordered_opaque in reget_buffer

2014-02-10 Thread John Stebbins
---
 libavcodec/utils.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 46f339f..b2b11ef 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -762,8 +762,11 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
 if (!frame-data[0])
 return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
 
-if (av_frame_is_writable(frame))
+if (av_frame_is_writable(frame)) {
+frame-pkt_pts = avctx-internal-pkt ? avctx-internal-pkt-pts : 
AV_NOPTS_VALUE;
+frame-reordered_opaque = avctx-reordered_opaque;
 return 0;
+}
 
 av_frame_move_ref(tmp, frame);
 
-- 
1.8.5.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavc: set AVFrame pkt_pts and reordered_opaque in reget_buffer

2014-02-10 Thread Anton Khirnov

On Mon, 10 Feb 2014 08:53:20 -0700, John Stebbins stebb...@jetheaddev.com 
wrote:
 ---
  libavcodec/utils.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/libavcodec/utils.c b/libavcodec/utils.c
 index 46f339f..b2b11ef 100644
 --- a/libavcodec/utils.c
 +++ b/libavcodec/utils.c
 @@ -762,8 +762,11 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame 
 *frame)
  if (!frame-data[0])
  return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
  
 -if (av_frame_is_writable(frame))
 +if (av_frame_is_writable(frame)) {
 +frame-pkt_pts = avctx-internal-pkt ? avctx-internal-pkt-pts : 
 AV_NOPTS_VALUE;
 +frame-reordered_opaque = avctx-reordered_opaque;
  return 0;
 +}
  
  av_frame_move_ref(tmp, frame);
  
 -- 
 1.8.5.3
 

Ok, thanks for the patch

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavfi: add compand audio filter

2014-02-10 Thread Andrew Kelley
This patch adds the `compand` audio filter from ffmpeg master branch
(currently at 7f0f47b3df) adapted to work with libav.

The filter makes use of `av_strtok` to parse the input parameters, and
it appears that libav has removed that function, so I inlined it into
the filter. Same goes for `av_clipd_c`. Same for
`av_samples_alloc_array_and_samples` except it looks like ffmpeg added
that function recently.
---
 Changelog|   1 +
 doc/filters.texi |  73 ++
 libavfilter/Makefile |   1 +
 libavfilter/af_compand.c | 596 +++
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 6 files changed, 673 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/af_compand.c

diff --git a/Changelog b/Changelog
index edd4754..fabbeee 100644
--- a/Changelog
+++ b/Changelog
@@ -56,6 +56,7 @@ version 10:
 - ATRAC3+ decoder
 - framepack filter
 - Mirillis FIC video decoder
+- compand audio filter
 
 
 version 9:
diff --git a/doc/filters.texi b/doc/filters.texi
index 8c83b4e..9624813 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -467,6 +467,79 @@ To fix a 5.1 WAV improperly encoded in AAC's native 
channel order
 avconv -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
 @end example
 
+@section compand
+Compress or expand audio dynamic range.
+
+A description of the accepted options follows.
+
+@table @option
+
+@item attacks
+@item decays
+Set list of times in seconds for each channel over which the instantaneous 
level
+of the input signal is averaged to determine its volume. @var{attacks} refers 
to
+increase of volume and @var{decays} refers to decrease of volume. For most
+situations, the attack time (response to the audio getting louder) should be
+shorter than the decay time because the human ear is more sensitive to sudden
+loud audio than sudden soft audio. Typical value for attack is 0.3 seconds and
+for decay 0.8 seconds.
+
+@item points
+Set list of points for transfer function, specified in dB relative to maximum
+possible signal amplitude. Each key points list must be defined using the
+following syntax: @code{x0/y0 x1/y1 x2/y2 }
+
+The input values must be in strictly increasing order but the transfer function
+does not have to be monotonically rising. The point @code{0/0} is assumed but
+may be overridden (by @code{0/out-dBn}). Typical values for the transfer
+function are @code{-70/-70 -60/-20}.
+
+@item soft-knee
+Set the curve radius in dB for all joints. Defaults to 0.01.
+
+@item gain
+Set additional gain in dB to be applied at all points on the transfer function.
+This allows easy adjustment of the overall gain. Defaults to 0.
+
+@item volume
+Set initial volume in dB to be assumed for each channel when filtering starts.
+This permits the user to supply a nominal level initially, so that, for
+example, a very large gain is not applied to initial signal levels before the
+companding has begun to operate. A typical value for audio which is initially
+quiet is -90 dB. Defaults to 0.
+
+@item delay
+Set delay in seconds. The input audio is analyzed immediately, but audio is
+delayed before being fed to the volume adjuster. Specifying a delay
+approximately equal to the attack/decay times allows the filter to effectively
+operate in predictive rather than reactive mode. Defaults to 0. 
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Make music with both quiet and loud passages suitable for listening in a noisy
+environment:
+@example
+compand=.3 .3:1 1:-90/-60 -60/-40 -40/-30 -20/-20:6:0:-90:0.2
+@end example
+
+@item
+Noise gate for when the noise is at a lower level than the signal:
+@example
+compand=.1 .1:.2 .2:-900/-900 -50.1/-900 -50/-50:.01:0:-90:.1
+@end example
+
+@item
+Here is another noise gate, this time for when the noise is at a higher level
+than the signal (making it, in some ways, similar to squelch):
+@example
+compand=.1 .1:.1 .1:-45.1/-45.1 -45/-900 0/-900:.01:45:-90:.1
+@end example
+@end itemize
+
 @section join
 Join multiple input streams into one multi-channel stream.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 92c1561..23dbd1d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -34,6 +34,7 @@ OBJS-$(CONFIG_ASYNCTS_FILTER)+= af_asyncts.o
 OBJS-$(CONFIG_ATRIM_FILTER)  += trim.o
 OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o
 OBJS-$(CONFIG_CHANNELSPLIT_FILTER)   += af_channelsplit.o
+OBJS-$(CONFIG_COMPAND_FILTER)+= af_compand.o
 OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_RESAMPLE_FILTER)   += af_resample.o
 OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o
diff --git a/libavfilter/af_compand.c b/libavfilter/af_compand.c
new file mode 100644
index 000..e582144
--- /dev/null
+++ b/libavfilter/af_compand.c
@@ -0,0 +1,596 @@
+/*
+ * Copyright (c) 1999 Chris Bagwell
+ * Copyright (c) 1999 Nick 

Re: [libav-devel] [PATCH] lavfi: add compand audio filter

2014-02-10 Thread Andrew Kelley
On Mon, Feb 10, 2014 at 7:13 AM, Diego Biurrun di...@biurrun.de wrote:
 On Sat, Feb 08, 2014 at 08:59:33PM -0500, Andrew Kelley wrote:
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -467,6 +467,80 @@ To fix a 5.1 WAV improperly encoded in AAC's native 
 channel order
 +
 +@item attacks
 +@item decays
 +Set list of times in seconds for each channel over which the instantaneous 
 level
 +of the input signal is averaged to determine its volume. @var{attacks} 
 refers to

 What is an instantaneous level?  A current level?

An instantaneous level is the peak of a single sample.

 +layouts = ff_all_channel_layouts();
 +if (!layouts)
 +return AVERROR(ENOMEM);
 +ff_set_common_channel_layouts(ctx, layouts);
 +
 +formats = ff_make_format_list(sample_fmts);
 +if (!formats)
 +return AVERROR(ENOMEM);
 +ff_set_common_formats(ctx, formats);
 +
 +formats = ff_all_samplerates();
 +if (!formats)
 +return AVERROR(ENOMEM);
 +ff_set_common_samplerates(ctx, formats);

 This looks like you leak memory if the second or third allocation fails
 and you return early.

Are you sure? It looks to me like memory ownership transfers to some kind of
reference counting in those ff_set_common_* functions.

 +int chan, i, av_uninit(dindex), oindex, av_uninit(count);

 The av_uninit look fishy.  Why are they necessary?

Because they are only assigned inside the loop that iterates over each channel.
We assume that there will be at least one channel, but the compiler does not
know that. Hence the av_uninit.



 +static char *av_strtok(char *s, const char *delim, char **saveptr)

 What's the problem with just using strtok()?

strtok does not have the saveptr argument.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavfi: add compand audio filter

2014-02-10 Thread Andrew Kelley
On Sat, Feb 8, 2014 at 11:22 PM, Luca Barbato lu_z...@gentoo.org wrote:

 In short, do not use av_assert* in new code you are committing to the
 mainline.


What should I do about the assert in av_clipd_c?

/**
 * Clip a double value into the amin-amax range.
 * @param  a value to clip
 * @param  amin  minimum value of the clip range
 * @param  amax  maximum value of the clip range
 * @return clipped value
 */
static av_always_inline av_const double av_clipd_c(double a, double
amin, double amax)
{
av_assert2(amin = amax);
if (a  amin)
return amin;
else if (a  amax)
return amax;
else
return a;
}

Should I simply remove it?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] libavfilter: example audio filtering program

2014-02-10 Thread Anton Khirnov
Based on a patch by Andrew Kelley superjo...@gmail.com
---
 configure   |2 +
 doc/Makefile|3 +-
 doc/examples/filter_audio.c |  362 +++
 3 files changed, 366 insertions(+), 1 deletion(-)
 create mode 100644 doc/examples/filter_audio.c

diff --git a/configure b/configure
index f4ee881..8d293d2 100755
--- a/configure
+++ b/configure
@@ -1094,6 +1094,7 @@ COMPONENT_LIST=
 
 
 EXAMPLE_LIST=
+filter_audio_example
 output_example
 transcode_aac_example
 
@@ -2017,6 +2018,7 @@ ocv_filter_deps=libopencv
 scale_filter_deps=swscale
 
 # examples
+filter_audio_example_deps=avfilter avutil
 output_example_deps=avcodec avformat avutil swscale
 transcode_aac_example_deps=avcodec avformat avresample
 
diff --git a/doc/Makefile b/doc/Makefile
index e92e72f..cd7f23b 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -15,9 +15,10 @@ DOCS-$(CONFIG_POD2MAN)  += 
$(MANPAGES) $(PODPAGES)
 DOCS-$(CONFIG_TEXI2HTML)+= $(HTMLPAGES)
 DOCS = $(DOCS-yes)
 
+DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio
 DOC_EXAMPLES-$(CONFIG_OUTPUT_EXAMPLE)   += output
 DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE)+= transcode_aac
-ALL_DOC_EXAMPLES = output transcode_aac
+ALL_DOC_EXAMPLES = filter_audio output transcode_aac
 
 DOC_EXAMPLES := $(DOC_EXAMPLES-yes:%=doc/examples/%$(EXESUF))
 ALL_DOC_EXAMPLES := $(ALL_DOC_EXAMPLES:%=doc/examples/%$(EXESUF))
diff --git a/doc/examples/filter_audio.c b/doc/examples/filter_audio.c
new file mode 100644
index 000..58e780b
--- /dev/null
+++ b/doc/examples/filter_audio.c
@@ -0,0 +1,362 @@
+/*
+ * copyright (c) 2013 Andrew Kelley
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * libavfilter API use example.
+ *
+ * @example doc/examples/filter.c
+ * This example will generate a sine wave audio
+ * pass it through a simple filter chain, and then compute the md5 checksum of
+ * the output data
+ *
+ * The filter chain it uses is:
+ * (input) - abuffer - volume - aformat - abuffersink - (output)
+ *
+ * abuffer: this provides the endpoint where you can feed the decoded samples.
+ * volume: in this example we hardcode it to 0.90
+ * aformat: this converts the samples to the samplefreq, channel layout,
+ *  and sample format required by the audio device.
+ * abuffersink: this provides the endpoint where you can read the samples after
+ *  they have passed through the filter chain.
+ */
+
+#include inttypes.h
+#include math.h
+#include stdio.h
+#include stdlib.h
+
+#include libavutil/channel_layout.h
+#include libavutil/md5.h
+#include libavutil/opt.h
+#include libavutil/samplefmt.h
+
+#include libavfilter/avfilter.h
+#include libavfilter/buffersink.h
+#include libavfilter/buffersrc.h
+
+#define INPUT_SAMPLERATE 48000
+#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
+#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
+
+#define VOLUME_VAL 0.90
+
+static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src, 
AVFilterContext **sink)
+{
+AVFilterGraph *filter_graph;
+AVFilterContext *abuffer_ctx;
+AVFilter*abuffer;
+AVFilterContext *volume_ctx;
+AVFilter*volume;
+AVFilterContext *aformat_ctx;
+AVFilter*aformat;
+AVFilterContext *abuffersink_ctx;
+AVFilter*abuffersink;
+
+AVDictionary *options_dict = NULL;
+uint8_t options_str[1024];
+uint8_t ch_layout[64];
+
+int err;
+
+/* create a new filtergraph, which will contain all the filters */
+filter_graph = avfilter_graph_alloc();
+if (!filter_graph) {
+fprintf(stderr, Unable to create filter graph.\n);
+return AVERROR(ENOMEM);
+}
+
+/* create the abuffer filter
+ * it will be used for feeding the data into the graph */
+abuffer = avfilter_get_by_name(abuffer);
+if (!abuffer) {
+fprintf(stderr, Could not find the abuffer filter.\n);
+return AVERROR_FILTER_NOT_FOUND;
+}
+
+abuffer_ctx = avfilter_graph_alloc_filter(filter_graph, abuffer, src);
+if (!abuffer_ctx) {
+fprintf(stderr, Could not allocate the abuffer instance.\n);
+return AVERROR(ENOMEM);
+}
+
+/* set the 

Re: [libav-devel] [PATCH] libavformat/mpegts: expose raw packet size

2014-02-10 Thread Leandro Dorileo

ping?


Leandro Dorileo wrote:

We cannot easily determine if an mpeg TS's packet size is DVHS, FEC
or so on, for that we need to expose the internal raw_packet_size
field.

Change-Id: I3eb179703b62748ae8bec6bd85a50760c0bc6d84
---
  libavformat/mpegts.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 3f828b4..428ac79 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -134,6 +134,8 @@ struct MpegTSContext {
  static const AVOption options[] = {
  {compute_pcr, Compute exact PCR for each transport stream packet., 
offsetof(MpegTSContext, mpeg2ts_compute_pcr), AV_OPT_TYPE_INT,
   {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
+{ts_packetsize, Output option carrying the raw packet size., 
offsetof(MpegTSContext, raw_packet_size), AV_OPT_TYPE_INT,
+ {.i64 = 0}, 0, 0, AV_OPT_FLAG_METADATA },
  { NULL },
  };




___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] libavformat/mpegts: expose raw packet size

2014-02-10 Thread Luca Barbato
On 10/02/14 21:39, Leandro Dorileo wrote:
 ping?

 Leandro Dorileo wrote:
 We cannot easily determine if an mpeg TS's packet size is DVHS, FEC
 or so on, for that we need to expose the internal raw_packet_size
 field.


Using an avoption this way is a first. Thanks for the patch Leandro.

Anton the documentation seems to describe the field that way, are you ok
with it?

lu


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] FATE: force FLAC in the lavf ogg test

2014-02-10 Thread Andrew Kelley
Apologies for missing this.

On Mon, Feb 10, 2014 at 1:48 AM, Anton Khirnov an...@khirnov.net wrote:
 Since b0c2c09, vorbis would be used if libvorbis is compiled in.
 ---
  tests/lavf-regression.sh |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
 index d9c8a8f..3083719 100755
 --- a/tests/lavf-regression.sh
 +++ b/tests/lavf-regression.sh
 @@ -226,7 +226,7 @@ do_audio_only s16.voc -ac 2 -acodec pcm_s16le
  fi

  if [ -n $do_ogg ] ; then
 -do_audio_only ogg
 +do_audio_only ogg  -c:a flac
  fi

  if [ -n $do_rso ] ; then
 --
 1.7.10.4

 ___
 libav-devel mailing list
 libav-devel@libav.org
 https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] buffersink: document special error codes returned from av_buffersink_get_frame

2014-02-10 Thread Anton Khirnov
---
 libavfilter/buffersink.h |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 75cea35..0b183f7 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -70,8 +70,12 @@ int av_buffersink_read_samples(AVFilterContext *ctx, 
AVFilterBufferRef **buf,
  * @param frame pointer to an allocated frame that will be filled with data.
  *  The data must be freed using av_frame_unref() / av_frame_free()
  *
- * @return = 0 in case of success, a negative AVERROR code in case of
- * failure.
+ * @return
+ * - = 0 if a frame was successfully returned.
+ * - AVERROR(EAGAIN) if no frames are available at this point; more
+ *   input frames must be added to the filtergraph to get more output.
+ * - AVERROR_EOF if there will be no more output frames on this sink.
+ * - A different negative AVERROR code in other failure cases.
  */
 int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame);
 
@@ -86,6 +90,9 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame);
  *  frame will contain exactly nb_samples audio samples, except at
  *  the end of stream, when it can contain less than nb_samples.
  *
+ * @return the return codes have the same meaning as for
+ * av_buffersink_get_samples()
+ *
  * @warning do not mix this function with av_buffersink_get_frame(). Use only 
one or
  * the other with a single sink, not both.
  */
-- 
1.7.10.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] lavfi doxy: add buffer{src, sink}.h to the main lavfi doxy group

2014-02-10 Thread Anton Khirnov
---
 libavfilter/buffersink.h |   11 +++
 libavfilter/buffersrc.h  |   11 +++
 2 files changed, 22 insertions(+)

diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 0b183f7..b2466f5 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -21,11 +21,18 @@
 
 /**
  * @file
+ * @ingroup lavfi_buffersink
  * memory buffer sink API
  */
 
 #include avfilter.h
 
+/**
+ * @defgroup lavfi_buffersink Buffer sink API
+ * @ingroup lavfi
+ * @{
+ */
+
 #if FF_API_AVFILTERBUFFER
 /**
  * Get a buffer with filtered data from sink and put it in buf.
@@ -98,4 +105,8 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame);
  */
 int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int 
nb_samples);
 
+/**
+ * @}
+ */
+
 #endif /* AVFILTER_BUFFERSINK_H */
diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
index c6f7ff9..419157c 100644
--- a/libavfilter/buffersrc.h
+++ b/libavfilter/buffersrc.h
@@ -22,11 +22,18 @@
 
 /**
  * @file
+ * @ingroup lavfi_buffersrc
  * Memory buffer source API.
  */
 
 #include avfilter.h
 
+/**
+ * @defgroup lavfi_buffersrc Buffer source API
+ * @ingroup lavfi
+ * @{
+ */
+
 #if FF_API_AVFILTERBUFFER
 /**
  * Add a buffer to the filtergraph s.
@@ -70,4 +77,8 @@ int av_buffersrc_write_frame(AVFilterContext *s, const 
AVFrame *frame);
  */
 int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
 
+/**
+ * @}
+ */
+
 #endif /* AVFILTER_BUFFERSRC_H */
-- 
1.7.10.4

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] dca xll aka DTS-HD Master Audio

2014-02-10 Thread Niels Möller
Hi,

I intend to add support for the xll extension to the dca decoder, aka
DTS-HD Master Audio, as requested on
https://wiki.videolan.org/Bounties#List_of_bounties. I work at Southpole
Consulting, together with Benjamin Larsson, and I'll hopefully be able
to spend a couple of weeks of working time on this.

There are two parts of this project. First, implement the parsing and
processing of the xll extension data. Second, reverse engineer whatever
details of the fixed point decoding operations are needed to actually
get bit exact lossless result, and implement them in libav.

Resources I'm aware of: 

The spec itself. As far as I understand the 2012-09 version is the
latest one. http://webapp.etsi.org/ewp/copy_file.asp?wki_id=39523

The wip patches at https://github.com/richardpl/FFmpeg/tree/xll

Test files at https://samples.libav.org/A-codecs/DTS/dts/

A couple of questions:

* the libavcodec/dcadec.c file look a bit different in ffmpeg and libav,
  and ffmpeg includes handling of the XXCH extension. I'm not yet
  familiar enough with dca to say how related this is to xll, but maybe
  it would make sense to first merge the ffmpeg changes to libav? (I don't
  know the history of the ffmpeg/libav split).

* I tried libav's make check, and as far as I could see, there were no
  testcases specific for the dca decoder. Is that right, or have I
  missed something?

* When I get to the bitexact part of this project, I'd need to have an
  original file (flac/wav, or whatever lossless format which is well
  supported in libav), and the same file compressed with dca and the xll
  lossless extension. The objective obviously being that the samples
  output from dcadec should be bit-by-bit identical to the original
  audio samples. Does anyone have such a set of test files?

Outside of work, I'm involved in the GNU Nettle crypto library,
and the GNU GMP bignum library. I'm new to libav.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel