[FFmpeg-devel] [PATCH] avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for HEVC copy and hv mc functions

2015-04-19 Thread shivraj.patil
From: Shivraj Patil 

Signed-off-by: Shivraj Patil 
---
 libavcodec/mips/hevcdsp_init_mips.c |   19 +
 libavcodec/mips/hevcdsp_mips.h  |   20 +
 libavcodec/mips/hevcdsp_msa.c   | 1098 +++
 libavutil/mips/generic_macros_msa.h |  133 +
 4 files changed, 1270 insertions(+)

diff --git a/libavcodec/mips/hevcdsp_init_mips.c 
b/libavcodec/mips/hevcdsp_init_mips.c
index 05ed81f..4fec336 100644
--- a/libavcodec/mips/hevcdsp_init_mips.c
+++ b/libavcodec/mips/hevcdsp_init_mips.c
@@ -25,6 +25,16 @@ static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c,
   const int bit_depth)
 {
 if (8 == bit_depth) {
+c->put_hevc_qpel[1][0][0] = ff_hevc_put_hevc_pel_pixels4_8_msa;
+c->put_hevc_qpel[2][0][0] = ff_hevc_put_hevc_pel_pixels6_8_msa;
+c->put_hevc_qpel[3][0][0] = ff_hevc_put_hevc_pel_pixels8_8_msa;
+c->put_hevc_qpel[4][0][0] = ff_hevc_put_hevc_pel_pixels12_8_msa;
+c->put_hevc_qpel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_8_msa;
+c->put_hevc_qpel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_8_msa;
+c->put_hevc_qpel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_msa;
+c->put_hevc_qpel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_8_msa;
+c->put_hevc_qpel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_8_msa;
+
 c->put_hevc_qpel[1][0][1] = ff_hevc_put_hevc_qpel_h4_8_msa;
 c->put_hevc_qpel[3][0][1] = ff_hevc_put_hevc_qpel_h8_8_msa;
 c->put_hevc_qpel[4][0][1] = ff_hevc_put_hevc_qpel_h12_8_msa;
@@ -42,6 +52,15 @@ static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c,
 c->put_hevc_qpel[7][1][0] = ff_hevc_put_hevc_qpel_v32_8_msa;
 c->put_hevc_qpel[8][1][0] = ff_hevc_put_hevc_qpel_v48_8_msa;
 c->put_hevc_qpel[9][1][0] = ff_hevc_put_hevc_qpel_v64_8_msa;
+
+c->put_hevc_qpel[1][1][1] = ff_hevc_put_hevc_qpel_hv4_8_msa;
+c->put_hevc_qpel[3][1][1] = ff_hevc_put_hevc_qpel_hv8_8_msa;
+c->put_hevc_qpel[4][1][1] = ff_hevc_put_hevc_qpel_hv12_8_msa;
+c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_8_msa;
+c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_8_msa;
+c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_8_msa;
+c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_8_msa;
+c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_8_msa;
 }
 }
 #endif  // #if HAVE_MSA
diff --git a/libavcodec/mips/hevcdsp_mips.h b/libavcodec/mips/hevcdsp_mips.h
index 13cdb5b..4f7f273 100644
--- a/libavcodec/mips/hevcdsp_mips.h
+++ b/libavcodec/mips/hevcdsp_mips.h
@@ -29,6 +29,16 @@ void ff_hevc_put_hevc_##PEL##_##DIRWIDTH##_8_msa(int16_t 
*dst,  \
  intptr_t my,   \
  int width)
 
+MC(pel, pixels, 4);
+MC(pel, pixels, 6);
+MC(pel, pixels, 8);
+MC(pel, pixels, 12);
+MC(pel, pixels, 16);
+MC(pel, pixels, 24);
+MC(pel, pixels, 32);
+MC(pel, pixels, 48);
+MC(pel, pixels, 64);
+
 MC(qpel, h, 4);
 MC(qpel, h, 8);
 MC(qpel, h, 12);
@@ -46,4 +56,14 @@ MC(qpel, v, 24);
 MC(qpel, v, 32);
 MC(qpel, v, 48);
 MC(qpel, v, 64);
