[FFmpeg-devel] [Outreachy][nyanyanya] Summary of this summer

2015-08-31 Thread Ludmila Glinskih
Hi guys!

My internship is finished (5 days ago) (if you still don't know: I was your
Outreachy intern;)). It was a great time with this project, thank you!

Thank you for all jokes on irc, all answers, all silly questions which
showed me that it's normal (to ask silly questions).

If you want to read about all my emotions during this summer, you can read
my Outreachy blog: http://lglinskih.blogspot.ru/.

I hope to see you on VideoLAN DevDays. I'll come to Paris on Thursday
evening and leave on Monday morning, so there will be a lot of time to meet
me (if you want) (because I want) (really). And I hope you will let me take
a selfie with you :)

Also if you want to contact me, it's easy: I'm lglinskih almost everywhere.
Because I'm really crazy about social networks, be prepared that I'll
subscribe to your account somewhere.

And yes...I won't leave you! Tomorrow is the first day of my university
year, so my rare patches will be twice more rare.

P.S. Please recommend Outreachy internship to all relevant women you know.
It's really a great chance to become...at least a better programmer=)

Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] api-h264-test: rename and expand

2015-08-26 Thread Ludmila Glinskih
Add support of floating point decoders. Add support of audio decoders.
---
 tests/api/Makefile |   2 +-
 tests/api/api-decode-test.c| 368 +
 tests/api/api-h264-test.c  | 166 ---
 tests/fate/api.mak |  12 +-
 tests/ref/fate/api-decode-h264 |  18 ++
 tests/ref/fate/api-h264|  18 --
 6 files changed, 396 insertions(+), 188 deletions(-)
 create mode 100644 tests/api/api-decode-test.c
 delete mode 100644 tests/api/api-h264-test.c
 create mode 100644 tests/ref/fate/api-decode-h264
 delete mode 100644 tests/ref/fate/api-h264

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 27f499f..57a7422 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,5 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
-APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-yes += api-decode
 APITESTPROGS-yes += api-seek
 APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
 APITESTPROGS += $(APITESTPROGS-yes)
diff --git a/tests/api/api-decode-test.c b/tests/api/api-decode-test.c
new file mode 100644
index 000..2795fe3
--- /dev/null
+++ b/tests/api/api-decode-test.c
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * Decode test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+#include libswresample/swresample.h
+#include libavutil/opt.h
+#include libavutil/intreadwrite.h
+
+static void print_sample_data(uint8_t *array, int size_of_array)
+{
+int i;
+uint16_t p = 0;
+for (i = 0; i  size_of_array; i += 2) {
+AV_WL16((p), (*(uint16_t*)(array + i)));
+fwrite(p, 2, 1, stdout);
+}
+}
+
+
+static int resample_and_print_data(AVCodecContext *ctx, AVFrame *fr, int 
sample_fmt)
+{
+struct SwrContext *swr_ctx;
+int dst_nb_samples;
+int dst_bufsize;
+int dst_linesize = 0;
+uint8_t **dst_data = NULL;
+int result;
+
+swr_ctx = swr_alloc_set_opts(NULL,
+fr-channel_layout,
+sample_fmt,
+fr-sample_rate,
+fr-channel_layout,
+ctx-sample_fmt,
+fr-sample_rate,
+0, NULL);
+if (!swr_ctx) {
+av_log(NULL, AV_LOG_ERROR, Could not allocate resampler context\n);
+return -1;
+}
+result = swr_init(swr_ctx);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't initialize the resampling 
context\n);
+return result;
+}
+dst_nb_samples = fr-nb_samples;
+result = av_samples_alloc_array_and_samples(dst_data, dst_linesize, 
fr-channels,
+ dst_nb_samples, sample_fmt, 0);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer for samples after 
resampling\n);
+return result;
+}
+
+result = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t 
**)fr-data, fr-nb_samples);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error while resampling\n);
+return result;
+}
+
+dst_bufsize = av_samples_get_buffer_size(dst_linesize, fr-channels, 
result, sample_fmt, 1);
+if (dst_bufsize  0) {
+av_log(NULL, AV_LOG_ERROR, Can'get buffer size after resampling\n);
+return dst_bufsize;
+}
+
+print_sample_data(dst_data[0], dst_bufsize);
+
+av_freep(dst_data);
+av_freep(dst_data);
+swr_free(swr_ctx);
+
+return 0;
+}
+
+static int decode_video(AVPacket *pkt, AVCodecContext *ctx, int is_bitexact, 
int i, int *got_frame, int stream)
+{
+AVFrame *fr = NULL;
+uint8_t *byte_buffer = NULL;
+int number_of_written_bytes;
+int byte_buffer_size = 0;
+int result;
+
+fr = av_frame_alloc();
+if (!fr) {
+av_log(NULL, AV_LOG_ERROR, Can't

Re: [FFmpeg-devel] [PATCH] api-h264-test: rename and expand

2015-08-26 Thread Ludmila Glinskih
Hi,

Thank you for the comment! I'm not sure if I fixed it right =/

Kind regards,
Ludmila Glinskih

ср, 26 авг. 2015 г. в 3:52, Michael Niedermayer mich...@niedermayer.cc:

 On Tue, Aug 25, 2015 at 11:00:40PM +0300, Ludmila Glinskih wrote:
  Add support of floating point decoders. Add support of audio decoders.
  ---
   tests/api/Makefile |   2 +-
   tests/api/api-decode-test.c| 355
 +
   tests/api/api-h264-test.c  | 166 ---
   tests/fate/api.mak |  12 +-
   tests/ref/fate/api-decode-h264 |  18 +++
   tests/ref/fate/api-h264|  18 ---
   6 files changed, 383 insertions(+), 188 deletions(-)
   create mode 100644 tests/api/api-decode-test.c
   delete mode 100644 tests/api/api-h264-test.c
   create mode 100644 tests/ref/fate/api-decode-h264
   delete mode 100644 tests/ref/fate/api-h264
 
  diff --git a/tests/api/Makefile b/tests/api/Makefile
  index 27f499f..57a7422 100644
  --- a/tests/api/Makefile
  +++ b/tests/api/Makefile
  @@ -1,5 +1,5 @@
   APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
  -APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
  +APITESTPROGS-yes += api-decode
   APITESTPROGS-yes += api-seek
   APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
   APITESTPROGS += $(APITESTPROGS-yes)
  diff --git a/tests/api/api-decode-test.c b/tests/api/api-decode-test.c
  new file mode 100644
  index 000..29c7dd7
  --- /dev/null
  +++ b/tests/api/api-decode-test.c
  @@ -0,0 +1,355 @@
  +/*
  + * Copyright (c) 2015 Ludmila Glinskih
  + *
  + * 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.
  + */
  +
  +/**
  + * Decode test.
  + */
  +
  +#include libavutil/adler32.h
  +#include libavcodec/avcodec.h
  +#include libavformat/avformat.h
  +#include libavutil/imgutils.h
  +#include libswresample/swresample.h
  +#include libavutil/opt.h
  +
  +static int resample_and_print_data(AVCodecContext *ctx, AVFrame *fr,
 int sample_fmt)
  +{
  +struct SwrContext *swr_ctx;
  +int dst_nb_samples;
  +int dst_bufsize;
  +int dst_linesize = 0;
  +uint8_t **dst_data = NULL;
  +int result;
  +
  +swr_ctx = swr_alloc_set_opts(NULL,
  +fr-channel_layout,
  +sample_fmt,
  +fr-sample_rate,
  +fr-channel_layout,
  +ctx-sample_fmt,
  +fr-sample_rate,
  +0, NULL);
  +if (!swr_ctx) {
  +av_log(NULL, AV_LOG_ERROR, Could not allocate resampler
 context\n);
  +return -1;
  +}
  +result = swr_init(swr_ctx);
  +if (result  0) {
  +av_log(NULL, AV_LOG_ERROR, Can't initialize the resampling
 context\n);
  +return result;
  +}
  +dst_nb_samples = fr-nb_samples;
  +result = av_samples_alloc_array_and_samples(dst_data,
 dst_linesize, fr-channels,
  + dst_nb_samples,
 sample_fmt, 0);
  +if (result  0) {
  +av_log(NULL, AV_LOG_ERROR, Can't allocate buffer for samples
 after resampling\n);
  +return result;
  +}
  +

  +result = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const
 uint8_t **)fr-data, fr-nb_samples);
  +if (result  0) {
  +av_log(NULL, AV_LOG_ERROR, Error while resampling\n);
  +return result;
  +}
  +
  +dst_bufsize = av_samples_get_buffer_size(dst_linesize,
 fr-channels, result, sample_fmt, 1);
  +if (dst_bufsize  0) {
  +av_log(NULL, AV_LOG_ERROR, Can'get buffer size after
 resampling\n);
  +return dst_bufsize;
  +}
  +
  +fwrite(dst_data[0], 1, dst_bufsize, stdout);

 this would mismatch on big endian


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

 Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker.
 User
 questions about the command line tools should

[FFmpeg-devel] [PATCH] api-h264-test: rename and expand

2015-08-25 Thread Ludmila Glinskih
Add support of floating point decoders. Add support of audio decoders.
---
 tests/api/Makefile |   2 +-
 tests/api/api-decode-test.c| 355 +
 tests/api/api-h264-test.c  | 166 ---
 tests/fate/api.mak |  12 +-
 tests/ref/fate/api-decode-h264 |  18 +++
 tests/ref/fate/api-h264|  18 ---
 6 files changed, 383 insertions(+), 188 deletions(-)
 create mode 100644 tests/api/api-decode-test.c
 delete mode 100644 tests/api/api-h264-test.c
 create mode 100644 tests/ref/fate/api-decode-h264
 delete mode 100644 tests/ref/fate/api-h264

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 27f499f..57a7422 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,5 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
-APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-yes += api-decode
 APITESTPROGS-yes += api-seek
 APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
 APITESTPROGS += $(APITESTPROGS-yes)
diff --git a/tests/api/api-decode-test.c b/tests/api/api-decode-test.c
new file mode 100644
index 000..29c7dd7
--- /dev/null
+++ b/tests/api/api-decode-test.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * Decode test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+#include libswresample/swresample.h
+#include libavutil/opt.h
+
+static int resample_and_print_data(AVCodecContext *ctx, AVFrame *fr, int 
sample_fmt)
+{
+struct SwrContext *swr_ctx;
+int dst_nb_samples;
+int dst_bufsize;
+int dst_linesize = 0;
+uint8_t **dst_data = NULL;
+int result;
+
+swr_ctx = swr_alloc_set_opts(NULL,
+fr-channel_layout,
+sample_fmt,
+fr-sample_rate,
+fr-channel_layout,
+ctx-sample_fmt,
+fr-sample_rate,
+0, NULL);
+if (!swr_ctx) {
+av_log(NULL, AV_LOG_ERROR, Could not allocate resampler context\n);
+return -1;
+}
+result = swr_init(swr_ctx);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't initialize the resampling 
context\n);
+return result;
+}
+dst_nb_samples = fr-nb_samples;
+result = av_samples_alloc_array_and_samples(dst_data, dst_linesize, 
fr-channels,
+ dst_nb_samples, sample_fmt, 0);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer for samples after 
resampling\n);
+return result;
+}
+
+result = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t 
**)fr-data, fr-nb_samples);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error while resampling\n);
+return result;
+}
+
+dst_bufsize = av_samples_get_buffer_size(dst_linesize, fr-channels, 
result, sample_fmt, 1);
+if (dst_bufsize  0) {
+av_log(NULL, AV_LOG_ERROR, Can'get buffer size after resampling\n);
+return dst_bufsize;
+}
+
+fwrite(dst_data[0], 1, dst_bufsize, stdout);
+
+av_freep(dst_data);
+av_freep(dst_data);
+swr_free(swr_ctx);
+
+return 0;
+}
+
+static int decode_video(AVPacket *pkt, AVCodecContext *ctx, int is_bitexact, 
int i, int *got_frame, int stream)
+{
+AVFrame *fr = NULL;
+uint8_t *byte_buffer = NULL;
+int number_of_written_bytes;
+int byte_buffer_size = 0;
+int result;
+
+fr = av_frame_alloc();
+if (!fr) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate frame\n);
+return AVERROR(ENOMEM);
+}
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+if (!byte_buffer) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n

