[FFmpeg-devel] [PATCH] ffmpeg/qsv: fix QSV-accelerated transcode performance drop issue

2016-08-11 Thread Jun Zhao
From cafa70e97ce48b65e2a4a99782f6ce3557fef755 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 11 Aug 2016 15:34:01 +0800
Subject: [PATCH] ffmpeg/qsv: fix QSV-accelerated transcode performance drop
 issue.

the merge commit 1b04ea1 "avconv: create simple filtergraphs earlier"
will init the filtergraphs earlier, then init the QSV transcode can't
suppose the nb_filters's value, else lead to the QSV transcode performance
drop.

Signed-off-by: Jun Zhao 
---
 ffmpeg_qsv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c
index 95a2351..acc54dd 100644
--- a/ffmpeg_qsv.c
+++ b/ffmpeg_qsv.c
@@ -210,8 +210,7 @@ int qsv_transcode_init(OutputStream *ost)
 
 /* check if the decoder supports QSV and the output only goes to this 
stream */
 ist = input_streams[ost->source_index];
-if (ist->nb_filters || ist->hwaccel_id != HWACCEL_QSV ||
-!ist->dec || !ist->dec->pix_fmts)
+if (ist->hwaccel_id != HWACCEL_QSV || !ist->dec || !ist->dec->pix_fmts)
 return 0;
 for (pix_fmt = ist->dec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++)
 if (*pix_fmt == AV_PIX_FMT_QSV)
-- 
2.1.4

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


[FFmpeg-devel] [PATCH] libavformat/http: add support for headers option in listen mode

2016-08-11 Thread Moritz Barsnick
Instead of silently ignoring the headers option in listen mode, use
the provided headers.

Signed-off-by: Moritz Barsnick 
---
 libavformat/http.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index cbeaebf..adb3d92 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -371,12 +371,14 @@ static int http_write_reply(URLContext* h, int 
status_code)
  "HTTP/1.1 %03d %s\r\n"
  "Content-Type: %s\r\n"
  "Content-Length: %"SIZE_SPECIFIER"\r\n"
+ "%s"
  "\r\n"
  "%03d %s\r\n",
  reply_code,
  reply_text,
  content_type,
  strlen(reply_text) + 6, // 3 digit status code + space + \r\n
+ s->headers ? s->headers : "",
  reply_code,
  reply_text);
 } else {
@@ -385,10 +387,12 @@ static int http_write_reply(URLContext* h, int 
status_code)
  "HTTP/1.1 %03d %s\r\n"
  "Content-Type: %s\r\n"
  "Transfer-Encoding: chunked\r\n"
+ "%s"
  "\r\n",
  reply_code,
  reply_text,
- content_type);
+ content_type,
+ s->headers ? s->headers : "");
 }
 av_log(h, AV_LOG_TRACE, "HTTP reply header: \n%s\n", message);
 if ((ret = ffurl_write(s->hd, message, message_len)) < 0)
-- 
2.7.4

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


[FFmpeg-devel] [PATCH] libavformat/http: add support for headers option in listen mode

2016-08-11 Thread Moritz Barsnick
Sorry, I shouldn't have refactored and remerged without testing. Big mistake.
Fixed (and tested) patch attached.

Moritz

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


Re: [FFmpeg-devel] [PATCH 04/11] avformat/muxers: Add non-blocking mode support for av_write_trailer

2016-08-11 Thread Jan Sebechlebsky

On 08/10/2016 07:04 PM, Michael Niedermayer wrote:


On Tue, Aug 02, 2016 at 03:24:15PM +0200, sebechlebsky...@gmail.com wrote:

From: Jan Sebechlebsky 

This makes av_write_trailer not to free the resources if write_trailer
call returns AVERROR(EAGAIN) allowing repeated calls of write_trailer of
non-blocking muxer.

Signed-off-by: Jan Sebechlebsky 
---
  libavformat/avformat.h | 6 +-
  libavformat/mux.c  | 3 +++
  2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 818184e..9191c69 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2508,8 +2508,12 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int 
stream_index);
   *
   * May only be called after a successful call to avformat_write_header.
   *
+ * If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN)
+ * meaning the operation is pending and the call should be repeated.
+ *
   * @param s media file handle
- * @return 0 if OK, AVERROR_xxx on error
+ * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated,
+ * other AVERROR on error
   */
  int av_write_trailer(AVFormatContext *s);
  
diff --git a/libavformat/mux.c b/libavformat/mux.c

index e9973ed..b58e4c1 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1238,6 +1238,9 @@ fail:
  }
  }
  
+if (ret == AVERROR(EAGAIN))

+return ret;

IIUC the non blocking code works only if packet interleaving is not
used (which is implied by AVFMT_FLAG_NONBLOCK being set)

is there an assert ensuring that EAGAIN only occurs in such case
somewhere ?
I've just added comment to av_interleaved_write_frame that it cannot be 
used with muxer
operating in non-blocking mode, but it is certainly good idea to add 
assert as well.

I'll modify and resend the patch with the comment change to add assert too.


if it would occur with the interleave code then
ret could be set before or maybe even set to EAGAIN and then

 if (s->internal->header_written && s->oformat->write_trailer) {
 if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
 avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
 if (ret >= 0) {
 ret = s->oformat->write_trailer(s);
 } else {
 s->oformat->write_trailer(s);
 }
 }

would do all kinds of unexpected things like ignoring the write_trailer
return  or returning to the user EAGAIN even when trailer didnt return
that, ...

[...]


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

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


Re: [FFmpeg-devel] [PATCH v2 03/11] avformat/fifo: Add fate test

2016-08-11 Thread Jan Sebechlebsky



On 08/09/2016 07:42 PM, Michael Niedermayer wrote:

On Tue, Aug 09, 2016 at 01:26:04PM +0200, sebechlebsky...@gmail.com wrote:

From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
  Changes since the last version:
  - Removed empty lines at the end of fifo_muxer.c file


[...]

diff --git a/tests/Makefile b/tests/Makefile
index 895944d..0848766 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -128,6 +128,7 @@ include $(SRC_PATH)/tests/fate/exif.mak
  include $(SRC_PATH)/tests/fate/ffmpeg.mak
  include $(SRC_PATH)/tests/fate/ffprobe.mak
  include $(SRC_PATH)/tests/fate/fft.mak
+include $(SRC_PATH)/tests/fate/fifo-muxer.mak
  include $(SRC_PATH)/tests/fate/filter-audio.mak
  include $(SRC_PATH)/tests/fate/filter-video.mak
  include $(SRC_PATH)/tests/fate/flac.mak
diff --git a/tests/fate/fifo-muxer.mak b/tests/fate/fifo-muxer.mak
new file mode 100644
index 000..a064069
--- /dev/null
+++ b/tests/fate/fifo-muxer.mak
@@ -0,0 +1,20 @@
+fate-fifo-muxer-h264: CMD = ffmpeg -i $(TARGET_SAMPLES)/mkv/1242-small.mkv 
-vframes 11\
+-c:v copy -c:a copy -map v:0 -map a:0 -flags 
+bitexact\
+-fflags +bitexact -f fifo -fifo_format framecrc -
+fate-fifo-muxer-h264: REF = $(SRC_PATH)/tests/ref/fate/mkv-1242
+FATE_FIFO_MUXER-$(call ALLYES, FIFO_MUXER, MATROSKA_DEMUXER, H264_DECODER) += 
fate-fifo-muxer-h264
+
+fate-fifo-muxer-wav: CMD = ffmpeg -i 
$(TARGET_SAMPLES)/audio-reference/chorusnoise_2ch_44kHz_s16.wav\
+   -c:a copy -map a:0 -flags +bitexact\
+  -fflags +bitexact -f fifo -fifo_format wav md5:

inconsistent mix of space and tab



+fate-fifo-muxer-wav: CMP = oneline
+fate-fifo-muxer-wav: REF = 4dda5dcc7ecdc2218b0739a152ada802
+FATE_FIFO_MUXER-$(call ALLYES, FIFO_MUXER, WAV_DEMUXER) += fate-fifo-muxer-wav
+
+fate-fifo-muxer-tst: libavformat/tests/fifo_muxer$(EXESUF)
+fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer
+FATE_FIFO_MUXER-$(CONFIG_FIFO_MUXER) += fate-fifo-muxer-tst
+
+FATE_SAMPLES_FFMPEG += fate-fifo-muxer-h264 fate-fifo-muxer-wav
+FATE_FFMPEG += fate-fifo-muxer-tst
+fate-fifo-muxer: $(FATE_FIFO_MUXER-yes)

works on linux 32 & 64bit

fails on mingw32 & 64