+
+MC(qpel, hv, 4);
+MC(qpel, hv, 8);
+MC(qpel, hv, 12);
+MC(qpel, hv, 16);
+MC(qpel, hv, 24);
+MC(qpel, hv, 32);
+MC(qpel, hv, 48);
+MC(qpel, hv, 64);
+
 #undef MC
diff --git a/libavcodec/mips/hevcdsp_msa.c b/libavcodec/mips/hevcdsp_msa.c
index 88e97d6..fcc344b 100644
--- a/libavcodec/mips/hevcdsp_msa.c
+++ b/libavcodec/mips/hevcdsp_msa.c
@@ -21,6 +21,18 @@
 #include "libavutil/mips/generic_macros_msa.h"
 #include "libavcodec/mips/hevcdsp_mips.h"
 
+#define HEVC_FILT_8TAP_DPADD_W(vec0, vec1, vec2, vec3,\
+   filt0, filt1, filt2, filt3)\
+( {   \
+v4i32 out;\
+  \
+out = __msa_dotp_s_w((v8i16) (vec0), (v8i16) (filt0));\
+out = __msa_dpadd_s_w(out, (v8i16) (vec1), (v8i16) (filt1));  \
+out = __msa_dpadd_s_w(out, (v8i16) (vec2), (v8i16) (filt2));  \
+out = __msa_dpadd_s_w(out, (v8i16) (vec3), (v8i16) (filt3));  \
+out;  \
+} )
+
 #define HEVC_FILT_8TAP_DPADD_H(vec0, vec1, vec2, vec3, 
\
filt0, filt1, filt2, filt3, 
\
var_in) 
\
@@ -34,6 +46,603 @@
 out;   
\
 } )
 