[FFmpeg-devel] [PATCH] MAINTAINERS: add myself as an API tests maintainer

2015-08-23 Thread Ludmila Glinskih
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a909211..68f0f18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -48,6 +48,7 @@ project server  Árpád Gereöffy, 
Michael Niedermayer,
 presets Robert Swain
 metadata subsystem  Aurelien Jacobs
 release management  Michael Niedermayer
+API tests   Ludmila Glinskih
 
 
 Communication
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] api-band-test: first version

2015-08-23 Thread Ludmila Glinskih
Works only for flv, h263 and huffyuv decoders.
Makes only one pass through the file (this should be changed to two passes)
---
 tests/api/Makefile|   1 +
 tests/api/api-band-test.c | 222 ++
 tests/fate/api.mak|   6 ++
 3 files changed, 229 insertions(+)
 create mode 100644 tests/api/api-band-test.c

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 59cbc7c..27f499f 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,6 +1,7 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
 APITESTPROGS-yes += api-seek
+APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
 APITESTPROGS += $(APITESTPROGS-yes)
 
 APITESTOBJS  := $(APITESTOBJS:%=$(APITESTSDIR)%) 
$(APITESTPROGS:%=$(APITESTSDIR)/%-test.o)
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
new file mode 100644
index 000..d0dee64
--- /dev/null
+++ b/tests/api/api-band-test.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * draw_horiz_band test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+uint8_t *slice_byte_buffer;
+uint8_t slice_byte_buffer_size;
+int draw_horiz_band_called;
+
+static void draw_horiz_band(AVCodecContext *ctx, const AVFrame *fr, int 
offset[4],
+int slice_position, int type, int height)
+{
+int i;
+const AVPixFmtDescriptor *pix_fmt_desc;
+int chroma_w, chroma_h;
+int shift_slice_position;
+int shift_height;
+
+draw_horiz_band_called = 1;
+
+pix_fmt_desc = av_pix_fmt_desc_get(ctx-pix_fmt);
+chroma_w = -((-ctx-width)  pix_fmt_desc-log2_chroma_w);
+chroma_h = -((-height)  pix_fmt_desc-log2_chroma_h);
+shift_slice_position = -((-slice_position)  pix_fmt_desc-log2_chroma_h);
+shift_height = -((-ctx-height)  pix_fmt_desc-log2_chroma_h);
+
+for (i = 0; i  height; i++) {
+memcpy(slice_byte_buffer + ctx-width * slice_position + i * 
ctx-width,
+   fr-data[0] + offset[0] + i * fr-linesize[0], ctx-width);
+}
+for (i = 0; i  chroma_h; i++) {
+memcpy(slice_byte_buffer + ctx-width * ctx-height + chroma_w * 
shift_slice_position + i * chroma_w,
+   fr-data[1] + offset[1] + i * fr-linesize[1], chroma_w);
+}
+for (i = 0; i  chroma_h; i++) {
+memcpy(slice_byte_buffer + ctx-width * ctx-height + chroma_w * 
shift_height + chroma_w * shift_slice_position + i * chroma_w,
+   fr-data[2] + offset[2] + i * fr-linesize[2], chroma_w);
+}
+}
+
+static int video_decode(const char *input_filename)
+{
+AVCodec *codec = NULL;
+AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+uint8_t *byte_buffer = NULL;
+AVFrame *fr = NULL;
+AVPacket pkt;
+AVFormatContext *fmt_ctx = NULL;
+int number_of_written_bytes;
+int video_stream;
+int got_frame = 0;
+int byte_buffer_size;
+int result;
+int end_of_stream = 0;
+
+draw_horiz_band_called = 0;
+
+result = avformat_open_input(fmt_ctx, input_filename, NULL, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't open file\n);
+return result;
+}
+
+result = avformat_find_stream_info(fmt_ctx, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't get stream info\n);
+return result;
+}
+
+video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, 
NULL, 0);
+if (video_stream  0) {
+  av_log(NULL, AV_LOG_ERROR, Can't find video stream in input file\n);
+  return -1;
+}
+
+origin_ctx = fmt_ctx-streams[video_stream]-codec;
+
+codec = avcodec_find_decoder(origin_ctx-codec_id);
+if (!codec) {
+av_log(NULL, AV_LOG_ERROR, Can't find decoder\n);
+return -1;
+}
+
+ctx

[FFmpeg-devel] [PATCH] api-h264-test: structure changes

2015-08-03 Thread Ludmila Glinskih
To avoid duplicate code
---
 tests/api/api-h264-test.c | 47 +++
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index 4d2a5b0..e4bc0b8 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -39,10 +39,11 @@ static int video_decode_example(const char *input_filename)
 AVFormatContext *fmt_ctx = NULL;
 int number_of_written_bytes;
 int video_stream;
-int get_frame = 0;
+int got_frame = 0;
 int byte_buffer_size;
 int i = 0;
 int result;
+int end_of_stream = 0;
 
 result = avformat_open_input(fmt_ctx, input_filename, NULL, NULL);
 if (result  0) {
@@ -104,17 +105,24 @@ static int video_decode_example(const char 
*input_filename)
 printf(#tb %d: %d/%d\n, video_stream, 
fmt_ctx-streams[video_stream]-time_base.num, 
fmt_ctx-streams[video_stream]-time_base.den);
 i = 0;
 av_init_packet(pkt);
-while (av_read_frame(fmt_ctx, pkt) = 0) {
-if (pkt.stream_index == video_stream) {
-get_frame = 0;
+do {
+if (!end_of_stream)
+if (av_read_frame(fmt_ctx, pkt)  0)
+end_of_stream = 1;
+if (end_of_stream) {
+pkt.data = NULL;
+pkt.size = 0;
+}
+if (pkt.stream_index == video_stream || end_of_stream) {
+got_frame = 0;
 if (pkt.pts == AV_NOPTS_VALUE)
 pkt.pts = pkt.dts = i;
-result = avcodec_decode_video2(ctx, fr, get_frame, pkt);
+result = avcodec_decode_video2(ctx, fr, got_frame, pkt);
 if (result  0) {
 av_log(NULL, AV_LOG_ERROR, Error decoding frame\n);
 return result;
 }
-if (get_frame) {
+if (got_frame) {
 number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, 
byte_buffer_size,
 (const uint8_t* const *)fr-data, 
(const int*) fr-linesize,
 ctx-pix_fmt, ctx-width, ctx-height, 
1);
@@ -130,32 +138,7 @@ static int video_decode_example(const char *input_filename)
 av_init_packet(pkt);
 }
 i++;
-}
-pkt.data = NULL;
-pkt.size = 0;
-if (pkt.pts == AV_NOPTS_VALUE)
-pkt.pts = pkt.dts = i;
-do {
-get_frame = 0;
-result =  avcodec_decode_video2(ctx, fr, get_frame, pkt);
-if (result  0) {
-av_log(NULL, AV_LOG_ERROR, Error decoding frame\n);
-return result;
-}
-if (get_frame) {
-number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, 
byte_buffer_size,
-(const uint8_t* const *)fr-data, (const 
int*) fr-linesize,
-ctx-pix_fmt, ctx-width, ctx-height, 1);
-if (number_of_written_bytes  0) {
-av_log(NULL, AV_LOG_ERROR, Can't copy image to buffer\n);
-return number_of_written_bytes;
-}
-printf(%d, %10PRId64, %10PRId64, %8PRId64, %8d, 0x%08lx\n, 
video_stream,
-fr-pkt_pts, fr-pkt_dts, av_frame_get_pkt_duration(fr),
-number_of_written_bytes, av_adler32_update(0, (const 
uint8_t*)byte_buffer, number_of_written_bytes));
-}
-i++;
-} while (get_frame);
+} while (!end_of_stream || got_frame);
 
 av_free_packet(pkt);
 av_frame_free(fr);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] api-seek-test: first version

2015-07-31 Thread Ludmila Glinskih
Works only with video stream.
First pass without seeking -- counts crcs of a frames and store it in an array.
After that it seeks a lot in different places and checks if crcs of these 
frames and crcs of frames in array are the same.
---
 tests/api/Makefile|   1 +
 tests/api/api-seek-test.c | 278 ++
 tests/fate/api.mak|   6 +
 3 files changed, 285 insertions(+)
 create mode 100644 tests/api/api-seek-test.c

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 704987e..59cbc7c 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,6 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-yes += api-seek
 APITESTPROGS += $(APITESTPROGS-yes)
 
 APITESTOBJS  := $(APITESTOBJS:%=$(APITESTSDIR)%) 
$(APITESTPROGS:%=$(APITESTSDIR)/%-test.o)
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
new file mode 100644
index 000..99fe90c
--- /dev/null
+++ b/tests/api/api-seek-test.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * Seek test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+int64_t *pts_array;
+int64_t *crc_array;
+int size_of_array;
+int number_of_elements;
+
+static int add_crc_to_array(int64_t crc, int64_t pts)
+{
+if (size_of_array = number_of_elements) {
+if (size_of_array == 0)
+size_of_array = 10;
+size_of_array *= 2;
+crc_array = av_realloc(crc_array, size_of_array * sizeof(int64_t));
+pts_array = av_realloc(pts_array, size_of_array * sizeof(int64_t));
+if ((crc_array == NULL) || (pts_array == NULL)) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate array to store crcs\n);
+return AVERROR(ENOMEM);
+}
+}
+crc_array[number_of_elements] = crc;
+pts_array[number_of_elements] = pts;
+number_of_elements++;
+return 0;
+}
+
+static int compare_crc_in_array(int64_t crc, int64_t pts)
+{
+int i;
+for (i = 0; i  number_of_elements; i++) {
+if (pts_array[i] == pts) {
+if (crc_array[i] == crc) {
+printf(Comparing 0x%08lx %PRId64 %d is OK\n, crc, pts, i);
+return 0;
+}
+else {
+av_log(NULL, AV_LOG_ERROR, Incorrect crc of a frame after 
seeking\n);
+return -1;
+}
+}
+}
+av_log(NULL, AV_LOG_ERROR, Incorrect pts of a frame after seeking\n);
+return -1;
+}
+
+static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
+AVCodecContext *ctx, AVFrame *fr, uint64_t 
ts_start, uint64_t ts_end, int no_seeking)
+{
+int number_of_written_bytes;
+int got_frame = 0;
+int result;
+int end_of_stream = 0;
+int byte_buffer_size;
+uint8_t *byte_buffer;
+int64_t crc;
+AVPacket pkt;
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+if (!byte_buffer) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n);
+return AVERROR(ENOMEM);
+}
+
+if (!no_seeking) {
+result = av_seek_frame(fmt_ctx, video_stream, ts_start, 
AVSEEK_FLAG_ANY);
+printf(Seeking to %PRId64, computing crc for frames with pts  
%PRId64\n, ts_start, ts_end);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error in seeking\n);
+return result;
+}
+avcodec_flush_buffers(ctx);
+}
+
+av_init_packet(pkt);
+do {
+if (!end_of_stream)
+if (av_read_frame(fmt_ctx, pkt)  0)
+end_of_stream = 1;
+if (end_of_stream) {
+pkt.data = NULL;
+pkt.size = 0

[FFmpeg-devel] [PATCH] api-band-test: first version

2015-07-28 Thread Ludmila Glinskih
Works only for flv, h263 and huffyuv decoders, for video with yuv420p pixel 
format.
Makes only one pass through the file (this should be changed to two passes)
---
 tests/api/Makefile|   1 +
 tests/api/api-band-test.c | 229 ++
 tests/fate/api.mak|   6 ++
 3 files changed, 236 insertions(+)
 create mode 100644 tests/api/api-band-test.c

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 704987e..46fccb8 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,6 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-$(call DEMDEC, H263, H263) += api-band
 APITESTPROGS += $(APITESTPROGS-yes)
 
 APITESTOBJS  := $(APITESTOBJS:%=$(APITESTSDIR)%) 
$(APITESTPROGS:%=$(APITESTSDIR)/%-test.o)
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
new file mode 100644
index 000..075b781
--- /dev/null
+++ b/tests/api/api-band-test.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * draw_horiz_band test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+uint8_t *slice_byte_buffer;
+uint8_t slice_byte_buffer_size;
+int draw_horiz_band_called;
+
+static void draw_horiz_band(AVCodecContext *ctx, const AVFrame *fr, int 
offset[4],
+int slice_position, int type, int height)
+{
+int i;
+
+draw_horiz_band_called = 1;
+
+if (!strcmp(av_get_pix_fmt_name(ctx-pix_fmt), yuv420p)) {
+for (i = 0; i  height; i++) {
+memcpy(slice_byte_buffer + ctx-width * slice_position + i * 
ctx-width,
+   fr-data[0] + offset[0] + i * fr-linesize[0], ctx-width);
+}
+for (i = 0; i  height / 2; i++) {
+memcpy(slice_byte_buffer + ctx-width * ctx-height + ctx-width * 
slice_position / 4 + i * ctx-width / 2,
+   fr-data[1] + offset[1] + i * fr-linesize[1], ctx-width / 
2);
+}
+for (i = 0; i  height / 2; i++) {
+memcpy(slice_byte_buffer + 5 * ctx-width * ctx-height / 4 + 
ctx-width * slice_position / 4 + i * ctx-width / 2,
+   fr-data[2] + offset[2] + i * fr-linesize[2], ctx-width / 
2);
+}
+}
+
+else if (!strcmp(av_get_pix_fmt_name(ctx-pix_fmt), yuv422p)) {
+for (i = 0; i  height; i++) {
+memcpy(slice_byte_buffer + ctx-width * slice_position + i * 
ctx-width,
+   fr-data[0] + offset[0] + i * fr-linesize[0], ctx-width);
+}
+for (i = 0; i  height; i++) {
+memcpy(slice_byte_buffer + ctx-width * ctx-height + ctx-width * 
slice_position / 2 + i * ctx-width / 2,
+   fr-data[1] + offset[1] + i * fr-linesize[1], ctx-width / 
2);
+}
+for (i = 0; i  height; i++) {
+memcpy(slice_byte_buffer + 3 * ctx-width * ctx-height / 2 + 
ctx-width * slice_position / 2 + i * ctx-width / 2,
+   fr-data[2] + offset[2] + i * fr-linesize[2], ctx-width / 
2);
+}
+}
+}
+
+static int video_decode(const char *input_filename)
+{
+AVCodec *codec = NULL;
+AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+uint8_t *byte_buffer = NULL;
+AVFrame *fr = NULL;
+AVPacket pkt;
+AVFormatContext *fmt_ctx = NULL;
+int number_of_written_bytes;
+int video_stream;
+int got_frame = 0;
+int byte_buffer_size;
+int result;
+int end_of_stream = 0;
+
+draw_horiz_band_called = 0;
+
+result = avformat_open_input(fmt_ctx, input_filename, NULL, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't open file\n);
+return result;
+}
+
+result = avformat_find_stream_info(fmt_ctx, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't get stream info\n

[FFmpeg-devel] [PATCH] test for draw_horiz_band

2015-07-28 Thread Ludmila Glinskih
It works for decoding only in one thread. I use only one buffer, so when 
different frames are decoded in different threads I get wrong pieces in my 
result buffer. I don't know how to work with multiple buffers (which call of 
draw_horiz_band is for which frame?). 

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


[FFmpeg-devel] [PATCH v2] api-seek-test: first version

2015-07-04 Thread Ludmila Glinskih
I fixed brackets and added dependency on fate-lavf to be sure that lavf.flv 
exists.

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


[FFmpeg-devel] [PATCH] api-seek-test: first version

2015-07-04 Thread Ludmila Glinskih
Works only with video stream.
---
 tests/api/Makefile|   1 +
 tests/api/api-seek-test.c | 194 ++
 tests/fate/api.mak|   4 +
 tests/ref/fate/api-seek   | 147 +++
 4 files changed, 346 insertions(+)
 create mode 100644 tests/api/api-seek-test.c
 create mode 100644 tests/ref/fate/api-seek

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 704987e..59cbc7c 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,6 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-yes += api-seek
 APITESTPROGS += $(APITESTPROGS-yes)
 
 APITESTOBJS  := $(APITESTOBJS:%=$(APITESTSDIR)%) 
$(APITESTPROGS:%=$(APITESTSDIR)/%-test.o)
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
new file mode 100644
index 000..85430a3
--- /dev/null
+++ b/tests/api/api-seek-test.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * Seek test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
+AVCodecContext *ctx, AVFrame *fr, uint64_t 
ts_start, uint64_t ts_end)
+{
+int number_of_written_bytes;
+int got_frame = 0;
+int result;
+int end_of_stream = 0;
+int byte_buffer_size;
+uint8_t *byte_buffer;
+AVPacket pkt;
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+if (!byte_buffer) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n);
+return AVERROR(ENOMEM);
+}
+
+result = av_seek_frame(fmt_ctx, video_stream, ts_start, AVSEEK_FLAG_ANY);
+printf(Seeking to %PRId64, computing crc for frames with pts  
%PRId64\n, ts_start, ts_end);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error in seeking\n);
+return result;
+}
+avcodec_flush_buffers(ctx);
+
+av_init_packet(pkt);
+do {
+if (!end_of_stream)
+if (av_read_frame(fmt_ctx, pkt)  0)
+end_of_stream = 1;
+if (end_of_stream) {
+pkt.data = NULL;
+pkt.size = 0;
+}
+if (pkt.stream_index == video_stream || end_of_stream) {
+got_frame = 0;
+if (pkt.pts == AV_NOPTS_VALUE) {
+av_log(NULL, AV_LOG_ERROR, Error: frames doesn't have pts 
values\n);
+return -1;
+}
+result = avcodec_decode_video2(ctx, fr, got_frame, pkt);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error decoding frame\n);
+return result;
+}
+if (got_frame) {
+number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, 
byte_buffer_size,
+(const uint8_t* const *)fr-data, 
(const int*) fr-linesize,
+ctx-pix_fmt, ctx-width, ctx-height, 
1);
+if (number_of_written_bytes  0) {
+av_log(NULL, AV_LOG_ERROR, Can't copy image to buffer\n);
+return number_of_written_bytes;
+}
+if (fr-pkt_pts  ts_end)
+break;
+printf(%10PRId64, 0x%08lx\n, fr-pkt_pts, 
av_adler32_update(0, (const uint8_t*)byte_buffer,
+number_of_written_bytes));
+}
+}
+av_free_packet(pkt);
+av_init_packet(pkt);
+} while ((!end_of_stream || got_frame)  (fr-pkt_pts + 
av_frame_get_pkt_duration(fr) = ts_end));
+
+av_free_packet(pkt);
+av_freep(byte_buffer);
+
+return 0;
+}
+
+static int seek_test(const char

[FFmpeg-devel] [PATCH] api-seek-test: first version

2015-07-02 Thread Ludmila Glinskih
Works only with video stream.
---
 tests/api/Makefile|   1 +
 tests/api/api-seek-test.c | 197 ++
 tests/fate/api.mak|   4 +
 tests/ref/fate/api-seek   | 147 ++
 4 files changed, 349 insertions(+)
 create mode 100644 tests/api/api-seek-test.c
 create mode 100644 tests/ref/fate/api-seek

diff --git a/tests/api/Makefile b/tests/api/Makefile
index 704987e..59cbc7c 100644
--- a/tests/api/Makefile
+++ b/tests/api/Makefile
@@ -1,5 +1,6 @@
 APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac
 APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264
+APITESTPROGS-yes += api-seek
 APITESTPROGS += $(APITESTPROGS-yes)
 
 APITESTOBJS  := $(APITESTOBJS:%=$(APITESTSDIR)%) 
$(APITESTPROGS:%=$(APITESTSDIR)/%-test.o)
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
new file mode 100644
index 000..9f8bad9
--- /dev/null
+++ b/tests/api/api-seek-test.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * Seek test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream,
+AVCodecContext *ctx, AVFrame *fr, uint64_t 
ts_start, uint64_t ts_end)
+{
+int number_of_written_bytes;
+int got_frame = 0;
+int result;
+int end_of_stream = 0;
+int byte_buffer_size;
+uint8_t *byte_buffer;
+AVPacket pkt;
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+if (!byte_buffer) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n);
+return AVERROR(ENOMEM);
+}
+
+result = av_seek_frame(fmt_ctx, video_stream, ts_start, AVSEEK_FLAG_ANY);
+printf(Seeking to %PRId64, computing crc for frames with pts  
%PRId64\n, ts_start, ts_end);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error in seeking\n);
+return result;
+}
+avcodec_flush_buffers(ctx);
+
+av_init_packet(pkt);
+do {
+if (!end_of_stream)
+if (av_read_frame(fmt_ctx, pkt)  0)
+end_of_stream = 1;
+if (end_of_stream)
+{
+pkt.data = NULL;
+pkt.size = 0;
+}
+if (pkt.stream_index == video_stream || end_of_stream) {
+got_frame = 0;
+if (pkt.pts == AV_NOPTS_VALUE) {
+av_log(NULL, AV_LOG_ERROR, Error: frames doesn't have pts 
values\n);
+return -1;
+}
+result = avcodec_decode_video2(ctx, fr, got_frame, pkt);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Error decoding frame\n);
+return result;
+}
+if (got_frame) {
+number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, 
byte_buffer_size,
+(const uint8_t* const *)fr-data, 
(const int*) fr-linesize,
+ctx-pix_fmt, ctx-width, ctx-height, 
1);
+if (number_of_written_bytes  0) {
+av_log(NULL, AV_LOG_ERROR, Can't copy image to buffer\n);
+return number_of_written_bytes;
+}
+if (fr-pkt_pts  ts_end)
+break;
+printf(%10PRId64, 0x%08lx\n, fr-pkt_pts, 
av_adler32_update(0, (const uint8_t*)byte_buffer,
+number_of_written_bytes));
+}
+}
+av_free_packet(pkt);
+av_init_packet(pkt);
+} while ((!end_of_stream || got_frame)  (fr-pkt_pts + 
av_frame_get_pkt_duration(fr) = ts_end));
+
+av_free_packet(pkt);
+av_freep(byte_buffer);
+
+return 0;
+}
+
+static int seek_test