make: *** No rule to make target `libavformat/tests/fifo_muxer.exe', needed by 
`fate-fifo-muxer-tst'.
make: Target `fate-fifo-muxer-tst' not remade because of errors.
I was not able to reproduce the exactly same error you got, however I've 
fixed the whitespace and also there was $(EXESUF) missing at


fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer

line - I hope that was the cause the test refused to built. I've setup 
windows build and found also some other issues, now it passes fate on 
linux 32/64 bit build and also mingw32/64 bit build.


Thank you for testing it - I will try to run windows tests as well in 
future to avoid such mistakes.
I'll resend fixed patches soon - can you please re-run the 
fate-fifo-muxer test as well in your environment?


Regards,
Jan

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


Re: [FFmpeg-devel] [PATCH 1/2] avisynth: simplify the pix_fmt check for the newer AviSynth API

2016-08-11 Thread Michael Niedermayer
On Wed, Aug 10, 2016 at 11:14:35PM -0400, Stephen Hutchinson wrote:
> The values don't need to be hardcoded since the correct values are
> returned by avs_bits_per_pixel.
> ---
>  libavformat/avisynth.c | 27 +--
>  1 file changed, 5 insertions(+), 22 deletions(-)

does this work with all supported AviSynth versions ?

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

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


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


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

2016-08-11 Thread Michael Niedermayer
On Wed, Aug 10, 2016 at 06:23:32PM +0200, Paul B Mahol wrote:
> Hi,
> 
> patch attached.

>  doc/filters.texi  |   49 +++
>  libavfilter/Makefile  |1 
>  libavfilter/af_acrusher.c |  291 
> ++
>  libavfilter/allfilters.c  |1 
>  4 files changed, 342 insertions(+)
> edb554dcdc55f1658d3570acf9eb1ab8b7699a88  
> 0001-avfilter-add-acrusher-filter.patch
> From 0d50ac2d704ebc719ab2557c1024ed4b58505a28 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Wed, 10 Aug 2016 16:11:37 +0200
> Subject: [PATCH] avfilter: add acrusher filter
> 
> ---
>  doc/filters.texi  |  49 
>  libavfilter/Makefile  |   1 +
>  libavfilter/af_acrusher.c | 291 
> ++
>  libavfilter/allfilters.c  |   1 +
>  4 files changed, 342 insertions(+)
>  create mode 100644 libavfilter/af_acrusher.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 9dab959..562fff5 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -441,6 +441,55 @@ ffmpeg -i first.flac -i second.flac -filter_complex 
> acrossfade=d=10:o=0:c1=exp:c
>  @end example
>  @end itemize
>  
> +@section acrusher
> +
> +Reduce audio bit resolution.
> +
> +This filter is bit crusher with enhanced funcionality. A bit crusher
> +is used to audibly reduce number of bits an audio signal is sampled
> +with. This doesn't change the bit depth at all, it just produces the
> +effect. Material reduced in bit depth sounds more harsh and "digital".
> +This filter is able to even round to continous values instead of discrete
> +bit depths.
> +Additionally it has a D/C offset which results in different crushing of
> +the lower and the upper half of the signal.
> +An Anti-Aliasing setting is able to produce "softer" crushing sounds.
> +
> +Another feature of this filter is the logarithmic mode.
> +This setting switches from linear distances between bits to logarithmic ones.
> +The result is a much more "natural" sounding crusher which doesn't gate low
> +signals for example. The human ear has a logarithmic perception, too
> +so this kind of crushing is much more pleasant.
> +Logarithmic crushing is also able to get anti-aliased.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item level_in
> +Set level in.
> +
> +@item level_out
> +Set level out.
> +
> +@item bits
> +Set bit reduction.
> +
> +@item mix
> +Set mixing ammount.
> +
> +@item mode
> +Can be linear: @code{lin} or logarithmic: @code{log}.
> +
> +@item dc
> +Set DC.
> +
> +@item aa
> +Set anti-aliasing.
> +
> +@item samples
> +Set sample reduction.
> +@end table
> +
>  @section adelay
>  
>  Delay one or more audio channels.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index cd62fd5..0d94f84 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -30,6 +30,7 @@ OBJS-$(HAVE_THREADS) += pthread.o
>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>  OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
> +OBJS-$(CONFIG_ACRUSHER_FILTER)   += af_acrusher.o
>  OBJS-$(CONFIG_ADELAY_FILTER) += af_adelay.o
>  OBJS-$(CONFIG_AECHO_FILTER)  += af_aecho.o
>  OBJS-$(CONFIG_AEMPHASIS_FILTER)  += af_aemphasis.o
> diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
> new file mode 100644
> index 000..339cbf2
> --- /dev/null
> +++ b/libavfilter/af_acrusher.c
> @@ -0,0 +1,291 @@
> +/*
> + * Copyright (c) Markus Schmidt and Christian Holschuh
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/opt.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +#include "audio.h"
> +
> +typedef struct SRContext {
> +double target;
> +double real;
> +double samples;
> +double last;
> +} SRContext;
> +
> +typedef struct ACrusherContext {
> +const AVClass *class;
> +
> +double level_in;
> +double level_out;
> +double bits;
> +double mix;
> +int mode;
> +double dc;
> +double aa;
> +double samples;
> +
> +double sqr;
> +double aa1;
> +double coeff

[FFmpeg-devel] [PATCH v7 01/11] avformat: Add fifo pseudo-muxer

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version of the patch:
 - Fixed thread include (old patch included pthread.h directly)

 Changelog|   1 +
 configure|   1 +
 doc/muxers.texi  |  93 +++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/fifo.c   | 665 +++
 libavformat/version.h|   2 +-
 7 files changed, 763 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fifo.c

diff --git a/Changelog b/Changelog
index d9b6ecb..db6e415 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - MediaCodec hwaccel
 - True Audio (TTA) muxer
 - crystalizer audio filter
+- fifo muxer
 
 
 version 3.1:
diff --git a/configure b/configure
index 8e30c68..7599dc1 100755
--- a/configure
+++ b/configure
@@ -2834,6 +2834,7 @@ dv_muxer_select="dvprofile"
 dxa_demuxer_select="riffdec"
 eac3_demuxer_select="ac3_parser"
 f4v_muxer_select="mov_muxer"
+fifo_muxer_deps="pthreads"
 flac_demuxer_select="flac_parser"
 hds_muxer_select="flv_muxer"
 hls_muxer_select="mpegts_muxer"
diff --git a/doc/muxers.texi b/doc/muxers.texi
index 5873269..e2f06d3 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1436,6 +1436,99 @@ Specify whether to remove all fragments when finished. 
Default 0 (do not remove)
 
 @end table
 
+@section fifo
+
+The fifo pseudo-muxer allows the separation of encoding and muxing by using
+first-in-first-out queue and running the actual muxer in a separate thread. 
This
+is especially useful in combination with the @ref{tee} muxer and output to
+several destinations with different reliability/writing speed/latency.
+
+The behavior of the fifo muxer if the queue fills up or if the output fails is
+selectable,
+
+@itemize @bullet
+
+@item
+output can be transparently restarted with configurable delay between retries
+based on real time or time of the processed stream.
+
+@item
+encoding can be blocked during temporary failure, or continue transparently
+dropping packets in case fifo queue fills up.
+
+@end itemize
+
+@table @option
+
+@item fifo_format
+Specify the format name. Useful if it cannot be guessed from the
+output name suffix.
+
+@item queue_size
+Specify size of the queue (number of packets). Default value is 60.
+
+@item format_opts
+Specify format options for the underlying muxer. Muxer options can be specified
+as a list of @var{key}=@var{value} pairs separated by ':'.
+
+@item drop_pkts_on_overflow @var{bool}
+If set to 1 (true), in case the fifo queue fills up, packets will be dropped
+rather than blocking the encoder. This allows to continue streaming without
+delaying the input, at the cost of ommiting part of the stream. By default
+this option is set to 0 (false), so in such cases the encoder will be blocked
+until the muxer processes some of the packets and none of them is lost.
+
+@item attempt_recovery @var{bool}
+If failure occurs, attempt to recover the output. This is especially useful
+when used with network output, allows to restart streaming transparently.
+By default this option set to 0 (false).
+
+@item max_recovery_attempts
+Sets maximum number of successive unsucessful recovery attempts after which
+the output fails permanently. Unlimited if set to zero. Default value is 16.
+
+@item recovery_wait_time @var{duration}
+Waiting time before the next recovery attempt after previous unsuccessfull
+recovery attempt. Default value is 5 seconds.
+
+s@item recovery_wait_streamtime @var{bool}
+If set to 0 (false), the real time is used when waiting for the recovery
+attempt (i.e. the recovery will be attempted after at least
+recovery_wait_time seconds).
+If set to 1 (true), the time of the processed stream is taken into account
+instead (i.e. the recovery will be attempted after at least 
@var{recovery_wait_time}
+seconds of the stream is omitted).
+By default, this option is set to 0 (false).
+
+@item recover_any_error @var{bool}
+If set to 1 (true), recovery will be attempted regardless of type of the error
+causing the failure. By default this option is set to 0 (false) and in case of
+certain (usually permanent) errors the recovery is not attempted even when
+@var{attempt_recovery} is set to 1.
+
+@item restart_with_keyframe @var{bool}
+Specify whether to wait for the keyframe after recovering from
+queue overflow or failure. This option is set to 0 (false) by default.
+
+@end table
+
+@subsection Examples
+
+@itemize
+
+@item
+Stream something to rtmp server, continue processing the stream at real-time
+rate even in case of temporary failure (network outage) and attempt to recover
+streaming every second indefinitely.
+@example
+ffmpeg -re -i ... -c:v libx264 -c:a mp2 -f fifo -fifo_format flv -map 0:v -map 
0:a
+  -block_on_overflow 0 -attempt_recovery 1 -recovery_wait_time 1
+  -max_recovery_attempts 0 rtmp://example.com/live/stream_name
+@end example
+
+@end itemize
+
+@anchor tee
 @section tee
 
 

[FFmpeg-devel] [PATCH v3 03/11] avformat/fifo: Add fate test

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version of the patch:
 - Fixed whitespace and missing $(EXESUF) in fifo-muxer.mak
 - Fixed "overflow with packet dropping" test which skipped write_trailer
   call in case of failure.

 libavformat/Makefile   |   1 +
 libavformat/tests/fifo_muxer.c | 443 +
 tests/Makefile |   1 +
 tests/fate/fifo-muxer.mak  |  20 ++
 tests/ref/fate/fifo-muxer-tst  |  11 +
 5 files changed, 476 insertions(+)
 create mode 100644 libavformat/tests/fifo_muxer.c
 create mode 100644 tests/fate/fifo-muxer.mak
 create mode 100644 tests/ref/fate/fifo-muxer-tst

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2d2b78c..5d827d31 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -591,6 +591,7 @@ TESTPROGS = seek
\
 url \
 #   async   \
 
+TESTPROGS-$(CONFIG_FIFO_MUXER)   += fifo_muxer
 TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
new file mode 100644
index 000..d6ce85d
--- /dev/null
+++ b/libavformat/tests/fifo_muxer.c
@@ -0,0 +1,443 @@
+/*
+ * FIFO pseudo-muxer
+ * Copyright (c) 2016 Jan Sebechlebsky
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavutil/opt.h"
+#include "libavutil/time.h"
+#include "libavutil/avassert.h"
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+
+#define MAX_TST_PACKETS 128
+#define SLEEPTIME_50_MS 5
+#define SLEEPTIME_10_MS 1
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+/* This is structure of data sent in packets to
+ * failing muxer */
+typedef struct FailingMuxerPacketData {
+int ret; /* return value of write_packet call*/
+int recover_after;   /* set ret to zero after this number of recovery 
attempts */
+unsigned sleep_time; /* sleep for this long in write_packet to simulate 
long I/O operation */
+} FailingMuxerPacketData;
+
+
+typedef struct FailingMuxerContext {
+AVClass *class;
+int write_header_ret;
+int write_trailer_ret;
+/* If non-zero, summary of processed packets will be printed in deinit */
+uint8_t print_deinit_summary;
+
+int flush_count;
+int pts_written[MAX_TST_PACKETS];
+int pts_written_nr;
+} FailingMuxerContext;
+
+static int failing_write_header(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_header_ret;
+}
+
+static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+int ret = 0;
+if (!pkt) {
+ctx->flush_count++;
+} else {
+FailingMuxerPacketData *data = (FailingMuxerPacketData*) pkt->data;
+
+if (!data->recover_after) {
+data->ret = 0;
+} else {
+data->recover_after--;
+}
+
+ret = data->ret;
+
+if (data->sleep_time) {
+int64_t slept = 0;
+while (slept < data->sleep_time) {
+if (ff_check_interrupt(&avf->interrupt_callback))
+return AVERROR_EXIT;
+av_usleep(SLEEPTIME_10_MS);
+slept += SLEEPTIME_10_MS;
+}
+}
+
+if (!ret) {
+ctx->pts_written[ctx->pts_written_nr++] = pkt->pts;
+av_packet_unref(pkt);
+}
+}
+return ret;
+}
+
+static int failing_write_trailer(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_trailer_ret;
+}
+
+static void failing_deinit(AVFormatContext *avf)
+{
+int i;
+FailingMuxerContext *ctx = avf->priv_data;
+
+if (!ctx->print_deinit_summary)
+return;
+
+printf("flush count: %d\n", ctx->flush_count);
+printf("pts seen nr: %d\n", ctx->pts_written_nr);
+printf("pts seen: ");
+for (i = 0; i < ctx->pts_written_nr; ++i ) {
+  

[FFmpeg-devel] [PATCH v2 04/11] avformat/muxers: Add non-blocking mode support for av_write_trailer

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

This makes av_write_trailer not to free the resources if write_trailer
call returns AVERROR(EAGAIN) allowing repeated calls of write_trailer of
non-blocking muxer.

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version of the patch:
 - Added assert to the part of the code dealing with flushing
   interleaved packets which should not be entered if 
   muxer in non-blocking mode is used.
   (also there is assert for the same condition added into
av_interleaved_write_packet in one of the following 
patches).

 libavformat/avformat.h |  6 +-
 libavformat/mux.c  | 10 --
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d8a6cf3..2cc3156 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2510,8 +2510,12 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int 
stream_index);
  *
  * May only be called after a successful call to avformat_write_header.
  *
+ * If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN)
+ * meaning the operation is pending and the call should be repeated.
+ *
  * @param s media file handle
- * @return 0 if OK, AVERROR_xxx on error
+ * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated,
+ * other AVERROR on error
  */
 int av_write_trailer(AVFormatContext *s);
 
diff --git a/libavformat/mux.c b/libavformat/mux.c
index e9973ed..3ae924c 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1204,11 +1204,14 @@ int av_write_trailer(AVFormatContext *s)
 for (;; ) {
 AVPacket pkt;
 ret = interleave_packet(s, &pkt, NULL, 1);
-if (ret < 0)
-goto fail;
 if (!ret)
 break;
 
+av_assert0(!(s->flags & AVFMT_FLAG_NONBLOCK));
+
+if (ret < 0)
+goto fail;
+
 ret = write_packet(s, &pkt);
 if (ret >= 0)
 s->streams[pkt.stream_index]->nb_frames++;
@@ -1238,6 +1241,9 @@ fail:
 }
 }
 
+if (ret == AVERROR(EAGAIN))
+return ret;
+
 if (s->oformat->deinit)
 s->oformat->deinit(s);
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v2 05/11] avformat/mux: Refactor muxer deinit from av_write_trailer

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Move muxer deinitialization and private resources freeing
in a separate static function free_muxer(AVFormatContext*).

Signed-off-by: Jan Sebechlebsky 
---
 No changes since the last version, just rebased because
 of changes in previous patch.

 libavformat/mux.c | 31 ---
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 3ae924c..45f1401 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1197,9 +1197,27 @@ fail:
 return ret;
 }
 
+static void deinit_muxer(AVFormatContext *s)
+{
+int i;
+
+if (s->oformat->deinit)
+s->oformat->deinit(s);
+
+for (i = 0; i < s->nb_streams; i++) {
+av_freep(&s->streams[i]->priv_data);
+av_freep(&s->streams[i]->index_entries);
+}
+
+if (s->oformat->priv_class)
+av_opt_free(s->priv_data);
+
+av_freep(&s->priv_data);
+}
+
 int av_write_trailer(AVFormatContext *s)
 {
-int ret, i;
+int ret;
 
 for (;; ) {
 AVPacket pkt;
@@ -1244,20 +1262,11 @@ fail:
 if (ret == AVERROR(EAGAIN))
 return ret;
 
-if (s->oformat->deinit)
-s->oformat->deinit(s);
-
 if (s->pb)
avio_flush(s->pb);
 if (ret == 0)
ret = s->pb ? s->pb->error : 0;
-for (i = 0; i < s->nb_streams; i++) {
-av_freep(&s->streams[i]->priv_data);
-av_freep(&s->streams[i]->index_entries);
-}
-if (s->oformat->priv_class)
-av_opt_free(s->priv_data);
-av_freep(&s->priv_data);
+deinit_muxer(s);
 return ret;
 }
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v3 06/11] avformat: add avformat_write_abort() function

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 No changes since the last version of the patch, just rebased
 because of the changes in previous patches.

 libavformat/avformat.h | 15 +++
 libavformat/mux.c  | 13 +
 2 files changed, 28 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 2cc3156..83903b5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2512,6 +2512,8 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int 
stream_index);
  *
  * If AVFMT_FLAG_NONBLOCK is set, this call may return AVERROR(EAGAIN)
  * meaning the operation is pending and the call should be repeated.
+ * If caller decides to abort operation (after too many calls have returned
+ * AVERROR(EAGAIN)), it can be done by calling @ref avformat_write_abort().
  *
  * @param s media file handle
  * @return 0 if OK, AVERROR(EAGAIN) in case call should be repeated,
@@ -2520,6 +2522,19 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int 
stream_index);
 int av_write_trailer(AVFormatContext *s);
 
 /**
+ * Abort muxer operation and free private data.
+ * For muxer operating in blocking mode, this is equivalent to calling
+ * av_write_trailer. For muxer operating in non-blocking mode, this will
+ * call deinitialize routine even if there is operation pending
+ * and @ref av_write_trailer() keeps returning AVERROR(EAGAIN).
+ * May only be called after a successful call to avformat_write_header.
+ *
+ * @param s Media file handle
+ * return >= 0 on success, negative AVERROR on error
+ */
+int avformat_write_abort(AVFormatContext *s);
+
+/**
  * Return the output format in the list of registered output formats
  * which best matches the provided parameters, or return NULL if
  * there is no match.
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 45f1401..0f002a3 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1270,6 +1270,19 @@ fail:
 return ret;
 }
 
+int avformat_write_abort(AVFormatContext *s)
+{
+int ret;
+
+ret = av_write_trailer(s);
+if (ret == AVERROR(EAGAIN)) {
+deinit_muxer(s);
+ret = 0;
+}
+
+return ret;
+}
+
 int av_get_output_timestamp(struct AVFormatContext *s, int stream,
 int64_t *dts, int64_t *wall)
 {
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v3 07/11] avformat/mux: Comment and assert AVFMT_FLAG_NONBLOCK

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Add comments regarding AVFMG_FLAG_NONBLOCK usage with muxers.
Add assert forbiding use of nonblocking muxer with
av_interleaved_write_frame.

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version of the patch:
 - added assert to the beginning of av_interleaved_write_frame ensuring
   it is not called with muxer in nonblocking mode.
 - Changed commit description.

 libavformat/avformat.h | 9 -
 libavformat/mux.c  | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 83903b5..79c2511 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1428,7 +1428,7 @@ typedef struct AVFormatContext {
 int flags;
 #define AVFMT_FLAG_GENPTS   0x0001 ///< Generate missing pts even if it 
requires parsing future frames.
 #define AVFMT_FLAG_IGNIDX   0x0002 ///< Ignore index.
-#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets 
from input.
+#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets 
from input / writing packets to output.
 #define AVFMT_FLAG_IGNDTS   0x0008 ///< Ignore DTS on frames that contain 
both DTS & PTS
 #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other 
values, just return what is stored in the container
 #define AVFMT_FLAG_NOPARSE  0x0020 ///< Do not use AVParsers, you also 
must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing 
-> no frames. Also seeking to frames can not work if parsing to find frame 
boundaries has been disabled
@@ -2391,6 +2391,10 @@ int avformat_write_header(AVFormatContext *s, 
AVDictionary **options);
  * the interleaving should call av_interleaved_write_frame() instead of this
  * function.
  *
+ * In case the muxer is operating in non-blocking mode (AVFMT_FLAG_NONBLOCK
+ * is set), this function can return AVERROR(EAGAIN) meaning the call should
+ * be repeated.
+ *
  * @param s media file handle
  * @param pkt The packet containing the data to be written. Note that unlike
  *av_interleaved_write_frame(), this function does not take
@@ -2433,6 +2437,9 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  * knowledge of future packets, improving e.g. the behaviour of the mp4
  * muxer for VFR content in fragmenting mode.
  *
+ * This call is not supported and must not be called if muxer is operating
+ * in non-blocking mode (AVFMT_FLAG_NONBLOCK is set).
+ *
  * @param s media file handle
  * @param pkt The packet containing the data to be written.
  *
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 0f002a3..b4698b7 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1139,6 +1139,8 @@ int av_interleaved_write_frame(AVFormatContext *s, 
AVPacket *pkt)
 {
 int ret, flush = 0;
 
+av_assert0(!(s->flags & AVFMT_FLAG_NONBLOCK));
+
 ret = prepare_input_packet(s, pkt);
 if (ret < 0)
 goto fail;
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v4 10/11] avformat/fifo: Add AVFMT_FLAG_NONBLOCK support

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Add support for nonblocking calls.

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version:
 - fixed wrong flag passed to av_thread_message_queue_recv()
 - fixed memleak when queue is full in nonblocking mode

 libavformat/fifo.c | 61 --
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 8896b9e..cdf9f49 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -19,12 +19,14 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/atomic.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
 #include "libavutil/thread.h"
 #include "libavutil/threadmessage.h"
 #include "avformat.h"
 #include "internal.h"
+#include "url.h"
 
 #define FIFO_DEFAULT_QUEUE_SIZE  60
 #define FIFO_DEFAULT_MAX_RECOVERY_ATTEMPTS   16
@@ -77,6 +79,17 @@ typedef struct FifoContext {
 /* Value > 0 signals queue overflow */
 volatile uint8_t overflow_flag;
 
+/* Whether termination was requested by invoking deinit
+ * before the thread was finished. Used only in non-blocking
+ * mode - when AVFMT_FLAG_NONBLOCK is set. */
+volatile int termination_requested;
+
+/* Initially 0, set to 1 immediately before thread function
+ * returns */
+volatile int thread_finished_flag;
+
+/* Original interrupt callback of the underlying muxer. */
+AVIOInterruptCB orig_interrupt_callback;
 } FifoContext;
 
 typedef struct FifoThreadContext {
@@ -111,6 +124,16 @@ typedef struct FifoMessage {
 AVPacket pkt;
 } FifoMessage;
 
+static int fifo_interrupt_callback_wrapper(void *arg)
+{
+FifoContext *ctx = arg;
+
+if (avpriv_atomic_int_get(&ctx->termination_requested))
+return 1;
+
+return ff_check_interrupt(&ctx->orig_interrupt_callback);
+}
+
 static int fifo_thread_write_header(FifoThreadContext *ctx)
 {
 AVFormatContext *avf = ctx->avf;
@@ -433,12 +456,17 @@ static void *fifo_consumer_thread(void *data)
 
 fifo->write_trailer_ret = fifo_thread_write_trailer(&fifo_thread_ctx);
 
+/* This must be only return path from fifo_consumer_thread function,
+ * so the thread_finised_flag is set. */
+avpriv_atomic_int_set(&fifo->thread_finished_flag, 1);
 return NULL;
 }
 
 static int fifo_mux_init(AVFormatContext *avf)
 {
 FifoContext *fifo = avf->priv_data;
+AVIOInterruptCB interrupt_cb = {.callback = 
fifo_interrupt_callback_wrapper,
+.opaque = fifo};
 AVFormatContext *avf2;
 int ret = 0, i;
 
@@ -449,7 +477,8 @@ static int fifo_mux_init(AVFormatContext *avf)
 
 fifo->avf = avf2;
 
-avf2->interrupt_callback = avf->interrupt_callback;
+fifo->orig_interrupt_callback = avf->interrupt_callback;
+avf2->interrupt_callback = interrupt_cb;
 avf2->max_delay = avf->max_delay;
 ret = av_dict_copy(&avf2->metadata, avf->metadata, 0);
 if (ret < 0)
@@ -536,7 +565,7 @@ static int fifo_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 {
 FifoContext *fifo = avf->priv_data;
 FifoMessage msg = {.type = pkt ? FIFO_WRITE_PACKET : FIFO_FLUSH_OUTPUT};
-int ret;
+int ret, queue_flags = 0;
 
 if (pkt) {
 av_init_packet(&msg.pkt);
@@ -545,15 +574,21 @@ static int fifo_write_packet(AVFormatContext *avf, 
AVPacket *pkt)
 return ret;
 }
 
-ret = av_thread_message_queue_send(fifo->queue, &msg,
-   fifo->drop_pkts_on_overflow ?
-   AV_THREAD_MESSAGE_NONBLOCK : 0);
+if (fifo->drop_pkts_on_overflow || (avf->flags & AVFMT_FLAG_NONBLOCK))
+queue_flags |= AV_THREAD_MESSAGE_NONBLOCK;
+
+ret = av_thread_message_queue_send(fifo->queue, &msg, queue_flags);
+
 if (ret == AVERROR(EAGAIN)) {
-uint8_t overflow_set = 0;
+uint8_t overflow_set;
+
+if (avf->flags & AVFMT_FLAG_NONBLOCK)
+goto fail;
 
 /* Queue is full, set fifo->overflow_flag to 1
  * to let consumer thread know the queue should
  * be flushed. */
+overflow_set = 0;
 pthread_mutex_lock(&fifo->overflow_flag_lock);
 if (!fifo->overflow_flag)
 fifo->overflow_flag = overflow_set = 1;
@@ -581,6 +616,10 @@ static int fifo_write_trailer(AVFormatContext *avf)
 
 av_thread_message_queue_set_err_recv(fifo->queue, AVERROR_EOF);
 
+if ((avf->flags & AVFMT_FLAG_NONBLOCK) &&
+!avpriv_atomic_int_get(&fifo->thread_finished_flag))
+   return AVERROR(EAGAIN);
+
 ret = pthread_join( fifo->writer_thread, NULL);
 if (ret < 0) {
 av_log(avf, AV_LOG_ERROR, "pthread join error: %s\n",
@@ -596,6 +635,16 @@ static void fifo_deinit(AVFormatContext *avf)
 {
 FifoContext *fifo = avf->priv_data;
 
+if (avf->flags & AVFMT_FLAG_NONBLOCK) {
+int ret;
+avpriv_atomic_int_set(&fifo->termination_requested, 1);
+   

[FFmpeg-devel] [PATCH v3 11/11] avformat/fifo: Add test for nonblocking mode

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 No changes since the last version of the patch, just rebased 
 because of changes in previous fate test patch.

 libavformat/tests/fifo_muxer.c | 139 +
 tests/ref/fate/fifo-muxer-tst  |   5 ++
 2 files changed, 144 insertions(+)

diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
index d6ce85d..deb2656 100644
--- a/libavformat/tests/fifo_muxer.c
+++ b/libavformat/tests/fifo_muxer.c
@@ -336,6 +336,137 @@ fail:
 return ret;
 }
 
+static int retry_write_frame(AVFormatContext *oc, AVPacket *pkt, int 
max_retries)
+{
+int ret = 0, retry_count = 0;
+do {
+ret = av_write_frame(oc, pkt);
+if (ret == AVERROR(EAGAIN)) {
+av_usleep(SLEEPTIME_10_MS);
+retry_count++;
+}
+} while ( ret == AVERROR(EAGAIN) && retry_count < max_retries);
+return ret;
+}
+
+static int retry_write_trailer(AVFormatContext *oc, int max_retries)
+{
+int ret = 0, retry_count = 0;
+do {
+ret = av_write_trailer(oc);
+if (ret == AVERROR(EAGAIN)) {
+av_usleep(SLEEPTIME_10_MS);
+retry_count++;
+}
+} while (ret == AVERROR(EAGAIN) && retry_count < max_retries);
+return ret;
+}
+
+static int fifo_nonblock_test(AVFormatContext *oc, AVDictionary **opts,
+  const FailingMuxerPacketData *pkt_data)
+{
+int ret = 0, i;
+AVPacket pkt;
+
+av_init_packet(&pkt);
+
+oc->flags |= AVFMT_FLAG_NONBLOCK;
+
+ret = avformat_write_header(oc, opts);
+if (ret) {
+fprintf(stderr, "Unexpected write_header failure: %s\n",
+av_err2str(ret));
+return ret;
+}
+
+for (i = 0; i < 16; i++ ) {
+ret = prepare_packet(&pkt, pkt_data, i);
+if (ret < 0) {
+fprintf(stderr, "Failed to prepare test packet: %s\n",
+av_err2str(ret));
+goto fail;
+}
+ret = retry_write_frame(oc, &pkt, 100);
+av_packet_unref(&pkt);
+if (ret < 0)
+break;
+}
+
+if (ret) {
+fprintf(stderr, "Unexpected write_packet error: %s\n", 
av_err2str(ret));
+goto fail;
+}
+
+ret = retry_write_trailer(oc, 100);
+if (ret == AVERROR(EAGAIN)) {
+fprintf(stderr, "write_trailer() operation timeout\n");
+goto fail;
+} else if (ret < 0)
+fprintf(stderr, "Unexpected write_trailer error: %s\n", 
av_err2str(ret));
+
+return ret;
+fail:
+avformat_write_abort(oc);
+return ret;
+}
+
+static int fifo_nonblock_abort_test(AVFormatContext *oc, AVDictionary **opts,
+const FailingMuxerPacketData *pkt_data)
+{
+int ret = 0, i;
+AVPacket pkt;
+int64_t start_time, end_time, duration;
+
+av_init_packet(&pkt);
+
+oc->flags |= AVFMT_FLAG_NONBLOCK;
+
+ret = avformat_write_header(oc, opts);
+if (ret) {
+fprintf(stderr, "Unexpected write header failure: %s\n",
+av_err2str(ret));
+goto fail;
+}
+
+av_assert0(pkt_data->sleep_time > 0);
+
+start_time = av_gettime_relative();
+for (i = 0; i < 16; i++ ) {
+ret = prepare_packet(&pkt, pkt_data, i);
+if (ret < 0) {
+fprintf(stderr, "Failed to prepare test packet: %s\n",
+av_err2str(ret));
+goto fail;
+}
+ret = retry_write_frame(oc, &pkt, 100);
+av_packet_unref(&pkt);
+if (ret < 0)
+break;
+}
+
+if (ret) {
+fprintf(stderr, "Unexpected write_packet error: %s\n", 
av_err2str(ret));
+goto fail;
+}
+
+avformat_write_abort(oc);
+
+end_time = av_gettime_relative();
+duration = end_time - start_time;
+
+if (duration > (16*pkt_data->sleep_time)/2 ) {
+fprintf(stderr, "Aborting output took too much time: %u us,"
+" expected time if not aborted %u us\n",
+(unsigned) duration, 16*pkt_data->sleep_time);
+ret = AVERROR(ETIMEDOUT);
+}
+
+return ret;
+fail:
+avformat_write_abort(oc);
+return ret;
+}
+
 typedef struct TestCase {
 int (*test_func)(AVFormatContext *, AVDictionary **,const 
FailingMuxerPacketData *pkt_data);
 const char *test_name;
@@ -423,6 +554,14 @@ const TestCase tests[] = {
 {fifo_overflow_drop_test, "overflow with packet dropping", 
"queue_size=3:drop_pkts_on_overflow=1",
  0, 0, 0, {0, 0, SLEEPTIME_50_MS}},
 
+/* Simple test of nonblocking mode, the consumer should receive all 
the packets. */
+{fifo_nonblock_test, "nonblocking mode test", "queue_size=3",
+ 1, 0, 0, {0, 0, SLEEPTIME_10_MS}},
+
+/* Test of terminating fifo muxer with av_abort_format() */
+{fifo_nonblock_abort_test, "abort in nonblocking mode", 
"queue_size=16",
+ 0, 0, 0, {0, 0, SLEEPTIME_50_MS}},
+
 {NULL}
 };
 
diff --git 

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

2016-08-11 Thread Paul B Mahol
On 8/11/16, Michael Niedermayer  wrote:
> On Wed, Aug 10, 2016 at 06:23:32PM +0200, Paul B Mahol wrote:
>> Hi,
>>
>> patch attached.
>
>>  doc/filters.texi  |   49 +++
>>  libavfilter/Makefile  |1
>>  libavfilter/af_acrusher.c |  291
>> ++
>>  libavfilter/allfilters.c  |1
>>  4 files changed, 342 insertions(+)
>> edb554dcdc55f1658d3570acf9eb1ab8b7699a88
>> 0001-avfilter-add-acrusher-filter.patch
>> From 0d50ac2d704ebc719ab2557c1024ed4b58505a28 Mon Sep 17 00:00:00 2001
>> From: Paul B Mahol 
>> Date: Wed, 10 Aug 2016 16:11:37 +0200
>> Subject: [PATCH] avfilter: add acrusher filter
>>
>> ---
>>  doc/filters.texi  |  49 
>>  libavfilter/Makefile  |   1 +
>>  libavfilter/af_acrusher.c | 291
>> ++
>>  libavfilter/allfilters.c  |   1 +
>>  4 files changed, 342 insertions(+)
>>  create mode 100644 libavfilter/af_acrusher.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 9dab959..562fff5 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -441,6 +441,55 @@ ffmpeg -i first.flac -i second.flac -filter_complex
>> acrossfade=d=10:o=0:c1=exp:c
>>  @end example
>>  @end itemize
>>
>> +@section acrusher
>> +
>> +Reduce audio bit resolution.
>> +
>> +This filter is bit crusher with enhanced funcionality. A bit crusher
>> +is used to audibly reduce number of bits an audio signal is sampled
>> +with. This doesn't change the bit depth at all, it just produces the
>> +effect. Material reduced in bit depth sounds more harsh and "digital".
>> +This filter is able to even round to continous values instead of
>> discrete
>> +bit depths.
>> +Additionally it has a D/C offset which results in different crushing of
>> +the lower and the upper half of the signal.
>> +An Anti-Aliasing setting is able to produce "softer" crushing sounds.
>> +
>> +Another feature of this filter is the logarithmic mode.
>> +This setting switches from linear distances between bits to logarithmic
>> ones.
>> +The result is a much more "natural" sounding crusher which doesn't gate
>> low
>> +signals for example. The human ear has a logarithmic perception, too
>> +so this kind of crushing is much more pleasant.
>> +Logarithmic crushing is also able to get anti-aliased.
>> +
>> +The filter accepts the following options:
>> +
>> +@table @option
>> +@item level_in
>> +Set level in.
>> +
>> +@item level_out
>> +Set level out.
>> +
>> +@item bits
>> +Set bit reduction.
>> +
>> +@item mix
>> +Set mixing ammount.
>> +
>> +@item mode
>> +Can be linear: @code{lin} or logarithmic: @code{log}.
>> +
>> +@item dc
>> +Set DC.
>> +
>> +@item aa
>> +Set anti-aliasing.
>> +
>> +@item samples
>> +Set sample reduction.
>> +@end table
>> +
>>  @section adelay
>>
>>  Delay one or more audio channels.
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index cd62fd5..0d94f84 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -30,6 +30,7 @@ OBJS-$(HAVE_THREADS) +=
>> pthread.o
>>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
>>  OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
>>  OBJS-$(CONFIG_ACROSSFADE_FILTER) += af_afade.o
>> +OBJS-$(CONFIG_ACRUSHER_FILTER)   += af_acrusher.o
>>  OBJS-$(CONFIG_ADELAY_FILTER) += af_adelay.o
>>  OBJS-$(CONFIG_AECHO_FILTER)  += af_aecho.o
>>  OBJS-$(CONFIG_AEMPHASIS_FILTER)  += af_aemphasis.o
>> diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
>> new file mode 100644
>> index 000..339cbf2
>> --- /dev/null
>> +++ b/libavfilter/af_acrusher.c
>> @@ -0,0 +1,291 @@
>> +/*
>> + * Copyright (c) Markus Schmidt and Christian Holschuh
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301 USA
>> + */
>> +
>> +#include "libavutil/opt.h"
>> +#include "avfilter.h"
>> +#include "internal.h"
>> +#include "audio.h"
>> +
>> +typedef struct SRContext {
>> +double target;
>> +double real;
>> +double samples;
>> +double last;
>> +} SRContext;
>> +
>> +typedef struct ACrusherContext {
>> +const AVClass *class;
>> +
>> +double level_in;
>> +double level

Re: [FFmpeg-devel] [PATCH 1/2] avisynth: simplify the pix_fmt check for the newer AviSynth API

2016-08-11 Thread Stephen Hutchinson

On 8/11/2016 6:31 AM, Michael Niedermayer wrote:

does this work with all supported AviSynth versions ?



Yes, it works with both 2.6 and Plus.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 03/11] avformat/fifo: Add fate test

2016-08-11 Thread Michael Niedermayer
On Thu, Aug 11, 2016 at 11:19:33AM +0200, Jan Sebechlebsky wrote:
> 
> 
> On 08/09/2016 07:42 PM, Michael Niedermayer wrote:
> >On Tue, Aug 09, 2016 at 01:26:04PM +0200, sebechlebsky...@gmail.com wrote:
> >>From: Jan Sebechlebsky 
> >>
> >>Signed-off-by: Jan Sebechlebsky 
> >>---
> >>  Changes since the last version:
> >>  - Removed empty lines at the end of fifo_muxer.c file
> >>
> >[...]
> >>diff --git a/tests/Makefile b/tests/Makefile
> >>index 895944d..0848766 100644
> >>--- a/tests/Makefile
> >>+++ b/tests/Makefile
> >>@@ -128,6 +128,7 @@ include $(SRC_PATH)/tests/fate/exif.mak
> >>  include $(SRC_PATH)/tests/fate/ffmpeg.mak
> >>  include $(SRC_PATH)/tests/fate/ffprobe.mak
> >>  include $(SRC_PATH)/tests/fate/fft.mak
> >>+include $(SRC_PATH)/tests/fate/fifo-muxer.mak
> >>  include $(SRC_PATH)/tests/fate/filter-audio.mak
> >>  include $(SRC_PATH)/tests/fate/filter-video.mak
> >>  include $(SRC_PATH)/tests/fate/flac.mak
> >>diff --git a/tests/fate/fifo-muxer.mak b/tests/fate/fifo-muxer.mak
> >>new file mode 100644
> >>index 000..a064069
> >>--- /dev/null
> >>+++ b/tests/fate/fifo-muxer.mak
> >>@@ -0,0 +1,20 @@
> >>+fate-fifo-muxer-h264: CMD = ffmpeg -i $(TARGET_SAMPLES)/mkv/1242-small.mkv 
> >>-vframes 11\
> >>+-c:v copy -c:a copy -map v:0 -map a:0 -flags 
> >>+bitexact\
> >>+-fflags +bitexact -f fifo -fifo_format 
> >>framecrc -
> >>+fate-fifo-muxer-h264: REF = $(SRC_PATH)/tests/ref/fate/mkv-1242
> >>+FATE_FIFO_MUXER-$(call ALLYES, FIFO_MUXER, MATROSKA_DEMUXER, H264_DECODER) 
> >>+= fate-fifo-muxer-h264
> >>+
> >>+fate-fifo-muxer-wav: CMD = ffmpeg -i 
> >>$(TARGET_SAMPLES)/audio-reference/chorusnoise_2ch_44kHz_s16.wav\
> >>+   -c:a copy -map a:0 -flags +bitexact\
> >>+  -fflags +bitexact -f fifo -fifo_format wav md5:
> >inconsistent mix of space and tab
> >
> >
> >>+fate-fifo-muxer-wav: CMP = oneline
> >>+fate-fifo-muxer-wav: REF = 4dda5dcc7ecdc2218b0739a152ada802
> >>+FATE_FIFO_MUXER-$(call ALLYES, FIFO_MUXER, WAV_DEMUXER) += 
> >>fate-fifo-muxer-wav
> >>+
> >>+fate-fifo-muxer-tst: libavformat/tests/fifo_muxer$(EXESUF)
> >>+fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer
> >>+FATE_FIFO_MUXER-$(CONFIG_FIFO_MUXER) += fate-fifo-muxer-tst
> >>+
> >>+FATE_SAMPLES_FFMPEG += fate-fifo-muxer-h264 fate-fifo-muxer-wav
> >>+FATE_FFMPEG += fate-fifo-muxer-tst
> >>+fate-fifo-muxer: $(FATE_FIFO_MUXER-yes)
> >works on linux 32 & 64bit
> >
> >fails on mingw32 & 64
> >
> >make: *** No rule to make target `libavformat/tests/fifo_muxer.exe', needed 
> >by `fate-fifo-muxer-tst'.
> >make: Target `fate-fifo-muxer-tst' not remade because of errors.
> I was not able to reproduce the exactly same error you got, however
> I've fixed the whitespace and also there was $(EXESUF) missing at
> 
> fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer
> 
> line - I hope that was the cause the test refused to built. I've
> setup windows build and found also some other issues, now it passes
> fate on linux 32/64 bit build and also mingw32/64 bit build.
> 
> Thank you for testing it - I will try to run windows tests as well
> in future to avoid such mistakes.
> I'll resend fixed patches soon - can you please re-run the
> fate-fifo-muxer test as well in your environment?