+static void hevc_copy_4w_msa(uint8_t * __restrict src, int32_t src_stride,
+ int16_t * __restrict dst, int32_t dst_stride,
+ int32_t height)
+{
+v16i8 zero = { 0 };
+
+if (2 == height) {
+uint64_t out0, out

Re: [FFmpeg-devel] [PATCH] avformat/http: Return an error in case of prematurely ending data

2015-04-19 Thread Michael Niedermayer
On Sun, Mar 29, 2015 at 12:33:35AM +0100, Michael Niedermayer wrote:
> Fixes Ticket 4039
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/http.c |8 
>  1 file changed, 8 insertions(+)

applied

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

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


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


Re: [FFmpeg-devel] [PATCH] avformat/http: Return an error in case of prematurely ending data

2015-04-19 Thread wm4
On Sun, 29 Mar 2015 00:33:35 +0100
Michael Niedermayer  wrote:

> Fixes Ticket 4039
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/http.c |8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index da3c9be..a1d3763 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -907,6 +907,14 @@ static int http_buf_read(URLContext *h, uint8_t *buf, 
> int size)
>  s->filesize >= 0 && s->off >= s->filesize)
>  return AVERROR_EOF;
>  len = ffurl_read(s->hd, buf, size);
> +if (!len && (!s->willclose || s->chunksize < 0) &&
> +s->filesize >= 0 && s->off < s->filesize) {
> +av_log(h, AV_LOG_ERROR,
> +   "Streams ends prematurly at %"PRId64", should be 
> %"PRId64"\n",

2 typos.

> +   s->off, s->filesize
> +  );
> +return AVERROR(EIO);
> +}
>  }
>  if (len > 0) {
>  s->off += len;

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


Re: [FFmpeg-devel] [PATCH] avformat/http: Return an error in case of prematurely ending data

2015-04-19 Thread Michael Niedermayer
On Sun, Apr 19, 2015 at 02:17:09PM +0200, wm4 wrote:
> On Sun, 29 Mar 2015 00:33:35 +0100
> Michael Niedermayer  wrote:
> 
> > Fixes Ticket 4039
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/http.c |8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/libavformat/http.c b/libavformat/http.c
> > index da3c9be..a1d3763 100644
> > --- a/libavformat/http.c
> > +++ b/libavformat/http.c
> > @@ -907,6 +907,14 @@ static int http_buf_read(URLContext *h, uint8_t *buf, 
> > int size)
> >  s->filesize >= 0 && s->off >= s->filesize)
> >  return AVERROR_EOF;
> >  len = ffurl_read(s->hd, buf, size);
> > +if (!len && (!s->willclose || s->chunksize < 0) &&
> > +s->filesize >= 0 && s->off < s->filesize) {
> > +av_log(h, AV_LOG_ERROR,
> > +   "Streams ends prematurly at %"PRId64", should be 
> > %"PRId64"\n",
> 
> 2 typos.

fixed, hopefully

thnaks

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/riff: support G729A

2015-04-19 Thread Michael Niedermayer
On Fri, Apr 17, 2015 at 05:30:37PM +0200, Paul B Mahol wrote:
> On 4/17/15, Michael Niedermayer  wrote:
> > On Fri, Apr 17, 2015 at 02:37:33PM +, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavformat/riff.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >
> > LGTM
> >
> > where can i find such sample ?
> 
> MyTest.wav in incoming.

thanks

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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


Re: [FFmpeg-devel] Pixel format 12bit grayscale

2015-04-19 Thread Reimar Döffinger
On Mon, Apr 13, 2015 at 09:59:57AM +, Marco Porsch wrote:
> Previously we had regular 16bit RAW that worked like a charm as input to 
> FFmpeg. The naïve approach of upscaling the 12bit to 16bit destroys the 
> compression efficiency of course...

I think there's your problem, that is not a "of course at all".
Upscaling 12 to 16 bit should take a at best negligible amount of extra
encoding space with any sane compression method.
(besides the existing possibility as mentioned later of telling the
encoder how many of those 16 bits actually are relevant).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter/vf_colorkey: Add colorkey video filter

2015-04-19 Thread Timo Rothenpieler
---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 doc/filters.texi  |  39 
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_colorkey.c | 226 ++
 6 files changed, 269 insertions(+)
 create mode 100644 libavfilter/vf_colorkey.c

diff --git a/Changelog b/Changelog
index 2e30b24..e99d1e9 100644
--- a/Changelog
+++ b/Changelog
@@ -17,6 +17,7 @@ version :
 - WebM Live Chunk Muxer
 - nvenc level and tier options
 - chorus filter
+- colorkey video filter
 
 
 version 2.6:
diff --git a/MAINTAINERS b/MAINTAINERS
index 598c0b3..18f6ba3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -352,6 +352,7 @@ Filters:
   avf_showcqt.c Muhammad Faiz
   vf_blend.cPaul B Mahol
   vf_colorbalance.c Paul B Mahol
+  vf_colorkey.c Timo Rothenpieler
   vf_dejudder.c Nicholas Robbins
   vf_delogo.c   Jean Delvare (CC )
   vf_drawbox.c/drawgrid Andrey Utkin
diff --git a/doc/filters.texi b/doc/filters.texi
index 0f2e720..79c0753 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3026,6 +3026,45 @@ colorbalance=rs=.3
 @end example
 @end itemize
 
+@section colorkey
+RGB colorspace color keying.
+
+The filter accepts the following options:
+
+@table @option
+@item color
+The color which will be replaced with transparency.
+
+@item similarity
+Similarity percentage with the key color.
+
+0.01 matches only the exact key color, while 1.0 matches everything.
+
+@item blend
+Blend percentage.
+
+0.0 makes pixels either fully transparent, or not transparent at all.
+
+Higher values result in semi-transparent pixels, with a higher transparency
+the more similar the pixels color is to the key color.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Make every green pixel in the input image transparent:
+@example
+ffmpeg -i input.png -vf colorkey=green out.png
+@end example
+
+@item
+Make every red pixel in the input image transparent, with a high similarity 
tolerance:
+@example
+ffmpeg -i input.png -vf colorkey=0xFF:0.3 out.png
+@end example
+@end itemize
+
 @section colorlevels
 
 Adjust video input frames using levels.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 48cee50..60e6b52 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -102,6 +102,7 @@ OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
+OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
 OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 7961dca..2eeec7f 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -118,6 +118,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(CODECVIEW,  codecview,  vf);
 REGISTER_FILTER(COLORBALANCE,   colorbalance,   vf);
 REGISTER_FILTER(COLORCHANNELMIXER, colorchannelmixer, vf);
+REGISTER_FILTER(COLORKEY,   colorkey,   vf);
 REGISTER_FILTER(COLORLEVELS,colorlevels,vf);
 REGISTER_FILTER(COLORMATRIX,colormatrix,vf);
 REGISTER_FILTER(COPY,   copy,   vf);
diff --git a/libavfilter/vf_colorkey.c b/libavfilter/vf_colorkey.c
new file mode 100644
index 000..b5180cf
--- /dev/null
+++ b/libavfilter/vf_colorkey.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2015 Timo Rothenpieler 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct ColorkeyContext {
+const AVClass *class;
+
+uint8_t colorkey_rgba[4];
+float cf[3];
+
+float similarity;
+float blend;
+} ColorkeyContext;
+
+static inline int convert_format(int fmt)
+{
+switch(fmt) {
+case AV_PIX_FMT_0R

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

2015-04-19 Thread Thilo Borgmann
Am 19.04.15 um 00:49 schrieb Michael Niedermayer:
> On Sun, Apr 19, 2015 at 12:20:01AM +0200, Andreas Cadhalpun wrote:
>> On 18.04.2015 23:34, Michael Niedermayer wrote:
>>> On Sat, Apr 18, 2015 at 10:28:53PM +0200, Andreas Cadhalpun wrote:
 I don't think an assert would be good here. If you want to protect against
 future code changes, I would rather leave the error return.
 But I'd also be fine with dropping this check altogether.
 What do you prefer?
>>>
>>> whatever you prefer, the important part is to add checks where they
>>> are needed
>>
>> OK, then lets keep both checks as in the second patch I sent.
> 
> applied
> 
> thanks

Thanks!

-Thilo

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_colorkey: Add colorkey video filter

2015-04-19 Thread Michael Niedermayer
On Sun, Apr 19, 2015 at 06:15:48PM +0200, Timo Rothenpieler wrote:
[...]
> +#define SATURATE(val) (FFMAX(FFMIN((val), 1.0), 0.0))
> +
> +static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, 
> uint8_t b)
> +{
> +float diff_r = r / 255.0 - ctx->cf[0];
> +float diff_g = g / 255.0 - ctx->cf[1];
> +float diff_b = b / 255.0 - ctx->cf[2];
> +
> +float diff = sqrt(diff_r * diff_r + diff_g * diff_g + diff_b * diff_b);
> +
> +return SATURATE(FFMAX(diff - ctx->similarity, 0.0) / ctx->blend) * 255.0;


i suggest you factor the 255.0 out
like in

> +#define SATURATE(val) (FFMAX(FFMIN((val), 255.0), 0.0))
> +
> +static uint8_t do_colorkey_pixel(ColorkeyContext *ctx, uint8_t r, uint8_t g, 
> uint8_t b)
> +{
> +float diff_r = r - ctx->cf[0];
> +float diff_g = g - ctx->cf[1];
> +float diff_b = b - ctx->cf[2];
> +
> +float diff = sqrt(diff_r * diff_r + diff_g * diff_g + diff_b * diff_b);
> +
> +return SATURATE(FFMAX(diff - ctx->similarity, 0.0) / ctx->blend);

this changes the units of all the used "constants"

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

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_colorkey: Add colorkey video filter

2015-04-19 Thread Michael Niedermayer
On Sun, Apr 19, 2015 at 06:15:48PM +0200, Timo Rothenpieler wrote:
> ---
>  Changelog |   1 +
>  MAINTAINERS   |   1 +
>  doc/filters.texi  |  39 
>  libavfilter/Makefile  |   1 +
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/vf_colorkey.c | 226 
> ++
>  6 files changed, 269 insertions(+)
>  create mode 100644 libavfilter/vf_colorkey.c
> 
> diff --git a/Changelog b/Changelog
> index 2e30b24..e99d1e9 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -17,6 +17,7 @@ version :
>  - WebM Live Chunk Muxer
>  - nvenc level and tier options
>  - chorus filter
> +- colorkey video filter
>  
>  
>  version 2.6:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 598c0b3..18f6ba3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -352,6 +352,7 @@ Filters:
>avf_showcqt.c Muhammad Faiz
>vf_blend.cPaul B Mahol
>vf_colorbalance.c Paul B Mahol
> +  vf_colorkey.c Timo Rothenpieler
>vf_dejudder.c Nicholas Robbins
>vf_delogo.c   Jean Delvare (CC 
> )
>vf_drawbox.c/drawgrid Andrey Utkin
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 0f2e720..79c0753 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -3026,6 +3026,45 @@ colorbalance=rs=.3
>  @end example
>  @end itemize
>  
> +@section colorkey
> +RGB colorspace color keying.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item color
> +The color which will be replaced with transparency.
> +
> +@item similarity
> +Similarity percentage with the key color.
> +
> +0.01 matches only the exact key color, while 1.0 matches everything.
> +
> +@item blend
> +Blend percentage.
> +
> +0.0 makes pixels either fully transparent, or not transparent at all.
> +
> +Higher values result in semi-transparent pixels, with a higher transparency
> +the more similar the pixels color is to the key color.
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Make every green pixel in the input image transparent:
> +@example
> +ffmpeg -i input.png -vf colorkey=green out.png
> +@end example
> +
> +@item
> +Make every red pixel in the input image transparent, with a high similarity 
> tolerance:
> +@example
> +ffmpeg -i input.png -vf colorkey=0xFF:0.3 out.png
> +@end example
> +@end itemize
> +
>  @section colorlevels
>  
>  Adjust video input frames using levels.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 48cee50..60e6b52 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -102,6 +102,7 @@ OBJS-$(CONFIG_BOXBLUR_FILTER)+= 
> vf_boxblur.o
>  OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
>  OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
>  OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
> +OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
>  OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
>  OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
>  OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 7961dca..2eeec7f 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -118,6 +118,7 @@ void avfilter_register_all(void)
>  REGISTER_FILTER(CODECVIEW,  codecview,  vf);
>  REGISTER_FILTER(COLORBALANCE,   colorbalance,   vf);
>  REGISTER_FILTER(COLORCHANNELMIXER, colorchannelmixer, vf);
> +REGISTER_FILTER(COLORKEY,   colorkey,   vf);
>  REGISTER_FILTER(COLORLEVELS,colorlevels,vf);
>  REGISTER_FILTER(COLORMATRIX,colormatrix,vf);
>  REGISTER_FILTER(COPY,   copy,   vf);
> diff --git a/libavfilter/vf_colorkey.c b/libavfilter/vf_colorkey.c
> new file mode 100644
> index 000..b5180cf
> --- /dev/null
> +++ b/libavfilter/vf_colorkey.c
> @@ -0,0 +1,226 @@
> +/*
> + * Copyright (c) 2015 Timo Rothenpieler 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/opt.h"
> +#

[FFmpeg-devel] Test for FLAC

2015-04-19 Thread Ludmila Glinskih
Hi! 

Now I don't use sin() to generate sound, also the test is running in FATE.

I added api-flac-test to libavcodec/Makefile (and the .c file is located in 
this directory as well). 
I think it should be placed in (future) api folder in the fate directory. 
Now I couldn't figure out how to add necessary commands to Makefile for correct 
linking with libavcodec library. 
Maybe I don't understand some simple ways how to do it (and also makefiles are 
new for me), I need help with this.

Kind regards,
Ludmila Glinskih


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


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

2015-04-19 Thread Ludmila Glinskih
---
 libavcodec/Makefile|   1 +
 libavcodec/api-flac-test.c | 290 +
 tests/fate/libavcodec.mak  |   6 +
 3 files changed, 297 insertions(+)
 create mode 100644 libavcodec/api-flac-test.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b01ecd6..6f09ba5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -883,6 +883,7 @@ TESTPROGS = imgconvert  
\
 options \
 avfft   \
 
+TESTPROGS += api-flac
 
 TESTPROGS-$(CONFIG_CABAC) += cabac
 TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed fft-fixed32
diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
new file mode 100644
index 000..0078b7a
--- /dev/null
+++ b/libavcodec/api-flac-test.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ * Copyright (c) 2001 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/*
+ * FLAC codec test.
+ * Encodes raw data to FLAC format and decodes it back to raw. Compares 
raw-data
+ * after that.
+ */
+
+#include 
+#include 
+#include 
+
+#define NUMBER_OF_FRAMES 200
+#define NAME_BUFF_SIZE 100
+
+/* generate i-th frame of test audio */
+static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate,
+  int channels, int frame_size)
+{
+int j, k;
+
+for (j = 0; j < frame_size; j++)
+{
+frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
+for (k = 1; k < channels; k++)
+frame_data[channels * j + k] = frame_data[channels * j] * 2;
+}
+return 0;
+}
+
+static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx,
+int64_t ch_layout, int sample_rate)
+{
+AVCodecContext *ctx;
+int result;
+char name_buff[NAME_BUFF_SIZE];
+
+av_get_channel_layout_string(name_buff, NAME_BUFF_SIZE, 0, ch_layout);
+av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", 
name_buff, sample_rate);
+
+ctx = avcodec_alloc_context3(enc);
+if (!ctx)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n");
+return AVERROR(ENOMEM);
+}
+
+ctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ctx->sample_rate = sample_rate;
+ctx->channel_layout = ch_layout;
+
+result = avcodec_open2(ctx, enc, NULL);
+if (result < 0)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't open encoder\n");
+return AVERROR_UNKNOWN;
+}
+
+*enc_ctx = ctx;
+return 0;
+}
+
+static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx,
+int64_t ch_layout)
+{
+AVCodecContext *ctx;
+int result;
+
+ctx = avcodec_alloc_context3(dec);
+if (!ctx)
+{
+av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n");
+return AVERROR(ENOMEM);
+}
+
+ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+/* XXX: FLAC ignores it for some reason */
+ctx->request_channel_layout = ch_layout;
+ctx->channel_layout = ch_layout;
+
+result = avcodec_open2(ctx, dec, NULL);
+if (result < 0)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't open decoder\n");
+return AVERROR_UNKNOWN;
+}
+
+*dec_ctx = ctx;
+return 0;
+}
+
+static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
+AVCodecContext *dec_ctx)
+{
+AVPacket enc_pkt;
+AVFrame *in_frame, *out_frame;
+uint8_t *raw_in = NULL, *raw_out = NULL;
+int in_offset = 0, out_offset = 0;
+int frame_data_size = 0;
+int result = 0;
+int got_output = 0;
+int i = 0;
+
+in_frame = av_frame_alloc();
+if (!in_frame)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n");
+return AVERROR(ENOMEM);
+}
+
+in_frame->nb_

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