[FFmpeg-devel] [PATCH] Fix the bug of comparing zero bytes

2015-06-27 Thread Ludmila Glinskih
Add check for linesize.
---
 tests/api/api-flac-test.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index a6180bc..07030d6 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -112,10 +112,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 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;
+int in_frame_bytes, out_frame_bytes;
 
 in_frame = av_frame_alloc();
 if (!in_frame) {
@@ -156,8 +156,13 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 
 generate_raw_frame((uint16_t*)(in_frame-data[0]), i, 
enc_ctx-sample_rate,
enc_ctx-channels, enc_ctx-frame_size);
-memcpy(raw_in + in_offset, in_frame-data[0], in_frame-linesize[0]);
-in_offset += in_frame-linesize[0];
+in_frame_bytes = in_frame-nb_samples * 
av_frame_get_channels(in_frame) * sizeof(uint16_t);
+if (in_frame_bytes  in_frame-linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, Incorrect value of input frame 
linesize\n);
+return 1;
+}
+memcpy(raw_in + in_offset, in_frame-data[0], in_frame_bytes);
+in_offset += in_frame_bytes;
 result = avcodec_encode_audio2(enc_ctx, enc_pkt, in_frame, 
got_output);
 if (result  0) {
 av_log(NULL, AV_LOG_ERROR, Error encoding audio frame\n);
@@ -192,14 +197,19 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 av_log(NULL, AV_LOG_ERROR, Error frames before and after 
decoding has different sample format\n);
 return AVERROR_UNKNOWN;
 }
