[FFmpeg-devel] [PATCH] avformat/mux: remove unnecessary autobsf hack

2016-09-22 Thread James Almer
autobsf has been ported to the new bsf API.

Signed-off-by: James Almer 
---
 libavformat/mux.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index bbfc0fc..79fbbfc 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -309,12 +309,6 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
-/* update internal context from codecpar, old bsf api needs this
- * FIXME: remove when autobsf uses new bsf API */
-ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
-if (ret < 0)
-goto fail;
-
 if (!st->time_base.num) {
 /* fall back on the default timebase values */
 if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->sample_rate)
-- 
2.9.1

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


[FFmpeg-devel] [PATCH] avformat/concatdec: don't call open_file when seek position within a file

2016-09-22 Thread raymondzheng1...@gmail.com
Thanks for your suggest, I have modified patch. see below.
---
 libavformat/concatdec.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index b3a430e..5cc239a 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -689,7 +689,7 @@ static int try_seek(AVFormatContext *avf, int stream,
 }
 
 static int real_seek(AVFormatContext *avf, int stream,
- int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
+ int64_t min_ts, int64_t ts, int64_t max_ts, int flags, 
AVFormatContext *cur_avf)
 {
 ConcatContext *cat = avf->priv_data;
 int ret, left, right;
@@ -711,13 +711,19 @@ static int real_seek(AVFormatContext *avf, int stream,
 left  = mid;
 }
 
-if ((ret = open_file(avf, left)) < 0)
-return ret;
+if (cat->cur_file != >files[left]) {
+if ((ret = open_file(avf, left)) < 0)
+return ret;
+} else {
+cat->avf = cur_avf;
+}
 
 ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
 if (ret < 0 &&
 left < cat->nb_files - 1 &&
 cat->files[left + 1].start_time < max_ts) {
+if (cat->cur_file == >files[left])
+cat->avf = NULL;
 if ((ret = open_file(avf, left + 1)) < 0)
 return ret;
 ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
@@ -738,13 +744,17 @@ static int concat_seek(AVFormatContext *avf, int stream,
 if (flags & (AVSEEK_FLAG_BYTE | AVSEEK_FLAG_FRAME))
 return AVERROR(ENOSYS);
 cat->avf = NULL;
-if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags)) < 0) {
-if (cat->avf)
-avformat_close_input(>avf);
+if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags, 
cur_avf_saved)) < 0) {
+if (cat->cur_file != cur_file_saved) {
+if (cat->avf)
+avformat_close_input(>avf);
+}
 cat->avf  = cur_avf_saved;
 cat->cur_file = cur_file_saved;
 } else {
-avformat_close_input(_avf_saved);
+if (cat->cur_file != cur_file_saved) {
+avformat_close_input(_avf_saved);
+}
 cat->eof = 0;
 }
 return ret;
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: avoid using marked decoders for probing

2016-09-22 Thread Michael Niedermayer
On Thu, Sep 22, 2016 at 06:44:09PM +0200, Timo Rothenpieler wrote:
> ---
>  libavformat/utils.c | 19 ++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

should be ok

thx

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

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


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


Re: [FFmpeg-devel] [PATCH 1/5] lavd: Add SDL2 output device

2016-09-22 Thread Michael Niedermayer
On Thu, Sep 22, 2016 at 08:28:47PM +0100, Josh de Kock wrote:
> Acked-by: Michael Niedermayer
> Signed-off-by: Josh de Kock 
> ---
>  Changelog|   1 +
>  configure|  28 +++-
>  libavdevice/Makefile |   1 +
>  libavdevice/alldevices.c |   1 +
>  libavdevice/sdl2.c   | 377 
> +++
>  5 files changed, 407 insertions(+), 1 deletion(-)
>  create mode 100644 libavdevice/sdl2.c

This still breaks cross-build x86_64 -> 32

/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.so when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.a when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.so when 
searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.a when 
searching for -lSDL2
/usr/bin/ld: cannot find -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when 
searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.a when 
searching for -lpthread
collect2: ld returned 1 exit status
make: *** [ffserver_g] Error 1
make: *** Waiting for unfinished jobs
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.so when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.a when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.so when 
searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.a when 
searching for -lSDL2
/usr/bin/ld: cannot find -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when 
searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.a when 
searching for -lpthread
collect2: ld returned 1 exit status
make: *** [ffprobe_g] Error 1
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.so when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.a when 
searching for -ldl
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.so when 
searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libSDL2.a when 
searching for -lSDL2
/usr/bin/ld: cannot find -lSDL2
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when 
searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.a when 
searching for -lpthread
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1

config.h:
!HAVE_SDL=yes
HAVE_SDL2=yes
!CONFIG_SDL=yes
CONFIG_SDL2=yes
!CONFIG_SDL_OUTDEV=yes
CONFIG_SDL2_OUTDEV=yes



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

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


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


Re: [FFmpeg-devel] [PATCH] avfilter: add dynoverlay filter.

2016-09-22 Thread Priebe, Jason
Thanks for the detailed review of the code, Paul.  You caught some dumb
mistakes that I should have picked up on before I sent the submission.

> dynoverlay sounds very powerful, but this filter funcionality is very limited.

True, it is limited, but it does something that no other filter does (I am
interested in your named pipe idea, though -- see note at the end).

> What's up with code identation?

I don't know -- I didn't realize there was a problem.  I'm just using vi; maybe
it formatted stuff in a funny way.  Or maybe you don't like my braces on new
lines?

> > +If the named PNG file does not exist, the filter will do nothing.
> 
> I do not like this design. Supporting only PNG with RGBA, working only
> in YUV420P.

I built the filter to satisfy a specific need; I thought that maybe others
who needed other formats could add in the support for those formats later.
I thought I saw some filters in ffmpeg that only support specific formats,
so I didn't realize that was a problem.

> > +@item check_interval
> > +(optional) The interval (in ms) between checks for updates to the overlay
> > file. For
> > +efficiency, the filter does not check the filesystem on every frame. You
> > can make
> > +it check more frequently (less efficient, but more responsive to changes in
> > the
> > +overlay PNG) by specifying a lower number. Or you can make it check less
> > frequently
> > +(more efficient, but less responsive to changes in the overlay PNG) by
> > specifying
> > +a higher number.
> > +
> > +Default value is @code{250}.
> > +@end table
> 
> This approach is bad to provide such functionality.

Why?  Yes, it's a lot of system calls, but it's still performant, so is 
it fundamentally wrong?

> > + -vf format=pix_fmts=yuv420p \
> > + -vf dynoverlay=overlayfile=/var/tmp/overlay.png:check_interval=100 \
> 
> You can not give more than one -vf's, only one will ever be used.

My mistake - I was trying to take a much more complicated example and distill it
down and anonymize it. 

> > +#include 
> > ... many headers omitted ...
> > +#include "libavutil/lfg.h"
> 
> Are all those headers really needed?

Probably not; I could try to pare it down.

> > + if (ctx->overlay_frame)
> > + {
> > + // TODO - make sure we have freed everything
> > + av_freep(>overlay_frame->data[0]);
> > + }
> > + ctx->overlay_frame = NULL;
> 
> This is wrong.

Thanks for catching this; I should use av_frame_free(), right?

> > + if (ctx->overlay_frame)
> > + {
> 
> Check is not needed.
> 
> > + av_frame_free (>overlay_frame);
> > + }
> > + ctx->overlay_frame = NULL;
> 
> Not needed.

Does this mean that it is safe to call av_frame_free() with NULL ?

> I think much better approach is to use named pipes, probably as
> separate video filter source.