2015-04-19 Thread Nicolas George
Le primidi 1er floréal, an CCXXIII, Ludmila Glinskih a écrit :
> ---
>  libavcodec/Makefile|   1 +
>  libavcodec/api-flac-test.c | 290 
> +
>  tests/fate/libavcodec.mak  |   6 +
>  3 files changed, 297 insertions(+)
>  create mode 100644 libavcodec/api-flac-test.c

Can you explain precisely what this program does that can not be done with
ffmpeg itself?

> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index b01ecd6..6f09ba5 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -883,6 +883,7 @@ TESTPROGS = imgconvert
>   \
>  options \
>  avfft   \
>  
> +TESTPROGS += api-flac
>  
>  TESTPROGS-$(CONFIG_CABAC) += cabac
>  TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed fft-fixed32
> diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
> new file mode 100644
> index 000..0078b7a
> --- /dev/null
> +++ b/libavcodec/api-flac-test.c
> @@ -0,0 +1,290 @@
> +/*
> + * Copyright (c) 2015 Ludmila Glinskih
> + * Copyright (c) 2001 Fabrice Bellard
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +/*
> + * FLAC codec test.
> + * Encodes raw data to FLAC format and decodes it back to raw. Compares 
> raw-data
> + * after that.
> + */
> +
> +#include 
> +#include 
> +#include 