-memcpy(raw_out + out_offset, out_frame-data[0], 
out_frame-linesize[0]);
-out_offset += out_frame-linesize[0];
+out_frame_bytes = out_frame-nb_samples * 
av_frame_get_channels(out_frame) * sizeof(uint16_t);
+if (out_frame_bytes  out_frame-linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, Incorrect value of output 
frame linesize\n);
+return 1;
+}
+memcpy(raw_out + out_offset, out_frame-data[0], 
out_frame_bytes);
+out_offset += out_frame_bytes;
 }
 }
 av_free_packet(enc_pkt);
 }
 
-if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0) {
+if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) {
 av_log(NULL, AV_LOG_ERROR, Output differs\n);
 return 1;
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] api-h264-test: build with another api test

2015-06-27 Thread Ludmila Glinskih
Location of api-h264-test changed to special directory for api tests.
---
 libavformat/Makefile|   1 -
 libavformat/api-h264-test.c | 183 
 tests/api/Makefile  |   1 +
 tests/api/api-h264-test.c   | 183 
 tests/fate/api.mak  |   9 ++-
 tests/fate/libavformat.mak  |   4 -
 6 files changed, 192 insertions(+), 189 deletions(-)
 delete mode 100644 libavformat/api-h264-test.c
 create mode 100644 tests/api/api-h264-test.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 5380a2a..993ec09 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -547,7 +547,6 @@ TESTPROGS = seek