I would love to see an example of this technique.  Based on what I read online
(http://ffmpeg.gusari.org/viewtopic.php?f=11=2774 for example), I didn't
think this technique worked.  And even if it could work, wouldn't I need a 
process
that is constantly generating frame data from PNGs to feed it to ffmpeg, which
then has to read it 30 times a second (when it only changes every 2-3 
*minutes*).

That seems extremely inefficient for overlays that are not changing frequently.

This is why I was trying to read the PNG once, hold it in memory until it 
changes
or is removed.  Maybe it would be more elegant if I wasn't polling the 
filesystem;
I could send signals to ffmpeg instead.  But I don't see a clear advantage to 
that
technique, and there are some disadvantages.  It's extremely simple for an 
external
application to write to a specified file.  But a model based on signalling would
require that the process also know the PID of the ffmpeg process.

I guess my question for you is whether this filter has any value to the larger
community.  If not, I'll just maintain it myself as a patch that I can apply to
my own builds.

Jason Priebe
CBC New Media
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mov: Read aspect ratio from ares atom for dnxhd

2016-09-22 Thread Paul B Mahol
On 9/20/16, Carl Eugen Hoyos  wrote:
> 2016-09-19 14:57 GMT+02:00 Paul B Mahol :
>> On 9/19/16, Paul B Mahol  wrote:
>
>>> Ignore that one above, patck with corrected text is ok.
>>
>> title should mentioned what kind of aspect ratio this is about. As I
>> thought it is about sar.
>
> Log message changed locally to "lavf/mov: Read display
> aspect ratio from ares atom also for dnxhd."

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


Re: [FFmpeg-devel] [PATCH] avfilter: add dynoverlay filter.

2016-09-22 Thread Paul B Mahol
On 9/22/16, Priebe, Jason  wrote:
> This patch adds a new filter that allows you to drive dynamic graphic
> overlays
> on a live encoding by creating/updating/deleting a specified 32-bit PNG.
> This is very different from the overlay filter, because it lets you change
> the overlay in real time during a live stream.  It doesn't allow you to
> overlay
> video on top of video, but you can overlay still images over video, which is
> useful for things like lower-thirds and fullscreen graphics.
>
> It is efficient in its handling of PNG files, as it only decodes the PNG
> data
> when it changes.  It is not optimized in its handling of the compositing,
> since
> it composites the entire image on every frame, even if the majority of the
> overlay is fully transparent.  Even with that caveat, it only takes about
> 2% of overall CPU while compositing 1920x1080 images on HD video on a
> Core i7-6700K.
>
> I'm pretty sure that I'm allocating my frames/buffers correctly and that I'm
> freeing them as expected.  But if I've missed something, please let me know.
>
> I did my best with the FATE test.  I understand the concept of "generate
> video, perform the filter, calculate the MD5 of the output, compare to
> expected MD5".  But I didn't really see how I was supposed to visually
> inspect
> the output video before committing the test.
>
> I modified the fate-run.sh script to output the ffmpeg command it was
> running
> so I could capture the output video and make sure it contained what I
> expected.
> So I think my test is good.
>
> It's a very basic test -- just makes sure it can read the PNG and overlay
> it.
> I don't do anything fancy like remove or update the PNG during the encoding,
> although that would be a more complete test of what the filter is designed
> to do.
>
> The test included requires a PNG overlay image, dynoverlay.png.  It can be
> downloaded from http://imgur.com/a/6PIkT
>
>
>
> ---
> Changelog | 1 +
> doc/filters.texi | 54 ++
> libavfilter/Makefile | 1 +
> libavfilter/allfilters.c | 1 +
> libavfilter/version.h | 2 +-
> libavfilter/vf_dynoverlay.c | 439
> 

dynoverlay sounds very powerful, but this filter funcionality is very limited.

> tests/fate/filter-video.mak | 3 +
> 7 files changed, 500 insertions(+), 1 deletion(-)
> create mode 100644 libavfilter/vf_dynoverlay.c
>

What's up with code identation?

> diff --git a/Changelog b/Changelog
> index 2d0a449..5b620b4 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -31,6 +31,7 @@ version :
> - MediaCodec HEVC decoding
> - TrueHD encoder
> - Meridian Lossless Packing (MLP) encoder
> +- dynoverlay filter
> version 3.1:
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 070e57d..e67e29a 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -7080,6 +7080,60 @@ For more information about fontconfig, check:
> For more information about libfribidi, check:
> @url{http://fribidi.org/}.
> +@section dynoverlay
> +
> +Uses a PNG with alpha to dynamically add, update, and remove overlays
> +during live streams.
> +
> +If the named PNG file does not exist, the filter will do nothing.

I do not like this design. Supporting only PNG with RGBA, working only
in YUV420P.


> +
> +When the filter first detects the presence of the PNG, it will load it
> +into a memory and overlay it on all frames until the PNG is either
> +updated or removed. If the PNG is updated, the filter will read it into
> +memory again. If the PNG is removed, the filter will clear the memory
> +and stop overlaying the image.
> +
> +Note that this filter only works with YUV420P video.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item overlayfile
> +(required) The name of the PNG that will contain the overlays. Note that
> the file
> +may or may not exist when ffmpeg is launched. It can be created, updated,
> +and removed from the filesystem, and the filter will respond accordingly.
> +
> +@item check_interval
> +(optional) The interval (in ms) between checks for updates to the overlay
> file. For
> +efficiency, the filter does not check the filesystem on every frame. You
> can make
> +it check more frequently (less efficient, but more responsive to changes in
> the
> +overlay PNG) by specifying a lower number. Or you can make it check less
> frequently
> +(more efficient, but less responsive to changes in the overlay PNG) by
> specifying
> +a higher number.
> +
> +Default value is @code{250}.
> +@end table

This approach is bad to provide such functionality.

> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Add an overlay to video captured from a DeckLink Mini card; check for
> updates to
> +the overlay PNG every 100ms
> +@example
> +ffmpeg -probesize 1k -r 3/1001 \
> + -f decklink -i 'DeckLink Mini Recorder (1)@@11' -y \
> + -vf format=pix_fmts=yuv420p \
> + -vf dynoverlay=overlayfile=/var/tmp/overlay.png:check_interval=100 \

You can not give more than one 

[FFmpeg-devel] [PATCH] avformat/matroskadec: retain error codes in matroska_resync() and matroska_read_packet()

2016-09-22 Thread Sophia Wang
Signed-off-by: Sophia Wang 
---
 libavformat/matroskadec.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 77b8a5d..936690d 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -738,13 +738,16 @@ static int matroska_read_close(AVFormatContext *s);
 static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
 {
 AVIOContext *pb = matroska->ctx->pb;
+int64_t ret;
 uint32_t id;
 matroska->current_id = 0;
 matroska->num_levels = 0;
 
 /* seek to next position to resync from */
-if (avio_seek(pb, last_pos + 1, SEEK_SET) < 0)
-goto eof;
+if ((ret = avio_seek(pb, last_pos + 1, SEEK_SET)) < 0) {
+matroska->done = 1;
+return ret;
+}
 
 id = avio_rb32(pb);
 
@@ -760,7 +763,6 @@ static int matroska_resync(MatroskaDemuxContext *matroska, 
int64_t last_pos)
 id = (id << 8) | avio_r8(pb);
 }
 
-eof:
 matroska->done = 1;
 return AVERROR_EOF;
 }
@@ -3317,13 +3319,14 @@ static int matroska_parse_cluster(MatroskaDemuxContext 
*matroska)
 static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 MatroskaDemuxContext *matroska = s->priv_data;
+int ret = 0;
 
 while (matroska_deliver_packet(matroska, pkt)) {
 int64_t pos = avio_tell(matroska->ctx->pb);
 if (matroska->done)
-return AVERROR_EOF;
+return (ret < 0) ? ret : AVERROR_EOF;
 if (matroska_parse_cluster(matroska) < 0)
-matroska_resync(matroska, pos);
+ret = matroska_resync(matroska, pos);
 }
 
 return 0;
-- 
2.8.0.rc3.226.g39d4020

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


[FFmpeg-devel] [PATCH 4/5] ffplay: add SDL2 support

2016-09-22 Thread Josh de Kock
From: Marton Balint 

This commit also drops SDL1 support for ffplay.

Tested-by: James Almer  (Windows, mingw-w64)
Signed-off-by: Josh de Kock 
---
 Changelog |   1 +
 configure |   6 +-
 ffplay.c  | 594 ++
 3 files changed, 250 insertions(+), 351 deletions(-)

diff --git a/Changelog b/Changelog
index 5d9141b..32278f0 100644
--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,7 @@ version :
 - TrueHD encoder
 - Meridian Lossless Packing (MLP) encoder
 - sdl2 output device
+- sdl2 support for ffplay
 
 
 version 3.1:
diff --git a/configure b/configure
index 2cae151..be9dee8 100755
--- a/configure
+++ b/configure
@@ -3141,8 +3141,8 @@ ffmpeg_deps="avcodec avfilter avformat swresample"
 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
null_filter
setpts_filter trim_filter"
-ffplay_deps="avcodec avformat swscale swresample sdl"
-ffplay_libs='$sdl_libs'
+ffplay_deps="avcodec avformat swscale swresample sdl2"
+ffplay_libs='$sdl2_libs'
 ffplay_select="rdft crop_filter transpose_filter hflip_filter vflip_filter 
rotate_filter"
 ffprobe_deps="avcodec avformat"
 ffserver_deps="avformat fork sarestart"
@@ -6668,7 +6668,7 @@ HOSTLD_O=$HOSTLD_O
 TARGET_EXEC=$target_exec $target_exec_args
 TARGET_PATH=$target_path
 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
-CFLAGS-ffplay=$sdl_cflags
+CFLAGS-ffplay=${sdl2_cflags}
 ZLIB=$($ldflags_filter -lz)
 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
 EXTRALIBS=$extralibs
diff --git a/ffplay.c b/ffplay.c
index adbe9cb..e64909a 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -105,6 +105,8 @@ const int program_birth_year = 2003;
 
 #define CURSOR_HIDE_DELAY 100
 
+#define USE_ONEPASS_SUBTITLE_RENDER 1
+
 static unsigned sws_flags = SWS_BICUBIC;
 
 typedef struct MyAVPacketList {
@@ -152,17 +154,17 @@ typedef struct Clock {
 typedef struct Frame {
 AVFrame *frame;
 AVSubtitle sub;
-AVSubtitleRect **subrects;  /* rescaled subtitle rectangles in yuva */
 int serial;
 double pts;   /* presentation timestamp for the frame */
 double duration;  /* estimated duration of the frame */
 int64_t pos;  /* byte position of the frame in the input file */
-SDL_Overlay *bmp;
+SDL_Texture *bmp;
 int allocated;
-int reallocate;
 int width;
 int height;
+int format;
 AVRational sar;
+int uploaded;
 } Frame;
 
 typedef struct FrameQueue {
@@ -272,6 +274,8 @@ typedef struct VideoState {
 FFTSample *rdft_data;
 int xpos;
 double last_vis_time;
+SDL_Texture *vis_texture;
+SDL_Texture *sub_texture;
 
 int subtitle_stream;
 AVStream *subtitle_st;
@@ -284,11 +288,8 @@ typedef struct VideoState {
 AVStream *video_st;
 PacketQueue videoq;
 double max_frame_duration;  // maximum duration of a frame - above 
this, we consider the jump a timestamp discontinuity
-#if !CONFIG_AVFILTER
 struct SwsContext *img_convert_ctx;
-#endif
 struct SwsContext *sub_convert_ctx;
-SDL_Rect last_display_rect;
 int eof;
 
 char *filename;
@@ -313,8 +314,6 @@ typedef struct VideoState {
 static AVInputFormat *file_iformat;
 static const char *input_filename;
 static const char *window_title;
-static int fs_screen_width;
-static int fs_screen_height;
 static int default_width  = 640;
 static int default_height = 480;
 static int screen_width  = 0;
@@ -362,7 +361,8 @@ static AVPacket flush_pkt;
 #define FF_ALLOC_EVENT   (SDL_USEREVENT)
 #define FF_QUIT_EVENT(SDL_USEREVENT + 2)
 
-static SDL_Surface *screen;
+static SDL_Window *window;
+static SDL_Renderer *renderer;
 
 #if CONFIG_AVFILTER
 static int opt_add_vfilter(void *optctx, const char *opt, const char *arg)
@@ -650,12 +650,6 @@ static void decoder_destroy(Decoder *d) {
 
 static void frame_queue_unref_item(Frame *vp)
 {
-int i;
-for (i = 0; i < vp->sub.num_rects; i++) {
-av_freep(>subrects[i]->data[0]);
-av_freep(>subrects[i]);
-}
-av_freep(>subrects);
 av_frame_unref(vp->frame);
 avsubtitle_free(>sub);
 }
@@ -798,113 +792,47 @@ static void decoder_abort(Decoder *d, FrameQueue *fq)
 packet_queue_flush(d->queue);
 }
 
-static inline void fill_rectangle(SDL_Surface *screen,
-  int x, int y, int w, int h, int color, int 
update)
+static inline void fill_rectangle(int x, int y, int w, int h)
 {
 SDL_Rect rect;
 rect.x = x;
 rect.y = y;
 rect.w = w;
 rect.h = h;
-SDL_FillRect(screen, , color);
-if (update && w > 0 && h > 0)
-SDL_UpdateRect(screen, x, y, w, h);
-}
-
-/* draw only the border of a rectangle */
-static void fill_border(int xleft, int ytop, int width, int height, int x, int 
y, int w, int h, int color, int update)
-{
-int w1, w2, h1, h2;
-
-/* fill the background */
-w1 = x;
-if (w1 < 0)
-w1 = 0;
-w2 = width - (x + w);
-if (w2 

[FFmpeg-devel] [PATCH 2/5] MAINTAINERS: update my entries

2016-09-22 Thread Josh de Kock
Acked-by: Michael Niedermayer 
Signed-off-by: Josh de Kock 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index f1f991d..d1e487a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -285,6 +285,7 @@ libavdevice
   pulse_audio_enc.c Lukasz Marek
   qtkit.m   Thilo Borgmann
   sdl   Stefano Sabatini
+  sdl2.cJosh de Kock
   v4l2.cGiorgio Vazzana
   vfwcap.c  Ramiro Polla
   xv.c  Lukasz Marek
-- 
2.8.4 (Apple Git-73)

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


[FFmpeg-devel] [PATCH 0/5] Add SDL2 support & drop SDL1 support

2016-09-22 Thread Josh de Kock
Hopefully the final iteration of this set--it drops SDL1 support
entirely rather than adding another ffplay version and keeping the
SDL1 output device. All of it has been reviewed before, so there
shouldn't be too much (or anything to change).

Josh de Kock (3):
  lavd: Add SDL2 output device
  MAINTAINERS: update my entries
  lavd: drop SDL1 device & drop SDL1 support in general

Lukasz Marek (1):
  lavd/opengl: use SDL2

Marton Balint (1):
  ffplay: add SDL2 support

 Changelog|   4 +
 MAINTAINERS  |   1 +
 configure|  51 ++--
 ffplay.c | 594 ---
 libavdevice/Makefile |   2 +-
 libavdevice/alldevices.c |   2 +-
 libavdevice/opengl_enc.c | 109 -
 libavdevice/sdl.c| 377 --
 libavdevice/sdl2.c   | 377 ++
 9 files changed, 702 insertions(+), 815 deletions(-)
 delete mode 100644 libavdevice/sdl.c
 create mode 100644 libavdevice/sdl2.c

-- 
2.8.4 (Apple Git-73)

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


[FFmpeg-devel] [PATCH 3/5] lavd/opengl: use SDL2

2016-09-22 Thread Josh de Kock
From: Lukasz Marek 

Signed-off-by: Lukasz Marek 
Signed-off-by: Josh de Kock 
---
 libavdevice/opengl_enc.c | 109 +--
 1 file changed, 49 insertions(+), 60 deletions(-)

diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index 1dbbb80..94259a2 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -46,7 +46,7 @@
 #include 
 #endif
 
-#if HAVE_SDL
+#if HAVE_SDL2
 #include 
 #endif
 
@@ -174,8 +174,9 @@ static const GLushort g_index[6] =
 typedef struct OpenGLContext {
 AVClass *class;///< class for private options
 
-#if HAVE_SDL
-SDL_Surface *surface;
+#if HAVE_SDL2
+SDL_Window *window;
+SDL_GLContext glcontext;
 #endif
 FFOpenGLFunctions glprocs;
 
@@ -341,30 +342,14 @@ static int opengl_control_message(AVFormatContext *h, int 
type, void *data, size
 return AVERROR(ENOSYS);
 }
 
-#if HAVE_SDL
-static int opengl_sdl_recreate_window(OpenGLContext *opengl, int width, int 
height)
-{
-opengl->surface = SDL_SetVideoMode(width, height,
-   32, SDL_OPENGL | SDL_RESIZABLE);
-if (!opengl->surface) {
-av_log(opengl, AV_LOG_ERROR, "Unable to set video mode: %s\n", 
SDL_GetError());
-return AVERROR_EXTERNAL;
-}
-SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
-SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
-SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
-SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-return 0;
-}
-
+#if HAVE_SDL2
 static int opengl_sdl_process_events(AVFormatContext *h)
 {
-int ret;
 OpenGLContext *opengl = h->priv_data;
+AVDeviceRect message;
 SDL_Event event;
 SDL_PumpEvents();
-while (SDL_PeepEvents(, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0) {
+while (SDL_PeepEvents(, 1, SDL_GETEVENT, SDL_FIRSTEVENT, 
SDL_LASTEVENT) > 0) {
 switch (event.type) {
 case SDL_QUIT:
 return AVERROR(EIO);
@@ -375,23 +360,14 @@ static int opengl_sdl_process_events(AVFormatContext *h)
 return AVERROR(EIO);
 }
 return 0;
-case SDL_VIDEORESIZE: {
-char buffer[100];
-int reinit;
-AVDeviceRect message;
-/* clean up old context because SDL_SetVideoMode may lose its 
state. */
-SDL_VideoDriverName(buffer, sizeof(buffer));
-reinit = !av_strncasecmp(buffer, "quartz", sizeof(buffer));
-if (reinit) {
-opengl_deinit_context(opengl);
-}
-if ((ret = opengl_sdl_recreate_window(opengl, event.resize.w, 
event.resize.h)) < 0)
-return ret;
-if (reinit && (ret = opengl_init_context(opengl)) < 0)
-return ret;
-message.width = opengl->surface->w;
-message.height = opengl->surface->h;
-return opengl_control_message(h, AV_APP_TO_DEV_WINDOW_SIZE, 
, sizeof(AVDeviceRect));
+case SDL_WINDOWEVENT:
+switch(event.window.event) {
+case SDL_WINDOWEVENT_RESIZED:
+case SDL_WINDOWEVENT_SIZE_CHANGED:
+SDL_GL_GetDrawableSize(opengl->window, , 
);
+return opengl_control_message(h, AV_APP_TO_DEV_WINDOW_SIZE, 
, sizeof(AVDeviceRect));
+default:
+break;
 }
 }
 }
@@ -400,23 +376,34 @@ static int opengl_sdl_process_events(AVFormatContext *h)
 
 static int av_cold opengl_sdl_create_window(AVFormatContext *h)
 {
-int ret;
-char buffer[100];
 OpenGLContext *opengl = h->priv_data;
 AVDeviceRect message;
 if (SDL_Init(SDL_INIT_VIDEO)) {
 av_log(opengl, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", 
SDL_GetError());
 return AVERROR_EXTERNAL;
 }
-if ((ret = opengl_sdl_recreate_window(opengl, opengl->window_width,
-  opengl->window_height)) < 0)
-return ret;
-av_log(opengl, AV_LOG_INFO, "SDL driver: '%s'.\n", 
SDL_VideoDriverName(buffer, sizeof(buffer)));
-message.width = opengl->surface->w;
-message.height = opengl->surface->h;
-SDL_WM_SetCaption(opengl->window_title, NULL);
-opengl_control_message(h, AV_APP_TO_DEV_WINDOW_SIZE, , 
sizeof(AVDeviceRect));
-return 0;
+opengl->window = SDL_CreateWindow(opengl->window_title,
+  SDL_WINDOWPOS_UNDEFINED,
+  SDL_WINDOWPOS_UNDEFINED,
+  opengl->window_width, 
opengl->window_height,
+  SDL_WINDOW_RESIZABLE | 
SDL_WINDOW_OPENGL);
+if (!opengl->window) {
+av_log(opengl, AV_LOG_ERROR, "Unable to create default window: %s\n", 
SDL_GetError());
+return AVERROR_EXTERNAL;
+}
+opengl->glcontext = 

[FFmpeg-devel] [PATCH 5/5] lavd: drop SDL1 device & drop SDL1 support in general

2016-09-22 Thread Josh de Kock
Signed-off-by: Josh de Kock 
---
 Changelog|   2 +
 configure|  33 +
 libavdevice/Makefile |   1 -
 libavdevice/alldevices.c |   1 -
 libavdevice/sdl.c| 377 ---
 5 files changed, 3 insertions(+), 411 deletions(-)
 delete mode 100644 libavdevice/sdl.c

diff --git a/Changelog b/Changelog
index 32278f0..2652cd5 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,8 @@ version :
 - Meridian Lossless Packing (MLP) encoder
 - sdl2 output device
 - sdl2 support for ffplay
+- sdl1 output device removed
+- sdl1 support removed
 
 
 version 3.1:
diff --git a/configure b/configure
index be9dee8..75d91d0 100755
--- a/configure
+++ b/configure
@@ -291,7 +291,6 @@ External library support:
if gnutls is not used [no]
   --disable-schannel   disable SChannel SSP, needed for TLS support on
Windows if openssl and gnutls are not used 
[autodetect]
-  --disable-sdldisable sdl [autodetect]
   --disable-sdl2   disable sdl2 [autodetect]
   --disable-securetransport disable Secure Transport, needed for TLS support
on OSX if openssl and gnutls are not used 
[autodetect]
@@ -1548,7 +1547,6 @@ EXTERNAL_LIBRARY_LIST="
 opengl
 openssl
 schannel
-sdl
 sdl2
 securetransport
 videotoolbox
@@ -2023,7 +2021,6 @@ HAVE_LIST="
 MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
 perl
 pod2man
-sdl
 sdl2
 section_data_rel_ro
 texi2html
@@ -2950,7 +2947,6 @@ pulse_indev_deps="libpulse"
 pulse_outdev_deps="libpulse"
 qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework 
QuartzCore"
 qtkit_indev_select="qtkit"
-sdl_outdev_deps="sdl"
 sdl2_outdev_deps="sdl2"
 sndio_indev_deps="sndio_h"
 sndio_outdev_deps="sndio_h"
@@ -5857,7 +5853,7 @@ if enabled gcrypt; then
 fi
 fi
 
-if ! disabled sdl2 && ! enabled sdl; then
+if ! disabled sdl2; then
 SDL2_CONFIG="${cross_prefix}sdl2-config"
 if check_pkg_config sdl2 SDL_events.h SDL_PollEvent; then
 check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
@@ -5878,32 +5874,6 @@ if ! disabled sdl2 && ! enabled sdl; then
 fi
 enabled sdl2 && add_cflags $sdl2_cflags && add_extralibs $sdl2_libs
 
-if ! disabled sdl && ! enabled sdl2; then
-SDL_CONFIG="${cross_prefix}sdl-config"
-if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
-check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
-check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
-enable sdl
-else
-if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
-sdl_cflags=$("${SDL_CONFIG}" --cflags)
-sdl_libs=$("${SDL_CONFIG}" --libs)
-check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags 
$sdl_libs &&
-check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
-check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
-enable sdl
-elif enabled sdl ; then
-die "ERROR: SDL not found"
-else
-disable sdl
-fi
-fi
-if test $target_os = "mingw32"; then
-sdl_libs="$sdl_libs -mconsole"
-fi
-fi
-enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
-
 disabled securetransport || { check_func SecIdentityCreate 
"-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
 check_lib2 "Security/SecureTransport.h Security/Security.h" 
"SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation 
-Wl,-framework,Security" &&
 enable securetransport; }
@@ -6507,7 +6477,6 @@ echo "new filter support${avfilter-no}"
 echo "network support   ${network-no}"
 echo "threading support ${thread_type-no}"
 echo "safe bitstream reader ${safe_bitstream_reader-no}"
-echo "SDL support   ${sdl-no}"
 echo "SDL2 support  ${sdl2-no}"
 echo "opencl enabled${opencl-no}"
 echo "JNI support   ${jni-no}"
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 1c4b4d3..256e140 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -40,7 +40,6 @@ OBJS-$(CONFIG_PULSE_INDEV)   += pulse_audio_dec.o 
\
 OBJS-$(CONFIG_PULSE_OUTDEV)  += pulse_audio_enc.o \
 pulse_audio_common.o
 OBJS-$(CONFIG_QTKIT_INDEV)   += qtkit.o
-OBJS-$(CONFIG_SDL_OUTDEV)+= sdl.o
 OBJS-$(CONFIG_SDL2_OUTDEV)   += sdl2.o
 OBJS-$(CONFIG_SNDIO_INDEV)   += sndio_dec.o sndio.o
 OBJS-$(CONFIG_SNDIO_OUTDEV)

[FFmpeg-devel] [PATCH 1/5] lavd: Add SDL2 output device

2016-09-22 Thread Josh de Kock
Acked-by: Michael Niedermayer
Signed-off-by: Josh de Kock 
---
 Changelog|   1 +
 configure|  28 +++-
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/sdl2.c   | 377 +++
 5 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 libavdevice/sdl2.c

diff --git a/Changelog b/Changelog
index 2d0a449..5d9141b 100644
--- a/Changelog
+++ b/Changelog
@@ -31,6 +31,7 @@ version :
 - MediaCodec HEVC decoding
 - TrueHD encoder
 - Meridian Lossless Packing (MLP) encoder
+- sdl2 output device
 
 
 version 3.1:
diff --git a/configure b/configure
index af3fbf4..2cae151 100755
--- a/configure
+++ b/configure
@@ -292,6 +292,7 @@ External library support:
   --disable-schannel   disable SChannel SSP, needed for TLS support on
Windows if openssl and gnutls are not used 
[autodetect]
   --disable-sdldisable sdl [autodetect]
+  --disable-sdl2   disable sdl2 [autodetect]
   --disable-securetransport disable Secure Transport, needed for TLS support
on OSX if openssl and gnutls are not used 
[autodetect]
   --enable-x11grab enable X11 grabbing (legacy) [no]
@@ -1548,6 +1549,7 @@ EXTERNAL_LIBRARY_LIST="
 openssl
 schannel
 sdl
+sdl2
 securetransport
 videotoolbox
 x11grab
@@ -2022,6 +2024,7 @@ HAVE_LIST="
 perl
 pod2man
 sdl
+sdl2
 section_data_rel_ro
 texi2html
 threads
@@ -2948,6 +2951,7 @@ pulse_outdev_deps="libpulse"
 qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework 
QuartzCore"
 qtkit_indev_select="qtkit"
 sdl_outdev_deps="sdl"
+sdl2_outdev_deps="sdl2"
 sndio_indev_deps="sndio_h"
 sndio_outdev_deps="sndio_h"
 v4l_indev_deps="linux_videodev_h"
@@ -5853,7 +5857,28 @@ if enabled gcrypt; then
 fi
 fi
 
-if ! disabled sdl; then
+if ! disabled sdl2 && ! enabled sdl; then
+SDL2_CONFIG="${cross_prefix}sdl2-config"
+if check_pkg_config sdl2 SDL_events.h SDL_PollEvent; then
+check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
+check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags &&
+enable sdl2
+else
+  if "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
+sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
+sdl2_libs=$("${SDL2_CONFIG}" --libs)
+check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
+check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags &&
+enable sdl2
+  fi
+fi
+if test $target_os = "mingw32"; then
+sdl2_libs="$sdl2_libs -mconsole"
+fi
+fi
+enabled sdl2 && add_cflags $sdl2_cflags && add_extralibs $sdl2_libs
+
+if ! disabled sdl && ! enabled sdl2; then
 SDL_CONFIG="${cross_prefix}sdl-config"
 if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
 check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
@@ -6483,6 +6508,7 @@ echo "network support   ${network-no}"
 echo "threading support ${thread_type-no}"
 echo "safe bitstream reader ${safe_bitstream_reader-no}"
 echo "SDL support   ${sdl-no}"
+echo "SDL2 support  ${sdl2-no}"
 echo "opencl enabled${opencl-no}"
 echo "JNI support   ${jni-no}"
 echo "texi2html enabled ${texi2html-no}"
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 585827b..1c4b4d3 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -41,6 +41,7 @@ OBJS-$(CONFIG_PULSE_OUTDEV)  += pulse_audio_enc.o 
\
 pulse_audio_common.o
 OBJS-$(CONFIG_QTKIT_INDEV)   += qtkit.o
 OBJS-$(CONFIG_SDL_OUTDEV)+= sdl.o
+OBJS-$(CONFIG_SDL2_OUTDEV)   += sdl2.o
 OBJS-$(CONFIG_SNDIO_INDEV)   += sndio_dec.o sndio.o
 OBJS-$(CONFIG_SNDIO_OUTDEV)  += sndio_enc.o sndio.o
 OBJS-$(CONFIG_V4L2_INDEV)+= v4l2.o v4l2-common.o timefilter.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 26aecf2..c0a9d9a 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -64,6 +64,7 @@ void avdevice_register_all(void)
 REGISTER_INOUTDEV(PULSE,pulse);
 REGISTER_INDEV   (QTKIT,qtkit);
 REGISTER_OUTDEV  (SDL,  sdl);
+REGISTER_OUTDEV  (SDL2, sdl2);
 REGISTER_INOUTDEV(SNDIO,sndio);
 REGISTER_INOUTDEV(V4L2, v4l2);
 //REGISTER_INDEV   (V4L,  v4l
diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c
new file mode 100644
index 000..bce3c00

[FFmpeg-devel] [PATCH] avfilter: add dynoverlay filter.

2016-09-22 Thread Priebe, Jason
This patch adds a new filter that allows you to drive dynamic graphic overlays
on a live encoding by creating/updating/deleting a specified 32-bit PNG.
This is very different from the overlay filter, because it lets you change
the overlay in real time during a live stream.  It doesn't allow you to overlay
video on top of video, but you can overlay still images over video, which is
useful for things like lower-thirds and fullscreen graphics.

It is efficient in its handling of PNG files, as it only decodes the PNG data
when it changes.  It is not optimized in its handling of the compositing, since
it composites the entire image on every frame, even if the majority of the
overlay is fully transparent.  Even with that caveat, it only takes about
2% of overall CPU while compositing 1920x1080 images on HD video on a 
Core i7-6700K.

I'm pretty sure that I'm allocating my frames/buffers correctly and that I'm
freeing them as expected.  But if I've missed something, please let me know.

I did my best with the FATE test.  I understand the concept of "generate 
video, perform the filter, calculate the MD5 of the output, compare to
expected MD5".  But I didn't really see how I was supposed to visually inspect
the output video before committing the test.  

I modified the fate-run.sh script to output the ffmpeg command it was running
so I could capture the output video and make sure it contained what I expected.
So I think my test is good.  

It's a very basic test -- just makes sure it can read the PNG and overlay it.
I don't do anything fancy like remove or update the PNG during the encoding,
although that would be a more complete test of what the filter is designed to 
do.

The test included requires a PNG overlay image, dynoverlay.png.  It can be
downloaded from http://imgur.com/a/6PIkT



---
Changelog | 1 +
doc/filters.texi | 54 ++
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/version.h | 2 +-
libavfilter/vf_dynoverlay.c | 439 
tests/fate/filter-video.mak | 3 +
7 files changed, 500 insertions(+), 1 deletion(-)
create mode 100644 libavfilter/vf_dynoverlay.c

diff --git a/Changelog b/Changelog
index 2d0a449..5b620b4 100644
--- a/Changelog
+++ b/Changelog
@@ -31,6 +31,7 @@ version :
- MediaCodec HEVC decoding
- TrueHD encoder
- Meridian Lossless Packing (MLP) encoder
+- dynoverlay filter
version 3.1:
diff --git a/doc/filters.texi b/doc/filters.texi
index 070e57d..e67e29a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7080,6 +7080,60 @@ For more information about fontconfig, check:
For more information about libfribidi, check:
@url{http://fribidi.org/}.
+@section dynoverlay
+
+Uses a PNG with alpha to dynamically add, update, and remove overlays
+during live streams.
+
+If the named PNG file does not exist, the filter will do nothing.
+
+When the filter first detects the presence of the PNG, it will load it
+into a memory and overlay it on all frames until the PNG is either
+updated or removed. If the PNG is updated, the filter will read it into
+memory again. If the PNG is removed, the filter will clear the memory
+and stop overlaying the image.
+
+Note that this filter only works with YUV420P video.
+
+The filter accepts the following options:
+
+@table @option
+@item overlayfile
+(required) The name of the PNG that will contain the overlays. Note that the 
file
+may or may not exist when ffmpeg is launched. It can be created, updated,
+and removed from the filesystem, and the filter will respond accordingly.
+
+@item check_interval
+(optional) The interval (in ms) between checks for updates to the overlay 
file. For
+efficiency, the filter does not check the filesystem on every frame. You can 
make
+it check more frequently (less efficient, but more responsive to changes in the
+overlay PNG) by specifying a lower number. Or you can make it check less 
frequently
+(more efficient, but less responsive to changes in the overlay PNG) by 
specifying
+a higher number.
+
+Default value is @code{250}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Add an overlay to video captured from a DeckLink Mini card; check for updates 
to
+the overlay PNG every 100ms
+@example
+ffmpeg -probesize 1k -r 3/1001 \
+ -f decklink -i 'DeckLink Mini Recorder (1)@@11' -y \
+ -vf format=pix_fmts=yuv420p \
+ -vf dynoverlay=overlayfile=/var/tmp/overlay.png:check_interval=100 \
+ -pix_fmt yuv420p \
+ -s 960x540 \
+ -c:v libx264 -profile:v baseline \
+ -b:v 1024k \
+ -c:a aac -ac 2 -b:a 192k -ar 44100 \
+ -f flv -flags +global_header 'rtmp://streaming.example.com/appname/streamname'
+@end example
+@end itemize
+
@section edgedetect
Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 5cd10fa..80a485c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -164,6 +164,7 @@ OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o
OBJS-$(CONFIG_DRAWGRAPH_FILTER) += 

Re: [FFmpeg-devel] [PATCH 6/6] ffprobe.c: Indicate decode-but-discard packets when doing -show_packets.

2016-09-22 Thread Sasi Inguva
ping

On Thu, Sep 15, 2016 at 1:36 PM, Sasi Inguva  wrote:

> Signed-off-by: Sasi Inguva 
> ---
>  ffprobe.c  |   3 +-
>  tests/ref/fate/concat-demuxer-extended-lavf-mxf|   2 +-
>  .../ref/fate/concat-demuxer-extended-lavf-mxf_d10  |   2 +-
>  tests/ref/fate/concat-demuxer-simple1-lavf-mxf | 242
> -
>  tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 | 140 +-
>  tests/ref/fate/concat-demuxer-simple2-lavf-ts  | 298
> ++---
>  tests/ref/fate/ffprobe_compact |  28 +-
>  tests/ref/fate/ffprobe_csv |  28 +-
>  tests/ref/fate/ffprobe_default |  28 +-
>  tests/ref/fate/ffprobe_flat|  28 +-
>  tests/ref/fate/ffprobe_ini |  28 +-
>  tests/ref/fate/ffprobe_json|  28 +-
>  tests/ref/fate/ffprobe_xml |  28 +-
>  13 files changed, 442 insertions(+), 441 deletions(-)
>
> diff --git a/ffprobe.c b/ffprobe.c
> index 657867d..e64c66e 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -1815,7 +1815,8 @@ static void show_packet(WriterContext *w, InputFile
> *ifile, AVPacket *pkt, int p
>  print_val("size", pkt->size, unit_byte_str);
>  if (pkt->pos != -1) print_fmt("pos", "%"PRId64, pkt->pos);
>  elseprint_str_opt("pos", "N/A");
> -print_fmt("flags", "%c",  pkt->flags & AV_PKT_FLAG_KEY ? 'K' :
> '_');
> +print_fmt("flags", "%c%c",  pkt->flags & AV_PKT_FLAG_KEY ? 'K' :
> '_',
> +  pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_');
>
>  if (pkt->side_data_elems) {
>  int size;
> diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
> b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
> index b894938..f7905aa 100644
> --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
> +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
> @@ -1 +1 @@
> -0aa1ca6ff6e2e5aa926454d22fdaecd5 *tests/data/fate/concat-
> demuxer-extended-lavf-mxf.ffprobe
> +21eb3a629ff504b55c93a66879a31362 *tests/data/fate/concat-
> demuxer-extended-lavf-mxf.ffprobe
> diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
> b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
> index b378a2d..0c49f1f 100644
> --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
> +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
> @@ -1 +1 @@
> -14c2b8d8f82f261c9627b33c481c0e8c *tests/data/fate/concat-
> demuxer-extended-lavf-mxf_d10.ffprobe
> +67a03ad49f1bd17131f751313639b61e *tests/data/fate/concat-
> demuxer-extended-lavf-mxf_d10.ffprobe
> diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
> b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
> index 3fc7957..6bba76a 100644
> --- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
> +++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
> @@ -1,124 +1,124 @@
> -video|0|0|0.00|-1|-0.04|1|0.04|N/A|N/A|24801|6144|K
> -audio|1|0|0.00|0|0.00|1920|0.04|N/A|N/A|3840|31232|K
> -video|0|3|0.12|0|0.00|1|0.04|N/A|N/A|16743|35840|_
> -audio|1|1920|0.04|1920|0.04|1920|0.04|N/A|N/A|3840|52736|K
> -video|0|1|0.04|1|0.04|1|0.04|N/A|N/A|13812|57344|_
> -audio|1|3840|0.08|3840|0.08|1920|0.04|N/A|N/A|3840|71680|K
> -video|0|2|0.08|2|0.08|1|0.04|N/A|N/A|13607|76288|_
> -audio|1|5760|0.12|5760|0.12|1920|0.04|N/A|N/A|3840|90112|K
> -video|0|6|0.24|3|0.12|1|0.04|N/A|N/A|16158|94720|_
> -audio|1|7680|0.16|7680|0.16|1920|0.04|N/A|N/A|3840|04|K
> -video|0|4|0.16|4|0.16|1|0.04|N/A|N/A|13943|115712|_
> -audio|1|9600|0.20|9600|0.20|1920|0.04|N/A|N/A|3840|130048|K
> -video|0|5|0.20|5|0.20|1|0.04|N/A|N/A|11223|134656|_
> -audio|1|11520|0.24|11520|0.24|1920|0.04|N/A|N/A|3840|145920|K
> -video|0|9|0.36|6|0.24|1|0.04|N/A|N/A|20298|150528|_
> -audio|1|13440|0.28|13440|0.28|1920|0.04|N/A|N/A|3840|171008|K
> -video|0|7|0.28|7|0.28|1|0.04|N/A|N/A|13341|175616|_
> -audio|1|15360|0.32|15360|0.32|1920|0.04|N/A|N/A|3840|189440|K
> -video|0|8|0.32|8|0.32|1|0.04|N/A|N/A|12362|194048|_
> -audio|1|17280|0.36|17280|0.36|1920|0.04|N/A|N/A|3840|206848|K
> -video|0|12|0.48|9|0.36|1|0.04|N/A|N/A|24786|211456|K
> -audio|1|19200|0.40|19200|0.40|1920|0.04|N/A|N/A|3840|236544|K
> -video|0|10|0.40|10|0.40|1|0.04|N/A|N/A|13377|241152|_
> -audio|1|21120|0.44|21120|0.44|1920|0.04|N/A|N/A|3840|254976|K
> -video|0|11|0.44|11|0.44|1|0.04|N/A|N/A|15624|259584|_
> -audio|1|23040|0.48|23040|0.48|1920|0.04|N/A|N/A|3840|275456|K
> -video|0|15|0.60|12|0.48|1|0.04|N/A|N/A|22597|280064|_
> -audio|1|24960|0.52|24960|0.52|1920|0.04|N/A|N/A|3840|303104|K
> 

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list. Fixes gapless decoding.

2016-09-22 Thread Sasi Inguva
On Thu, Sep 22, 2016 at 5:49 AM, wm4  wrote:

> On Tue, 20 Sep 2016 14:29:46 -0700
> Sasi Inguva  wrote:
>
> > Signed-off-by: Sasi Inguva 
> > ---
> >  libavcodec/utils.c   | 15 +++---
> >  libavformat/mov.c| 81
> 
> >  tests/ref/fate/gaplessenc-itunes-to-ipod-aac |  2 +-
> >  tests/ref/fate/gaplessenc-pcm-to-mov-aac |  2 +-
> >  4 files changed, 78 insertions(+), 22 deletions(-)
> >
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index b0345b6..e18476c 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -2320,7 +2320,6 @@ int attribute_align_arg 
> > avcodec_decode_audio4(AVCodecContext
> *avctx,
> >  uint32_t discard_padding = 0;
> >  uint8_t skip_reason = 0;
> >  uint8_t discard_reason = 0;
> > -int demuxer_skip_samples = 0;
> >  // copy to ensure we do not change avpkt
> >  AVPacket tmp = *avpkt;
> >  int did_split = av_packet_split_side_data();
> > @@ -2328,7 +2327,6 @@ int attribute_align_arg 
> > avcodec_decode_audio4(AVCodecContext
> *avctx,
> >  if (ret < 0)
> >  goto fail;
> >
> > -demuxer_skip_samples = avctx->internal->skip_samples;
> >  avctx->internal->pkt = 
> >  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
> >  ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr,
> );
> > @@ -2353,13 +2351,6 @@ int attribute_align_arg 
> > avcodec_decode_audio4(AVCodecContext
> *avctx,
> >  frame->sample_rate = avctx->sample_rate;
> >  }
> >
> > -
> > -if (frame->flags & AV_FRAME_FLAG_DISCARD) {
> > -// If using discard frame flag, ignore skip_samples set by
> the decoder.
> > -avctx->internal->skip_samples = demuxer_skip_samples;
> > -*got_frame_ptr = 0;
> > -}
> > -
> >  side= av_packet_get_side_data(avctx->internal->pkt,
> AV_PKT_DATA_SKIP_SAMPLES, _size);
> >  if(side && side_size>=10) {
> >  avctx->internal->skip_samples = AV_RL32(side);
> > @@ -2369,6 +2360,12 @@ int attribute_align_arg 
> > avcodec_decode_audio4(AVCodecContext
> *avctx,
> >  skip_reason = AV_RL8(side + 8);
> >  discard_reason = AV_RL8(side + 9);
> >  }
> > +
> > +if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr) {
> > +avctx->internal->skip_samples -= frame->nb_samples;
> > +*got_frame_ptr = 0;
> > +}
> > +
> >  if (avctx->internal->skip_samples > 0 && *got_frame_ptr &&
> >  !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
> >  if(frame->nb_samples <= avctx->internal->skip_samples){
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index b84d9c0..bb86780 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -2856,6 +2856,21 @@ static int64_t add_index_entry(AVStream *st,
> int64_t pos, int64_t timestamp,
> >  }
> >
> >  /**
> > + * Rewrite timestamps of index entries in the range [end_index -
> frame_duration_buffer_size, end_index)
> > + * by subtracting end_ts successively by the amounts given in
> frame_duration_buffer.
> > + */
> > +static void fix_index_entry_timestamps(AVStream* st, int end_index,
> int64_t end_ts,
> > +   int64_t* frame_duration_buffer,
> > +   int frame_duration_buffer_size) {
> > +int i = 0;
> > +av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
> > +for (i = 0; i < frame_duration_buffer_size; i++) {
> > +end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1
> - i];
> > +st->index_entries[end_index - 1 - i].timestamp = end_ts;
> > +}
> > +}
> > +
> > +/**
> >   * Append a new ctts entry to ctts_data.
> >   * Returns the new ctts_count if successful, else returns -1.
> >   */
> > @@ -2919,7 +2934,10 @@ static void mov_fix_index(MOVContext *mov,
> AVStream *st)
> >  int64_t edit_list_media_time_dts = 0;
> >  int64_t edit_list_start_encountered = 0;
> >  int64_t search_timestamp = 0;
> > -
> > +int64_t* frame_duration_buffer = NULL;
> > +int num_discarded_begin = 0;
> > +int first_non_zero_audio_edit = -1;
> > +int packet_skip_samples = 0;
> >
> >  if (!msc->elst_data || msc->elst_count <= 0) {
> >  return;
> > @@ -2955,6 +2973,7 @@ static void mov_fix_index(MOVContext *mov,
> AVStream *st)
> >  edit_list_index++;
> >  edit_list_dts_counter = edit_list_dts_entry_end;
> >  edit_list_dts_entry_end += edit_list_duration;
> > +num_discarded_begin = 0;
> >  if (edit_list_media_time == -1) {
> >  continue;
> >  }
> > @@ -2962,7 +2981,14 @@ static void mov_fix_index(MOVContext *mov,
> AVStream *st)
> >  // If we encounter a 

[FFmpeg-devel] [PATCH] lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list. Fixes gapless decoding.

2016-09-22 Thread Sasi Inguva
Signed-off-by: Sasi Inguva 
---
 libavcodec/utils.c   | 16 +++---
 libavformat/mov.c| 81 
 tests/ref/fate/gaplessenc-itunes-to-ipod-aac |  2 +-
 tests/ref/fate/gaplessenc-pcm-to-mov-aac |  2 +-
 4 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b0345b6..6323156 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2320,7 +2320,6 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
 uint32_t discard_padding = 0;
 uint8_t skip_reason = 0;
 uint8_t discard_reason = 0;
-int demuxer_skip_samples = 0;
 // copy to ensure we do not change avpkt
 AVPacket tmp = *avpkt;
 int did_split = av_packet_split_side_data();
@@ -2328,7 +2327,6 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
 if (ret < 0)
 goto fail;
 
-demuxer_skip_samples = avctx->internal->skip_samples;
 avctx->internal->pkt = 
 if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
 ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, );
@@ -2353,13 +2351,6 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
 frame->sample_rate = avctx->sample_rate;
 }
 
-
-if (frame->flags & AV_FRAME_FLAG_DISCARD) {
-// If using discard frame flag, ignore skip_samples set by the 
decoder.
-avctx->internal->skip_samples = demuxer_skip_samples;
-*got_frame_ptr = 0;
-}
-
 side= av_packet_get_side_data(avctx->internal->pkt, 
AV_PKT_DATA_SKIP_SAMPLES, _size);
 if(side && side_size>=10) {
 avctx->internal->skip_samples = AV_RL32(side);
@@ -2369,6 +2360,13 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
 skip_reason = AV_RL8(side + 8);
 discard_reason = AV_RL8(side + 9);
 }
+
+if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr &&
+!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
+avctx->internal->skip_samples -= frame->nb_samples;
+*got_frame_ptr = 0;
+}
+
 if (avctx->internal->skip_samples > 0 && *got_frame_ptr &&
 !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
 if(frame->nb_samples <= avctx->internal->skip_samples){
diff --git a/libavformat/mov.c b/libavformat/mov.c
index b84d9c0..bb86780 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2856,6 +2856,21 @@ static int64_t add_index_entry(AVStream *st, int64_t 
pos, int64_t timestamp,
 }
 
 /**
+ * Rewrite timestamps of index entries in the range [end_index - 
frame_duration_buffer_size, end_index)
+ * by subtracting end_ts successively by the amounts given in 
frame_duration_buffer.
+ */
+static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t 
end_ts,
+   int64_t* frame_duration_buffer,
+   int frame_duration_buffer_size) {
+int i = 0;
+av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
+for (i = 0; i < frame_duration_buffer_size; i++) {
+end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];
+st->index_entries[end_index - 1 - i].timestamp = end_ts;
+}
+}
+
+/**
  * Append a new ctts entry to ctts_data.
  * Returns the new ctts_count if successful, else returns -1.
  */
@@ -2919,7 +2934,10 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 int64_t edit_list_media_time_dts = 0;
 int64_t edit_list_start_encountered = 0;
 int64_t search_timestamp = 0;
-
+int64_t* frame_duration_buffer = NULL;
+int num_discarded_begin = 0;
+int first_non_zero_audio_edit = -1;
+int packet_skip_samples = 0;
 
 if (!msc->elst_data || msc->elst_count <= 0) {
 return;
@@ -2955,6 +2973,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 edit_list_index++;
 edit_list_dts_counter = edit_list_dts_entry_end;
 edit_list_dts_entry_end += edit_list_duration;
+num_discarded_begin = 0;
 if (edit_list_media_time == -1) {
 continue;
 }
@@ -2962,7 +2981,14 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 // If we encounter a non-negative edit list reset the 
skip_samples/start_pad fields and set them
 // according to the edit list below.
 if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-st->skip_samples = msc->start_pad = 0;
+if (first_non_zero_audio_edit < 0) {
+first_non_zero_audio_edit = 1;
+} else {
+first_non_zero_audio_edit = 0;
+}
+
+if (first_non_zero_audio_edit > 0)
+st->skip_samples = msc->start_pad = 0;
 }
 
  

Re: [FFmpeg-devel] Dropping SDL1 support [VOTE]

2016-09-22 Thread James Almer
On 9/15/2016 2:36 PM, James Almer wrote:
> There have been some complains from developers about keeping both
> SDL1 and SDL2 support at the same time even after all SDL1 code
> has been already ported, and especially since it makes maintaining
> ffplay more complex, so seeing the waters are divided I think the
> best solution will be to vote.
> 
> Arguments in favor of keeping SDL1:
> * Debian Old-Stable and Ubuntu 12.04 don't ship an usable SDL2
>   by default, meaning a few extra steps for anyone wanting to
>   compile ffmpeg git would be needed to keep ffplay and the sdl
>   outdev working on them.
> * We have a dev willing to maintain the SDL1 version of ffplay
>   until the above two distros are EOLed.
> 
> Arguments in favor of dropping SDL1:
> * SDL1 is old and effectively unmaintained.
> * The above distros will never upgrade their ffmpeg packages.
> * Anyone compiling ffmpeg git from source on any of the above
>   distros most likely already has to deal with other missing
>   deps, like any recent x264, be it from unnofficial PPAs or
>   manually compiling from source. SDL2 would not be any
>   different in that regard.
> * Even though we have a dev willing to maintain the deprecated
>   SDL1 code, he'd rather not have to deal with it.
> 
> Other arguments in favor or against are welcome.
> 
> The vote will end 1 week from now, simple majority wins, and
> it's open only to those in the voting committee[1].
> Marton Balint, while not in the committee, should IMO also
> have the chance to vote or at least comment since he's the
> main ffplay maintainer.
> 
> Regards.
> 
> [1] https://ffmpeg.org/pipermail/ffmpeg-devel/2015-October/182207.html

The final result is

In favor of dropping SDL1:
Clément Bœsch
Hendrik Leppkes
Rostislav Pehlivanov
Ronald S. Bultje
Lou Logan
wm4

No votes against.

Not counted:
Lukas Marek, Marton Balint, Carl Eugen Hoyos, Michael Niedermayer and
Paul B Mahol, as they didn't cast a clear vote.

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: retain error codes in matroska_resync() and matroska_read_packet()

2016-09-22 Thread Sophia Wang
I think you're right. Seems like the best solution is to maintain the
number of calls to matroska_deliver_packet(); patch modification on the way.

On Wed, Aug 31, 2016 at 6:30 PM, Michael Niedermayer  wrote:

>
> On Mon, Aug 15, 2016 at 10:27:47AM -0700, Sophia Wang wrote:
> > Of the 3 functions that directly add to matroska->packets, 2 of them will
> > always return 0 afterwards, and the third (matroska_parse_rm_audio) will
> > only return something other than 0 in the case of AVERROR(ENOMEM) or
> > AVERROR(EINVAL).
>
> but they can add multiple packets, so even if they return 0 there
> could be packets in the buffer after one is consumed
>
>
> > All 3 functions are called from matroska_parse_block,
> > which immediately returns the result if there is no error.
>
> did you mean "if there is AN error" ?
>
>
> > If an error does
> > occur, then the error code may eventually be returned, or it may be
> > overwritten by the return value of any of the 3 packet-adding functions.
> >
> > matroska_parse_block is called from matroska_parse_cluster and its helper
> > matroska_parse_cluster_incremental, both of which simply return the
> result
> > (though it maybe overwritten by another invocation in
> > matroska_parse_cluster). So in any case, if packets are added, the only
> > sources of failure are ENOMEM and EINVAL, and I'm not sure if it makes
> > sense to write code to work around those.
>
> you add code in matroska_resync() and its caller to immedeatly
> break out and return failure if the seek fails.
> At this point there can still be packets in the buffers unless i
> miss something, should the error not be returned after the packets
> that where read before the error ?
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No great genius has ever existed without some touch of madness. --
> Aristotle
>
> ___
> 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] lavf: add ffprobe demuxer

2016-09-22 Thread Stefano Sabatini
On date Sunday 2016-09-18 15:28:45 +0200, Stefano Sabatini encoded:
> On date Saturday 2016-09-17 18:42:35 +0200, Paul B Mahol encoded:
> > On 9/17/16, Stefano Sabatini  wrote:
> > > On date Sunday 2016-09-04 23:25:56 +0200, Michael Niedermayer encoded:
> > >> On Sun, Sep 04, 2016 at 06:24:37PM +0200, Stefano Sabatini wrote:
> > >> > From: Nicolas George 
> > >> >
> > >> > With several modifications and documentation by Stefano Sabatini
> > >> > .
> > >> >
> > >> > Signed-off-by: Nicolas George 
> > >> > ---
> > >> >  doc/ffprobe-format.texi  | 130 
> > >> >  libavformat/Makefile |   1 +
> > >> >  libavformat/allformats.c |   2 +
> > >> >  libavformat/ffprobedec.c | 397
> > >> > +++
> > >> >  4 files changed, 530 insertions(+)
> > >> >  create mode 100644 doc/ffprobe-format.texi
> > >> >  create mode 100644 libavformat/ffprobedec.c
> > >>
> > >> this seems not to apply cleanly
> > >>
> > >> can i pick this from some git repo ? (should work better than patch
> > >> with unavailable ancestors)
> > >
> > > Updated, this should apply cleanly on master.
> > 
> > Why we need this hack?
> 
> My use case: I need to inject a metadata stream using the ff*
> tools. Metadata must be specified in a textual format. I already
> designed and implemented the fftextdata format, but that was regarded
> too limited.
> 
> Example:
> ffmpeg -i input.mp4 -copyts -i data.ffprobe -map 0:v -map 0:a -map 1:0 
> -codec:d copy input+data.ts
> 
> With this format we allow to cover my use case, and it provides a more
> generic format for such purposes (since you can specify multiple
> streams). Also, it's inspired by the ffprobe output, so it can be used
> together with ffprobe (via simple text editing) to generate files
> which can be edited and feed to ffmpeg.
> 
> It would be possible to use any binary format for injecting the
> metadata, but this approach is not very scriptable. Alternatively a
> custom program to convert a custom textual format to any binary format
> we support, but this would imply an additional step I want to avoid.
> 
> That said, if someone want/can propose an alternative path to this I'm
> very open to suggestions.

Ping. I'd like to commit this if there are no objections. Also,
possibly add a muxer to generate output directly readable by the
demuxer (this way we don't need ffprobe for generating the output, and
we avoid the ordering issue).
-- 
FFmpeg = Fundamental and Fundamental Mere Ponderous Elastic Gargoyle
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/utils: avoid using marked decoders for probing

2016-09-22 Thread Timo Rothenpieler
---
 libavformat/utils.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 05d2315..93ea6ff 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -188,6 +188,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream 
*st, enum AVCodecID codec_id)
 {
+const AVCodec *codec;
+
 #if CONFIG_H264_DECODER
 /* Other parts of the code assume this decoder to be used for h264,
  * so force it if possible. */
@@ -195,7 +197,22 @@ static const AVCodec *find_probe_decoder(AVFormatContext 
*s, const AVStream *st,
 return avcodec_find_decoder_by_name("h264");
 #endif
 
-return find_decoder(s, st, codec_id);
+codec = find_decoder(s, st, codec_id);
+if (!codec)
+return NULL;
+
+if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING) {
+const AVCodec *probe_codec = NULL;
+while (probe_codec = av_codec_next(probe_codec)) {
+if (probe_codec->id == codec_id &&
+av_codec_is_decoder(probe_codec) &&
+!(probe_codec->capabilities & (AV_CODEC_CAP_AVOID_PROBING 
| AV_CODEC_CAP_EXPERIMENTAL))) {
+return probe_codec;
+}
+}
+}
+
+return codec;
 }
 
 int av_format_get_probe_score(const AVFormatContext *s)
-- 
2.10.0

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


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Michael Fritscher

Hi,

master uses _WIN32 checks in both places so if its not set, it will
never error, because it'll never even try to call it.

3.1 uses a different check because it was refactored in master later,
and while 3.1.3 was still missing one check, it was fixed after that
release was made.
Unless master actually fails, or the latest commit in the 3.1 branch
fails, there is nothing we have to do. We cannot retroactively fix
3.1.3, but it is fixed for the next release as far as I can tell.

- Hendrik


You are right, I missed the changed #ifdef in master on line 115.

Best regards,
Michael Fritscher
--
ZfT - Zentrum für Telematik e.V.
Michael Fritscher
Magdalene-Schoch-Straße 5
97074 Würzburg
Tel: +49 (931) 615 633 - 57
Fax: +49 (931) 615 633 - 11
Email: michael.fritsc...@telematik-zentrum.de
Web: http://www.telematik-zentrum.de

Vorstand:
Prof. Dr. Klaus Schilling, Hans-Joachim Leistner
Sitz: Gerbrunn
USt.-ID Nr.: DE 257 244 580, Steuer-Nr.:  257/111/70203
Amtsgericht Würzburg, Vereinsregister-Nr.: VR 200 167
<>

smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] img2: added support for %t output pattern

2016-09-22 Thread Roger Pack
On 1/4/12, Yuval Adam  wrote:
> From: Yuval Adam 
>
> The image2 muxer now supports timestamps in output filenames.
> When used in an output patterm '%t' will be replaced with the frames
> timestamp in hours, minutes and seconds (hh:mm:ss).

A somewhat updated (but not yet cleaned up) revision:

https://gist.github.com/rdp/e518616f2a702367ae5a922b56e09e04

see also https://trac.ffmpeg.org/ticket/1452
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Dropping SDL1 support [VOTE]

2016-09-22 Thread wm4
On Thu, 15 Sep 2016 14:36:32 -0300
James Almer  wrote:

> There have been some complains from developers about keeping both
> SDL1 and SDL2 support at the same time even after all SDL1 code
> has been already ported, and especially since it makes maintaining
> ffplay more complex, so seeing the waters are divided I think the
> best solution will be to vote.

I vote for dropping SDL1 completely.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] avformat/utils: avoid using marked decoders for probing

2016-09-22 Thread Michael Niedermayer
On Thu, Sep 22, 2016 at 02:00:04PM +0200, Timo Rothenpieler wrote:
> ---
>  libavformat/utils.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 05d2315..87a6dd7 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -188,6 +188,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  
>  static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream 
> *st, enum AVCodecID codec_id)
>  {
> +const AVCodec *codec;
> +
>  #if CONFIG_H264_DECODER
>  /* Other parts of the code assume this decoder to be used for h264,
>   * so force it if possible. */
> @@ -195,7 +197,14 @@ static const AVCodec *find_probe_decoder(AVFormatContext 
> *s, const AVStream *st,
>  return avcodec_find_decoder_by_name("h264");
>  #endif
>  
> -return find_decoder(s, st, codec_id);
> +codec = find_decoder(s, st, codec_id);
> +if (!codec)
> +return NULL;
> +
> +if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING)
> +return avcodec_find_decoder(codec_id);

this should be using a loop with av_codec_next() to preferaly
select a codec without AV_CODEC_CAP_AVOID_PROBING or
AV_CODEC_CAP_EXPERIMENTAL

or such function could be added to libavcodec if usefull elsewhere

Theres no gurantee that avcodec_find_decoder() would not pick a
AV_CODEC_CAP_AVOID_PROBING codec unless iam missing something

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec: add new AVOID_PROBING capability

2016-09-22 Thread Michael Niedermayer
On Thu, Sep 22, 2016 at 02:00:03PM +0200, Timo Rothenpieler wrote:
> ---
>  doc/APIchanges   |  3 +++
>  libavcodec/avcodec.h | 10 ++
>  libavcodec/version.h |  4 ++--
>  3 files changed, 15 insertions(+), 2 deletions(-)

LGTM

thx

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Tobias Rapp

On 22.09.2016 14:23, Hendrik Leppkes wrote:

On Thu, Sep 22, 2016 at 2:21 PM, Timo Rothenpieler
 wrote:

master uses _WIN32 checks in both places so if its not set, it will
never error, because it'll never even try to call it.


But wasn't the HAVE_SETDLLDIRECTORY introduced because of Windows XP
compatibility, as the function doesn't exist there, but _WIN32 is
obviously set?

Or does master just not care about WinXP anymore?


Windows XP has this function, at least as of Service Pack 1 (and
support for plain XP without service packs should have died like a
decade ago)


Indeed. The original discussion thread can be found here:
https://ffmpeg.org/pipermail/ffmpeg-devel/2016-August/197992.html

Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH 3/4] lavc: Add a flag in AVPacket to discard packet after decoding. Discard frames after decoding based on the flag.

2016-09-22 Thread wm4
On Mon, 19 Sep 2016 21:20:08 +0200
Carl Eugen Hoyos  wrote:

> 2016-09-19 20:32 GMT+02:00 wm4 :
> 
> > But I guess you don't care, neither did whoever pushed this
> > low quality patch before the patch was fixed?  
> 
> I believe you didn't oppose the current mailing list rules so
> please refrain from personal attacks.
> 

I wouldn't call it a personal attack, rather accusation of
carelessness. My tone might have been off though, and I apologize.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list. Fixes gapless decoding.

2016-09-22 Thread wm4
On Tue, 20 Sep 2016 14:29:46 -0700
Sasi Inguva  wrote:

> Signed-off-by: Sasi Inguva 
> ---
>  libavcodec/utils.c   | 15 +++---
>  libavformat/mov.c| 81 
> 
>  tests/ref/fate/gaplessenc-itunes-to-ipod-aac |  2 +-
>  tests/ref/fate/gaplessenc-pcm-to-mov-aac |  2 +-
>  4 files changed, 78 insertions(+), 22 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index b0345b6..e18476c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2320,7 +2320,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext *avctx,
>  uint32_t discard_padding = 0;
>  uint8_t skip_reason = 0;
>  uint8_t discard_reason = 0;
> -int demuxer_skip_samples = 0;
>  // copy to ensure we do not change avpkt
>  AVPacket tmp = *avpkt;
>  int did_split = av_packet_split_side_data();
> @@ -2328,7 +2327,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext *avctx,
>  if (ret < 0)
>  goto fail;
>  
> -demuxer_skip_samples = avctx->internal->skip_samples;
>  avctx->internal->pkt = 
>  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
>  ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, );
> @@ -2353,13 +2351,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext *avctx,
>  frame->sample_rate = avctx->sample_rate;
>  }
>  
> -
> -if (frame->flags & AV_FRAME_FLAG_DISCARD) {
> -// If using discard frame flag, ignore skip_samples set by the 
> decoder.
> -avctx->internal->skip_samples = demuxer_skip_samples;
> -*got_frame_ptr = 0;
> -}
> -
>  side= av_packet_get_side_data(avctx->internal->pkt, 
> AV_PKT_DATA_SKIP_SAMPLES, _size);
>  if(side && side_size>=10) {
>  avctx->internal->skip_samples = AV_RL32(side);
> @@ -2369,6 +2360,12 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext *avctx,
>  skip_reason = AV_RL8(side + 8);
>  discard_reason = AV_RL8(side + 9);
>  }
> +
> +if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr) {
> +avctx->internal->skip_samples -= frame->nb_samples;
> +*got_frame_ptr = 0;
> +}
> +
>  if (avctx->internal->skip_samples > 0 && *got_frame_ptr &&
>  !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
>  if(frame->nb_samples <= avctx->internal->skip_samples){
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index b84d9c0..bb86780 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2856,6 +2856,21 @@ static int64_t add_index_entry(AVStream *st, int64_t 
> pos, int64_t timestamp,
>  }
>  
>  /**
> + * Rewrite timestamps of index entries in the range [end_index - 
> frame_duration_buffer_size, end_index)
> + * by subtracting end_ts successively by the amounts given in 
> frame_duration_buffer.
> + */
> +static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t 
> end_ts,
> +   int64_t* frame_duration_buffer,
> +   int frame_duration_buffer_size) {
> +int i = 0;
> +av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
> +for (i = 0; i < frame_duration_buffer_size; i++) {
> +end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];
> +st->index_entries[end_index - 1 - i].timestamp = end_ts;
> +}
> +}
> +
> +/**
>   * Append a new ctts entry to ctts_data.
>   * Returns the new ctts_count if successful, else returns -1.
>   */
> @@ -2919,7 +2934,10 @@ static void mov_fix_index(MOVContext *mov, AVStream 
> *st)
>  int64_t edit_list_media_time_dts = 0;
>  int64_t edit_list_start_encountered = 0;
>  int64_t search_timestamp = 0;
> -
> +int64_t* frame_duration_buffer = NULL;
> +int num_discarded_begin = 0;
> +int first_non_zero_audio_edit = -1;
> +int packet_skip_samples = 0;
>  
>  if (!msc->elst_data || msc->elst_count <= 0) {
>  return;
> @@ -2955,6 +2973,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
>  edit_list_index++;
>  edit_list_dts_counter = edit_list_dts_entry_end;
>  edit_list_dts_entry_end += edit_list_duration;
> +num_discarded_begin = 0;
>  if (edit_list_media_time == -1) {
>  continue;
>  }
> @@ -2962,7 +2981,14 @@ static void mov_fix_index(MOVContext *mov, AVStream 
> *st)
>  // If we encounter a non-negative edit list reset the 
> skip_samples/start_pad fields and set them
>  // according to the edit list below.
>  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
> -st->skip_samples = msc->start_pad = 0;
> +if 

Re: [FFmpeg-devel] [PATCH 1/3] avcodec: add new AVOID_PROBING capability

2016-09-22 Thread wm4
On Thu, 22 Sep 2016 14:00:03 +0200
Timo Rothenpieler  wrote:

> ---
>  doc/APIchanges   |  3 +++
>  libavcodec/avcodec.h | 10 ++
>  libavcodec/version.h |  4 ++--
>  3 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 158a0b2..5d577e4 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2015-08-28
>  
>  API changes, most recent first:
>  
> +2016-09-xx - xxx - lavc 57.58.100 - avcodec.h
> +  Add AV_CODEC_CAP_AVOID_PROBING codec capability flag.
> +
>  2016-09-xx - xxx - lavf 57.49.100 - avformat.h
>Add avformat_transfer_internal_stream_timing_info helper to help with 
> stream
>copy.
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index db1061d..b174116 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1036,6 +1036,16 @@ typedef struct RcOverride{
>   */
>  #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
>  /**
> + * Decoder is not a preferred choice for probing.
> + * This indicates that the decoder is not a good choice for probing.
> + * It could for example be an expensive to spin up hardware decoder,
> + * or it could simply not provide a lot of useful information about
> + * the stream.
> + * A decoder marked with this flag should only be used as last resort
> + * choice for probing.
> + */
> +#define AV_CODEC_CAP_AVOID_PROBING   (1 << 17)
> +/**
>   * Codec is intra only.
>   */
>  #define AV_CODEC_CAP_INTRA_ONLY   0x4000
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 9acf081..9e44eca 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -28,8 +28,8 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVCODEC_VERSION_MAJOR  57
> -#define LIBAVCODEC_VERSION_MINOR  57
> -#define LIBAVCODEC_VERSION_MICRO 101
> +#define LIBAVCODEC_VERSION_MINOR  58
> +#define LIBAVCODEC_VERSION_MICRO 100
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> LIBAVCODEC_VERSION_MINOR, \

Actually seems like a good idea. All hw decoders should be marked like
this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Hendrik Leppkes
On Thu, Sep 22, 2016 at 2:21 PM, Timo Rothenpieler
 wrote:
>> master uses _WIN32 checks in both places so if its not set, it will
>> never error, because it'll never even try to call it.
>
> But wasn't the HAVE_SETDLLDIRECTORY introduced because of Windows XP
> compatibility, as the function doesn't exist there, but _WIN32 is
> obviously set?
>
> Or does master just not care about WinXP anymore?

Windows XP has this function, at least as of Service Pack 1 (and
support for plain XP without service packs should have died like a
decade ago)

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


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Timo Rothenpieler
> master uses _WIN32 checks in both places so if its not set, it will
> never error, because it'll never even try to call it.

But wasn't the HAVE_SETDLLDIRECTORY introduced because of Windows XP
compatibility, as the function doesn't exist there, but _WIN32 is
obviously set?

Or does master just not care about WinXP anymore?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Hendrik Leppkes
On Thu, Sep 22, 2016 at 1:52 PM, Timo Rothenpieler
 wrote:
> Am 22.09.2016 um 13:37 schrieb Michael Fritscher:
>> Hi,
>>
>> ok, I rephrase it: I have the issue that HAVE_SETDLLDIRECTORY is
>> defined, but _WIN32 is not if compiling under cygwin (fresh install, no
>> mingw).
>>
>> SetDllDirectory() is called whenever HAVE_SETDLLDIRECTORY is defined,
>> there is no check for _WIN32.
>>
>> The configure script seems to test windows.h for SetDllDirectory without
>> a test of running in a _WIN32 environment:
>>> check_func_headers windows.h SetDllDirectory
>>
>> So cygwin has the situation that the compiler (or the headers) doesn't
>> set _WIN32, but have windows.h (c:\cygwin64\usr\include\w32api\windows.h).
>
> This was broken by f4b8892ccbf08ea5b38177bb7ad042921d082eac
> No idea why that commit is not present in master.
>
> The correct solution would be checking for both _WIN32 and
> HAVE_SETDLLDIRECTORY.

master uses _WIN32 checks in both places so if its not set, it will
never error, because it'll never even try to call it.

3.1 uses a different check because it was refactored in master later,
and while 3.1.3 was still missing one check, it was fixed after that
release was made.
Unless master actually fails, or the latest commit in the 3.1 branch
fails, there is nothing we have to do. We cannot retroactively fix
3.1.3, but it is fixed for the next release as far as I can tell.

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


[FFmpeg-devel] [PATCH 2/3] avformat/utils: avoid using marked decoders for probing

2016-09-22 Thread Timo Rothenpieler
---
 libavformat/utils.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 05d2315..87a6dd7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -188,6 +188,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream 
*st, enum AVCodecID codec_id)
 {
+const AVCodec *codec;
+
 #if CONFIG_H264_DECODER
 /* Other parts of the code assume this decoder to be used for h264,
  * so force it if possible. */
@@ -195,7 +197,14 @@ static const AVCodec *find_probe_decoder(AVFormatContext 
*s, const AVStream *st,
 return avcodec_find_decoder_by_name("h264");
 #endif
 
-return find_decoder(s, st, codec_id);
+codec = find_decoder(s, st, codec_id);
+if (!codec)
+return NULL;
+
+if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING)
+return avcodec_find_decoder(codec_id);
+
+return codec;
 }
 
 int av_format_get_probe_score(const AVFormatContext *s)
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 3/3] avcodec/cuvid: mark as avoid for probing

2016-09-22 Thread Timo Rothenpieler
---
 libavcodec/cuvid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index db96ac6..c040b09 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -911,7 +911,7 @@ static const AVOption options[] = {
 .send_packet= cuvid_decode_packet, \
 .receive_frame  = cuvid_output_frame, \
 .flush  = cuvid_flush, \
-.capabilities   = AV_CODEC_CAP_DELAY, \
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
 AV_PIX_FMT_NV12, \
 AV_PIX_FMT_NONE }, \
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 1/3] avcodec: add new AVOID_PROBING capability

2016-09-22 Thread Timo Rothenpieler
---
 doc/APIchanges   |  3 +++
 libavcodec/avcodec.h | 10 ++
 libavcodec/version.h |  4 ++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 158a0b2..5d577e4 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-09-xx - xxx - lavc 57.58.100 - avcodec.h
+  Add AV_CODEC_CAP_AVOID_PROBING codec capability flag.
+
 2016-09-xx - xxx - lavf 57.49.100 - avformat.h
   Add avformat_transfer_internal_stream_timing_info helper to help with stream
   copy.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index db1061d..b174116 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1036,6 +1036,16 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
 /**
+ * Decoder is not a preferred choice for probing.
+ * This indicates that the decoder is not a good choice for probing.
+ * It could for example be an expensive to spin up hardware decoder,
+ * or it could simply not provide a lot of useful information about
+ * the stream.
+ * A decoder marked with this flag should only be used as last resort
+ * choice for probing.
+ */
+#define AV_CODEC_CAP_AVOID_PROBING   (1 << 17)
+/**
  * Codec is intra only.
  */
 #define AV_CODEC_CAP_INTRA_ONLY   0x4000
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 9acf081..9e44eca 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  57
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MINOR  58
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.10.0

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


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Timo Rothenpieler
Am 22.09.2016 um 13:37 schrieb Michael Fritscher:
> Hi,
> 
> ok, I rephrase it: I have the issue that HAVE_SETDLLDIRECTORY is
> defined, but _WIN32 is not if compiling under cygwin (fresh install, no
> mingw).
> 
> SetDllDirectory() is called whenever HAVE_SETDLLDIRECTORY is defined,
> there is no check for _WIN32.
> 
> The configure script seems to test windows.h for SetDllDirectory without
> a test of running in a _WIN32 environment:
>> check_func_headers windows.h SetDllDirectory
> 
> So cygwin has the situation that the compiler (or the headers) doesn't
> set _WIN32, but have windows.h (c:\cygwin64\usr\include\w32api\windows.h).

This was broken by f4b8892ccbf08ea5b38177bb7ad042921d082eac
No idea why that commit is not present in master.

The correct solution would be checking for both _WIN32 and
HAVE_SETDLLDIRECTORY.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Michael Fritscher

Hi,

ok, I rephrase it: I have the issue that HAVE_SETDLLDIRECTORY is 
defined, but _WIN32 is not if compiling under cygwin (fresh install, no 
mingw).


SetDllDirectory() is called whenever HAVE_SETDLLDIRECTORY is defined, 
there is no check for _WIN32.


The configure script seems to test windows.h for SetDllDirectory without 
a test of running in a _WIN32 environment:

> check_func_headers windows.h SetDllDirectory

So cygwin has the situation that the compiler (or the headers) doesn't 
set _WIN32, but have windows.h (c:\cygwin64\usr\include\w32api\windows.h).


Best regards,
Michael Fritscher

--
ZfT - Zentrum für Telematik e.V.
Michael Fritscher
Magdalene-Schoch-Straße 5
97074 Würzburg
Tel: +49 (931) 615 633 - 57
Fax: +49 (931) 615 633 - 11
Email: michael.fritsc...@telematik-zentrum.de
Web: http://www.telematik-zentrum.de

Vorstand:
Prof. Dr. Klaus Schilling, Hans-Joachim Leistner
Sitz: Gerbrunn
USt.-ID Nr.: DE 257 244 580, Steuer-Nr.:  257/111/70203
Amtsgericht Würzburg, Vereinsregister-Nr.: VR 200 167
<>

smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Tobias Rapp

On 22.09.2016 12:30, Michael Fritscher wrote:

Hi,

I try to build ffmpeg 3.1.3 on cygwin64 on Windows.

Configstring: ./configure --prefix=/usr/local --enable-ffplay
--enable-ffmpeg --enable-ffserver --enable-gpl --enable-version3
--enable-nonfree --enable-shared --enable-libfreetype --enable-libgsm
--enable-libmp3lame --enable-libopencv --enable-libtheora
--enable-libvorbis --enable-libx264 --enable-libxvid --enable-ffplay
--enable-outdev=sdl --enable-outdev=xv --enable-indev=dshow
--enable-pthreads --enable-ffplay --enable-ffmpeg --enable-ffserver
--enable-demuxer=mpegvideo --enable-parser=mpegvideo
--enable-muxer=mpjpeg --enable-muxer=mjpeg --enable-demuxer=mjpeg
--enable-parser=mjpeg

Output:
CC  cmdutils.o
cmdutils.c: In Funktion »init_dynload«:
cmdutils.c:115:5: Fehler: Implizite Deklaration der Funktion
»SetDllDirectory« [-Werror=implicit-function-declaration]
  SetDllDirectory("");

My quick fix was to add

#if HAVE_SETDLLDIRECTORY
#include 
#endif

on line 64. Is this the right way to cope with this? At least it
compiles, links and works ;-)


I stumbled over a similar issue, it has also been fixed in the 
release/3.1 branch but after n3.1.3 in commit 
12320c08221f0eecf6d9af3a6f12f42e656f0674.


See https://ffmpeg.org/pipermail/ffmpeg-devel/2016-August/198476.html


In current git I found
#ifdef _WIN32
#include 
#endif,

which does not work under cygwin. Apparently _WIN32 is not defined in
this environment.


But in this case SetDllDirectory() is not called as it's also 
ifdef-depending on _WIN32.


Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: force native h264 decoder for probing

2016-09-22 Thread Timo Rothenpieler
Am 22.09.2016 um 12:36 schrieb Michael Niedermayer:
> On Thu, Sep 22, 2016 at 11:09:08AM +0200, Timo Rothenpieler wrote:
>> ---
>>  libavformat/utils.c | 18 +++---
>>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> LGTM
> 
> thx

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


Re: [FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Hendrik Leppkes
On Thu, Sep 22, 2016 at 12:30 PM, Michael Fritscher
 wrote:
> Hi,
>
> I try to build ffmpeg 3.1.3 on cygwin64 on Windows.
>
> Configstring: ./configure --prefix=/usr/local --enable-ffplay
> --enable-ffmpeg --enable-ffserver --enable-gpl --enable-version3
> --enable-nonfree --enable-shared --enable-libfreetype --enable-libgsm
> --enable-libmp3lame --enable-libopencv --enable-libtheora --enable-libvorbis
> --enable-libx264 --enable-libxvid --enable-ffplay --enable-outdev=sdl
> --enable-outdev=xv --enable-indev=dshow --enable-pthreads --enable-ffplay
> --enable-ffmpeg --enable-ffserver --enable-demuxer=mpegvideo
> --enable-parser=mpegvideo --enable-muxer=mpjpeg --enable-muxer=mjpeg
> --enable-demuxer=mjpeg --enable-parser=mjpeg
>
> Output:
> CC  cmdutils.o
> cmdutils.c: In Funktion »init_dynload«:
> cmdutils.c:115:5: Fehler: Implizite Deklaration der Funktion
> »SetDllDirectory« [-Werror=implicit-function-declaration]
>   SetDllDirectory("");
>
> My quick fix was to add
>
> #if HAVE_SETDLLDIRECTORY
> #include 
> #endif
>
> on line 64. Is this the right way to cope with this? At least it compiles,
> links and works ;-)
>
> In current git I found
> #ifdef _WIN32
> #include 
> #endif,
>
> which does not work under cygwin. Apparently _WIN32 is not defined in this
> environment.
>

If WIN32 would not be defined, then the code in question would never
be executed, since its under the same condition.
Rather, you should find out why your windows.h does not expose this
API, which is available in all currently supported versions of
windows.

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: force native h264 decoder for probing

2016-09-22 Thread Michael Niedermayer
On Thu, Sep 22, 2016 at 11:09:08AM +0200, Timo Rothenpieler wrote:
> ---
>  libavformat/utils.c | 18 +++---
>  1 file changed, 15 insertions(+), 3 deletions(-)

LGTM

thx

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


[FFmpeg-devel] [RFC FIX] Build error with ffmpeg 3.1.3 (and current git) on cygwin

2016-09-22 Thread Michael Fritscher

Hi,

I try to build ffmpeg 3.1.3 on cygwin64 on Windows.

Configstring: ./configure --prefix=/usr/local --enable-ffplay 
--enable-ffmpeg --enable-ffserver --enable-gpl --enable-version3 
--enable-nonfree --enable-shared --enable-libfreetype --enable-libgsm 
--enable-libmp3lame --enable-libopencv --enable-libtheora 
--enable-libvorbis --enable-libx264 --enable-libxvid --enable-ffplay 
--enable-outdev=sdl --enable-outdev=xv --enable-indev=dshow 
--enable-pthreads --enable-ffplay --enable-ffmpeg --enable-ffserver 
--enable-demuxer=mpegvideo --enable-parser=mpegvideo 
--enable-muxer=mpjpeg --enable-muxer=mjpeg --enable-demuxer=mjpeg 
--enable-parser=mjpeg


Output:
CC  cmdutils.o
cmdutils.c: In Funktion »init_dynload«:
cmdutils.c:115:5: Fehler: Implizite Deklaration der Funktion 
»SetDllDirectory« [-Werror=implicit-function-declaration]

  SetDllDirectory("");

My quick fix was to add

#if HAVE_SETDLLDIRECTORY
#include 
#endif

on line 64. Is this the right way to cope with this? At least it 
compiles, links and works ;-)


In current git I found
#ifdef _WIN32
#include 
#endif,

which does not work under cygwin. Apparently _WIN32 is not defined in 
this environment.


Best regards,
Michael Fritscher
--
ZfT - Zentrum für Telematik e.V.
Michael Fritscher
Magdalene-Schoch-Straße 5
97074 Würzburg
Tel: +49 (931) 615 633 - 57
Fax: +49 (931) 615 633 - 11
Email: michael.fritsc...@telematik-zentrum.de
Web: http://www.telematik-zentrum.de

Vorstand:
Prof. Dr. Klaus Schilling, Hans-Joachim Leistner
Sitz: Gerbrunn
USt.-ID Nr.: DE 257 244 580, Steuer-Nr.:  257/111/70203
Amtsgericht Würzburg, Vereinsregister-Nr.: VR 200 167

<>

smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/aaccoder: Limit sf_idx difference for all cases

2016-09-22 Thread Claudio Freire
On Sat, Sep 10, 2016 at 3:37 AM, Claudio Freire  wrote:
> On Thu, Aug 25, 2016 at 8:57 AM, Rostislav Pehlivanov
>  wrote:
>>> 64ed96a710787ba5d0666746a8562e7d.dee
>>>
>>> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>  libavcodec/aaccoder.c | 8 +++-
>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
>>> index 284b401..995724b 100644
>>> --- a/libavcodec/aaccoder.c
>>> +++ b/libavcodec/aaccoder.c
>>> @@ -196,7 +196,7 @@ typedef struct TrellisPath {
>>>  static void set_special_band_scalefactors(AACEncContext *s,
>>> SingleChannelElement *sce)
>>>  {
>>>  int w, g;
>>> -int prevscaler_n = -255, prevscaler_i = 0;
>>> +int prevscaler_n = -255, prevscaler_i = 0, prevscaler_d = -255;
>>>  int bands = 0;
>>>
>>>  for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
>>> @@ -211,6 +211,10 @@ static void set_special_band_scalefactors(AACEncContext
>>> *s, SingleChannelElement
>>>  if (prevscaler_n == -255)
>>>  prevscaler_n = sce->sf_idx[w*16+g];
>>>  bands++;
>>> +} else {
>>> +if (prevscaler_d == -255)
>>> +prevscaler_d = sce->sf_idx[w*16+g];
>>> +bands++;
>>>  }
>>>  }
>>>  }
>>> @@ -227,6 +231,8 @@ static void set_special_band_scalefactors(AACEncContext
>>> *s, SingleChannelElement
>>>  sce->sf_idx[w*16+g] = prevscaler_i =
>>> av_clip(sce->sf_idx[w*16+g], prevscaler_i - SCALE_MAX_DIFF, prevscaler_i +
>>> SCALE_MAX_DIFF);
>>>  } else if (sce->band_type[w*16+g] == NOISE_BT) {
>>>  sce->sf_idx[w*16+g] = prevscaler_n =
>>> av_clip(sce->sf_idx[w*16+g], prevscaler_n - SCALE_MAX_DIFF, prevscaler_n +
>>> SCALE_MAX_DIFF);
>>> +} else {
>>> +sce->sf_idx[w*16+g] = prevscaler_d =
>>> av_clip(sce->sf_idx[w*16+g], prevscaler_d - SCALE_MAX_DIFF, prevscaler_d +
>>> SCALE_MAX_DIFF);
>>>  }
>>>  }
>>>  }
>>> --
>>> 2.9.3
>>>
>>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>
>>
>> That fuzzed sample seems to be causing the algorithm which does SF
>> difference normalization between normal and PNS bands to fail. This commit
>> masks the problem downstream. IMO that's not the correct way to solve this,
>> as there's no guarantee that another sample won't trigger the same assert
>> even when limiting all scalefactors. Fixing a single fuzzed sample with a
>> hack which doesn't stop other fuzzed samples from triggering the same bug
>> isn't justified.
>> I have the time right now and I'll try to fix this properly, but it might
>> take me a day or two. I think the problem is that when the twoloop coder
>> does the the normalization it doesn't take into account the fact that IS
>> and PNS have their scalefactors modified by set_special_band_scalefactors()
>> later on before encoding.
>
> It seems the root of the issue is that the two stages of PNS don't
> agree on when they can apply PNS or not.
>
> I have a WIP that eliminates the issue by just making the two agree,
> but I've got unrelated changes so I'll try to distill the patch to the
> minimum necessary to fix this during the weekend.

Sorry for the delay, it turned out to be more complex than that.

There were a few potential violations that I had already identified in
a WIP patch but they did not apply to the fuzzed sample. That sample
triggered an interaction with TNS and trellis band type coding that
resulted in zeroed bands reappearing and thus invalidating all delta
scalefactor validations.

The attached patch series fixes most of the delta scalefactor
violation risks I could find, including that one.

It hasn't been thoroughly tested for quality regressions/improvements.
It's possible that it does change quality since it changes key
decision points that conduce to the violations but also to lots of
audible artifacts. So I believe it should improve quality, but one
never knows without proper ABX testing, which I'll be conducting, at
least in a limited way, in the following days.

In the meantime, I'm attaching the patch series for review.
From c14007975b40fcd1e4f550a9a37cb695d80c1c20 Mon Sep 17 00:00:00 2001
From: Claudio Freire 
Date: Wed, 21 Sep 2016 02:46:41 -0300
Subject: [PATCH 1/4] AAC Encoder: fix encoding issues with PNS

The two phases of PNS encoding (mark_pns and search_for_pns) were
not in aggreement when PNS could be used, which could cause holes
and illegally PNS'd bands (ie: that would make scalefactor delta
of normal bands exceed the allowed range).
---
 libavcodec/aaccoder.c | 17 -
 libavcodec/aaccoder_twoloop.h |  2 ++
 2 files 

[FFmpeg-devel] [PATCH] avformat/utils: force native h264 decoder for probing

2016-09-22 Thread Timo Rothenpieler
---
 libavformat/utils.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a9bd034..05d2315 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -186,6 +186,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return avcodec_find_decoder(codec_id);
 }
 
+static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream 
*st, enum AVCodecID codec_id)
+{
+#if CONFIG_H264_DECODER
+/* Other parts of the code assume this decoder to be used for h264,
+ * so force it if possible. */
+if (codec_id == AV_CODEC_ID_H264)
+return avcodec_find_decoder_by_name("h264");
+#endif
+
+return find_decoder(s, st, codec_id);
+}
+
 int av_format_get_probe_score(const AVFormatContext *s)
 {
 return s->probe_score;
@@ -2882,7 +2894,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream 
*st, AVPacket *avpkt,
 (st->codecpar->codec_id != -st->info->found_decoder || 
!st->codecpar->codec_id)) {
 AVDictionary *thread_opt = NULL;
 
-codec = find_decoder(s, st, st->codecpar->codec_id);
+codec = find_probe_decoder(s, st, st->codecpar->codec_id);
 
 if (!codec) {
 st->info->found_decoder = -st->codecpar->codec_id;
@@ -3379,7 +3391,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (st->request_probe <= 0)
 st->internal->avctx_inited = 1;
 
-codec = find_decoder(ic, st, st->codecpar->codec_id);
+codec = find_probe_decoder(ic, st, st->codecpar->codec_id);
 
 /* Force thread count to 1 since the H.264 decoder will not extract
  * SPS and PPS to extradata during multi-threaded decoding. */
@@ -3639,7 +3651,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 st = ic->streams[stream_index];
 avctx = st->internal->avctx;
 if (!has_codec_parameters(st, NULL)) {
-const AVCodec *codec = find_decoder(ic, st, 
st->codecpar->codec_id);
+const AVCodec *codec = find_probe_decoder(ic, st, 
st->codecpar->codec_id);
 if (codec && !avctx->codec) {
 if (avcodec_open2(avctx, codec, (options && stream_index < 
orig_nb_streams) ? [stream_index] : NULL) < 0)
 av_log(ic, AV_LOG_WARNING,
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH] avformat/concatdec: don't call open_file when seek position within a file

2016-09-22 Thread Nicolas George
Le jour de la Récompense, an CCXXIV, raymond a écrit :
> ---
>  libavformat/concatdec.c | 27 ---
>  1 file changed, 20 insertions(+), 7 deletions(-)

Thanks for the patch. The object of the change is interesting, but there are
some implementation concerns, see below.

Also, remember that top-posting is not accepted on this list; if you do not
know what it means, look it up.

> 
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index b3a430e..1cd9ec1 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.c
> @@ -64,6 +64,8 @@ typedef struct {
>  ConcatMatchMode stream_match_mode;
>  unsigned auto_convert;
>  int segment_time_metadata;

> +int cur_fileno;

This information is already available as "cur_file - files", see
open_next_file() for example. There is no need for an extra variable.

> +AVFormatContext *cur_avf_saved;

This variable serves only locally for concat_seek() and real_seek(), it
would be better as just a parameter to real_seek().

>  } ConcatContext;
>  
>  static int concat_probe(AVProbeData *probe)
> @@ -333,6 +335,8 @@ static int open_file(AVFormatContext *avf, unsigned 
> fileno)
>  avformat_close_input(>avf);
>  return ret;
>  }
> +
> +cat->cur_fileno = fileno;
>  cat->cur_file = file;
>  if (file->start_time == AV_NOPTS_VALUE)
>  file->start_time = !fileno ? 0 :
> @@ -711,13 +715,18 @@ static int real_seek(AVFormatContext *avf, int stream,
>  left  = mid;
>  }
>  
> -if ((ret = open_file(avf, left)) < 0)
> -return ret;
> +if (cat->cur_fileno != left) {
> +if ((ret = open_file(avf, left)) < 0)
> +return ret;
> +} else {
> +cat->avf = cat->cur_avf_saved;
> +}
>  
>  ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
>  if (ret < 0 &&
>  left < cat->nb_files - 1 &&
>  cat->files[left + 1].start_time < max_ts) {

> +cat->avf = NULL;

This leaks if cat->avf is not cur_avf_saved, I think.

>  if ((ret = open_file(avf, left + 1)) < 0)
>  return ret;
>  ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
> @@ -730,7 +739,7 @@ static int concat_seek(AVFormatContext *avf, int stream,
>  {
>  ConcatContext *cat = avf->priv_data;
>  ConcatFile *cur_file_saved = cat->cur_file;
> -AVFormatContext *cur_avf_saved = cat->avf;

> +cat->cur_avf_saved = cat->avf;
>  int ret;

Interleaving statements and variables is not allowed in the code base.

>  
>  if (!cat->seekable)
> @@ -739,12 +748,16 @@ static int concat_seek(AVFormatContext *avf, int stream,
>  return AVERROR(ENOSYS);
>  cat->avf = NULL;
>  if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags)) < 0) {
> -if (cat->avf)
> -avformat_close_input(>avf);
> -cat->avf  = cur_avf_saved;
> +if (cat->cur_file != cur_file_saved) {
> +if (cat->avf)
> +avformat_close_input(>avf);
> +}
> +cat->avf  = cat->cur_avf_saved;
>  cat->cur_file = cur_file_saved;
>  } else {
> -avformat_close_input(_avf_saved);
> +if (cat->cur_file != cur_file_saved) {
> +avformat_close_input(>cur_avf_saved);
> +}
>  cat->eof = 0;
>  }
>  return ret;

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH]lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy()

2016-09-22 Thread Carl Eugen Hoyos
2016-09-22 3:39 GMT+02:00 Michael Niedermayer :
> On Thu, Sep 22, 2016 at 01:07:06AM +0200, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes ticket #5857.
>>
>> Please comment, Carl Eugen
>
>>  avpacket.c |3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 6ff2850caef558476bbe522b398edd97233e69d9  
>> 0001-lavc-avpacket-Fix-undefined-behaviour-do-not-pass-a-.patch
>> From 20e673f5303fef7b0adc7737d2023bebfe18014f Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos 
>> Date: Thu, 22 Sep 2016 01:03:55 +0200
>> Subject: [PATCH] lavc/avpacket: Fix undefined behaviour, do not pass a null
>>  pointer to memcpy().
>>
>> Fixes ticket #5857.
>
> LGTM

Patch applied.

> please backport this one too

Done.

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list. Fixes gapless decoding.

2016-09-22 Thread Sasi Inguva
friendly ping

On Tue, Sep 20, 2016 at 2:29 PM, Sasi Inguva  wrote:

> Signed-off-by: Sasi Inguva 
> ---
>  libavcodec/utils.c   | 15 +++---
>  libavformat/mov.c| 81
> 
>  tests/ref/fate/gaplessenc-itunes-to-ipod-aac |  2 +-
>  tests/ref/fate/gaplessenc-pcm-to-mov-aac |  2 +-
>  4 files changed, 78 insertions(+), 22 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index b0345b6..e18476c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2320,7 +2320,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext
> *avctx,
>  uint32_t discard_padding = 0;
>  uint8_t skip_reason = 0;
>  uint8_t discard_reason = 0;
> -int demuxer_skip_samples = 0;
>  // copy to ensure we do not change avpkt
>  AVPacket tmp = *avpkt;
>  int did_split = av_packet_split_side_data();
> @@ -2328,7 +2327,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext
> *avctx,
>  if (ret < 0)
>  goto fail;
>
> -demuxer_skip_samples = avctx->internal->skip_samples;
>  avctx->internal->pkt = 
>  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
>  ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr,
> );
> @@ -2353,13 +2351,6 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext
> *avctx,
>  frame->sample_rate = avctx->sample_rate;
>  }
>
> -
> -if (frame->flags & AV_FRAME_FLAG_DISCARD) {
> -// If using discard frame flag, ignore skip_samples set by
> the decoder.
> -avctx->internal->skip_samples = demuxer_skip_samples;
> -*got_frame_ptr = 0;
> -}
> -
>  side= av_packet_get_side_data(avctx->internal->pkt,
> AV_PKT_DATA_SKIP_SAMPLES, _size);
>  if(side && side_size>=10) {
>  avctx->internal->skip_samples = AV_RL32(side);
> @@ -2369,6 +2360,12 @@ int attribute_align_arg 
> avcodec_decode_audio4(AVCodecContext
> *avctx,
>  skip_reason = AV_RL8(side + 8);
>  discard_reason = AV_RL8(side + 9);
>  }
> +
> +if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr) {
> +avctx->internal->skip_samples -= frame->nb_samples;
> +*got_frame_ptr = 0;
> +}
> +
>  if (avctx->internal->skip_samples > 0 && *got_frame_ptr &&
>  !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
>  if(frame->nb_samples <= avctx->internal->skip_samples){
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index b84d9c0..bb86780 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2856,6 +2856,21 @@ static int64_t add_index_entry(AVStream *st,
> int64_t pos, int64_t timestamp,
>  }
>
>  /**
> + * Rewrite timestamps of index entries in the range [end_index -
> frame_duration_buffer_size, end_index)
> + * by subtracting end_ts successively by the amounts given in
> frame_duration_buffer.
> + */
> +static void fix_index_entry_timestamps(AVStream* st, int end_index,
> int64_t end_ts,
> +   int64_t* frame_duration_buffer,
> +   int frame_duration_buffer_size) {
> +int i = 0;
> +av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
> +for (i = 0; i < frame_duration_buffer_size; i++) {
> +end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 -
> i];
> +st->index_entries[end_index - 1 - i].timestamp = end_ts;
> +}
> +}
> +
> +/**
>   * Append a new ctts entry to ctts_data.
>   * Returns the new ctts_count if successful, else returns -1.
>   */
> @@ -2919,7 +2934,10 @@ static void mov_fix_index(MOVContext *mov, AVStream
> *st)
>  int64_t edit_list_media_time_dts = 0;
>  int64_t edit_list_start_encountered = 0;
>  int64_t search_timestamp = 0;
> -
> +int64_t* frame_duration_buffer = NULL;
> +int num_discarded_begin = 0;
> +int first_non_zero_audio_edit = -1;
> +int packet_skip_samples = 0;
>
>  if (!msc->elst_data || msc->elst_count <= 0) {
>  return;
> @@ -2955,6 +2973,7 @@ static void mov_fix_index(MOVContext *mov, AVStream
> *st)
>  edit_list_index++;
>  edit_list_dts_counter = edit_list_dts_entry_end;
>  edit_list_dts_entry_end += edit_list_duration;
> +num_discarded_begin = 0;
>  if (edit_list_media_time == -1) {
>  continue;
>  }
> @@ -2962,7 +2981,14 @@ static void mov_fix_index(MOVContext *mov, AVStream
> *st)
>  // If we encounter a non-negative edit list reset the
> skip_samples/start_pad fields and set them
>  // according to the edit list below.
>  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
> -st->skip_samples = msc->start_pad = 0;
> +if (first_non_zero_audio_edit