Wrong quotes for internal includes. And lavc headers are local.

> +
> +#define NUMBER_OF_FRAMES 200
> +#define NAME_BUFF_SIZE 100
> +
> +/* generate i-th frame of test audio */
> +static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate,
> +  int channels, int frame_size)
> +{
> +int j, k;
> +

> +for (j = 0; j < frame_size; j++)
> +{

Wrong placement for the braces. Same at a lot of places.

> +frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
> +for (k = 1; k < channels; k++)

> +frame_data[channels * j + k] = frame_data[channels * j] * 2;

I do not understand the purpose of that "*2".

> +}
> +return 0;
> +}
> +
> +static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx,
> +int64_t ch_layout, int sample_rate)
> +{
> +AVCodecContext *ctx;
> +int result;
> +char name_buff[NAME_BUFF_SIZE];
> +
> +av_get_channel_layout_string(name_buff, NAME_BUFF_SIZE, 0, ch_layout);
> +av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", 
> name_buff, sample_rate);
> +
> +ctx = avcodec_alloc_context3(enc);
> +if (!ctx)
> +{
> +av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n");
> +return AVERROR(ENOMEM);
> +}
> +
> +ctx->sample_fmt = AV_SAMPLE_FMT_S16;
> +ctx->sample_rate = sample_rate;
> +ctx->channel_layout = ch_layout;
> +
> +result = avcodec_open2(ctx, enc, NULL);
> +if (result < 0)
> +{

> +av_log(NULL, AV_LOG_ERROR, "Can't open encoder\n");

You have a log context.

> +return AVERROR_UNKNOWN;

You have an error code.

> +}
> +
> +*enc_ctx = ctx;
> +return 0;
> +}
> +
> +static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx,
> +int64_t ch_layout)
> +{
> +AVCodecContext *ctx;
> +int result;
> +
> +ctx = avcodec_alloc_context3(dec);
> +if (!ctx)
> +{
> +av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n");
> +return AVERROR(ENOMEM);
> +}
> +

> +ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
> +/* XXX: FLAC ignores it for some reason */
> +ctx->request_channel_layout = ch_layout;

Are you really surprised that a lossless codec does not change the format or
layout from input to output?

> +ctx->channel_layout = ch_layout;
> +
> +re

Re: [FFmpeg-devel] [PATCH]Set interlaced flag when muxing interlaced dnxhd into mxf

2015-04-19 Thread Tomas Härdin
On Fri, 2015-04-17 at 00:31 +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Completely untested.
> 
> Please review, Carl Eugen

No idea really. Can't this flag be taken automagically from the codec
somehow?

/Tomas


signature.asc
Description: This is a digitally signed message part
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]Set interlaced flag when muxing interlaced dnxhd into mxf