it appears after closer inspection the fifo muxer was not enabled
with mingw32 here

you can get the same failure on linux with
make distclean ; ./configure --disable-pthreads --samples=.../ && make -j12 fate

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

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


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


[FFmpeg-devel] [PATCH] add append_list flag into hlsenc

2016-08-11 Thread Steven Liu
When ffmpeg exit by exception, start a new ffmpeg will cover the old
segment list, add this flag can continue append the new segments into old
hls segment list

Signed-off-by: LiuQi 
---
 doc/muxers.texi  |  4 
 libavformat/hlsenc.c | 63

 2 files changed, 67 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 5873269..2e95c6f 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -495,6 +495,10 @@ Will produce the playlist, @file{out.m3u8}, and a
single segment file,
 Segment files removed from the playlist are deleted after a period of time
 equal to the duration of the segment plus the duration of the playlist.

+@item hls_flags append_list
+Append new segments into the end of old segment list,
+and remove the @code{#EXT-X-ENDLIST} from the old segment list.
+
 @item hls_flags round_durations
 Round the duration info in the playlist file segment info to integer
 values, instead of using floating point.
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 9f076ba..a570db4 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -63,6 +63,7 @@ typedef enum HLSFlags {
 HLS_DISCONT_START = (1 << 3),
 HLS_OMIT_ENDLIST = (1 << 4),
 HLS_SPLIT_BY_TIME = (1 << 5),
+HLS_APPEND_LIST = (1 << 6),
 } HLSFlags;

 typedef enum {
@@ -265,6 +266,14 @@ static int hls_encryption_start(AVFormatContext *s)
 return 0;
 }

+static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
+{
+int len = ff_get_line(s, buf, maxlen);
+while (len > 0 && av_isspace(buf[len - 1]))
+buf[--len] = '\0';
+return len;
+}
+
 static int hls_mux_init(AVFormatContext *s)
 {
 HLSContext *hls = s->priv_data;
@@ -389,6 +398,55 @@ static int hls_append_segment(struct AVFormatContext
*s, HLSContext *hls, double
 return 0;
 }

+static int parse_playlist(AVFormatContext *s, const char *url)
+{
+HLSContext *hls = s->priv_data;
+AVIOContext *in;
+int ret = 0, is_segment = 0;
+int64_t new_start_pos;
+int64_t duration = 0;
+char line[1024];
+const char *ptr;
+
+if ((ret = ffio_open_whitelist(&in, url, AVIO_FLAG_READ,
+   &s->interrupt_callback, NULL,
+   s->protocol_whitelist,
s->protocol_blacklist)) < 0)
+return ret;
+
+read_chomp_line(in, line, sizeof(line));
+if (strcmp(line, "#EXTM3U")) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+while (!avio_feof(in)) {
+read_chomp_line(in, line, sizeof(line));
+if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
+duration = atoi(ptr);
+} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
+hls->sequence = atoi(ptr);
+} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
+} else if (av_strstart(line, "#EXTINF:", &ptr)) {
+is_segment = 1;
+hls->duration = atof(ptr);
+} else if (av_strstart(line, "#", NULL)) {
+continue;
+} else if (line[0]) {
+if (is_segment) {
+new_start_pos = avio_tell(hls->avf->pb);
+hls->size = new_start_pos - hls->start_pos;
+av_strlcpy(hls->avf->filename, line, sizeof(line));
+hls_append_segment(s, hls, hls->duration, hls->start_pos,
hls->size);
+is_segment = 0;
+}
+}
+}
+
+fail:
+avio_close(in);
+return ret;
+}
+
 static void hls_free_segments(HLSSegment *p)
 {
 HLSSegment *en;
@@ -752,6 +810,10 @@ static int hls_write_header(AVFormatContext *s)
 if ((ret = hls_mux_init(s)) < 0)
 goto fail;

+if (hls->flags & HLS_APPEND_LIST) {
+parse_playlist(s, s->filename);
+}
+
 if ((ret = hls_start(s)) < 0)
 goto fail;

@@ -927,6 +989,7 @@ static const AVOption options[] = {
 {"discont_start", "start the playlist with a discontinuity tag", 0,
AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX,   E, "flags"},
 {"omit_endlist", "Do not append an endlist when ending stream", 0,
AV_OPT_TYPE_CONST, {.i64 = HLS_OMIT_ENDLIST }, 0, UINT_MAX,   E, "flags"},
 {"split_by_time", "split the hls segment by time which user set by
hls_time", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SPLIT_BY_TIME }, 0, UINT_MAX,
  E, "flags"},
+{"append_list", "append the new segments into old hls segment list",
0, AV_OPT_TYPE_CONST, {.i64 = HLS_APPEND_LIST }, 0, UINT_MAX,   E, "flags"},
 {"use_localtime", "set filename expansion with strftime at segment
creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"use_localtime_mkdir", "create last directory component in
strftime-generated filename", OFFSET(use_localtime_mkdir),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type),
AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E,
"pl_type" 

Re: [FFmpeg-devel] [GSoC] Motion Interpolation

2016-08-11 Thread Paul B Mahol
On 8/10/16, Davinder Singh  wrote:
> On Mon, Jul 25, 2016 at 9:35 AM Davinder Singh  wrote:
>
>> https://github.com/dsmudhar/FFmpeg/commits/dev
>>
>> The Paper 2 algorithm is complete. It seems good. If I compare Paper 2
>> (which uses bilateral motion estimation) v/s motion vectors exported by
>> mEstimate filter:
>>
>> $ tiny_psnr 60_source_2.yuv 60_mest-esa+obmc.yuv
>> stddev:1.43 PSNR: 45.02 MAXDIFF:  174 bytes:476928000/474163200
>>
>> $ tiny_psnr 60_source_2.yuv 60_paper2_aobmc+cls.yuv
>> stddev:1.25 PSNR: 46.18 MAXDIFF:  187 bytes:476928000/474163200
>>
>> Frame comparison: http://www.mediafire.com/?qe7sc4o0s4hgug5
>>
>> Compared to simple OBMC which over-smooth edges, Objects clustering and
>> Adaptive OBMC makes the edges crisp but also introduce blocking artifacts
>> where MVs are bad (with default search window = 7). But I think it’s ESA’s
>> fault. The paper doesn’t specify which motion estimation method they used;
>> I have been using ESA. I think quality can be further improved with EPZS,
>> which I'm going to implement.
>>
>> I also tried to tweak VS-BMC (Variable size block motion compensation)
>> which reduced the blocking artifacts in VS-BMC area. Had to do experiments
>> a lot, more to be done.
>>
>> mEstimate filter (ESA) + Simple OBMC:
>> http://www.mediafire.com/?3b8j1zj1lsuw979
>> Paper 2 (full): http://www.mediafire.com/?npbw1iv6tmxwvyu
>>
>>
>> Regards,
>> DSM_
>>
>
>
>
> implemented all other modern fast ME algorithms:
> https://github.com/dsmudhar/FFmpeg/blob/dev/libavfilter/vf_mestimate.c

Could you please squash your commits and attach patches that add vf_mestimate
and vf_minterpolate filters?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_signalstats: add >8 bit depth support

2016-08-11 Thread Paul B Mahol
On 8/9/16, Paul B Mahol  wrote:
> Hi,
>
> patch attached.
>

Updated patches attached.


0001-avfilter-vf_signalstats-add-8-bit-depth-support.patch
Description: Binary data


0002-avfilter-vf_signalstats-measure-video-bitdepth.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2]Support QT b64a ARGB64 rawvideo

2016-08-11 Thread Paul B Mahol
On 8/9/16, Carl Eugen Hoyos  wrote:
> Hi!
>
>
>> Am 09.08.2016 um 18:26 schrieb Paul B Mahol :
>>
>>> On 8/9/16, Carl Eugen Hoyos  wrote:
>>> Hi!
>>>
>>> New patch attached that fixes ticket #5657.
>>>
>>> Please comment, Carl Eugen
>>
>> Micro should be 101.
>
> Definitely, thank you.
>
> Will fix locally, any other comments?
>

No, LGTM if works.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add max value output option to psnr stats log.

2016-08-11 Thread Lucas Cooper
This allows retroactive calculation/aggregation of PSNR from the stats
log.
---
 libavfilter/vf_psnr.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 3bec747..de5cc8f 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -45,6 +45,7 @@ typedef struct PSNRContext {
 char *stats_file_str;
 int stats_version;
 int stats_header_written;
+int stats_add_max;
 int max[4], average_max;
 int is_rgb;
 uint8_t rgba_map[4];
@@ -63,6 +64,7 @@ static const AVOption psnr_options[] = {
 {"stats_file", "Set file where to store per-frame difference information", 
OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 {"f",  "Set file where to store per-frame difference information", 
OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 {"stats_version", "Set the format version for the stats file.",
   OFFSET(stats_version),  AV_OPT_TYPE_INT,{.i64=1},1, 2, FLAGS },
+{"output_max",  "Add raw stats (max values) to the output log.",   
 OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 { NULL }
 };
 
@@ -182,6 +184,12 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame 
*main,
 for (j = 0; j < s->nb_components; j++) {
 fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
 }
+if (s->stats_add_max) {
+  fprintf(s->stats_file, ",max_avg");
+  for (j = 0; j < s->nb_components; j++) {
+  fprintf(s->stats_file, ",max_%c", s->comps[j]);
+  }
+}
 fprintf(s->stats_file, "\n");
 s->stats_header_written = 1;
 }
@@ -196,6 +204,13 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame 
*main,
 fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j],
 get_psnr(comp_mse[c], 1, s->max[c]));
 }
+if (s->stats_version == 2 && s->stats_add_max) {
+  fprintf(s->stats_file, "max_avg:%d ", s->average_max);
+  for (j = 0; j < s->nb_components; j++) {
+  c = s->is_rgb ? s->rgba_map[j] : j;
+  fprintf(s->stats_file, "max_%c:%d ", s->comps[j], s->max[c]);
+  }
+}
 fprintf(s->stats_file, "\n");
 }
 
-- 
2.8.0.rc3.226.g39d4020

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


Re: [FFmpeg-devel] [PATCH 1/2] avisynth: simplify the pix_fmt check for the newer AviSynth API

2016-08-11 Thread Michael Niedermayer
On Thu, Aug 11, 2016 at 10:55:22AM -0400, Stephen Hutchinson wrote:
> On 8/11/2016 6:31 AM, Michael Niedermayer wrote:
> >does this work with all supported AviSynth versions ?
> >
> 
> Yes, it works with both 2.6 and Plus.

ok ill apply it in a moment

thx

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


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


Re: [FFmpeg-devel] [GSoC] Motion Interpolation

2016-08-11 Thread Davinder Singh
On Thu, Aug 11, 2016 at 9:09 PM Paul B Mahol  wrote:

> On 8/10/16, Davinder Singh  wrote:
> > On Mon, Jul 25, 2016 at 9:35 AM Davinder Singh 
> wrote:
> >
> >> https://github.com/dsmudhar/FFmpeg/commits/dev
> >>
> >> The Paper 2 algorithm is complete. It seems good. If I compare Paper 2
> >> (which uses bilateral motion estimation) v/s motion vectors exported by
> >> mEstimate filter:
> >>
> >> $ tiny_psnr 60_source_2.yuv 60_mest-esa+obmc.yuv
> >> stddev:1.43 PSNR: 45.02 MAXDIFF:  174 bytes:476928000/474163200
> >>
> >> $ tiny_psnr 60_source_2.yuv 60_paper2_aobmc+cls.yuv
> >> stddev:1.25 PSNR: 46.18 MAXDIFF:  187 bytes:476928000/474163200
> >>
> >> Frame comparison: http://www.mediafire.com/?qe7sc4o0s4hgug5
> >>
> >> Compared to simple OBMC which over-smooth edges, Objects clustering and
> >> Adaptive OBMC makes the edges crisp but also introduce blocking
> artifacts
> >> where MVs are bad (with default search window = 7). But I think it’s
> ESA’s
> >> fault. The paper doesn’t specify which motion estimation method they
> used;
> >> I have been using ESA. I think quality can be further improved with
> EPZS,
> >> which I'm going to implement.
> >>
> >> I also tried to tweak VS-BMC (Variable size block motion compensation)
> >> which reduced the blocking artifacts in VS-BMC area. Had to do
> experiments
> >> a lot, more to be done.
> >>
> >> mEstimate filter (ESA) + Simple OBMC:
> >> http://www.mediafire.com/?3b8j1zj1lsuw979
> >> Paper 2 (full): http://www.mediafire.com/?npbw1iv6tmxwvyu
> >>
> >>
> >> Regards,
> >> DSM_
> >>
> >
> >
> >
> > implemented all other modern fast ME algorithms:
> > https://github.com/dsmudhar/FFmpeg/blob/dev/libavfilter/vf_mestimate.c
>
> Could you please squash your commits and attach patches that add
> vf_mestimate
> and vf_minterpolate filters?
>

will send very soon.


> ___
> 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 v2 03/11] avformat/fifo: Add fate test