\
 url \
 
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
-TESTPROGS-yes+= api-h264
 TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 
 TOOLS = aviocat \
diff --git a/libavformat/api-h264-test.c b/libavformat/api-h264-test.c
deleted file mode 100644
index 4d2a5b0..000
--- a/libavformat/api-h264-test.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2015 Ludmila Glinskih
- *
- * 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.
- */
-
-/**
- * H264 codec test.
- */
-
-#include libavutil/adler32.h
-#include libavcodec/avcodec.h
-#include libavformat/avformat.h
-#include libavutil/imgutils.h
-
-static int video_decode_example(const char *input_filename)
-{
-AVCodec *codec = NULL;
-AVCodecContext *origin_ctx = NULL, *ctx= NULL;
-AVFrame *fr = NULL;
-uint8_t *byte_buffer = NULL;
-AVPacket pkt;
-AVFormatContext *fmt_ctx = NULL;
-int number_of_written_bytes;
-int video_stream;
-int get_frame = 0;
-int byte_buffer_size;
-int i = 0;
-int result;
-
-result = avformat_open_input(fmt_ctx, input_filename, NULL, NULL);
-if (result  0) {
-av_log(NULL, AV_LOG_ERROR, Can't open file\n);
-return result;
-}
-
-result = avformat_find_stream_info(fmt_ctx, NULL);
-if (result  0) {
-av_log(NULL, AV_LOG_ERROR, Can't get stream info\n);
-return result;
-}
-
-video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, 
NULL, 0);
-if (video_stream  0) {
-  av_log(NULL, AV_LOG_ERROR, Can't find video stream in input file\n);
-  return -1;
-}
-
-origin_ctx = fmt_ctx-streams[video_stream]-codec;
-
-codec = avcodec_find_decoder(origin_ctx-codec_id);
-if (!codec) {
-av_log(NULL, AV_LOG_ERROR, Can't find decoder\n);
-return -1;
-}
-
-ctx = avcodec_alloc_context3(codec);
-if (!ctx) {
-av_log(NULL, AV_LOG_ERROR, Can't allocate decoder context\n);
-return AVERROR(ENOMEM);
-}
-
-result = avcodec_copy_context(ctx, origin_ctx);
-if (result) {
-av_log(NULL, AV_LOG_ERROR, Can't copy decoder context\n);
-return result;
-}
-
-result = avcodec_open2(ctx, codec, NULL);
-if (result  0) {
-av_log(ctx, AV_LOG_ERROR, Can't open decoder\n);
-return result;
-}
-
-fr = av_frame_alloc();
-if (!fr) {
-av_log(NULL, AV_LOG_ERROR, Can't allocate frame\n);
-return AVERROR(ENOMEM);
-}
-
-byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
-byte_buffer = av_malloc(byte_buffer_size);
-if (!byte_buffer) {
-av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n);
-return AVERROR(ENOMEM);
-}
-
-printf(#tb %d: %d/%d\n, video_stream, 
fmt_ctx-streams[video_stream]-time_base.num, 
fmt_ctx-streams[video_stream]-time_base.den);
-i = 0;
-av_init_packet(pkt);
-while (av_read_frame(fmt_ctx, pkt) = 0) {
-if (pkt.stream_index == video_stream) {
-get_frame = 0

[FFmpeg-devel] [PATCH] Fixes the bug of comparing zero bytes. Also new check for linesize is added.

2015-06-26 Thread Ludmila Glinskih
---
 libavcodec/api-flac-test.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index 402d4df..4cd0db7 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -112,10 +112,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 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;
+int in_frame_bytes, out_frame_bytes;
 
 in_frame = av_frame_alloc();
 if (!in_frame) {
@@ -156,8 +156,13 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 
 generate_raw_frame((uint16_t*)(in_frame-data[0]), i, 
enc_ctx-sample_rate,
enc_ctx-channels, enc_ctx-frame_size);
-memcpy(raw_in + in_offset, in_frame-data[0], in_frame-linesize[0]);
-in_offset += in_frame-linesize[0];
+in_frame_bytes = in_frame-nb_samples * in_frame-channels * 
sizeof(uint16_t);
+if (in_frame_bytes != in_frame-linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, Incorrect value of input frame 
linesize\n);
+return 1;
+}
+memcpy(raw_in + in_offset, in_frame-data[0], in_frame_bytes);
+in_offset += in_frame_bytes;
 result = avcodec_encode_audio2(enc_ctx, enc_pkt, in_frame, 
got_output);
 if (result  0) {
 av_log(NULL, AV_LOG_ERROR, Error encoding audio frame\n);
@@ -192,14 +197,19 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 av_log(NULL, AV_LOG_ERROR, Error frames before and after 
decoding has different sample format\n);
 return AVERROR_UNKNOWN;
 }
-memcpy(raw_out + out_offset, out_frame-data[0], 
out_frame-linesize[0]);
-out_offset += out_frame-linesize[0];
+out_frame_bytes = out_frame-nb_samples * out_frame-channels 
* sizeof(uint16_t);
+if (out_frame_bytes  out_frame-linesize[0]) {
+av_log(NULL, AV_LOG_ERROR, Incorrect value of output 
frame linesize\n);
+return 1;
+}
+memcpy(raw_out + out_offset, out_frame-data[0], 
out_frame_bytes);
+out_offset += out_frame_bytes;
 }
 }
 av_free_packet(enc_pkt);
 }
 
-if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0) {
+if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_FRAMES) != 0) {
 av_log(NULL, AV_LOG_ERROR, Output differs\n);
 return 1;
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCHv3] libavformat: Add H264 API test

2015-06-24 Thread Ludmila Glinskih
I added av_find_best_stream() and changed libavformat.mak, because previous 
version failed without samples.

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


Re: [FFmpeg-devel] [PATCH] libavformat: Add H264 API test

2015-06-23 Thread Ludmila Glinskih
Do you have any ideas why it differs from framecrc result on the same file?

пн, 22 июня 2015 г. в 12:50, Ludmila Glinskih lglins...@gmail.com:

 Result differs in pkt_duration and time_base.den for some reason.
 Right now it tests only one example (adjusted to match the output).

 Signed-off-by: Ludmila Glinskih lglins...@gmail.com
 ---
  libavformat/Makefile|   1 +
  libavformat/api-h264-test.c | 155
 
  tests/fate/libavformat.mak  |   4 ++
  tests/ref/fate/api-h264 |  18 +
  4 files changed, 178 insertions(+)
  create mode 100644 libavformat/api-h264-test.c
  create mode 100644 tests/ref/fate/api-h264

 diff --git a/libavformat/Makefile b/libavformat/Makefile
 index 993ec09..5cc0f6c 100644
 --- a/libavformat/Makefile
 +++ b/libavformat/Makefile
 @@ -547,6 +547,7 @@ TESTPROGS = seek
   \
  url \

  TESTPROGS-$(CONFIG_NETWORK)  += noproxy
 +TESTPROGS-yes  += api-h264
  TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh

  TOOLS = aviocat \
 diff --git a/libavformat/api-h264-test.c b/libavformat/api-h264-test.c
 new file mode 100644
 index 000..e25c8f0
 --- /dev/null
 +++ b/libavformat/api-h264-test.c
 @@ -0,0 +1,155 @@
 +/*
 + * Copyright (c) 2015 Ludmila Glinskih
 + *
 + * 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.
 + */
 +
 +/**
 + * H264 codec test.
 + */
 +
 +#include math.h
 +
 +#include libavutil/opt.h
 +#include libavutil/adler32.h
 +#include libavcodec/avcodec.h
 +#include libavformat/avformat.h
 +#include libavutil/common.h
 +#include libavutil/imgutils.h
 +#include libavutil/samplefmt.h
 +#include libavformat/internal.h
 +
 +static int video_decode_example(const char *input_filename)
 +{
 +AVCodec *codec = NULL;
 +AVCodecContext *origin_ctx = NULL, *ctx= NULL;
 +AVFrame *fr = NULL;
 +uint8_t *byte_buffer = NULL;
 +AVPacket pkt;
 +AVFormatContext *fmt_ctx = NULL;
 +int number_of_written_bytes;
 +int video_stream;
 +int get_frame = 0;
 +int byte_buffer_size;
 +int i = 0;
 +
 +
 +if (avformat_open_input(fmt_ctx, input_filename, NULL, NULL)  0) {
 +fprintf(stderr, Could not open source file %s\n,
 input_filename);
 +exit(1);
 +}
 +
 +if (avformat_find_stream_info(fmt_ctx, NULL)  0) {
 +fprintf(stderr, Could not find stream information\n);
 +exit(1);
 +}
 +
 +video_stream = -1;
 +for (i = 0; i  fmt_ctx-nb_streams; i++) {
 +if (fmt_ctx-streams[i]-codec-codec_type == AVMEDIA_TYPE_VIDEO)
 {
 +video_stream = i;
 +break;
 +}
 +}
 +
 +origin_ctx = fmt_ctx-streams[video_stream]-codec;
 +
 +codec = avcodec_find_decoder(origin_ctx-codec_id);
 +if (codec == NULL) {
 +return -1;
 +}
 +ctx = avcodec_alloc_context3(codec);
 +if (ctx == NULL) {
 +return -1;
 +}
 +
 +if (avcodec_copy_context(ctx, origin_ctx)) {
 +return -1;
 +}
 +
 +if (avcodec_open2(ctx, codec, NULL)  0) {
 +return -1;
 +}
 +
 +fr = av_frame_alloc();
 +if (fr == NULL) {
 +return -1;
 +}
 +
 +byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width,
 ctx-height, 16);
 +byte_buffer = av_malloc(byte_buffer_size);
 +
 +printf(#tb %d: %d/%d\n, video_stream,
 fmt_ctx-streams[video_stream]-time_base.num,
 fmt_ctx-streams[video_stream]-time_base.den);
 +i = 0;
 +av_init_packet(pkt);
 +while (av_read_frame(fmt_ctx, pkt) = 0) {
 +if (pkt.stream_index == video_stream) {
 +get_frame = 0;
 +if (pkt.pts == AV_NOPTS_VALUE)
 +pkt.pts = pkt.dts = i;
 +avcodec_decode_video2(ctx, fr, get_frame, pkt);
 +if (get_frame

[FFmpeg-devel] [PATCH] libavformat: Add H264 API test

2015-06-23 Thread Ludmila Glinskih
Result differs in pkt_duration and time_base.den for some reason.
Right now it tests only one example (adjusted to match the output).

Signed-off-by: Ludmila Glinskih lglins...@gmail.com
---
 libavformat/Makefile|   1 +
 libavformat/api-h264-test.c | 187 
 tests/fate/libavformat.mak  |   4 +
 tests/ref/fate/api-h264 |  18 +
 4 files changed, 210 insertions(+)
 create mode 100644 libavformat/api-h264-test.c
 create mode 100644 tests/ref/fate/api-h264

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 993ec09..5cc0f6c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -547,6 +547,7 @@ TESTPROGS = seek
\
 url \
 
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
+TESTPROGS-yes  += api-h264
 TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 
 TOOLS = aviocat \
diff --git a/libavformat/api-h264-test.c b/libavformat/api-h264-test.c
new file mode 100644
index 000..ac4acc4
--- /dev/null
+++ b/libavformat/api-h264-test.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * H264 codec test.
+ */
+
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/imgutils.h
+
+static int video_decode_example(const char *input_filename)
+{
+AVCodec *codec = NULL;
+AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+AVFrame *fr = NULL;
+uint8_t *byte_buffer = NULL;
+AVPacket pkt;
+AVFormatContext *fmt_ctx = NULL;
+int number_of_written_bytes;
+int video_stream;
+int get_frame = 0;
+int byte_buffer_size;
+int i = 0;
+int result;
+
+result = avformat_open_input(fmt_ctx, input_filename, NULL, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't open file\n);
+return result;
+}
+
+result = avformat_find_stream_info(fmt_ctx, NULL);
+if (result  0) {
+av_log(NULL, AV_LOG_ERROR, Can't get stream info\n);
+return result;
+}
+
+video_stream = -1;
+for (i = 0; i  fmt_ctx-nb_streams; i++) {
+if (fmt_ctx-streams[i]-codec-codec_type == AVMEDIA_TYPE_VIDEO) {
+video_stream = i;
+break;
+}
+}
+
+origin_ctx = fmt_ctx-streams[video_stream]-codec;
+
+codec = avcodec_find_decoder(origin_ctx-codec_id);
+if (codec == NULL) {
+av_log(NULL, AV_LOG_ERROR, Can't find decoder\n);
+return -1;
+}
+
+ctx = avcodec_alloc_context3(codec);
+if (ctx == NULL) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate decoder context\n);
+return AVERROR(ENOMEM);
+}
+
+result = avcodec_copy_context(ctx, origin_ctx);
+if (result) {
+av_log(NULL, AV_LOG_ERROR, Can't copy decoder context\n);
+return result;
+}
+
+result = avcodec_open2(ctx, codec, NULL);
+if (result  0) {
+av_log(ctx, AV_LOG_ERROR, Can't open decoder\n);
+return result;
+}
+
+fr = av_frame_alloc();
+if (fr == NULL) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate frame\n);
+return AVERROR(ENOMEM);
+}
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+if (byte_buffer == NULL) {
+av_log(NULL, AV_LOG_ERROR, Can't allocate buffer\n);
+return AVERROR(ENOMEM);
+}
+
+printf(#tb %d: %d/%d\n, video_stream, 
fmt_ctx-streams[video_stream]-time_base.num, 
fmt_ctx-streams[video_stream]-time_base.den);
+i = 0;
+av_init_packet(pkt);
+while (av_read_frame(fmt_ctx, pkt) = 0) {
+if (pkt.stream_index == video_stream) {
+get_frame = 0;
+if (pkt.pts

[FFmpeg-devel] [PATCH v2] libavformat: Add H264 API test

2015-06-23 Thread Ludmila Glinskih
Now there are no warnings, more checks, more error messages. I changed the loop 
for the last frames.
If the error occures program returns 1.
Thank you for comments!

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


[FFmpeg-devel] [PATCH] libavformat: Add H264 API test

2015-06-22 Thread Ludmila Glinskih
I really don't know how to avoid warnings in printf.

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


[FFmpeg-devel] [PATCH] libavformat: Add H264 API test

2015-06-22 Thread Ludmila Glinskih
Result differs in pkt_duration and time_base.den for some reason.
Right now it tests only one example (adjusted to match the output).

Signed-off-by: Ludmila Glinskih lglins...@gmail.com
---
 libavformat/Makefile|   1 +
 libavformat/api-h264-test.c | 155 
 tests/fate/libavformat.mak  |   4 ++
 tests/ref/fate/api-h264 |  18 +
 4 files changed, 178 insertions(+)
 create mode 100644 libavformat/api-h264-test.c
 create mode 100644 tests/ref/fate/api-h264

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 993ec09..5cc0f6c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -547,6 +547,7 @@ TESTPROGS = seek
\
 url \
 
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
+TESTPROGS-yes  += api-h264
 TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 
 TOOLS = aviocat \
diff --git a/libavformat/api-h264-test.c b/libavformat/api-h264-test.c
new file mode 100644
index 000..e25c8f0
--- /dev/null
+++ b/libavformat/api-h264-test.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2015 Ludmila Glinskih
+ *
+ * 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.
+ */
+
+/**
+ * H264 codec test.
+ */
+
+#include math.h
+
+#include libavutil/opt.h
+#include libavutil/adler32.h
+#include libavcodec/avcodec.h
+#include libavformat/avformat.h
+#include libavutil/common.h
+#include libavutil/imgutils.h
+#include libavutil/samplefmt.h
+#include libavformat/internal.h
+
+static int video_decode_example(const char *input_filename)
+{
+AVCodec *codec = NULL;
+AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+AVFrame *fr = NULL;
+uint8_t *byte_buffer = NULL;
+AVPacket pkt;
+AVFormatContext *fmt_ctx = NULL;
+int number_of_written_bytes;
+int video_stream;
+int get_frame = 0;
+int byte_buffer_size;
+int i = 0;
+
+
+if (avformat_open_input(fmt_ctx, input_filename, NULL, NULL)  0) {
+fprintf(stderr, Could not open source file %s\n, input_filename);
+exit(1);
+}
+
+if (avformat_find_stream_info(fmt_ctx, NULL)  0) {
+fprintf(stderr, Could not find stream information\n);
+exit(1);
+}
+
+video_stream = -1;
+for (i = 0; i  fmt_ctx-nb_streams; i++) {
+if (fmt_ctx-streams[i]-codec-codec_type == AVMEDIA_TYPE_VIDEO) {
+video_stream = i;
+break;
+}
+}
+
+origin_ctx = fmt_ctx-streams[video_stream]-codec;
+
+codec = avcodec_find_decoder(origin_ctx-codec_id);
+if (codec == NULL) {
+return -1;
+}
+ctx = avcodec_alloc_context3(codec);
+if (ctx == NULL) {
+return -1;
+}
+
+if (avcodec_copy_context(ctx, origin_ctx)) {
+return -1;
+}
+
+if (avcodec_open2(ctx, codec, NULL)  0) {
+return -1;
+}
+
+fr = av_frame_alloc();
+if (fr == NULL) {
+return -1;
+}
+
+byte_buffer_size = av_image_get_buffer_size(ctx-pix_fmt, ctx-width, 
ctx-height, 16);
+byte_buffer = av_malloc(byte_buffer_size);
+
+printf(#tb %d: %d/%d\n, video_stream, 
fmt_ctx-streams[video_stream]-time_base.num, 
fmt_ctx-streams[video_stream]-time_base.den);
+i = 0;
+av_init_packet(pkt);
+while (av_read_frame(fmt_ctx, pkt) = 0) {
+if (pkt.stream_index == video_stream) {
+get_frame = 0;
+if (pkt.pts == AV_NOPTS_VALUE)
+pkt.pts = pkt.dts = i;
+avcodec_decode_video2(ctx, fr, get_frame, pkt);
+if (get_frame) {
+number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, 
byte_buffer_size,
+(const uint8_t* const *)fr-data, 
(const int*) fr-linesize,
+ctx-pix_fmt, ctx-width, ctx-height, 
1

[FFmpeg-devel] [PATCH 2/2] api-flac-test: Coding style

2015-04-22 Thread Ludmila Glinskih
---
 libavcodec/api-flac-test.c | 72 --
 1 file changed, 24 insertions(+), 48 deletions(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index 1540da9..5ff8f12 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -40,8 +40,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
int sample_rate,
 {
 int j, k;
 
-for (j = 0; j  frame_size; j++)
-{
+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 + 1);
@@ -60,8 +59,7 @@ static int init_encoder(AVCodec *enc, AVCodecContext 
**enc_ctx,
 av_log(NULL, AV_LOG_INFO, channel layout: %s, sample rate: %i\n, 
name_buff, sample_rate);
 
 ctx = avcodec_alloc_context3(enc);
-if (!ctx)
-{
+if (!ctx) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate encoder context\n);
 return AVERROR(ENOMEM);
 }
@@ -71,8 +69,7 @@ static int init_encoder(AVCodec *enc, AVCodecContext 
**enc_ctx,
 ctx-channel_layout = ch_layout;
 
 result = avcodec_open2(ctx, enc, NULL);
-if (result  0)
-{
+if (result  0) {
 av_log(ctx, AV_LOG_ERROR, Can't open encoder\n);
 return result;
 }
@@ -88,8 +85,7 @@ static int init_decoder(AVCodec *dec, AVCodecContext 
**dec_ctx,
 int result;
 
 ctx = avcodec_alloc_context3(dec);
-if (!ctx)
-{
+if (!ctx) {
 av_log(NULL, AV_LOG_ERROR , Can't allocate decoder context\n);
 return AVERROR(ENOMEM);
 }
@@ -100,8 +96,7 @@ static int init_decoder(AVCodec *dec, AVCodecContext 
**dec_ctx,
 ctx-channel_layout = ch_layout;
 
 result = avcodec_open2(ctx, dec, NULL);
-if (result  0)
-{
+if (result  0) {
 av_log(ctx, AV_LOG_ERROR, Can't open decoder\n);
 return result;
 }
@@ -122,8 +117,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 int i = 0;
 
 in_frame = av_frame_alloc();
-if (!in_frame)
-{
+if (!in_frame) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate input frame\n);
 return AVERROR(ENOMEM);
 }
@@ -131,35 +125,30 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 in_frame-nb_samples = enc_ctx-frame_size;
 in_frame-format = enc_ctx-sample_fmt;
 in_frame-channel_layout = enc_ctx-channel_layout;
-if (av_frame_get_buffer(in_frame, 32) != 0)
-{
+if (av_frame_get_buffer(in_frame, 32) != 0) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate a buffer for input 
frame\n);
 return AVERROR(ENOMEM);
 }
 
 out_frame = av_frame_alloc();
-if (!out_frame)
-{
+if (!out_frame) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate output frame\n);
 return AVERROR(ENOMEM);
 }
 
 raw_in = av_malloc(in_frame-linesize[0] * NUMBER_OF_FRAMES);
-if (!raw_in)
-{
+if (!raw_in) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate memory for raw_in\n);
 return AVERROR(ENOMEM);
 }
 
 raw_out = av_malloc(in_frame-linesize[0] * NUMBER_OF_FRAMES);
-if (!raw_out)
-{
+if (!raw_out) {
 av_log(NULL, AV_LOG_ERROR, Can't allocate memory for raw_out\n);
 return AVERROR(ENOMEM);
 }
 
-for (i = 0; i  NUMBER_OF_FRAMES; i++)
-{
+for (i = 0; i  NUMBER_OF_FRAMES; i++) {
 av_init_packet(enc_pkt);
 enc_pkt.data = NULL;
 enc_pkt.size = 0;
@@ -169,44 +158,36 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 memcpy(raw_in + in_offset, in_frame-data[0], in_frame-linesize[0]);
 in_offset += in_frame-linesize[0];
 result = avcodec_encode_audio2(enc_ctx, enc_pkt, in_frame, 
got_output);
-if (result  0)
-{
+if (result  0) {
 av_log(NULL, AV_LOG_ERROR, Error encoding audio frame\n);
 return result;
 }
 
 /* if we get an encoded packet, feed it straight to the decoder */
-if (got_output)
-{
+if (got_output) {
 result = avcodec_decode_audio4(dec_ctx, out_frame, got_output, 
enc_pkt);
-if (result  0)
-{
+if (result  0) {
 av_log(NULL, AV_LOG_ERROR, Error decoding audio packet\n);
 return result;
 }
 
-if (got_output)
-{
-if (result != enc_pkt.size)
-{
+if (got_output) {
+if (result != enc_pkt.size) {
 av_log(NULL, AV_LOG_INFO, Decoder consumed only part of a 
packet, it is allowed to do so -- need to update this test\n);
 return AVERROR_UNKNOWN;
 }
 
-if (in_frame-nb_samples != out_frame-nb_samples)
-{
+if (in_frame-nb_samples != 

[FFmpeg-devel] [PATCH 1/2] api-flac-test: Fix stupid mistake

2015-04-22 Thread Ludmila Glinskih
Was comparing 0 bytes in memcmp
---
 libavcodec/api-flac-test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index 5ca8e8f..1540da9 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -117,7 +117,6 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 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;
@@ -218,7 +217,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 av_free_packet(enc_pkt);
 }
 
-if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) != 0)
+if (memcmp(raw_in, raw_out, out_frame-linesize[0] * NUMBER_OF_FRAMES) != 
0)
 {
 av_log(NULL, AV_LOG_ERROR, Output differs\n);
 return 1;
-- 
1.9.1

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


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

2015-04-21 Thread Ludmila Glinskih
вт, 21 апр. 2015 г. в 6:19, Clément Bœsch u...@pkh.me:

 On Mon, Apr 20, 2015 at 02:37:27PM +0200, Ludmila Glinskih wrote:
  ffmpeg | branch: master | Ludmila Glinskih lglins...@gmail.com | Mon
 Apr 20 03:03:08 2015 +0300| [be70c79af2bbbf8818707075ebc376d0be137582] |
 committer: Michael Niedermayer
 
  libavcodec: Add FLAC API test
 
  Signed-off-by: Ludmila Glinskih lglins...@gmail.com
  Signed-off-by: Michael Niedermayer michae...@gmx.at
 
  
 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be70c79af2bbbf8818707075ebc376d0be137582
  ---
 
   libavcodec/Makefile|1 +
   libavcodec/api-flac-test.c |  290
 
   tests/fate/libavcodec.mak  |6 +
   3 files changed, 297 insertions(+)
 
 [...]

  +TESTPROGS += api-flac

 Mmh... no TESTPROGRES-$(CONFIG_FLAC_DECODER) or similar?

For building this test It's not necessary for encodec/decodec to be
available. When FATE tests are running, my test won't be ran without
FLAC-codec/decodec, because in /tests/fate/libavcodec.mak I check
availability of the codec:
FATE_LIBAVCODEC-$(call ENCDEC, FLAC, FLAC) += fate-api-flac


 [...]
  +if (!ctx)
  +{

 Sorry to comment on such superficial issue, but this style (repeated all
 over the file) is an obvious violation of the coding style of the project.
 If the author or the person pushing the patch could fix this, that would
 be appreciated.

Ok, I'll fix it!)


 Thanks

 [...]

 --
 Clément B.
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2015-04-21 Thread Ludmila Glinskih
OOPS

вт, 21 апр. 2015 г. в 8:03, James Almer jamr...@gmail.com:

 On 19/04/15 9:03 PM, Ludmila Glinskih wrote:

  +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;

 This

 [...]

  +if (memcmp(raw_in, raw_out, frame_data_size * NUMBER_OF_FRAMES) !=
 0)

 And this are the only lines where frame_data_size is used. This means it's
 always 0.
 Is that intended? Because unless i'm missing something, that doesn't seem
 right for
 a memcmp.
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


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

2015-04-21 Thread Ludmila Glinskih
Sorry for the delay, thanks for comments!

вт, 21 апр. 2015 г. в 1:40, Kieran Kunhya kier...@obe.tv:

 On 20 April 2015 at 01:03, Ludmila Glinskih lglins...@gmail.com wrote:
  Signed-off-by: Ludmila Glinskih lglins...@gmail.com
  ---
   libavcodec/Makefile|   1 +
   libavcodec/api-flac-test.c | 290
 +

 I would put this in its own directory.

Do you mean libavcodec/api directory? I think the best is to put it in the
tests/api directory, but don't know how to make it (now).


 I think the next thing you should work on is a simple, shared version
 of framecrc so these tests can be integrated into FATE.
 Or you can use the framecrc in libavformat - I have no preference.

Now my test is running with all FATE tests, doesn't this mean, that it is
integrated?
Can you please explain to me, why framecrc is so important?


 You may need some help though from people who understand the build
 system better then me about fate integration.

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


Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] Fix mistake with repeating values in first and second channels

2015-04-20 Thread Ludmila Glinskih
Ooops, wrong threat. I need one more try)

On Mon, Apr 20, 2015 at 10:36 AM, Ludmila Glinskih lglins...@gmail.com wrote:
 Signed-off-by: Ludmila Glinskih lglins...@gmail.com
 ---
  libavcodec/api-flac-test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
 index b036385..38b2613 100644
 --- a/libavcodec/api-flac-test.c
 +++ b/libavcodec/api-flac-test.c
 @@ -44,7 +44,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
 int sample_rate,
  {
  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;
 +frame_data[channels * j + k] = frame_data[channels * j] * (k + 
 1);
  }
  return 0;
  }
 --
 1.9.1

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


Re: [FFmpeg-devel] [PATCH v4] Fix mistake with repeating values in first and second channels

2015-04-20 Thread Ludmila Glinskih
Oooops, this was meant to be in the last thread
=)

On Mon, Apr 20, 2015 at 10:34 AM, Ludmila Glinskih lglins...@gmail.com wrote:
 Signed-off-by: Ludmila Glinskih lglins...@gmail.com
 ---
  libavcodec/api-flac-test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
 index b036385..38b2613 100644
 --- a/libavcodec/api-flac-test.c
 +++ b/libavcodec/api-flac-test.c
 @@ -44,7 +44,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
 int sample_rate,
  {
  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;
 +frame_data[channels * j + k] = frame_data[channels * j] * (k + 
 1);
  }
  return 0;
  }
 --
 1.9.1

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


[FFmpeg-devel] [PATCH v4] Fix mistake with repeating values in first and second channels

2015-04-20 Thread Ludmila Glinskih
Signed-off-by: Ludmila Glinskih lglins...@gmail.com
---
 libavcodec/api-flac-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index b036385..38b2613 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -44,7 +44,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
int sample_rate,
 {
 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;
+frame_data[channels * j + k] = frame_data[channels * j] * (k + 1);
 }
 return 0;
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v4] Fix mistake with repeating values in first and second channels

2015-04-20 Thread Ludmila Glinskih
Signed-off-by: Ludmila Glinskih lglins...@gmail.com
---
 libavcodec/api-flac-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index b036385..38b2613 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -44,7 +44,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
int sample_rate,
 {
 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;
+frame_data[channels * j + k] = frame_data[channels * j] * (k + 1);
 }
 return 0;
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v4] Fix mistake with repeating values in first and second channels

2015-04-20 Thread Ludmila Glinskih
Signed-off-by: Ludmila Glinskih lglins...@gmail.com
---
 libavcodec/api-flac-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index b036385..38b2613 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -44,7 +44,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
int sample_rate,
 {
 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;
+frame_data[channels * j + k] = frame_data[channels * j] * (k + 1);
 }
 return 0;
 }
-- 
1.9.1

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


[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 libavcodec/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] * 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

[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 lglins...@gmail.com
---
 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 frame\n

Re: [FFmpeg-devel] [PATCH v2] examples: add flac_test

2015-04-14 Thread Ludmila Glinskih
Hi,

Thanks for you comments!

 +static int generate_raw_frame(uint16_t *frame_data, int i, int
 sample_rate,
  +  int channels, int frame_size)
  +{
  +double t, tincr, tincr2;
  +int j, k;
  +
  +t = 0.0;
  +tincr = 2 * M_PI * 440.0 / sample_rate;
  +tincr2 = tincr / sample_rate;
  +for (j = 0; j  frame_size; j++)
  +{
  +frame_data[channels * j] = (int)(sin(t) * 1);
  +for (k = 1; k  channels; k++)
  +frame_data[channels * j + k] = frame_data[channels * j] * 2;
  +t = i * tincr + (i * (i + 1) / 2.0 * tincr2);
  +}
  +return 0;
  +}

 This was mentioned before: using floating point in tests causes
 problems which can be avoided by using integers only. This includes the
 sin() function. (Maybe generate some sort of square wave instead? Or
 just silence? I don't know.)

 Yeah, I didn't decide how to do it right yet. I like Michael's idea about
audiogen.


  +result = avcodec_open2(ctx, enc, NULL);
  +if (result  0)
  +{
  +av_log(NULL, AV_LOG_ERROR, Can't open encoder\n);
  +return AVERROR_UNKNOWN;

 In this particular case, it would probably make sense to forward the
 error code. (Also affects some other lines in the patch.) I don't know
 how important this is for API tests, or what exactly we want, though.

I don't have any idea why I need it (right now). As soon as I find a reason
-- I'll change it.


  +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;

 Only some decoders can change the output, and then only in some cases.
 Normally, the API user is supposed to use libraries like libswresample
 to convert data to the required format. These fields (including
 request_sample_fmt) merely expose additional decoder features. They
 don't have to be present.

I test 4 different channel layouts, 2 of them have different values of
channel layout before and after encoding-decoding. Presetting
ctx-channel_layout fixes it.

 +out_frame = av_frame_alloc();
  +if (!out_frame)
  +{
  +av_log(NULL, AV_LOG_ERROR, Can't allocate output frame\n);
  +return AVERROR(ENOMEM);

 This leaks in_frame on error. But it might be ok in such a test. We
 have to decide whether it is. (I'd say it's ok.)

In my opinion it's ok. If in some situations it leads to problems -- it's
easy to fix).


  +if (got_output)
  +{
  +result = avcodec_decode_audio4(dec_ctx, out_frame,
 got_output, enc_pkt);
  +if (result  0)
  +{
  +av_log(NULL, AV_LOG_ERROR, Error decoding audio
 packet\n);
  +return AVERROR_UNKNOWN;
  +}
  +
  +if (got_output)
  +{
  +if (result != enc_pkt.size)
  +{
  +av_log(NULL, AV_LOG_INFO, Decoder consumed only
 part of a packet, it is allowed to do so -- need to update this test\n);

 The message probably lacks an if (if it is allowed).

 As I understood from the documentation -- every decoder is allowed to do
so. Message is to inform that this test doesn't cover this case.

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

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


[FFmpeg-devel] Test for FLAC

2015-04-13 Thread Ludmila Glinskih

Hi! 

I changed my test after your comments, thanks for your suggestions.=)

Now I test the codec with different parameters (sample rate and channel 
layout). For every set of parameters I create new input. I still use sin but 
now with double... The only other option I see is to pre-generate the inputs 
and commit them to the repository. Please help me if you know how to do it 
right.=(

And yeah, I understand that I test only how codec-decodec works (even here I 
don't test different sample formats, and use only positive cases). The next 
step (another test) should test common libavcodec functions (codec opening and 
so on). 

Let me know what you think.

Kind regards,
Ludmila Glinskih
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] examples: add flac_test

2015-04-13 Thread Ludmila Glinskih
This is a simple test for the FLAC codec.
It generates an increasing tone, encodes it, decodes it back and
compares with the original one byte-by-byte.
---
 configure|   2 +
 doc/Makefile |   1 +
 doc/examples/Makefile|   1 +
 doc/examples/flac_test.c | 295 +++
 4 files changed, 299 insertions(+)
 create mode 100644 doc/examples/flac_test.c

diff --git a/configure b/configure
index bc59271..5650ef8 100755
--- a/configure
+++ b/configure
@@ -1329,6 +1329,7 @@ EXAMPLE_LIST=
 filter_audio_example
 filtering_audio_example
 filtering_video_example
+flac_test_example
 metadata_example
 muxing_example
 qsvdec_example
@@ -2679,6 +2680,7 @@ extract_mvs_example_deps=avcodec avformat avutil
 filter_audio_example_deps=avfilter avutil
 filtering_audio_example_deps=avfilter avcodec avformat avutil
 filtering_video_example_deps=avfilter avcodec avformat avutil
+flac_test_example_deps=avcodec avutil
 metadata_example_deps=avformat avutil
 muxing_example_deps=avcodec avformat avutil swscale
 qsvdec_example_deps=avcodec avutil libmfx h264_qsv_decoder vaapi_x11
diff --git a/doc/Makefile b/doc/Makefile
index 4573531..f462acc 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -45,6 +45,7 @@ DOC_EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE)   += 
extract_mvs
 DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE)  += filter_audio
 DOC_EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE)   += filtering_audio
 DOC_EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE)   += filtering_video
+DOC_EXAMPLES-$(CONFIG_FLAC_TEST_EXAMPLE) += flac_test
 DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE)  += metadata
 DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= muxing
 DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec
diff --git a/doc/examples/Makefile b/doc/examples/Makefile
index 9699f11..72a2fb6 100644
--- a/doc/examples/Makefile
+++ b/doc/examples/Makefile
@@ -18,6 +18,7 @@ EXAMPLES=   avio_list_dir  \
 extract_mvs\
 filtering_video\
 filtering_audio\
+flac_test  \
 metadata   \
 muxing \
 remuxing   \
diff --git a/doc/examples/flac_test.c b/doc/examples/flac_test.c
new file mode 100644
index 000..392c50c
--- /dev/null
+++ b/doc/examples/flac_test.c
@@ -0,0 +1,295 @@
+/*
+ * 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 libavcodec/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)
+{
+double t, tincr, tincr2;
+int j, k;
+
+t = 0.0;
+tincr = 2 * M_PI * 440.0 / sample_rate;
+tincr2 = tincr / sample_rate;
+for (j = 0; j  frame_size; j++)
+{
+frame_data[channels * j] = (int)(sin(t) * 1);
+for (k = 1; k  channels; k++)
+frame_data[channels * j + k] = frame_data[channels * j] * 2;
+t = i * tincr + (i * (i + 1) / 2.0 * tincr2);
+}
+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