2015-04-19 Thread Carl Eugen Hoyos
Tomas Härdin  codemill.se> writes:

> On Fri, 2015-04-17 at 00:31 +0200, Carl Eugen Hoyos wrote:
> > Hi!
> > 
> > Completely untested.

> No idea really. Can't this flag be taken automagically 
> from the codec somehow?

Just like component_depth...

Since I don't even know how to really test, 
I don't want to touch the code more than 
absolutely necessary.

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


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

2015-04-19 Thread Michael Niedermayer
On Sun, Apr 19, 2015 at 11:51:52PM +0200, Nicolas George wrote:
> Le primidi 1er floréal, an CCXXIII, Ludmila Glinskih a écrit :
> > ---
> >  libavcodec/Makefile|   1 +
> >  libavcodec/api-flac-test.c | 290 
> > +
> >  tests/fate/libavcodec.mak  |   6 +
> >  3 files changed, 297 insertions(+)
> >  create mode 100644 libavcodec/api-flac-test.c
> 
> Can you explain precisely what this program does that can not be done with
> ffmpeg itself?

It can form the basis for testing/comparing various APIs, like
avcodec_decode_audio3() / avcodec_encode_audio() for example
but theres not enough time before the outreachy deadline to add actual
support for these now

[...]
> > +frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
> > +for (k = 1; k < channels; k++)
> 
> > +frame_data[channels * j + k] = frame_data[channels * j] * 2;
> 
> I do not understand the purpose of that "*2".