2016-08-11 Thread Jan Sebechlebsky



On 08/11/2016 05:00 PM, Michael Niedermayer wrote:

make: *** No rule to make target `libavformat/tests/fifo_muxer.exe', needed by 
`fate-fifo-muxer-tst'.
make: Target `fate-fifo-muxer-tst' not remade because of errors.

I was not able to reproduce the exactly same error you got, however
I've fixed the whitespace and also there was $(EXESUF) missing at

fate-fifo-muxer-tst: CMD = run libavformat/tests/fifo_muxer

line - I hope that was the cause the test refused to built. I've
setup windows build and found also some other issues, now it passes
fate on linux 32/64 bit build and also mingw32/64 bit build.

Thank you for testing it - I will try to run windows tests as well
in future to avoid such mistakes.
I'll resend fixed patches soon - can you please re-run the
fate-fifo-muxer test as well in your environment?

it appears after closer inspection the fifo muxer was not enabled
with mingw32 here

you can get the same failure on linux with
make distclean ; ./configure --disable-pthreads --samples=.../ && make -j12 fate



Sorry for that, I've missed that. I'll resend the patch.

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


[FFmpeg-devel] [PATCH v4 03/11] avformat/fifo: Add fate test

2016-08-11 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 Changes since the last version of patch:
 - Fixed make dependencies so the tests are not executed when 
   required components are disabled

 libavformat/Makefile   |   1 +
 libavformat/tests/fifo_muxer.c | 443 +
 tests/Makefile |   1 +
 tests/fate/fifo-muxer.mak  |  20 ++
 tests/ref/fate/fifo-muxer-tst  |  11 +
 5 files changed, 476 insertions(+)
 create mode 100644 libavformat/tests/fifo_muxer.c
 create mode 100644 tests/fate/fifo-muxer.mak
 create mode 100644 tests/ref/fate/fifo-muxer-tst

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2d2b78c..5d827d31 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -591,6 +591,7 @@ TESTPROGS = seek
\
 url \
 #   async   \
 
+TESTPROGS-$(CONFIG_FIFO_MUXER)  += fifo_muxer
 TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
 TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
 TESTPROGS-$(CONFIG_NETWORK)  += noproxy
diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
new file mode 100644
index 000..d6ce85d
--- /dev/null
+++ b/libavformat/tests/fifo_muxer.c
@@ -0,0 +1,443 @@
+/*
+ * FIFO pseudo-muxer
+ * Copyright (c) 2016 Jan Sebechlebsky
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavutil/opt.h"
+#include "libavutil/time.h"
+#include "libavutil/avassert.h"
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+
+#define MAX_TST_PACKETS 128
+#define SLEEPTIME_50_MS 5
+#define SLEEPTIME_10_MS 1
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+/* This is structure of data sent in packets to
+ * failing muxer */
+typedef struct FailingMuxerPacketData {
+int ret; /* return value of write_packet call*/
+int recover_after;   /* set ret to zero after this number of recovery 
attempts */
+unsigned sleep_time; /* sleep for this long in write_packet to simulate 
long I/O operation */
+} FailingMuxerPacketData;
+
+
+typedef struct FailingMuxerContext {
+AVClass *class;
+int write_header_ret;
+int write_trailer_ret;
+/* If non-zero, summary of processed packets will be printed in deinit */
+uint8_t print_deinit_summary;
+
+int flush_count;
+int pts_written[MAX_TST_PACKETS];
+int pts_written_nr;
+} FailingMuxerContext;
+
+static int failing_write_header(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_header_ret;
+}
+
+static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+int ret = 0;
+if (!pkt) {
+ctx->flush_count++;
+} else {
+FailingMuxerPacketData *data = (FailingMuxerPacketData*) pkt->data;
+
+if (!data->recover_after) {
+data->ret = 0;
+} else {
+data->recover_after--;
+}
+
+ret = data->ret;
+
+if (data->sleep_time) {
+int64_t slept = 0;
+while (slept < data->sleep_time) {
+if (ff_check_interrupt(&avf->interrupt_callback))
+return AVERROR_EXIT;
+av_usleep(SLEEPTIME_10_MS);
+slept += SLEEPTIME_10_MS;
+}
+}
+
+if (!ret) {
+ctx->pts_written[ctx->pts_written_nr++] = pkt->pts;
+av_packet_unref(pkt);
+}
+}
+return ret;
+}
+
+static int failing_write_trailer(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_trailer_ret;
+}
+
+static void failing_deinit(AVFormatContext *avf)
+{
+int i;
+FailingMuxerContext *ctx = avf->priv_data;
+
+if (!ctx->print_deinit_summary)
+return;
+
+printf("flush count: %d\n", ctx->flush_count);
+printf("pts seen nr: %d\n", ctx->pts_written_nr);
+printf("pts seen: ");
+for (i = 0; i < ctx->pts_written_nr; ++i ) {
+printf(i ? ",%d" : "%d", ctx->pts_written[i]);
+}
+printf(

Re: [FFmpeg-devel] [PATCH v4 03/11] avformat/fifo: Add fate test

2016-08-11 Thread Michael Niedermayer
On Thu, Aug 11, 2016 at 10:02:07PM +0200, sebechlebsky...@gmail.com wrote:
> From: Jan Sebechlebsky 
> 
> Signed-off-by: Jan Sebechlebsky 
> ---
>  Changes since the last version of patch:
>  - Fixed make dependencies so the tests are not executed when 
>required components are disabled
> 
>  libavformat/Makefile   |   1 +
>  libavformat/tests/fifo_muxer.c | 443 
> +
>  tests/Makefile |   1 +
>  tests/fate/fifo-muxer.mak  |  20 ++
>  tests/ref/fate/fifo-muxer-tst  |  11 +
>  5 files changed, 476 insertions(+)
>  create mode 100644 libavformat/tests/fifo_muxer.c
>  create mode 100644 tests/fate/fifo-muxer.mak
>  create mode 100644 tests/ref/fate/fifo-muxer-tst
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 2d2b78c..5d827d31 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -591,6 +591,7 @@ TESTPROGS = seek  
>   \
>  url \
>  #   async   \
>  
> +TESTPROGS-$(CONFIG_FIFO_MUXER)  += fifo_muxer
>  TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
>  TESTPROGS-$(CONFIG_MOV_MUXER)+= movenc
>  TESTPROGS-$(CONFIG_NETWORK)  += noproxy
> diff --git a/libavformat/tests/fifo_muxer.c b/libavformat/tests/fifo_muxer.c
> new file mode 100644
> index 000..d6ce85d
> --- /dev/null
> +++ b/libavformat/tests/fifo_muxer.c
> @@ -0,0 +1,443 @@
> +/*
> + * FIFO pseudo-muxer
> + * Copyright (c) 2016 Jan Sebechlebsky
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include 
> +#include "libavutil/opt.h"
> +#include "libavutil/time.h"
> +#include "libavutil/avassert.h"
> +#include "libavformat/avformat.h"
> +#include "libavformat/url.h"
> +
> +#define MAX_TST_PACKETS 128
> +#define SLEEPTIME_50_MS 5
> +#define SLEEPTIME_10_MS 1
> +
> +/* Implementation of mock muxer to simulate real muxer failures */
> +
> +/* This is structure of data sent in packets to
> + * failing muxer */
> +typedef struct FailingMuxerPacketData {
> +int ret; /* return value of write_packet call*/
> +int recover_after;   /* set ret to zero after this number of recovery 
> attempts */
> +unsigned sleep_time; /* sleep for this long in write_packet to simulate 
> long I/O operation */
> +} FailingMuxerPacketData;
> +
> +
> +typedef struct FailingMuxerContext {
> +AVClass *class;
> +int write_header_ret;
> +int write_trailer_ret;
> +/* If non-zero, summary of processed packets will be printed in deinit */

> +uint8_t print_deinit_summary;
[...]
> +#define OFFSET(x) offsetof(FailingMuxerContext, x)
> +static const AVOption options[] = {
> +{"write_header_ret", "write_header() return value", 
> OFFSET(write_header_ret),
> + AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, 
> AV_OPT_FLAG_ENCODING_PARAM},
> +{"write_trailer_ret", "write_trailer() return value", 
> OFFSET(write_trailer_ret),
> + AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, 
> AV_OPT_FLAG_ENCODING_PARAM},

> +{"print_deinit_summary", "print summary when deinitializing muxer", 
> OFFSET(print_deinit_summary),
> + AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},

Types mismatch, and fails on mips-qemu

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

You can kill me, but you cannot change the truth.


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


Re: [FFmpeg-devel] [PATCH] libavformat/http: add support for headers option in listen mode

2016-08-11 Thread Michael Niedermayer
On Thu, Aug 11, 2016 at 11:29:07AM +0200, Moritz Barsnick wrote:
> Instead of silently ignoring the headers option in listen mode, use
> the provided headers.
> 
> Signed-off-by: Moritz Barsnick 
> ---
>  libavformat/http.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

applied

thanks

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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