i would guess, its intended to generate a signal thats different
for each of the 2 channels, Ludmila can probably confirm/or correct
if its not so

i dont see a problem here, its not the most variied test signal but
for now that should do. It can be chnaged later 

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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


Re: [FFmpeg-devel] Test for FLAC

2015-04-19 Thread Michael Niedermayer
On Mon, Apr 20, 2015 at 12:36:33AM +0300, Ludmila Glinskih wrote:
> Hi! 
> 
> Now I don't use sin() to generate sound, also the test is running in FATE.
> 
> I added api-flac-test to libavcodec/Makefile (and the .c file is located in 
> this directory as well). 
> I think it should be placed in (future) api folder in the fate directory. 

> Now I couldn't figure out how to add necessary commands to Makefile for 
> correct linking with libavcodec library. 
> Maybe I don't understand some simple ways how to do it (and also makefiles 
> are new for me), I need help with this.

Best to contact your mentor about this, its his job to help with any
questions and problems you have, well thats unless someone happens to
know the awnser right away and replies ...
But moving the file out of libavcodec might actually be not so simple

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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


[FFmpeg-devel] libavcodec: Add FLAC API test

2015-04-19 Thread Ludmila Glinskih
Thank you for your comments!

> > > +frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
> > > +for (k = 1; k < channels; k++)
> >
> > > +frame_data[channels * j + k] = frame_data[channels * j] * 2;
> >
> > I do not understand the purpose of that "*2".

> i would guess, its intended to generate a signal thats different
> for each of the 2 channels, Ludmila can probably confirm/or correct
> if its not so

> i dont see a problem here, its not the most variied test signal but
> for now that should do. It can be chnaged later

Yes, I want to generate different signal for different channels, my mistake to 
write "*2" instead of "*k".
 
Kind regards,
Ludmila Glinskih

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


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

2015-04-19 Thread Ludmila Glinskih
Signed-off-by: Ludmila Glinskih 
---
 libavcodec/Makefile|   1 +
 libavcodec/api-flac-test.c | 290 +
 tests/fate/libavcodec.mak  |   6 +
 3 files changed, 297 insertions(+)
 create mode 100644 libavcodec/api-flac-test.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b01ecd6..6f09ba5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -883,6 +883,7 @@ TESTPROGS = imgconvert  
\
 options \
 avfft   \
 
+TESTPROGS += api-flac
 
 TESTPROGS-$(CONFIG_CABAC) += cabac
 TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed fft-fixed32
diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
new file mode 100644
index 000..b036385
--- /dev/null
+++ b/libavcodec/api-flac-test.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ * Copyright (c) 2001 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/*
+ * FLAC codec test.
+ * Encodes raw data to FLAC format and decodes it back to raw. Compares 
raw-data
+ * after that.
+ */
+
+#include "avcodec.h"
+#include "libavutil/common.h"
+#include "libavutil/samplefmt.h"
+
+#define NUMBER_OF_FRAMES 200
+#define NAME_BUFF_SIZE 100
+
+/* generate i-th frame of test audio */
+static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate,
+  int channels, int frame_size)
+{
+int j, k;
+
+for (j = 0; j < frame_size; j++)
+{
+frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
+for (k = 1; k < channels; k++)
+frame_data[channels * j + k] = frame_data[channels * j] * k;
+}
+return 0;
+}
+
+static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx,
+int64_t ch_layout, int sample_rate)
+{
+AVCodecContext *ctx;
+int result;
+char name_buff[NAME_BUFF_SIZE];
+
+av_get_channel_layout_string(name_buff, NAME_BUFF_SIZE, 0, ch_layout);
+av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", 
name_buff, sample_rate);
+
+ctx = avcodec_alloc_context3(enc);
+if (!ctx)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n");
+return AVERROR(ENOMEM);
+}
+
+ctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ctx->sample_rate = sample_rate;
+ctx->channel_layout = ch_layout;
+
+result = avcodec_open2(ctx, enc, NULL);
+if (result < 0)
+{
+av_log(ctx, AV_LOG_ERROR, "Can't open encoder\n");
+return result;
+}
+
+*enc_ctx = ctx;
+return 0;
+}
+
+static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx,
+int64_t ch_layout)
+{
+AVCodecContext *ctx;
+int result;
+
+ctx = avcodec_alloc_context3(dec);
+if (!ctx)
+{
+av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n");
+return AVERROR(ENOMEM);
+}
+
+ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+/* XXX: FLAC ignores it for some reason */
+ctx->request_channel_layout = ch_layout;
+ctx->channel_layout = ch_layout;
+
+result = avcodec_open2(ctx, dec, NULL);
+if (result < 0)
+{
+av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n");
+return result;
+}
+
+*dec_ctx = ctx;
+return 0;
+}
+
+static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
+AVCodecContext *dec_ctx)
+{
+AVPacket enc_pkt;
+AVFrame *in_frame, *out_frame;
+uint8_t *raw_in = NULL, *raw_out = NULL;
+int in_offset = 0, out_offset = 0;
+int frame_data_size = 0;
+int result = 0;
+int got_output = 0;
+int i = 0;
+
+in_frame = av_frame_alloc();
+if (!in_frame)
+{
+av_log(NULL, AV_LOG_ERROR, "Can't allocate input fram