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

2018-03-19 Thread Lou Logan
On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  60 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 486
>  +++>  libavfilter/allfilters.c | 
>   1 +
>  4 files changed, 548 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bd43a7ac6e..c298054325 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -3218,6 +3218,66 @@ Change highpass width.
>  Syntax for the command is : "@var{width}"
>  @end table
> 
> +@section hrtfm
> +
> +Apply simple Head Related Transfer Function Model to audio stream.
> +
> +hrtfm filter creates virtual loudspeakers around the user for
> binaural> +listening via headphones (audio formats up to 9 channels 
> supported).> +
> +This is very simple implementation which does not use any HRIRs.
> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item hradius

You didn’t like the head_radius option name suggestion?

> +Set head radius of listener. In meters. Default value is
> @code{0.0891}.
Why meters instead of cm? 

> +@item sspeed

No sound_speed option name?

> +Set sound speed in meters per second. Default value is @code{334}.
> +Allowed range is from @code{300} to @code{400}.
> +
> +@item amin
> +Set minimum alfa. Default value is @code{0.05}.

s/alfa/alpha

> +Allowed range is from @code{0.01} to @code{1}.
> +
> +@item gain
> +Set output gain in dB. Default value is @code{0}.
> +Allowed range is from @code{-20} to @code{40}.
> +
> +@item rotation
> +Set rotation of virtual loudspeakers in deg. Default is @code{0}.

s/deg/degrees

> +Allowed range is from @code{-360} to @code{360}.
> +
> +@item elevation
> +Set elevation of virtual speakers in deg. Default is @code{0}.

s/deg/degrees

> +Allowed range is from @code{-90} to @code{90}.
> +
> +@item speakers
> +Set custom positions of virtual loudspeakers. Syntax for this
> option is:> +  [|  |...].

Could use some sort of texinfo formatting. 

> +Each virtual loudspeaker is described with short channel name
> following with> +azimuth and elevation in degrees.
> +Each virtual loudspeaker description is separated by '|'.
> +For example to override front left and front right channel
> positions use:> +'speakers=FL 45 15|FR 345 15'.

Same as above. 

> +Descriptions with unrecognised channel names are ignored.
> +
> +@item lfegain
> +Set LFE gain in dB. Default value is @code{0}.
> +Allowed range is from @code{-11} to @code{11}.
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Apply filter with custom head radius, speed of sound and
> minimum alpha:> +@example
> +hrtfm=hradius=0.09:sspeed=334:amin=0.01
> +@end example
> +@end itemize
> +

Thanks for the example. No other comments from me. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH V3 04/11] lavc/dump_extradata_bsf: support dump options.

2018-03-19 Thread Jun Zhao
Ping? 

Anybody will help to review or apply:

Subject: [PATCH V3 04/11] lavc/dump_extradata_bsf: support dump options.
Subject: [PATCH V3 09/11] lavc/noise_bsf: support dump options.
Subject: [PATCH V3 10/11] lavc/remove_extradata_bsf: support dump options.
Subject: [PATCH V3 11/11] doc/fftools-common-opts: allow printing bsf details. 

patches 1-3, 5-8 have been pushed, Tks.

On 2018/3/14 13:42, Jun Zhao wrote:

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


Re: [FFmpeg-devel] [PATCH v2] lavf/movenc: write track title metadata for mov files

2018-03-19 Thread Courtland Idstrom
>
> Are you sure this is correct? The links above describe '©nam' as the
> title of the content, and 'name' as 'Name of Object", whatever that is
> supposed to mean.
>

From the spec, '©nam' appears to be a localized entry, which can also be
set per-track in Quicktime (exposed via their annotations editor). Name
appears to be the primary non-localized field used to identify the track,
which is the value I'm looking to set. I started with a Quicktime file as
my target (for some post production work), and worked backwards to figure
out how this field was encoded.


> Does this match what the MP4 spec says for 'name'?
>

I'm not familiar with the MP4 spec -- the specs I found online included the
definition of the user-data 'udta' section, but only one enumerated child
atom, which is copyright.

Any advice here? It's a requirement for my project that I set this field,
and the way it's being used for mp4 seemed exactly like what I wanted for
mov, and works perfectly. I submitted an earlier patch which included this
as an optional feature behind a flag, and I got a suggestion that since
it's a well-defined field, that perhaps it didn't need to be optional.

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


[FFmpeg-devel] [PATCH 1/3] avcodec/h264_metadata: fix memory leak in case of output packet creation failure

2018-03-19 Thread James Almer
Some function calls may fail after the output packet is initialized.

Signed-off-by: James Almer 
---
 libavcodec/h264_metadata_bsf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index e1f0c43b71..0381e9d102 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -545,6 +545,8 @@ fail:
 ff_cbs_fragment_uninit(ctx->cbc, au);
 av_freep(&displaymatrix_side_data);
 
+if (err < 0)
+av_packet_unref(&out);
 av_packet_free(&in);
 
 return err;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 2/3] avcodec/h265_metadata: fix memory leak in case of output packet creation failure

2018-03-19 Thread James Almer
Some function calls may fail after the output packet is initialized.

Signed-off-by: James Almer 
---
 libavcodec/h265_metadata_bsf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 8759e410f3..59ea67f718 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -324,6 +324,8 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket 
*out)
 fail:
 ff_cbs_fragment_uninit(ctx->cbc, au);
 
+if (err < 0)
+av_packet_unref(&out);
 av_packet_free(&in);
 
 return err;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 3/3] avcodec/mpeg2_metadata: fix memory leak in case of output packet creation failure

2018-03-19 Thread James Almer
Some function calls may fail after the output packet is initialized.

Signed-off-by: James Almer 
---
 libavcodec/mpeg2_metadata_bsf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index 6d5f581ab1..aa447db0b8 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -218,6 +218,8 @@ static int mpeg2_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 fail:
 ff_cbs_fragment_uninit(ctx->cbc, frag);
 
+if (err < 0)
+av_packet_unref(&out);
 av_packet_free(&in);
 
 return err;
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH v3 5/7] lavf, lavd: add AVClass for lavd & use iterate API

2018-03-19 Thread Michael Niedermayer
On Mon, Mar 19, 2018 at 07:35:39PM +, Josh de Kock wrote:
> Add an AVClass for AVDevice as the .child_class_next member for lavf's
> AVClass will no longer find devices.
> ---
>  fftools/cmdutils.c |  10 +
>  fftools/ffmpeg_opt.c   |   2 +-
>  libavdevice/Makefile   |   1 +
>  libavdevice/avdevice.h |   1 +
>  libavdevice/options.c  | 115 
> +
>  libavformat/options.c  |  46 +++-
>  6 files changed, 154 insertions(+), 21 deletions(-)
>  create mode 100644 libavdevice/options.c

this breaks
./ffmpeg -i somevideo.mp4 -encryption_key 0123456789abcdef0011223344556677  
-encryption_iv aabbccddeeff1133557799987654 crypto:file-crypt.nut

Unrecognized option 'encryption_iv'.
Error splitting the argument list: Option not found

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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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


[FFmpeg-devel] Asynchronously delivering data to FFmpeg, and extending the API to do this...

2018-03-19 Thread Philip Prindeville
Hi all,

I’m looking at the API and trying to figure out how to adapt it to our use, but 
without much luck.  If I get this working, I’ll try to upstream the enhancement 
in case it’s generically useful.

The problem in a nutshell is we’re using libevent2 and everything is 
event-driven, including notifications about data arriving from the network.

So rather than using avio_alloc_context() where the read_packet() function does 
a blocking read on a socket, I need to do the inverse: call a function which 
collects data until it’s parsed a complete frame, then return an indication of 
that.

Maybe something like:

bool avio_collect_frame(AVIOContext *avio, uint_t *ptr, size_t *size);

where it’s called with an AVIOContext where data is accumulated internally (and 
parsed), ptr is a pointer to the new data being presented, and size is a 
pointer to the number of bytes available (it may get rewritten with the number 
of bytes actually used… or it could just save the overflow from the current 
frame and use it for the subsequent frame).

Then in the (read) event handler for data arriving on a socket, we pass each 
new block to data to this function until it returns true.  When it returns 
true, then we activate an event to decode/render the frame (or handle it 
however else we might want to).

i.e. something like:

struct event *ev_render;

…


ev_render = event_new(evbase, -1, 0, render_cb, ctx);
event_add(ev_render, NULL);


and to fire the renderer:

bytes = bp->size;
if (avio_collect_frame(avio, bp->base, &bytes))
event_active(ev_render, 0, 1);

etc.

What’s involved in doing this?

Thanks,

-Philip

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


Re: [FFmpeg-devel] [PATCH] avcodec/vp9_superframe_split: move the reference in the bsf internal buffer

2018-03-19 Thread James Almer
On 3/19/2018 4:22 PM, James Almer wrote:
> On 3/16/2018 7:39 PM, James Almer wrote:
>> There's no need to allocate a new packet for it.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/vp9_superframe_split_bsf.c | 21 ++---
>>  1 file changed, 10 insertions(+), 11 deletions(-)
>>
>> diff --git a/libavcodec/vp9_superframe_split_bsf.c 
>> b/libavcodec/vp9_superframe_split_bsf.c
>> index 0d2523ebf7..7b6fa38554 100644
>> --- a/libavcodec/vp9_superframe_split_bsf.c
>> +++ b/libavcodec/vp9_superframe_split_bsf.c
>> @@ -30,7 +30,7 @@
>>  #include "get_bits.h"
>>  
>>  typedef struct VP9SFSplitContext {
>> -AVPacket *buffer_pkt;
>> +AVPacket buffer_pkt;
>>  
>>  int nb_frames;
>>  int next_frame;
>> @@ -43,13 +43,13 @@ static int vp9_superframe_split_filter(AVBSFContext 
>> *ctx, AVPacket *out)
>>  VP9SFSplitContext *s = ctx->priv_data;
>>  AVPacket *in;
>>  int i, j, ret, marker;
>> -int is_superframe = !!s->buffer_pkt;
>> +int is_superframe = !!s->buffer_pkt.data;
>>  
>> -if (!s->buffer_pkt) {
>> -ret = ff_bsf_get_packet(ctx, &s->buffer_pkt);
>> +if (!s->buffer_pkt.data) {
>> +ret = ff_bsf_get_packet_ref(ctx, &s->buffer_pkt);
>>  if (ret < 0)
>>  return ret;
>> -in = s->buffer_pkt;
>> +in = &s->buffer_pkt;
>>  
>>  marker = in->data[in->size - 1];
>>  if ((marker & 0xe0) == 0xc0) {
>> @@ -90,7 +90,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, 
>> AVPacket *out)
>>  GetBitContext gb;
>>  int profile, invisible = 0;
>>  
>> -ret = av_packet_ref(out, s->buffer_pkt);
>> +ret = av_packet_ref(out, &s->buffer_pkt);
>>  if (ret < 0)
>>  goto fail;
>>  
>> @@ -101,7 +101,7 @@ static int vp9_superframe_split_filter(AVBSFContext 
>> *ctx, AVPacket *out)
>>  s->next_frame++;
>>  
>>  if (s->next_frame >= s->nb_frames)
>> -av_packet_free(&s->buffer_pkt);
>> +av_packet_unref(&s->buffer_pkt);
>>  
>>  ret = init_get_bits8(&gb, out->data, out->size);
>>  if (ret < 0)
>> @@ -121,20 +121,19 @@ static int vp9_superframe_split_filter(AVBSFContext 
>> *ctx, AVPacket *out)
>>  out->pts = AV_NOPTS_VALUE;
>>  
>>  } else {
>> -av_packet_move_ref(out, s->buffer_pkt);
>> -av_packet_free(&s->buffer_pkt);
>> +av_packet_move_ref(out, &s->buffer_pkt);
>>  }
>>  
>>  return 0;
>>  fail:
>> -av_packet_free(&s->buffer_pkt);
>> +av_packet_unref(&s->buffer_pkt);
>>  return ret;
>>  }
>>  
>>  static void vp9_superframe_split_uninit(AVBSFContext *ctx)
>>  {
>>  VP9SFSplitContext *s = ctx->priv_data;
>> -av_packet_free(&s->buffer_pkt);
>> +av_packet_unref(&s->buffer_pkt);
>>  }
>>  
>>  const AVBitStreamFilter ff_vp9_superframe_split_bsf = {
> 
> Will apply later today.
> 

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


Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-19 Thread Michael Niedermayer
On Mon, Mar 19, 2018 at 09:31:44AM +0100, Tobias Rapp wrote:
> On 14.03.2018 09:55, Tobias Rapp wrote:
> >Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
> >using a distinct command-line option, similar to other flag options.
> >Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
> >to the "loglevel" option value.
> >
> >Signed-off-by: Tobias Rapp 
> >---
> >  doc/fftools-common-opts.texi | 13 +
> >  fftools/cmdutils.c   | 31 +++
> >  fftools/cmdutils.h   |  6 ++
> >  3 files changed, 50 insertions(+)
> >
> >[...]
> 
> Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on the
> CLI. Using the existing flags option string parsing functions seemed easier
> and more consistent that extending the custom loglevel string parser.

this means the feature would require every user app to add similar code
if one wants to support it.

it would be better if apps do not need changes for added options

[...]
-- 
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: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg][PATCH] lavc/cfhd: introduced interlaced using temporal horizontal transform

2018-03-19 Thread Michael Niedermayer
On Mon, Mar 19, 2018 at 03:17:59PM +0530, Gagandeep Singh wrote:
> interlaced files require horizontal-temporal transform that has been added.
> Output is not satisfactory yet!
> ---
>  libavcodec/cfhd.c | 137 
> +-
>  libavcodec/cfhd.h |   3 +-
>  2 files changed, 107 insertions(+), 33 deletions(-)

This seems not to apply cleanly on top of master

error: patch failed: libavcodec/cfhd.c:196
error: libavcodec/cfhd.c: patch does not apply
Patch failed at 0001 lavc/cfhd: introduced interlaced using temporal horizontal 
transform
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


[FFmpeg-devel] [PATCH] avformat/mov: Check STSC and remove invalid entries

2018-03-19 Thread Michael Niedermayer
Fixes assertion failure
Fixes: crbug 822547, crbug 822666 and crbug 823009

Affects: aark15sd_9A62E2FA.mp4

Found-by: ClusterFuzz
Reviewed-by: Matt Wolenetz 
Signed-off-by: Michael Niedermayer 
---
 libavformat/mov.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 232e59887e..075e833bad 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2655,6 +2655,21 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 
 sc->stsc_count = i;
+for (i = sc->stsc_count - 1; i < UINT_MAX; i--) {
+if ((i+1 < sc->stsc_count && sc->stsc_data[i].first >= 
sc->stsc_data[i+1].first) ||
+(i > 0 && sc->stsc_data[i].first <= sc->stsc_data[i-1].first) ||
+sc->stsc_data[i].first < 1 ||
+sc->stsc_data[i].count < 1 ||
+sc->stsc_data[i].id < 1) {
+av_log(c->fc, AV_LOG_WARNING, "STSC entry %d is invalid (first=%d 
count=%d id=%d)\n", i, sc->stsc_data[i].first, sc->stsc_data[i].count, 
sc->stsc_data[i].id);
+if (i+1 >= sc->stsc_count || sc->stsc_data[i+1].first < 2)
+return AVERROR_INVALIDDATA;
+// We replace this entry by the next valid
+sc->stsc_data[i].first = sc->stsc_data[i+1].first - 1;
+sc->stsc_data[i].count = sc->stsc_data[i+1].count;
+sc->stsc_data[i].id= sc->stsc_data[i+1].id;
+}
+}
 
 if (pb->eof_reached) {
 av_log(c->fc, AV_LOG_WARNING, "reached eof, corrupted STSC atom\n");
@@ -4144,6 +4159,11 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
st->index);
 return 0;
 }
+if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > 
sc->chunk_count) {
+av_log(c->fc, AV_LOG_ERROR, "stream %d, contradictionary STSC and 
STCO\n",
+   st->index);
+return AVERROR_INVALIDDATA;
+}
 
 fix_timescale(c, sc);
 
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH]lavfi/deshake: Check alignment before calling asm init function

2018-03-19 Thread Carl Eugen Hoyos
2018-03-16 20:02 GMT+01:00, James Almer :
> On 3/16/2018 3:55 PM, Carl Eugen Hoyos wrote:

>> +aligned = !((unsigned long)in->data[0] & 15 | in->linesize[0] & 15);
>
> Should be intptr_t, not unsigned long.

Definitely, thank you!

Pushed with that change, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: Add OpenCL avgblur filter

2018-03-19 Thread Carl Eugen Hoyos
2018-03-18 19:50 GMT+01:00, Mark Thompson :
> On 18/03/18 18:36, Carl Eugen Hoyos wrote:
>> 2018-03-18 19:12 GMT+01:00, Mark Thompson :

[...]

> I was just wondering if there was any specific reason
> why you were encouraging it in this case

Because it is good practice.

> (I don't think I've seen you ask for it before,
> though I admit I wouldn't necessarily notice).
>
>>> The only source for anyone actually needing authorship
>>> information should be the commit history.
>>
>> FFmpeg is a superb example for a project where looking
>> at the commit history is not sufficient to find out about
>> authorship (this is just to explain that there are different,
>> not necessarily closely related issues at hand).
>
> I agree that this is true for older code in the repository

> (pre-git in particular).

No.

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


Re: [FFmpeg-devel] [PATCH] area changed:in cfhd height initialization was buggy for chroma plane

2018-03-19 Thread Carl Eugen Hoyos
2018-03-16 11:27 GMT+01:00, Gagandeep Singh :
> From: Gagandeep Singh 

> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index fd834b..a064cd1599 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -195,14 +195,14 @@ static int alloc_buffers(AVCodecContext *avctx)
>  int w8, h8, w4, h4, w2, h2;
>  int width  = i ? avctx->width  >> chroma_x_shift : avctx->width;
>  int height = i ? avctx->height >> chroma_y_shift : avctx->height;
> -ptrdiff_t stride = FFALIGN(width  / 8, 8) * 8;
> -height   = FFALIGN(height / 8, 2) * 8;
> +ptrdiff_t stride   = FFALIGN(width  / 8, 8) * 8;
> +if (chroma_y_shift) height = FFALIGN(height / 8, 2) * 8;
>  s->plane[i].width  = width;
>  s->plane[i].height = height;
>  s->plane[i].stride = stride;
>
>  w8 = FFALIGN(s->plane[i].width  / 8, 8);
> -h8 = FFALIGN(s->plane[i].height / 8, 2);
> +h8 = height / 8;

In addition to what was already discussed, this
patch "breaks" fate (it is of course our mistake
to use a broken test but you still have to fix the
issue now).

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


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Paul B Mahol
On 3/20/18, Carl Eugen Hoyos  wrote:
> 2018-03-19 21:49 GMT+01:00, Derek Buitenhuis :
>
>> libutvideo was handled 100% incorrectly. We hardcoded
>> libstdc++ as a dependency
>
> Which worked fine on osx (and all other systems that were
> ever tested).
>
> More important imo is that Jeff forgot to attach his patch.

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


Re: [FFmpeg-devel] [PATCH] lavfi: Add OpenCL avgblur filter

2018-03-19 Thread Mark Thompson
On 19/03/18 02:30, dylanf...@gmail.com wrote:
> From: drfer3 
> 
> Behaves like the existing avgblur filter, except working on OpenCL
> hardware frames. Takes exactly the same options.
> ---
>  configure   |   1 +
>  libavfilter/Makefile|   2 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/opencl/avgblur.cl   |  60 
>  libavfilter/opencl_source.h |   1 +
>  libavfilter/vf_avgblur_opencl.c | 328 
> 
>  6 files changed, 393 insertions(+)
>  create mode 100644 libavfilter/opencl/avgblur.cl
>  create mode 100644 libavfilter/vf_avgblur_opencl.c
> 
> diff --git a/configure b/configure
> index 0c5ed07a07..481d338caf 100755
> --- a/configure
> +++ b/configure
> @@ -3202,6 +3202,7 @@ aresample_filter_deps="swresample"
>  ass_filter_deps="libass"
>  atempo_filter_deps="avcodec"
>  atempo_filter_select="rdft"
> +avgblur_opencl_filter_deps="opencl"
>  azmq_filter_deps="libzmq"
>  blackframe_filter_deps="gpl"
>  boxblur_filter_deps="gpl"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fc16512e2c..1043b41d80 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -139,6 +139,8 @@ OBJS-$(CONFIG_ALPHAMERGE_FILTER) += 
> vf_alphamerge.o
>  OBJS-$(CONFIG_ASS_FILTER)+= vf_subtitles.o
>  OBJS-$(CONFIG_ATADENOISE_FILTER) += vf_atadenoise.o
>  OBJS-$(CONFIG_AVGBLUR_FILTER)+= vf_avgblur.o
> +OBJS-$(CONFIG_AVGBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o 
> \
> +opencl/avgblur.o
>  OBJS-$(CONFIG_BBOX_FILTER)   += bbox.o vf_bbox.o
>  OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
>  OBJS-$(CONFIG_BITPLANENOISE_FILTER)  += vf_bitplanenoise.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index cc423af738..3f67e321bf 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -149,6 +149,7 @@ static void register_all(void)
>  REGISTER_FILTER(ASS,ass,vf);
>  REGISTER_FILTER(ATADENOISE, atadenoise, vf);
>  REGISTER_FILTER(AVGBLUR,avgblur,vf);
> +REGISTER_FILTER(AVGBLUR_OPENCL, avgblur_opencl, vf);
>  REGISTER_FILTER(BBOX,   bbox,   vf);
>  REGISTER_FILTER(BENCH,  bench,  vf);
>  REGISTER_FILTER(BITPLANENOISE,  bitplanenoise,  vf);
> diff --git a/libavfilter/opencl/avgblur.cl b/libavfilter/opencl/avgblur.cl
> new file mode 100644
> index 00..6a8d70df93
> --- /dev/null
> +++ b/libavfilter/opencl/avgblur.cl
> @@ -0,0 +1,60 @@
> +/*
> + * Copyright (c) 2018 Dylan Fernando
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +
> +__kernel void avgblur_horiz(__write_only image2d_t dst,
> +__read_only  image2d_t src,
> +int rad)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_FILTER_NEAREST);
> +int2 loc = (int2)(get_global_id(0), get_global_id(1));
> +int2 size = (int2)(get_global_size(0), get_global_size(1));
> +
> +int count = 0;
> +float4 acc = (float4)(0,0,0,0);
> +
> +for (int xx = max(0, loc.x - rad); xx < min(loc.x + rad + 1, size.x); 
> xx++) {
> +count++;
> +acc += read_imagef(src, sampler, (int2)(xx, loc.y));
> +}
> +
> +write_imagef(dst, loc, acc / count);
> +}
> +
> +__kernel void avgblur_vert(__write_only image2d_t dst,
> +   __read_only  image2d_t src,
> +   int radv)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_FILTER_NEAREST);
> +int2 loc = (int2)(get_global_id(0), get_global_id(1));
> +int2 size = (int2)(get_global_size(0), get_global_size(1));
> +
> +int count = 0;
> +float4 acc = (float4)(0,0,0,0);
> +
> +for (int yy = max(0, loc.y - radv); yy < min(loc.y + radv + 1, size.y); 
> yy++) {
> +count++;
> +acc += read_imagef(src, sampler, (int2)(loc.x, yy));
> +}
> +
> +write_imagef(dst, loc, acc / count);
> +}
> diff --git a/libav

[FFmpeg-devel] [PATCH] avcodec/mediacodecdec: propagate SAR to h/w frames

2018-03-19 Thread Aman Gupta
From: Aman Gupta 

Allows consumers who are converting hardware buffers
to OpenGL textures to render the frames at the intended
display resolution.
---
 libavcodec/mediacodecdec_common.c | 13 +
 libavcodec/mediacodecdec_common.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index 635ee73486..437bffcd7c 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -205,6 +205,7 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
 frame->width = avctx->width;
 frame->height = avctx->height;
 frame->format = avctx->pix_fmt;
+frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
 
 if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
 frame->pts = av_rescale_q(info->presentationTimeUs,
@@ -414,6 +415,18 @@ static int mediacodec_dec_parse_format(AVCodecContext 
*avctx, MediaCodecDecConte
 width = s->crop_right + 1 - s->crop_left;
 height = s->crop_bottom + 1 - s->crop_top;
 
+AMEDIAFORMAT_GET_INT32(s->display_width,  "display-width",  0);
+AMEDIAFORMAT_GET_INT32(s->display_height, "display-height", 0);
+
+if (s->display_width && s->display_height) {
+AVRational sar = av_div_q(
+(AVRational){ s->display_width, s->display_height },
+(AVRational){ width, height });
+ff_set_sar(avctx, sar);
+} else {
+ff_set_sar(avctx, (AVRational){0,1});
+}
+
 av_log(avctx, AV_LOG_INFO,
 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
 "resulting dimensions width=%d height=%d\n",
diff --git a/libavcodec/mediacodecdec_common.h 
b/libavcodec/mediacodecdec_common.h
index 4f3b4f9fa5..023d4c5fa7 100644
--- a/libavcodec/mediacodecdec_common.h
+++ b/libavcodec/mediacodecdec_common.h
@@ -61,6 +61,8 @@ typedef struct MediaCodecDecContext {
 int crop_bottom;
 int crop_left;
 int crop_right;
+int display_width;
+int display_height;
 
 uint64_t output_buffer_count;
 
-- 
2.14.2

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


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Carl Eugen Hoyos
2018-03-19 21:49 GMT+01:00, Derek Buitenhuis :

> libutvideo was handled 100% incorrectly. We hardcoded
> libstdc++ as a dependency

Which worked fine on osx (and all other systems that were
ever tested).

More important imo is that Jeff forgot to attach his patch.

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


[FFmpeg-devel] [PATCH 3/3] hwcontext_opencl: Avoid deprecation warnings when built with post-1.2 headers

2018-03-19 Thread Mark Thompson
Matching the previous commit.  This is not applied to the installed header
because it could incorrectly suppress the warning inside user programs.
---
 libavutil/hwcontext_opencl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index a725a491e2..f1d9d80f07 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+
 #include 
 
 #include "config.h"
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 1/3] lavfi/opencl: Derive global work size from plane image sizes

2018-03-19 Thread Mark Thompson
Add a new function to find the global work size given the output image and
the required block alignment, then use it in the overlay, program and unsharp
filters.  Fixes the overlay and unsharp filters applying the kernel to
locations outside the frame when subsampled planes are present.
---
 libavfilter/opencl.c| 64 +
 libavfilter/opencl.h|  8 ++
 libavfilter/vf_overlay_opencl.c |  6 ++--
 libavfilter/vf_program_opencl.c |  8 +++---
 libavfilter/vf_unsharp_opencl.c | 16 +--
 5 files changed, 87 insertions(+), 15 deletions(-)

diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index 37afc41f8b..ae61667380 100644
--- a/libavfilter/opencl.c
+++ b/libavfilter/opencl.c
@@ -22,6 +22,7 @@
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_opencl.h"
 #include "libavutil/mem.h"
+#include "libavutil/pixdesc.h"
 
 #include "avfilter.h"
 #include "formats.h"
@@ -276,3 +277,66 @@ fail:
 av_freep(&src);
 return err;
 }
+
+int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx,
+  size_t *work_size,
+  AVFrame *frame, int plane,
+  int block_alignment)
+{
+cl_mem image;
+cl_mem_object_type type;
+size_t width, height;
+cl_int cle;
+
+if (frame->format != AV_PIX_FMT_OPENCL) {
+av_log(avctx, AV_LOG_ERROR, "Invalid frame format %s, "
+   "opencl required.\n", av_get_pix_fmt_name(frame->format));
+return AVERROR(EINVAL);
+}
+
+image = (cl_mem)frame->data[plane];
+if (!image) {
+av_log(avctx, AV_LOG_ERROR, "Plane %d required but not set.\n",
+   plane);
+return AVERROR(EINVAL);
+}
+
+cle = clGetMemObjectInfo(image, CL_MEM_TYPE, sizeof(type),
+ &type, NULL);
+if (cle != CL_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query object type of "
+   "plane %d: %d.\n", plane, cle);
+return AVERROR_UNKNOWN;
+}
+if (type != CL_MEM_OBJECT_IMAGE2D) {
+av_log(avctx, AV_LOG_ERROR, "Plane %d is not a 2D image.\n",
+   plane);
+return AVERROR(EINVAL);
+}
+
+cle = clGetImageInfo(image, CL_IMAGE_WIDTH,  sizeof(size_t),
+ &width, NULL);
+if (cle != CL_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query plane %d width: %d.\n",
+   plane, cle);
+return AVERROR_UNKNOWN;
+}
+
+cle = clGetImageInfo(image, CL_IMAGE_HEIGHT, sizeof(size_t),
+ &height, NULL);
+if (cle != CL_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query plane %d height: %d.\n",
+   plane, cle);
+return AVERROR_UNKNOWN;
+}
+
+if (block_alignment) {
+width  = FFALIGN(width,  block_alignment);
+height = FFALIGN(height, block_alignment);
+}
+
+work_size[0] = width;
+work_size[1] = height;
+
+return 0;
+}
diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 4d740c18ab..45fe2a2e27 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -84,4 +84,12 @@ int ff_opencl_filter_load_program(AVFilterContext *avctx,
 int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx,
 const char *filename);
 
+/**
+ * Find the work size needed needed for a given plane of an image.
+ */
+int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx,
+  size_t *work_size,
+  AVFrame *frame, int plane,
+  int block_alignment);
+
 #endif /* AVFILTER_OPENCL_H */
diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index ee8381dfee..16e10f4371 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -216,8 +216,10 @@ static int overlay_opencl_blend(FFFrameSync *fs)
 goto fail_kernel_arg;
 }
 
-global_work[0] = output->width;
-global_work[1] = output->height;
+err = ff_opencl_filter_work_size_from_image(avctx, global_work,
+output, plane, 0);
+if (err < 0)
+goto fail;
 
 cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
  global_work, NULL, 0, NULL, NULL);
diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c
index 4ee9668236..0bcf188ac7 100644
--- a/libavfilter/vf_program_opencl.c
+++ b/libavfilter/vf_program_opencl.c
@@ -142,10 +142,10 @@ static int program_opencl_run(AVFilterContext *avctx)
 }
 }
 
-cle = clGetImageInfo(dst, CL_IMAGE_WIDTH,  sizeof(size_t),
- &global_work[0], NULL);
-cle = clGetIm

[FFmpeg-devel] [PATCH 2/3] lavif/opencl: Avoid deprecation warnings when built with post-1.2 headers

2018-03-19 Thread Mark Thompson
The intended target is OpenCL 1.2, so disable warnings for APIs deprecated
after that.  This primarily applies to clCreateCommandQueue(), we can't use
the replacement clCreateCommandQueueWithProperties() because it was
introduced in OpenCL 2.0.

Also remove some unnecessary includes from overlay and program filters so
that the define is available at the right moment.
---
 libavfilter/opencl.h| 6 ++
 libavfilter/vf_overlay_opencl.c | 8 +---
 libavfilter/vf_program_opencl.c | 6 +-
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 45fe2a2e27..c0a4519785 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -19,6 +19,12 @@
 #ifndef AVFILTER_OPENCL_H
 #define AVFILTER_OPENCL_H
 
+// The intended target is OpenCL 1.2, so disable warnings for APIs
+// deprecated after that.  This primarily applies to clCreateCommandQueue(),
+// we can't use the replacement clCreateCommandQueueWithProperties() because
+// it was introduced in OpenCL 2.0.
+#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
+
 #include "libavutil/buffer.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_opencl.h"
diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c
index 16e10f4371..b43050df58 100644
--- a/libavfilter/vf_overlay_opencl.c
+++ b/libavfilter/vf_overlay_opencl.c
@@ -16,16 +16,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/avassert.h"
-#include "libavutil/buffer.h"
-#include "libavutil/common.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_opencl.h"
 #include "libavutil/log.h"
-#include "libavutil/mathematics.h"
 #include "libavutil/mem.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 
 #include "avfilter.h"
 #include "framesync.h"
diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c
index 0bcf188ac7..a0027923fb 100644
--- a/libavfilter/vf_program_opencl.c
+++ b/libavfilter/vf_program_opencl.c
@@ -17,14 +17,10 @@
  */
 
 #include "libavutil/avstring.h"
-#include "libavutil/buffer.h"
-#include "libavutil/common.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_opencl.h"
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 
 #include "avfilter.h"
 #include "framesync.h"
-- 
2.16.1

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


Re: [FFmpeg-devel] [PATCH v2] lavf/movenc: write track title metadata for mov files

2018-03-19 Thread Derek Buitenhuis
On 3/19/2018 9:11 PM, Courtland Idstrom wrote:
> Track title (atom 'name') is a well defined user data atom for mov files. 
> Existing code (for mp4) only writes title metadata if present.
> 
> Relevant reference docs:
> 
>   
> https://developer.apple.com/library/content/documentation/QuickTime/Reference/QTRef_AtomsResources/Content/QTRef_AtomsResources4.html#//apple_ref/doc/uid/TP40004285-DontLinkChapterID_1--udta-
>   
> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-63839
> ---
>  libavformat/movenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Are you sure this is correct? The links above describe '©nam' as the
title of the content, and 'name' as 'Name of Object", whatever that is
supposed to mean.

Does this match what the MP4 spec says for 'name'?

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


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Rostislav Pehlivanov
On 19 March 2018 at 20:57, Nicolas George  wrote:

> Derek Buitenhuis (2018-03-19):
> > libutvideo was handled 100% incorrectly. We hardcoded libstdc++ as a
> > dependency, but the proper solution was to link with CXX instead of CC.
>
> This is not a *proper* solution, since it does not scale to the case
> where several languages all have that requirement. If the OpenCV people
> want to drop C support, then C apps should drop OpenCV support.
>
> Regards,
>
> --
>   Nicolas George
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Yeah, I agree, I don't think vf_opencv is very useful and we ought to drop
it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2018-03-19 Thread Paul B Mahol
On 3/19/18, Nicolas George  wrote:
> Paul B Mahol (2018-03-19):
>> No I will not!
>
> Changes are to be sent to the mailing-list, that is the policy. You are
> not allowed to change it unilaterally.

I'm not aware of such policy.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Derek Buitenhuis
On 3/19/2018 8:57 PM, Nicolas George wrote:
> Derek Buitenhuis (2018-03-19):
>> libutvideo was handled 100% incorrectly. We hardcoded libstdc++ as a
>> dependency, but the proper solution was to link with CXX instead of CC.
> 
> This is not a *proper* solution, since it does not scale to the case
> where several languages all have that requirement. If the OpenCV people
> want to drop C support, then C apps should drop OpenCV support.

If you want to link with a C++ library that is indeed the 'proper' solution.
As far as I am aware "several languages all have that requirement" is simply
a theoretical scenario that doesn't actually exist. What else beside C++
requires this?

Regardless, I agree that dropping OpenCV support is the likely outcome
or "solution" here.

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


[FFmpeg-devel] [PATCH v2] lavf/movenc: write track title metadata for mov files

2018-03-19 Thread Courtland Idstrom
Track title (atom 'name') is a well defined user data atom for mov files. 
Existing code (for mp4) only writes title metadata if present.

Relevant reference docs:

  
https://developer.apple.com/library/content/documentation/QuickTime/Reference/QTRef_AtomsResources/Content/QTRef_AtomsResources4.html#//apple_ref/doc/uid/TP40004285-DontLinkChapterID_1--udta-
  
https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP4939-CH204-63839
---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b1e66c897..ca15a00265 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3027,7 +3027,7 @@ static int mov_write_track_udta_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 if (ret < 0)
 return ret;
 
-if (mov->mode & MODE_MP4)
+if (mov->mode & (MODE_MP4|MODE_MOV))
 mov_write_track_metadata(pb_buf, st, "name", "title");
 
 if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {
-- 
2.14.3 (Apple Git-98)

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


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Nicolas George
Derek Buitenhuis (2018-03-19):
> libutvideo was handled 100% incorrectly. We hardcoded libstdc++ as a
> dependency, but the proper solution was to link with CXX instead of CC.

This is not a *proper* solution, since it does not scale to the case
where several languages all have that requirement. If the OpenCV people
want to drop C support, then C apps should drop OpenCV support.

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 2/2] ffmpeg: do not finish output streams manually on eof even if no input is provided

2018-03-19 Thread Marton Balint



On Mon, 19 Mar 2018, Michael Niedermayer wrote:


On Sun, Mar 18, 2018 at 08:09:09PM +0100, Marton Balint wrote:

The generic code should be able to finish the streams just fine initializing
and flushing the filters and codecs properly.

Signed-off-by: Marton Balint 
---
 fftools/ffmpeg.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)


This changes:
./ffmpeg -i ~/tickets/3015/test_video -filter:a apad -f flv -vcodec flv -ar 
22050 -shortest test.flv

Didnt investigate beyond a quick look which didnt tell me anything.
If the change is good this could be turned into a fate test


Change seems good, before the change no audio stream was written, after 
the change an audio stream is written with the same length as the video, 
so the command line (using -shortest with apad filter) actually starting 
to make sense.


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


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Derek Buitenhuis
On 3/19/2018 5:01 PM, Jan Ekström wrote:
> On Mon, Mar 19, 2018 at 6:28 PM, wm4  wrote:
>> On Mon, 19 Mar 2018 09:35:22 -0400
>> Jeff Cook  wrote:
>>
>>> Hello,
>>>
>>> Please see the bug report at https://github.com/opencv/opencv/issues/10963 
>>> , which discusses OpenCV's failure to build as pure C since upstream 
>>> version 3.4.1, and also discusses how all modules that use OpenCV 2 or 
>>> later should be compiled as C++ to avoid esoteric issues and serious 
>>> breakages.
>>>
>>> There is a large amount of discussion there that I don't want to needlessly 
>>> duplicate and/or badly summarize here, but the high-level overview is that 
>>> it seems that ffmpeg will need to convert avfilter/vf_opencv.c to build as 
>>> C++ if the OpenCV filter is going to continue to work. The current 
>>> situation is affecting many prominent projects like VLC.
>>
>> FFmpeg is a C project, and due to missing features in C++ (initializers)
>> it's very awkward to build things in C++ mode. Can't OpenCV just fix
>> their stuff.
>>
> 
> https://github.com/opencv/opencv/issues/8438#issuecomment-288638915
> 
> tl;dr
> 
> They're breaking C compatibility knowingly. If and only if we want to
> keep whatever features we get by linking against OpenCV, then the
> correct mode of operation is to make that specific file compile as C++
> and export the relevant C end points. Or maybe just link with the C++
> side of things; whatever was done with libutvideo back in the day?

As the author of that...

libutvideo was handled 100% incorrectly. We hardcoded libstdc++ as a
dependency, but the proper solution was to link with CXX instead of CC.

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


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

2018-03-19 Thread Nicolas George
Paul B Mahol (2018-03-19):
> No I will not!

Changes are to be sent to the mailing-list, that is the policy. You are
not allowed to change it unilaterally.

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] avfilter: add hrtfm filter

2018-03-19 Thread Paul B Mahol
On 3/19/18, Nicolas George  wrote:
> Paul B Mahol (2018-03-19):
>> If there are no more comments, I would like to push
>> an improved version of this.
>
> If it is changed compared to what was sent to the mailing-list, re-send
> it to the mailing-list.

No I will not! And what can you do to me?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 3/7] cmdutils: use new iteration APIs

2018-03-19 Thread Nicolas George
Josh de Kock (2018-03-19):
> +x(av_muxer_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS && 
> !device_only);
> +x(av_demuxer_iterate, ifmt, muxdemuxers != SHOW_MUXERS && 
> !device_only);
> +#if CONFIG_AVDEVICE
> +x(av_outdev_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS);
> +x(av_indev_iterate, ifmt, muxdemuxers != SHOW_MUXERS);
> +#endif
> +#undef x

Nack.

If applications need to do that kind of stunt to enumerate devices, they
will not bother doing it, thus losing features in a few unusual cases
and reducing the testing coverage of lavd by users.

Since indevs and demuxers behave the same way and outdevs and muxers
ditto, the default API need to return them all once.

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] avfilter: add hrtfm filter

2018-03-19 Thread Nicolas George
Paul B Mahol (2018-03-19):
> If there are no more comments, I would like to push
> an improved version of this.

If it is changed compared to what was sent to the mailing-list, re-send
it to the mailing-list.

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] avfilter: add hrtfm filter

2018-03-19 Thread Paul B Mahol
On 3/16/18, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  60 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 486
> +++
>  libavfilter/allfilters.c |   1 +
>  4 files changed, 548 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c
>

If there are no more comments, I would like to push
an improved version of this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 7/7] lavf/img2dec: use new iteration API

2018-03-19 Thread Josh de Kock
---
 libavformat/img2dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index f3f52c83b3..159617f046 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -324,6 +324,7 @@ int ff_img_read_header(AVFormatContext *s1)
 int probe_buffer_size = 2048;
 uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + 
AVPROBE_PADDING_SIZE);
 AVInputFormat *fmt = NULL;
+void *opaque = NULL;
 AVProbeData pd = { 0 };
 
 if (!probe_buffer)
@@ -340,7 +341,7 @@ int ff_img_read_header(AVFormatContext *s1)
 pd.buf_size = probe_buffer_size;
 pd.filename = s1->url;
 
-while ((fmt = av_iformat_next(fmt))) {
+while ((fmt = av_demuxer_iterate(&opaque))) {
 if (fmt->read_header != ff_img_read_header ||
 !fmt->read_probe ||
 (fmt->flags & AVFMT_NOFILE) ||
-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH v3 4/7] fftools/ff*.c: use iteration API to find formats

2018-03-19 Thread Josh de Kock
With the new API, if avdevice_register_all() isn't called
av_find_input_format() wont find devices, so switch to
the new API to make sure devices would always be checked if
they are available even if devices are not registered
through the old API.
---
 fftools/ffmpeg_opt.c | 25 +
 fftools/ffplay.c | 21 +++--
 fftools/ffprobe.c| 21 +++--
 3 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d7a7eb0662..45c26c391e 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -27,6 +27,10 @@
 
 #include "libavcodec/avcodec.h"
 
+#if CONFIG_AVDEVICE
+#include "libavdevice/avdevice.h"
+#endif
+
 #include "libavfilter/avfilter.h"
 
 #include "libavutil/avassert.h"
@@ -963,7 +967,7 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 {
 InputFile *f;
 AVFormatContext *ic;
-AVInputFormat *file_iformat = NULL;
+const AVInputFormat *file_iformat = NULL;
 int err, i, ret;
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
@@ -990,12 +994,25 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 }
 
 if (o->format) {
-if (!(file_iformat = av_find_input_format(o->format))) {
-av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", 
o->format);
-exit_program(1);
+void *opaque = NULL;
+
+while ((file_iformat = av_demuxer_iterate(&opaque))) {
+if (av_match_name(o->format, file_iformat->name))
+goto format_found;
 }
+#if CONFIG_AVDEVICE
+opaque = NULL;
+while ((file_iformat = av_indev_iterate(&opaque))) {
+if (av_match_name(o->format, file_iformat->name))
+goto format_found;
+}
+#endif
+av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
+exit_program(1);
 }
 
+format_found:
+
 if (!strcmp(filename, "-"))
 filename = "pipe:";
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index f2028d4b13..64da518d0c 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -307,7 +307,7 @@ typedef struct VideoState {
 } VideoState;
 
 /* options specified by the user */
-static AVInputFormat *file_iformat;
+static const AVInputFormat *file_iformat;
 static const char *input_filename;
 static const char *window_title;
 static int default_width  = 640;
@@ -3460,12 +3460,21 @@ static int opt_height(void *optctx, const char *opt, 
const char *arg)
 
 static int opt_format(void *optctx, const char *opt, const char *arg)
 {
-file_iformat = av_find_input_format(arg);
-if (!file_iformat) {
-av_log(NULL, AV_LOG_FATAL, "Unknown input format: %s\n", arg);
-return AVERROR(EINVAL);
+void *opaque = NULL;
+
+while ((file_iformat = av_demuxer_iterate(&opaque))) {
+if (av_match_name(arg, file_iformat->name))
+return 0;
 }
-return 0;
+#if CONFIG_AVDEVICE
+opaque = NULL;
+while ((file_iformat = av_indev_iterate(&opaque))) {
+if (av_match_name(arg, file_iformat->name))
+return 0;
+}
+#endif
+av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg);
+return AVERROR(EINVAL);
 }
 
 static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a4ac6972a2..931e321930 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -250,7 +250,7 @@ static const OptionDef *options;
 
 /* FFprobe context */
 static const char *input_filename;
-static AVInputFormat *iformat = NULL;
+static const AVInputFormat *iformat = NULL;
 
 static struct AVHashContext *hash;
 
@@ -3139,12 +3139,21 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
 
 static int opt_format(void *optctx, const char *opt, const char *arg)
 {
-iformat = av_find_input_format(arg);
-if (!iformat) {
-av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
-return AVERROR(EINVAL);
+void *opaque = NULL;
+
+while ((iformat = av_demuxer_iterate(&opaque))) {
+if (av_match_name(arg, iformat->name))
+return 0;
 }
-return 0;
+#if CONFIG_AVDEVICE
+opaque = NULL;
+while ((iformat = av_indev_iterate(&opaque))) {
+if (av_match_name(arg, iformat->name))
+return 0;
+}
+#endif
+av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg);
+return AVERROR(EINVAL);
 }
 
 static inline void mark_section_show_entries(SectionID section_id,
-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH v3 6/7] lav*, tests: remove several register_all() calls

2018-03-19 Thread Josh de Kock
---
 doc/examples/filter_audio.c  | 2 --
 doc/examples/filtering_audio.c   | 2 --
 doc/examples/filtering_video.c   | 2 --
 doc/examples/transcoding.c   | 2 --
 fftools/ffmpeg.c | 6 --
 fftools/ffplay.c | 7 ---
 fftools/ffprobe.c| 4 
 libavcodec/tests/utils.c | 1 -
 libavdevice/lavfi.c  | 2 --
 libavfilter/lavfutils.c  | 2 --
 libavfilter/src_movie.c  | 2 --
 libavfilter/tests/filtfmts.c | 2 --
 libavformat/tests/movenc.c   | 2 --
 libavformat/tests/seek.c | 3 ---
 tests/api/api-band-test.c| 2 --
 tests/api/api-codec-param-test.c | 2 --
 tests/api/api-flac-test.c| 2 --
 tests/api/api-h264-test.c| 2 --
 tests/api/api-seek-test.c| 2 --
 tools/aviocat.c  | 1 -
 tools/enum_options.c | 2 --
 tools/graph2dot.c| 2 --
 tools/ismindex.c | 2 --
 tools/pktdumper.c| 3 ---
 tools/probetest.c| 3 ---
 tools/seek_print.c   | 1 -
 tools/sidxindex.c| 2 --
 tools/uncoded_frame.c| 4 
 28 files changed, 69 deletions(-)

diff --git a/doc/examples/filter_audio.c b/doc/examples/filter_audio.c
index 7467c21c30..1611e3d952 100644
--- a/doc/examples/filter_audio.c
+++ b/doc/examples/filter_audio.c
@@ -289,8 +289,6 @@ int main(int argc, char *argv[])
 return 1;
 }
 
-avfilter_register_all();
-
 /* Allocate the frame we will be using to store the data. */
 frame  = av_frame_alloc();
 if (!frame) {
diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c
index 73a00e814c..b109dbcb96 100644
--- a/doc/examples/filtering_audio.c
+++ b/doc/examples/filtering_audio.c
@@ -228,8 +228,6 @@ int main(int argc, char **argv)
 exit(1);
 }
 
-avfilter_register_all();
-
 if ((ret = open_input_file(argv[1])) < 0)
 goto end;
 if ((ret = init_filters(filter_descr)) < 0)
diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 01d6644620..ed4e7bbd81 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -222,8 +222,6 @@ int main(int argc, char **argv)
 exit(1);
 }
 
-avfilter_register_all();
-
 if ((ret = open_input_file(argv[1])) < 0)
 goto end;
 if ((ret = init_filters(filter_descr)) < 0)
diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index ed1fd6411b..a83fa3a185 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -517,8 +517,6 @@ int main(int argc, char **argv)
 return 1;
 }
 
-avfilter_register_all();
-
 if ((ret = open_input_file(argv[1])) < 0)
 goto end;
 if ((ret = open_output_file(argv[2])) < 0)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ee7258fcd1..47236774ef 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4803,12 +4803,6 @@ int main(int argc, char **argv)
 argv++;
 }
 
-avcodec_register_all();
-#if CONFIG_AVDEVICE
-avdevice_register_all();
-#endif
-avfilter_register_all();
-av_register_all();
 avformat_network_init();
 
 show_banner(argc, argv, options);
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 64da518d0c..9fbe7490e5 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3661,13 +3661,6 @@ int main(int argc, char **argv)
 parse_loglevel(argc, argv, options);
 
 /* register all codecs, demux and protocols */
-#if CONFIG_AVDEVICE
-avdevice_register_all();
-#endif
-#if CONFIG_AVFILTER
-avfilter_register_all();
-#endif
-av_register_all();
 avformat_network_init();
 
 init_opts();
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 931e321930..67133383ef 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3576,12 +3576,8 @@ int main(int argc, char **argv)
 
 options = real_options;
 parse_loglevel(argc, argv, options);
-av_register_all();
 avformat_network_init();
 init_opts();
-#if CONFIG_AVDEVICE
-avdevice_register_all();
-#endif
 
 show_banner(argc, argv, options);
 parse_options(NULL, argc, argv, options, opt_input_file);
diff --git a/libavcodec/tests/utils.c b/libavcodec/tests/utils.c
index e2891fb389..f6ba7fe66e 100644
--- a/libavcodec/tests/utils.c
+++ b/libavcodec/tests/utils.c
@@ -21,7 +21,6 @@
 int main(void){
 AVCodec *codec = NULL;
 int ret = 0;
-avcodec_register_all();
 
 while (codec = av_codec_next(codec)) {
 if (av_codec_is_encoder(codec)) {
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 6f2ae958dc..ca8f05f3f7 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -130,8 +130,6 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
 if (!pix_fmts)
 FAIL(AVERROR(ENOMEM));
 
-avfilter_register_all();
-
 buffersink = avfilter_get_by_name("buffersink");
 abuffersink = avfilter_get_by_name("abuffe

[FFmpeg-devel] [PATCH v3 0/7] Implementation of option one

2018-03-19 Thread Josh de Kock
This set 'finishes' off the new API, it creates duct tape between the
lavd and lavf libraries such that the groundwork for separating them
is there, but lavd still requires lavf for the time-being. I have tagged
this set with v3 (while they may not all be v3), to redirect review to
this thread as it falls under the overarching discussion.

On 2018/03/19 18:08, Nicolas George wrote:
> I do not understand what "in their current state" means? Before the
> patches? After the patches? After half the patches but before the other
> half?

It's dependent on which route we take, options 2-4 wouldn't include this
set as they would be replaced by other sets:

2) would change the way this patch has interactions between lavf and lavd.
3) would remove the interactions between lavf and lavd as they would just
be the same library.
4) this set wouldnt exist.

Josh de Kock (7):
  checkasm/Makefile: add EXTRALIBS-libavformat
  lavfi: add new iteration API
  cmdutils: use new iteration APIs
  fftools/ff*.c: use iteration API to find formats
  lavf,lavd: add AVClass for lavd & use iterate API
  lav*,tests: remove several register_all() calls
  lavf/img2dec: use new iteration API

 configure|  24 +-
 doc/APIchanges   |   4 +
 doc/examples/filter_audio.c  |   2 -
 doc/examples/filtering_audio.c   |   2 -
 doc/examples/filtering_video.c   |   2 -
 doc/examples/transcoding.c   |   2 -
 doc/writing_filters.txt  |   6 +-
 fftools/cmdutils.c   | 249 ++--
 fftools/ffmpeg.c |   6 -
 fftools/ffmpeg_opt.c |  23 +-
 fftools/ffplay.c |  28 +-
 fftools/ffprobe.c|  25 +-
 libavcodec/tests/utils.c |   1 -
 libavdevice/Makefile |   1 +
 libavdevice/avdevice.h   |   1 +
 libavdevice/lavfi.c  |   2 -
 libavdevice/options.c| 115 ++
 libavfilter/allfilters.c | 818 ---
 libavfilter/avfilter.c   |  45 ---
 libavfilter/avfilter.h   |  29 +-
 libavfilter/lavfutils.c  |   2 -
 libavfilter/src_movie.c  |   2 -
 libavfilter/tests/filtfmts.c |   2 -
 libavfilter/version.h|   3 +
 libavformat/img2dec.c|   3 +-
 libavformat/options.c|  46 ++-
 libavformat/tests/movenc.c   |   2 -
 libavformat/tests/seek.c |   3 -
 tests/api/api-band-test.c|   2 -
 tests/api/api-codec-param-test.c |   2 -
 tests/api/api-flac-test.c|   2 -
 tests/api/api-h264-test.c|   2 -
 tests/api/api-seek-test.c|   2 -
 tests/checkasm/Makefile  |   2 +-
 tools/aviocat.c  |   1 -
 tools/enum_options.c |   2 -
 tools/graph2dot.c|   2 -
 tools/ismindex.c |   2 -
 tools/pktdumper.c|   3 -
 tools/probetest.c|   3 -
 tools/seek_print.c   |   1 -
 tools/sidxindex.c|   2 -
 tools/uncoded_frame.c|   4 -
 43 files changed, 795 insertions(+), 685 deletions(-)
 create mode 100644 libavdevice/options.c

-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH v3 3/7] cmdutils: use new iteration APIs

2018-03-19 Thread Josh de Kock
---
 fftools/cmdutils.c | 239 +
 1 file changed, 112 insertions(+), 127 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 708a849f51..2da313cc0a 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1250,19 +1250,11 @@ int show_license(void *optctx, const char *opt, const 
char *arg)
 return 0;
 }
 
-static int is_device(const AVClass *avclass)
-{
-if (!avclass)
-return 0;
-return AV_IS_INPUT_DEVICE(avclass->category) || 
AV_IS_OUTPUT_DEVICE(avclass->category);
-}
-
 static int show_formats_devices(void *optctx, const char *opt, const char 
*arg, int device_only, int muxdemuxers)
 {
-AVInputFormat *ifmt  = NULL;
-AVOutputFormat *ofmt = NULL;
+const AVInputFormat *ifmt  = NULL;
+const AVOutputFormat *ofmt = NULL;
 const char *last_name;
-int is_dev;
 
 printf("%s\n"
" D. = Demuxing supported\n"
@@ -1270,46 +1262,38 @@ static int show_formats_devices(void *optctx, const 
char *opt, const char *arg,
" --\n", device_only ? "Devices:" : "File formats:");
 last_name = "000";
 for (;;) {
-int decode = 0;
-int encode = 0;
+int is_ifmt = 0;
+int is_ofmt = 0;
 const char *name  = NULL;
 const char *long_name = NULL;
 
-if (muxdemuxers !=SHOW_DEMUXERS) {
-while ((ofmt = av_oformat_next(ofmt))) {
-is_dev = is_device(ofmt->priv_class);
-if (!is_dev && device_only)
-continue;
-if ((!name || strcmp(ofmt->name, name) < 0) &&
-strcmp(ofmt->name, last_name) > 0) {
-name  = ofmt->name;
-long_name = ofmt->long_name;
-encode= 1;
-}
-}
-}
-if (muxdemuxers != SHOW_MUXERS) {
-while ((ifmt = av_iformat_next(ifmt))) {
-is_dev = is_device(ifmt->priv_class);
-if (!is_dev && device_only)
-continue;
-if ((!name || strcmp(ifmt->name, name) < 0) &&
-strcmp(ifmt->name, last_name) > 0) {
-name  = ifmt->name;
-long_name = ifmt->long_name;
-encode= 0;
-}
-if (name && strcmp(ifmt->name, name) == 0)
-decode = 1;
-}
-}
+#define x(func, type, condition) do {   \
+void *i = 0;\
+if (condition) {\
+while ((type = func(&i))) { \
+if ((!name || strcmp(type->name, name) < 0) &&  \
+strcmp(type->name, last_name) > 0) {\
+name  = type->name; \
+long_name = type->long_name;\
+is_ ## type = 1;\
+}   \
+}   \
+} } while(0)
+
+x(av_muxer_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS && 
!device_only);
+x(av_demuxer_iterate, ifmt, muxdemuxers != SHOW_MUXERS && 
!device_only);
+#if CONFIG_AVDEVICE
+x(av_outdev_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS);
+x(av_indev_iterate, ifmt, muxdemuxers != SHOW_MUXERS);
+#endif
+#undef x
 if (!name)
 break;
 last_name = name;
 
 printf(" %s%s %-15s %s\n",
-   decode ? "D" : " ",
-   encode ? "E" : " ",
+   is_ifmt ? "D" : " ",
+   is_ofmt ? "E" : " ",
name,
 long_name ? long_name:" ");
 }
@@ -1439,15 +1423,45 @@ static char get_media_type_char(enum AVMediaType type)
 }
 }
 
-static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
-int encoder)
+
+static int compare_codec(const void *a, const void *b)
+{
+const AVCodec * const *ca = a;
+const AVCodec * const *cb = b;
+
+return strcmp((*ca)->name, (*cb)->name);
+}
+
+static unsigned get_codecs_sorted(enum AVCodecID id, const AVCodec ***rcodecs, 
int encoder)
 {
-while ((prev = av_codec_next(prev))) {
-if (prev->id == id &&
-(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
-return prev;
+const AVCodec *codec = NULL;
+const AVCodec **codecs;
+unsigned nb_codecs = 0, i = 0;
+void *opaque = 0;
+
+while ((codec = av_codec_iterate(&opaque))) {
+if (codec->id == id &&
+(encoder ? av_codec_is_encoder(codec) : 
av_codec_is_decoder(codec)))
+nb_codecs++;
+}
+
+if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs {
+av_log(NULL, 

[FFmpeg-devel] [PATCH v3 5/7] lavf, lavd: add AVClass for lavd & use iterate API

2018-03-19 Thread Josh de Kock
Add an AVClass for AVDevice as the .child_class_next member for lavf's
AVClass will no longer find devices.
---
 fftools/cmdutils.c |  10 +
 fftools/ffmpeg_opt.c   |   2 +-
 libavdevice/Makefile   |   1 +
 libavdevice/avdevice.h |   1 +
 libavdevice/options.c  | 115 +
 libavformat/options.c  |  46 +++-
 6 files changed, 154 insertions(+), 21 deletions(-)
 create mode 100644 libavdevice/options.c

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 2da313cc0a..88ff3ec87a 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -549,6 +549,9 @@ int opt_default(void *optctx, const char *opt, const char 
*arg)
 char opt_stripped[128];
 const char *p;
 const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
+#if CONFIG_AVDEVICE
+const AVClass *dc = avdevice_get_class();
+#endif
 #if CONFIG_AVRESAMPLE
 const AVClass *rc = avresample_get_class();
 #endif
@@ -580,6 +583,13 @@ int opt_default(void *optctx, const char *opt, const char 
*arg)
 av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and 
muxer layer\n", opt);
 consumed = 1;
 }
+#if CONFIG_AVDEVICE
+if ((o = opt_find(&dc, opt, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
+av_dict_set(&format_opts, opt, arg, FLAGS);
+consumed = 1;
+}
+#endif
 #if CONFIG_SWSCALE
 if (!consumed && (o = opt_find(&sc, opt, NULL, 0,
  AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 45c26c391e..82944c903a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -967,7 +967,7 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 {
 InputFile *f;
 AVFormatContext *ic;
-const AVInputFormat *file_iformat = NULL;
+AVInputFormat *file_iformat = NULL;
 int err, i, ret;
 int64_t timestamp;
 AVDictionary *unused_opts = NULL;
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index f11a6f2a86..65f7c2971d 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -7,6 +7,7 @@ HEADERS = avdevice.h
\
 OBJS= alldevices.o  \
   avdevice.o\
   utils.o   \
+  options.o
 
 OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
 OBJS-$(CONFIG_SHARED)+= reverse.o
diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
index dd6ad9365e..bacc2c3aad 100644
--- a/libavdevice/avdevice.h
+++ b/libavdevice/avdevice.h
@@ -535,6 +535,7 @@ int avdevice_list_input_sources(struct AVInputFormat 
*device, const char *device
 int avdevice_list_output_sinks(struct AVOutputFormat *device, const char 
*device_name,
AVDictionary *device_options, AVDeviceInfoList 
**device_list);
 
+const AVClass *avdevice_get_class(void);
 /**
  * @}
  */
diff --git a/libavdevice/options.c b/libavdevice/options.c
new file mode 100644
index 00..e9d79d7481
--- /dev/null
+++ b/libavdevice/options.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "libavformat/avformat.h"
+
+#include "libavdevice/avdevice.h"
+
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+
+/**
+ * @file
+ * Options definition for AVFormatContext.
+ */
+
+FF_DISABLE_DEPRECATION_WARNINGS
+//#include "options_table.h"
+static const AVOption avdevice_options[] = {
+{ NULL },
+};
+FF_ENABLE_DEPRECATION_WARNINGS
+
+static const char* device_to_name(void* ptr)
+{
+AVFormatContext* fc = (AVFormatContext*) ptr;
+if(fc->iformat) return fc->iformat->name;
+else if(fc->oformat) return fc->oformat->name;
+else return "NULL";
+}
+
+static void *device_child_next(void *obj, void *prev)
+{
+AVFormatContext *s = obj;
+if (!prev && s->priv_data &&
+((s->iformat && s->iformat->priv_class) ||
+  s->oformat && s->oformat->priv_class))
+return s->priv_data;
+if (s->

[FFmpeg-devel] [PATCH v3 2/7] lavfi: add new iteration API

2018-03-19 Thread Josh de Kock
---
 configure|  24 +-
 doc/APIchanges   |   4 +
 doc/writing_filters.txt  |   6 +-
 libavfilter/allfilters.c | 818 +--
 libavfilter/avfilter.c   |  45 ---
 libavfilter/avfilter.h   |  29 +-
 libavfilter/version.h|   3 +
 7 files changed, 477 insertions(+), 452 deletions(-)

diff --git a/configure b/configure
index 6b27f571c6..7533a30848 100755
--- a/configure
+++ b/configure
@@ -3559,15 +3559,6 @@ for v in "$@"; do
 FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
 done
 
-find_things(){
-thing=$1
-pattern=$2
-file=$source_path/$3
-sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
-}
-
-FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
-
 find_things_extern(){
 thing=$1
 pattern=$2
@@ -3576,6 +3567,13 @@ find_things_extern(){
 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
 }
 
+find_filters_extern(){
+file=$source_path/$1
+#sed -n "s/^extern AVFilter 
ff_\([avfsinkrc]\{2,5\}\)_\(\w\+\);/\2_filter/p" $file
+sed -E -n "s/^extern AVFilter 
ff_([avfsinkrc]{2,5})_([a-zA-Z0-9]+);/\2_filter/p" $file
+}
+
+FILTER_LIST=$(find_filters_extern libavfilter/allfilters.c)
 OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c 
outdev)
 INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c 
indev)
 MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
@@ -7085,6 +7083,10 @@ echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
 
 cp_if_changed $TMPH libavutil/avconfig.h
 
+full_filter_name(){
+sed -n "s/^extern AVFilter ff_\([avfsinkrc]\{2,5\}\)_$1;/\1_$1/p" 
$source_path/libavfilter/allfilters.c
+}
+
 # generate the lists of enabled components
 print_enabled_components(){
 file=$1
@@ -7095,6 +7097,9 @@ print_enabled_components(){
 for c in $*; do
 if enabled $c; then
 case $name in
+filter_list)
+c=$(full_filter_name $(remove_suffix _filter $c))
+;;
 indev_list)
 c=$(add_suffix _demuxer $(remove_suffix _indev $c))
 ;;
@@ -7109,6 +7114,7 @@ print_enabled_components(){
 cp_if_changed $TMPH $file
 }
 
+print_enabled_components libavfilter/filter_list.c AVFilter filter_list 
$FILTER_LIST
 print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
 print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list 
$PARSER_LIST
 print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter 
bitstream_filters $BSF_LIST
diff --git a/doc/APIchanges b/doc/APIchanges
index 4c0ee7147a..27cf2514d7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xxx - lavc 7.13.100 - avcodec.h
+  Deprecate use of avfilter_register(), avfilter_register_all(),
+  avfilter_next(). Add av_filter_iterate().
+
 2018-03-18 - xxx - lavu 56.11.100 - frame.h
   Add AV_FRAME_DATA_QP_TABLE_PROPERTIES and AV_FRAME_DATA_QP_TABLE_DATA.
 
diff --git a/doc/writing_filters.txt b/doc/writing_filters.txt
index 5cd4ecd6a4..98b9c6f3d2 100644
--- a/doc/writing_filters.txt
+++ b/doc/writing_filters.txt
@@ -31,10 +31,8 @@ If everything went right, you should get a foobar.png with 
Lena edge-detected.
 That's it, your new playground is ready.
 
 Some little details about what's going on:
-libavfilter/allfilters.c:avfilter_register_all() is called at runtime to create
-a list of the available filters, but it's important to know that this file is
-also parsed by the configure script, which in turn will define variables for
-the build system and the C:
+libavfilter/allfilters.c:this file is parsed by the configure script, which in 
turn
+will define variables for the build system and the C:
 
 --- after running configure ---
 
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index cc423af738..23773aed09 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -23,409 +23,451 @@
 #include "avfilter.h"
 #include "config.h"
 
+extern AVFilter ff_af_abench;
+extern AVFilter ff_af_acompressor;
+extern AVFilter ff_af_acontrast;
+extern AVFilter ff_af_acopy;
+extern AVFilter ff_af_acrossfade;
+extern AVFilter ff_af_acrusher;
+extern AVFilter ff_af_adelay;
+extern AVFilter ff_af_aecho;
+extern AVFilter ff_af_aemphasis;
+extern AVFilter ff_af_aeval;
+extern AVFilter ff_af_afade;
+extern AVFilter ff_af_afftfilt;
+extern AVFilter ff_af_afir;
+extern AVFilter ff_af_aformat;
+extern AVFilter ff_af_agate;
+extern AVFilter ff_af_aiir;
+extern AVFilter ff_af_ainterleave;
+extern AVFilter ff_af_alimiter;
+extern AVFilter ff_af_allpass;
+extern AVFilter ff_af_aloop;
+extern AVFilter ff_af_amerge;
+extern AVFilter ff_af_ametadata;
+extern AVFilter ff_af_amix;
+extern AVFilter ff_af_anequalizer;
+extern AVFilter ff_af_anull;

[FFmpeg-devel] [PATCH v3 1/7] checkasm/Makefile: add EXTRALIBS-libavformat

2018-03-19 Thread Josh de Kock
---
 tests/checkasm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 0520e264e2..ae7e810d25 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -61,7 +61,7 @@ tests/checkasm/checkasm.o: CFLAGS += -Umain
 CHECKASM := tests/checkasm/checkasm$(EXESUF)
 
 $(CHECKASM): $(CHECKASMOBJS) $(FF_STATIC_DEP_LIBS)
-   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) 
$(FF_STATIC_DEP_LIBS) $(EXTRALIBS-avcodec) $(EXTRALIBS-avfilter) 
$(EXTRALIBS-avutil) $(EXTRALIBS-swresample) $(EXTRALIBS)
+   $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) 
$(FF_STATIC_DEP_LIBS) $(EXTRALIBS-avcodec) $(EXTRALIBS-avfilter) 
$(EXTRALIBS-avformat) $(EXTRALIBS-avutil) $(EXTRALIBS-swresample) $(EXTRALIBS)
 
 checkasm: $(CHECKASM)
 
-- 
2.14.3 (Apple Git-98)

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


Re: [FFmpeg-devel] [PATCH] avcodec/vp9_superframe_split: move the reference in the bsf internal buffer

2018-03-19 Thread James Almer
On 3/16/2018 7:39 PM, James Almer wrote:
> There's no need to allocate a new packet for it.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/vp9_superframe_split_bsf.c | 21 ++---
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/vp9_superframe_split_bsf.c 
> b/libavcodec/vp9_superframe_split_bsf.c
> index 0d2523ebf7..7b6fa38554 100644
> --- a/libavcodec/vp9_superframe_split_bsf.c
> +++ b/libavcodec/vp9_superframe_split_bsf.c
> @@ -30,7 +30,7 @@
>  #include "get_bits.h"
>  
>  typedef struct VP9SFSplitContext {
> -AVPacket *buffer_pkt;
> +AVPacket buffer_pkt;
>  
>  int nb_frames;
>  int next_frame;
> @@ -43,13 +43,13 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, 
> AVPacket *out)
>  VP9SFSplitContext *s = ctx->priv_data;
>  AVPacket *in;
>  int i, j, ret, marker;
> -int is_superframe = !!s->buffer_pkt;
> +int is_superframe = !!s->buffer_pkt.data;
>  
> -if (!s->buffer_pkt) {
> -ret = ff_bsf_get_packet(ctx, &s->buffer_pkt);
> +if (!s->buffer_pkt.data) {
> +ret = ff_bsf_get_packet_ref(ctx, &s->buffer_pkt);
>  if (ret < 0)
>  return ret;
> -in = s->buffer_pkt;
> +in = &s->buffer_pkt;
>  
>  marker = in->data[in->size - 1];
>  if ((marker & 0xe0) == 0xc0) {
> @@ -90,7 +90,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, 
> AVPacket *out)
>  GetBitContext gb;
>  int profile, invisible = 0;
>  
> -ret = av_packet_ref(out, s->buffer_pkt);
> +ret = av_packet_ref(out, &s->buffer_pkt);
>  if (ret < 0)
>  goto fail;
>  
> @@ -101,7 +101,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, 
> AVPacket *out)
>  s->next_frame++;
>  
>  if (s->next_frame >= s->nb_frames)
> -av_packet_free(&s->buffer_pkt);
> +av_packet_unref(&s->buffer_pkt);
>  
>  ret = init_get_bits8(&gb, out->data, out->size);
>  if (ret < 0)
> @@ -121,20 +121,19 @@ static int vp9_superframe_split_filter(AVBSFContext 
> *ctx, AVPacket *out)
>  out->pts = AV_NOPTS_VALUE;
>  
>  } else {
> -av_packet_move_ref(out, s->buffer_pkt);
> -av_packet_free(&s->buffer_pkt);
> +av_packet_move_ref(out, &s->buffer_pkt);
>  }
>  
>  return 0;
>  fail:
> -av_packet_free(&s->buffer_pkt);
> +av_packet_unref(&s->buffer_pkt);
>  return ret;
>  }
>  
>  static void vp9_superframe_split_uninit(AVBSFContext *ctx)
>  {
>  VP9SFSplitContext *s = ctx->priv_data;
> -av_packet_free(&s->buffer_pkt);
> +av_packet_unref(&s->buffer_pkt);
>  }
>  
>  const AVBitStreamFilter ff_vp9_superframe_split_bsf = {

Will apply later today.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] ffmpeg: fallback to codecpar parameters on input filter eof

2018-03-19 Thread Marton Balint



On Mon, 19 Mar 2018, wm4 wrote:


On Sun, 18 Mar 2018 20:09:08 +0100
Marton Balint  wrote:


Fixes ticket #6854 and the following simpler case:

ffmpeg -f lavfi -i testsrc=d=1 -f lavfi -i testsrc=d=0 -filter_complex overlay 
-f null none

Signed-off-by: Marton Balint 
---
 fftools/ffmpeg.c | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ee7258fcd1..8876c99560 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1855,23 +1855,6 @@ static void flush_encoders(void)
ost->file_index, ost->st->index);

 if (ost->filter && !fg->graph) {
-int x;
-for (x = 0; x < fg->nb_inputs; x++) {
-InputFilter *ifilter = fg->inputs[x];
-if (ifilter->format < 0) {
-AVCodecParameters *par = ifilter->ist->st->codecpar;
-// We never got any input. Set a fake format, which 
will
-// come from libavformat.
-ifilter->format = par->format;
-ifilter->sample_rate= par->sample_rate;
-ifilter->channels   = par->channels;
-ifilter->channel_layout = par->channel_layout;
-ifilter->width  = par->width;
-ifilter->height = par->height;
-ifilter->sample_aspect_ratio= 
par->sample_aspect_ratio;
-}
-}
-
 if (!ifilter_has_all_input_formats(fg))
 continue;

@@ -2214,6 +2197,22 @@ static int ifilter_send_eof(InputFilter *ifilter, 
int64_t pts)
 } else {
 // the filtergraph was never configured
 FilterGraph *fg = ifilter->graph;
+if (ifilter->format < 0) {
+AVCodecParameters *par = ifilter->ist->st->codecpar;
+// We never got any input. Set a fake format, which will
+// come from libavformat.
+ifilter->format = par->format;
+ifilter->sample_rate= par->sample_rate;
+ifilter->channels   = par->channels;
+ifilter->channel_layout = par->channel_layout;
+ifilter->width  = par->width;
+ifilter->height = par->height;
+ifilter->sample_aspect_ratio= par->sample_aspect_ratio;
+}
+if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || 
ifilter->type == AVMEDIA_TYPE_VIDEO)) {
+av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input %d, stream %d after 
EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);
+return AVERROR_INVALIDDATA;
+}
 for (i = 0; i < fg->nb_inputs; i++)
 if (!fg->inputs[i]->eof)
 break;


Does it make sense to mux audio or video without packets? And why?


Because filters may generate packets on output even if no packets are 
received on some input.


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


Re: [FFmpeg-devel] [DISCUSSION] New iteration APIs, lavf and lavd

2018-03-19 Thread Rostislav Pehlivanov
On 19 March 2018 at 02:59, Josh de Kock  wrote:

> Hi,
>
> The new iteration API to replace the old _next() is nearing the end of
> it's completion with the lavfi patch on the mailing list and only one
> outstanding issue:
>
> AVOptions would not be found for devices as there is no AVClass for lavd.
> At the moment it would work if you were to still call
> avdevice_register_all() because then devices get registered as formats in
> the old API (which the child_class_next function still uses). When the
> format_child_class_next() function switches to the iterate() API
> it would no longer have access to devices and thus there would be no way
> for av_opt_find() to find an option for devices. The fix for this is
> simple, add an AVClass for lavd--fairly clean and unobjectionable.
>
>
> This leaves the new iteration API in an odd limbo of both being now
> consistent with the newer BSF API, and using static lav* components, but
> also lying to the user that lavf and lavd are separate libraries. We have a
> few options in regards to this:
>
> 1) Agree that both lavf and lavd are fine in their current state
>
> This requires no further discussion, and is the easiest to implement but
> leaves ffmpeg with a questionable ecosystem of dependent libraries. It also
> would require another iteration API change if lavf and lavd were to be
> separated in the future (luckily only return types due to the usage of an
> opaque state i.e. `const AVInputFormat *av_indev_iterate(void **opaque)` ->
> `const AVInputDevice *av_indev_iterate(void **opaque)`)
>
> 2) Disagree that both lavf and lavd are fine in their current state and
> move towards defining lavd as its own separate library immediately at the
> same time as the new iteration APIs.
>
> This is possibly the hardest and most annoying option, as it would require
> designing a new API for essentially a new library, and converting the
> current library's components (also doing it immediately). This could range
> from being simple-ish to being quite tough depending on how much the new
> library API just copies the lavf API directly (though a disadvantage of
> this is that it wouldn't be able to take good use of designing the API
> around how devices should be, it has to design around how they currently
> are).
>
> 3) Disagree that both lavf and lavd are fine in their current state and
> merge lavd into lavd to allow redesigning of lavd to happen slowly at its
> own pace.
>
> This may require a fair amount of work, but not too much upfront. It takes
> the fact that lavf and lavd aren't really separate libraries to 'delete'
> lavd to give space for a new library to be designed from scratch.
>
>
I think this is the best option, though for now option 1 is fine as well.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [DISCUSSION] New iteration APIs, lavf and lavd

2018-03-19 Thread Nicolas George
Josh de Kock (2018-03-19):
> The new iteration API to replace the old _next() is nearing the end of it's
> completion with the lavfi patch on the mailing list and only one outstanding
> issue:
> 
> AVOptions would not be found for devices as there is no AVClass for lavd. At
> the moment it would work if you were to still call avdevice_register_all()
> because then devices get registered as formats in the old API (which the
> child_class_next function still uses). When the format_child_class_next()
> function switches to the iterate() API
> it would no longer have access to devices and thus there would be no way for
> av_opt_find() to find an option for devices. The fix for this is simple, add
> an AVClass for lavd--fairly clean and unobjectionable.
> 
> 
> This leaves the new iteration API in an odd limbo of both being now
> consistent with the newer BSF API, and using static lav* components, but
> also lying to the user that lavf and lavd are separate libraries. We have a
> few options in regards to this:
> 
> 1) Agree that both lavf and lavd are fine in their current state
> 
> This requires no further discussion, and is the easiest to implement but
> leaves ffmpeg with a questionable ecosystem of dependent libraries. It also
> would require another iteration API change if lavf and lavd were to be
> separated in the future (luckily only return types due to the usage of an
> opaque state i.e. `const AVInputFormat *av_indev_iterate(void **opaque)` ->
> `const AVInputDevice *av_indev_iterate(void **opaque)`)

I do not understand what "in their current state" means? Before the
patches? After the patches? After half the patches but before the other
half?

I do not understand what "separate libraries" means either. lavf and
lavd are, right now, separate libraries, but what does it have to do
with anything.

Your summary of the API changes is not detailed enough for somebody who
was not involved in the previous discussions. Please be more detailed
and start from scratch.

> 2) Disagree that both lavf and lavd are fine in their current state and move
> towards defining lavd as its own separate library immediately at the same
> time as the new iteration APIs.
> 
> This is possibly the hardest and most annoying option, as it would require
> designing a new API for essentially a new library, and converting the
> current library's components (also doing it immediately). This could range
> from being simple-ish to being quite tough depending on how much the new
> library API just copies the lavf API directly (though a disadvantage of this
> is that it wouldn't be able to take good use of designing the API around how
> devices should be, it has to design around how they currently are).

Looks like an enormous waste of time for a terrible outcome. Scrap that
idea.

Having devices presented as demuxsrs or muxers has the benefit that
applications do not need to be designed to use them, they just can
transparently. That means if you have an application that can mux
things, you can have it output a quick preview by just giving an
adequate device name. It only uses basic functionality, but it serves a
lot. Furthermore, applications that want to use devices do not need to
implement a different code path, just a few exceptions specific to the
devices.

If your proposal breaks that, if your proposal requires changes to
applications in order to allow them to uses devices in place of
(de)muxers, then it is not acceptable.

> 3) Disagree that both lavf and lavd are fine in their current state and
> merge lavd into lavd to allow redesigning of lavd to happen slowly at its
> own pace.
> 
> This may require a fair amount of work, but not too much upfront. It takes
> the fact that lavf and lavd aren't really separate libraries to 'delete'
> lavd to give space for a new library to be designed from scratch.

lavd was separated from lavf exactly to avoid that. On the other hand,
the people who wanted it have mostly gone and forked themselves, so we
can safely ignore them.

> 4) Scrap the entire API
> 
> This is super easy, just figure out which commits are related to the new API
> using `git log`, then revert. We can then have a whole new discussion on how
> we'd rather do things entirely instead, though this sounds like a lot of
> work that people would agree to and then it'd just not get done.
> 
> There may be other options I haven't described, I'd love to hear them. As
> for the ones I did, 2 will impede the new ffmpeg release the most (something
> I think no one wants), and 4 just moves backwards. I think 1 or 3 are
> preferred, and I lean towards 3 (and obviously this is just my opinion, you
> are entitled to your own).

Option 5: revert the new API as is for now, design it better, not
rushing things and learning from the mistakes made on this one.

Regards,

-- 
  Nicolas George


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

Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Jan Ekström
On Mon, Mar 19, 2018 at 6:28 PM, wm4  wrote:
> On Mon, 19 Mar 2018 09:35:22 -0400
> Jeff Cook  wrote:
>
>> Hello,
>>
>> Please see the bug report at https://github.com/opencv/opencv/issues/10963 , 
>> which discusses OpenCV's failure to build as pure C since upstream version 
>> 3.4.1, and also discusses how all modules that use OpenCV 2 or later should 
>> be compiled as C++ to avoid esoteric issues and serious breakages.
>>
>> There is a large amount of discussion there that I don't want to needlessly 
>> duplicate and/or badly summarize here, but the high-level overview is that 
>> it seems that ffmpeg will need to convert avfilter/vf_opencv.c to build as 
>> C++ if the OpenCV filter is going to continue to work. The current situation 
>> is affecting many prominent projects like VLC.
>
> FFmpeg is a C project, and due to missing features in C++ (initializers)
> it's very awkward to build things in C++ mode. Can't OpenCV just fix
> their stuff.
>

https://github.com/opencv/opencv/issues/8438#issuecomment-288638915

tl;dr

They're breaking C compatibility knowingly. If and only if we want to
keep whatever features we get by linking against OpenCV, then the
correct mode of operation is to make that specific file compile as C++
and export the relevant C end points. Or maybe just link with the C++
side of things; whatever was done with libutvideo back in the day?

Unfortunately, fixing this will end up on whomever cares about this
functionality, since I don't think we have an active maintainer for
this component?

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


Re: [FFmpeg-devel] [PATCH] avcodec/avpacket: add av_packet_make_writable()

2018-03-19 Thread James Almer
On 3/19/2018 1:32 PM, wm4 wrote:
> On Mon, 19 Mar 2018 12:42:16 -0300
> James Almer  wrote:
> 
>> Useful as well to quickly make a packet reference counted when it
>> isn't already so.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/avcodec.h  | 11 +++
>>  libavcodec/avpacket.c | 24 
>>  2 files changed, 35 insertions(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index a8322fb62a..a78017f1fb 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -4518,6 +4518,17 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src);
>>   */
>>  int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
>>  
>> +/**
>> + * Create a writable reference for the data described by a given packet,
>> + * avoiding data copy if possible.
>> + *
>> + * @param pkt Packet whose data should be made writable.
>> + *
>> + * @return 0 on success, a negative AVERROR on failure. On failure, the
>> + * packet is unchanged.
>> + */
>> +int av_packet_make_writable(AVPacket *pkt);
>> +
>>  /**
>>   * Convert valid timing fields (timestamps / durations) in a packet from one
>>   * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) 
>> will be
>> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
>> index fe8113ab76..0693ca6f62 100644
>> --- a/libavcodec/avpacket.c
>> +++ b/libavcodec/avpacket.c
>> @@ -652,6 +652,30 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src)
>>  src->size = 0;
>>  }
>>  
>> +int av_packet_make_writable(AVPacket *pkt)
>> +{
>> +AVBufferRef *buf = NULL;
>> +int ret;
>> +
>> +if (pkt->buf && av_buffer_is_writable(pkt->buf))
>> +return 0;
>> +
>> +if (!pkt->data)
>> +return AVERROR(EINVAL);
>> +
>> +ret = packet_alloc(&buf, pkt->size);
>> +if (ret < 0)
>> +return ret;
>> +if (pkt->size)
>> +memcpy(buf->data, pkt->data, pkt->size);
>> +
>> +av_buffer_unref(&pkt->buf);
>> +pkt->buf  = buf;
>> +pkt->data = buf->data;
>> +
>> +return 0;
>> +}
>> +
>>  void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational 
>> dst_tb)
>>  {
>>  if (pkt->pts != AV_NOPTS_VALUE)
> 
> Why not just call av_buffer_make_writable()? This code seems fine too,
> though.

That would require duplicating all or most of these checks every time
you need to make sure a packet is writable. pkt->buf may be NULL,
pkt->buf may already be writable, pkt->data may be NULL, the like.

I figured a helper function like this where you just call one function
that is "make this packet writable, whatever the current state is" would
come in handy and simplify some parts of the tree. See the two commits i
mentioned in my reply to Paul, or the mpeg4_unpack_bframes patch i sent
last night.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [DISCUSSION] New iteration APIs, lavf and lavd

2018-03-19 Thread Paul B Mahol
On 3/19/18, wm4  wrote:
> On Mon, 19 Mar 2018 02:59:54 +
> Josh de Kock  wrote:
>
>> Hi,
>>
>> The new iteration API to replace the old _next() is nearing the end of
>> it's completion with the lavfi patch on the mailing list and only one
>> outstanding issue:
>>
>> AVOptions would not be found for devices as there is no AVClass for
>> lavd. At the moment it would work if you were to still call
>> avdevice_register_all() because then devices get registered as formats
>> in the old API (which the child_class_next function still uses). When
>> the format_child_class_next() function switches to the iterate() API
>> it would no longer have access to devices and thus there would be no way
>> for av_opt_find() to find an option for devices. The fix for this is
>> simple, add an AVClass for lavd--fairly clean and unobjectionable.
>
> I really don't understand the problem, or why this AVClass crap is
> needed. It sounds absurd.

Yes, avdevice (non)API is absurd.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] ffmpeg: fallback to codecpar parameters on input filter eof

2018-03-19 Thread wm4
On Sun, 18 Mar 2018 20:09:08 +0100
Marton Balint  wrote:

> Fixes ticket #6854 and the following simpler case:
> 
> ffmpeg -f lavfi -i testsrc=d=1 -f lavfi -i testsrc=d=0 -filter_complex 
> overlay -f null none
> 
> Signed-off-by: Marton Balint 
> ---
>  fftools/ffmpeg.c | 33 -
>  1 file changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index ee7258fcd1..8876c99560 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1855,23 +1855,6 @@ static void flush_encoders(void)
> ost->file_index, ost->st->index);
>  
>  if (ost->filter && !fg->graph) {
> -int x;
> -for (x = 0; x < fg->nb_inputs; x++) {
> -InputFilter *ifilter = fg->inputs[x];
> -if (ifilter->format < 0) {
> -AVCodecParameters *par = ifilter->ist->st->codecpar;
> -// We never got any input. Set a fake format, which 
> will
> -// come from libavformat.
> -ifilter->format = par->format;
> -ifilter->sample_rate= par->sample_rate;
> -ifilter->channels   = par->channels;
> -ifilter->channel_layout = 
> par->channel_layout;
> -ifilter->width  = par->width;
> -ifilter->height = par->height;
> -ifilter->sample_aspect_ratio= 
> par->sample_aspect_ratio;
> -}
> -}
> -
>  if (!ifilter_has_all_input_formats(fg))
>  continue;
>  
> @@ -2214,6 +2197,22 @@ static int ifilter_send_eof(InputFilter *ifilter, 
> int64_t pts)
>  } else {
>  // the filtergraph was never configured
>  FilterGraph *fg = ifilter->graph;
> +if (ifilter->format < 0) {
> +AVCodecParameters *par = ifilter->ist->st->codecpar;
> +// We never got any input. Set a fake format, which will
> +// come from libavformat.
> +ifilter->format = par->format;
> +ifilter->sample_rate= par->sample_rate;
> +ifilter->channels   = par->channels;
> +ifilter->channel_layout = par->channel_layout;
> +ifilter->width  = par->width;
> +ifilter->height = par->height;
> +ifilter->sample_aspect_ratio= par->sample_aspect_ratio;
> +}
> +if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || 
> ifilter->type == AVMEDIA_TYPE_VIDEO)) {
> +av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input %d, 
> stream %d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);
> +return AVERROR_INVALIDDATA;
> +}
>  for (i = 0; i < fg->nb_inputs; i++)
>  if (!fg->inputs[i]->eof)
>  break;

Does it make sense to mux audio or video without packets? And why?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [DISCUSSION] New iteration APIs, lavf and lavd

2018-03-19 Thread wm4
On Mon, 19 Mar 2018 02:59:54 +
Josh de Kock  wrote:

> Hi,
> 
> The new iteration API to replace the old _next() is nearing the end of 
> it's completion with the lavfi patch on the mailing list and only one 
> outstanding issue:
> 
> AVOptions would not be found for devices as there is no AVClass for 
> lavd. At the moment it would work if you were to still call 
> avdevice_register_all() because then devices get registered as formats 
> in the old API (which the child_class_next function still uses). When 
> the format_child_class_next() function switches to the iterate() API
> it would no longer have access to devices and thus there would be no way 
> for av_opt_find() to find an option for devices. The fix for this is 
> simple, add an AVClass for lavd--fairly clean and unobjectionable.

I really don't understand the problem, or why this AVClass crap is
needed. It sounds absurd.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/avpacket: add av_packet_make_writable()

2018-03-19 Thread wm4
On Mon, 19 Mar 2018 12:42:16 -0300
James Almer  wrote:

> Useful as well to quickly make a packet reference counted when it
> isn't already so.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/avcodec.h  | 11 +++
>  libavcodec/avpacket.c | 24 
>  2 files changed, 35 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index a8322fb62a..a78017f1fb 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4518,6 +4518,17 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src);
>   */
>  int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
>  
> +/**
> + * Create a writable reference for the data described by a given packet,
> + * avoiding data copy if possible.
> + *
> + * @param pkt Packet whose data should be made writable.
> + *
> + * @return 0 on success, a negative AVERROR on failure. On failure, the
> + * packet is unchanged.
> + */
> +int av_packet_make_writable(AVPacket *pkt);
> +
>  /**
>   * Convert valid timing fields (timestamps / durations) in a packet from one
>   * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will 
> be
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index fe8113ab76..0693ca6f62 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -652,6 +652,30 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src)
>  src->size = 0;
>  }
>  
> +int av_packet_make_writable(AVPacket *pkt)
> +{
> +AVBufferRef *buf = NULL;
> +int ret;
> +
> +if (pkt->buf && av_buffer_is_writable(pkt->buf))
> +return 0;
> +
> +if (!pkt->data)
> +return AVERROR(EINVAL);
> +
> +ret = packet_alloc(&buf, pkt->size);
> +if (ret < 0)
> +return ret;
> +if (pkt->size)
> +memcpy(buf->data, pkt->data, pkt->size);
> +
> +av_buffer_unref(&pkt->buf);
> +pkt->buf  = buf;
> +pkt->data = buf->data;
> +
> +return 0;
> +}
> +
>  void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational 
> dst_tb)
>  {
>  if (pkt->pts != AV_NOPTS_VALUE)

Why not just call av_buffer_make_writable()? This code seems fine too,
though.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread wm4
On Mon, 19 Mar 2018 09:35:22 -0400
Jeff Cook  wrote:

> Hello,
> 
> Please see the bug report at https://github.com/opencv/opencv/issues/10963 , 
> which discusses OpenCV's failure to build as pure C since upstream version 
> 3.4.1, and also discusses how all modules that use OpenCV 2 or later should 
> be compiled as C++ to avoid esoteric issues and serious breakages.
> 
> There is a large amount of discussion there that I don't want to needlessly 
> duplicate and/or badly summarize here, but the high-level overview is that it 
> seems that ffmpeg will need to convert avfilter/vf_opencv.c to build as C++ 
> if the OpenCV filter is going to continue to work. The current situation is 
> affecting many prominent projects like VLC.

FFmpeg is a C project, and due to missing features in C++ (initializers)
it's very awkward to build things in C++ mode. Can't OpenCV just fix
their stuff.

(Ignore my previous mail, bad mail client.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread wm4
On Mon, 19 Mar 2018 09:35:22 -0400
Jeff Cook  wrote:

> Hello,
> 
> Please see the bug report at https://github.com/opencv/opencv/issues/10963 , 
> which discusses OpenCV's failure to build as pure C since upstream version 
> 3.4.1, and also discusses how all modules that use OpenCV 2 or later should 
> be compiled as C++ to avoid esoteric issues and serious breakages.
> 
> There is a large amount of discussion there that I don't want to needlessly 
> duplicate and/or badly summarize here, but the high-level overview is that it 
> seems that ffmpeg will need to convert avfilter/vf_opencv.c to build as C++ 
> if the OpenCV filter is going to continue to work. The current situation is 
> affecting many prominent projects like VLC.

FFmpeg is a C project, and due to missing features in C
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/avpacket: add av_packet_make_writable()

2018-03-19 Thread James Almer
On 3/19/2018 12:45 PM, Paul B Mahol wrote:
> On 3/19/18, James Almer  wrote:
>> Useful as well to quickly make a packet reference counted when it
>> isn't already so.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/avcodec.h  | 11 +++
>>  libavcodec/avpacket.c | 24 
>>  2 files changed, 35 insertions(+)
>>
> 
> Will this ever be used?

Probably? It's public API, downstream projects and users decide what
they want to use based on their needs.

And in our tree it can for example be used to simplify the change i made
in a22c6a4796 and e91f0c4f8b, or in bitstream filters to allow changes
to be made directly to the input packet's data.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/avpacket: add av_packet_make_writable()

2018-03-19 Thread Paul B Mahol
On 3/19/18, James Almer  wrote:
> Useful as well to quickly make a packet reference counted when it
> isn't already so.
>
> Signed-off-by: James Almer 
> ---
>  libavcodec/avcodec.h  | 11 +++
>  libavcodec/avpacket.c | 24 
>  2 files changed, 35 insertions(+)
>

Will this ever be used?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/avpacket: add av_packet_make_writable()

2018-03-19 Thread James Almer
Useful as well to quickly make a packet reference counted when it
isn't already so.

Signed-off-by: James Almer 
---
 libavcodec/avcodec.h  | 11 +++
 libavcodec/avpacket.c | 24 
 2 files changed, 35 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a8322fb62a..a78017f1fb 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4518,6 +4518,17 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src);
  */
 int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
 
+/**
+ * Create a writable reference for the data described by a given packet,
+ * avoiding data copy if possible.
+ *
+ * @param pkt Packet whose data should be made writable.
+ *
+ * @return 0 on success, a negative AVERROR on failure. On failure, the
+ * packet is unchanged.
+ */
+int av_packet_make_writable(AVPacket *pkt);
+
 /**
  * Convert valid timing fields (timestamps / durations) in a packet from one
  * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index fe8113ab76..0693ca6f62 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -652,6 +652,30 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src)
 src->size = 0;
 }
 
+int av_packet_make_writable(AVPacket *pkt)
+{
+AVBufferRef *buf = NULL;
+int ret;
+
+if (pkt->buf && av_buffer_is_writable(pkt->buf))
+return 0;
+
+if (!pkt->data)
+return AVERROR(EINVAL);
+
+ret = packet_alloc(&buf, pkt->size);
+if (ret < 0)
+return ret;
+if (pkt->size)
+memcpy(buf->data, pkt->data, pkt->size);
+
+av_buffer_unref(&pkt->buf);
+pkt->buf  = buf;
+pkt->data = buf->data;
+
+return 0;
+}
+
 void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
 {
 if (pkt->pts != AV_NOPTS_VALUE)
-- 
2.16.2

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


Re: [FFmpeg-devel] [FFmpeg][PATCH] lavc/cfhd: introduced interlaced using temporal horizontal transform

2018-03-19 Thread James Almer
On 3/19/2018 6:47 AM, Gagandeep Singh wrote:
> interlaced files require horizontal-temporal transform that has been added.
> Output is not satisfactory yet!
> ---
>  libavcodec/cfhd.c | 137 
> +-
>  libavcodec/cfhd.h |   3 +-
>  2 files changed, 107 insertions(+), 33 deletions(-)
> 
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index a064cd1599..da0f0fadf6 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -46,6 +46,7 @@ enum CFHDParam {
>  SubbandNumber=  48,
>  Quantization =  53,
>  ChannelNumber=  62,
> +Progressive  =  68,
>  BitsPerComponent = 101,
>  ChannelWidth = 104,
>  ChannelHeight= 105,
> @@ -83,6 +84,7 @@ static void init_frame_defaults(CFHDContext *s)
>  s->wavelet_depth = 3;
>  s->pshift= 1;
>  s->codebook  = 0;
> +s->progressive   = 0;
>  init_plane_defaults(s);
>  }
>  
> @@ -137,6 +139,43 @@ static inline void filter(int16_t *output, ptrdiff_t 
> out_stride,
>  }
>  }
>  
> +static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, 
> int16_t *high,
> + int width, int linesize, int plane)
> +{
> +int i;
> +int even, odd;
> +for (i = 0; i < width; i++) {
> +  even = (*low - *high)/2;
> +  odd  = (*low + *high)/2;
> +
> +  even = FFMIN(even, 1023);
> +  even = FFMAX(even, 0);
> +  odd  = FFMIN(odd, 1023);
> +  odd  = FFMAX(odd, 0);

Use av_clip_uintp2() for both even and odd instead.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] OpenCV filter should be built as C++, and C builds fail since OpenCV 3.4.1

2018-03-19 Thread Jeff Cook
Hello,

Please see the bug report at https://github.com/opencv/opencv/issues/10963 , 
which discusses OpenCV's failure to build as pure C since upstream version 
3.4.1, and also discusses how all modules that use OpenCV 2 or later should be 
compiled as C++ to avoid esoteric issues and serious breakages.

There is a large amount of discussion there that I don't want to needlessly 
duplicate and/or badly summarize here, but the high-level overview is that it 
seems that ffmpeg will need to convert avfilter/vf_opencv.c to build as C++ if 
the OpenCV filter is going to continue to work. The current situation is 
affecting many prominent projects like VLC.

Thanks,
Jeff
--
  Jeff Cook
  jeff.c...@strongstrata.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c - drain all decoded frames during stream_loop flush

2018-03-19 Thread Gyan Doshi



On 3/16/2018 10:24 AM, Gyan Doshi wrote:
Revised patch only drains 1 packet per call and loops via 
transcode_step() till EOF, just like when decoders are truly closed. 
Functionally the same result as first version.


On 3/15/2018 3:31 PM, Gyan Doshi wrote:
Fixes a bug with flushing decoders during stream_loop. Note that the 
issue is also averted if we skip flushing altogether.


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


[FFmpeg-devel] [FFmpeg][PATCH] lavc/cfhd: introduced interlaced using temporal horizontal transform

2018-03-19 Thread Gagandeep Singh
interlaced files require horizontal-temporal transform that has been added.
Output is not satisfactory yet!
---
 libavcodec/cfhd.c | 137 +-
 libavcodec/cfhd.h |   3 +-
 2 files changed, 107 insertions(+), 33 deletions(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index a064cd1599..da0f0fadf6 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -46,6 +46,7 @@ enum CFHDParam {
 SubbandNumber=  48,
 Quantization =  53,
 ChannelNumber=  62,
+Progressive  =  68,
 BitsPerComponent = 101,
 ChannelWidth = 104,
 ChannelHeight= 105,
@@ -83,6 +84,7 @@ static void init_frame_defaults(CFHDContext *s)
 s->wavelet_depth = 3;
 s->pshift= 1;
 s->codebook  = 0;
+s->progressive   = 0;
 init_plane_defaults(s);
 }
 
@@ -137,6 +139,43 @@ static inline void filter(int16_t *output, ptrdiff_t 
out_stride,
 }
 }
 
+static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, 
int16_t *high,
+ int width, int linesize, int plane)
+{
+int i;
+int even, odd;
+for (i = 0; i < width; i++) {
+  even = (*low - *high)/2;
+  odd  = (*low + *high)/2;
+
+  even = FFMIN(even, 1023);
+  even = FFMAX(even, 0);
+  odd  = FFMIN(odd, 1023);
+  odd  = FFMAX(odd, 0);
+
+  output[i] = even;
+  output[i + linesize] = odd;
+  low++;
+  high++;
+}
+}
+
+static inline void horiz_haar_filter(int16_t *output, int16_t *low, int16_t 
*high,
+ int width)
+{
+int i;
+int even, odd;
+for (i = 0; i < width; i+=2) {
+  even = (*low - *high);
+  odd  = (*low + *high);
+
+  output[i] = even;
+  output[i + 1] =odd;
+  low++;
+  high++;
+}
+}
+
 static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
  int width)
 {
@@ -196,7 +235,8 @@ static int alloc_buffers(AVCodecContext *avctx)
 int width  = i ? avctx->width  >> chroma_x_shift : avctx->width;
 int height = i ? avctx->height >> chroma_y_shift : avctx->height;
 ptrdiff_t stride   = FFALIGN(width  / 8, 8) * 8;
-if (chroma_y_shift) height = FFALIGN(height / 8, 2) * 8;
+if (chroma_y_shift)
+height = FFALIGN(height / 8, 2) * 8;
 s->plane[i].width  = width;
 s->plane[i].height = height;
 s->plane[i].stride = stride;
@@ -207,7 +247,6 @@ static int alloc_buffers(AVCodecContext *avctx)
 h4 = h8 * 2;
 w2 = w4 * 2;
 h2 = h4 * 2;
-
 s->plane[i].idwt_buf =
 av_mallocz_array(height * stride, sizeof(*s->plane[i].idwt_buf));
 s->plane[i].idwt_tmp =
@@ -247,7 +286,6 @@ static int alloc_buffers(AVCodecContext *avctx)
 s->a_height = s->coded_height;
 s->a_width  = s->coded_width;
 s->a_format = s->coded_format;
-
 return 0;
 }
 
@@ -277,6 +315,9 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 uint16_t data   = bytestream2_get_be16(&gb);
 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
 av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 
16) | data);
+} else if (tag == Progressive) {
+av_log(avctx, AV_LOG_DEBUG, "Progressive? %"PRIu16"\n", 0x0001 & 
data);
+s->progressive = 0x0001 & data;
 } else if (tag == ImageWidth) {
 av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
 s->coded_width = data;
@@ -757,7 +798,6 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 lowpass_height  = s->plane[plane].band[2][1].height;
 lowpass_width   = s->plane[plane].band[2][1].width;
 highpass_stride = s->plane[plane].band[2][1].stride;
-
 if (lowpass_height > s->plane[plane].band[2][1].a_height || 
lowpass_width > s->plane[plane].band[2][1].a_width ||
 !highpass_stride || s->plane[plane].band[2][1].width > 
s->plane[plane].band[2][1].a_width) {
 av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");
@@ -766,36 +806,69 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, 
lowpass_height, lowpass_width, highpass_stride);
+if (s->progressive) {
+  low= s->plane[plane].subband[0];
+  high   = s->plane[plane].subband[8];
+  output = s->plane[plane].l_h[6];
+  for (i = 0; i < lowpass_width; i++) {
+  vert_filter(output, lowpass_width, low, lowpass_width, high, 
highpass_stride, lowpass_height);
+  low++;
+  high++;
+  output++;
+  }
+
+  low= s->plane[plane].subband[7];
+  high   = s->plane[plane].subband[9];
+  output = s->plane[plane].l_h[7];
+  for (i = 0; i < lowpass_width; i++

Re: [FFmpeg-devel] [PATCH 1/2] fftools/cmdutils: add logflags option

2018-03-19 Thread Tobias Rapp

On 14.03.2018 09:55, Tobias Rapp wrote:

Allows to set the AV_LOG_PRINT_LEVEL and AV_LOG_SKIP_REPEATED flags
using a distinct command-line option, similar to other flag options.
Previously only the AV_LOG_SKIP_REPEATED flag was supported as a prefix
to the "loglevel" option value.

Signed-off-by: Tobias Rapp 
---
  doc/fftools-common-opts.texi | 13 +
  fftools/cmdutils.c   | 31 +++
  fftools/cmdutils.h   |  6 ++
  3 files changed, 50 insertions(+)

[...]


Any opinions? My motivation was adding support for AV_LOG_PRINT_LEVEL on 
the CLI. Using the existing flags option string parsing functions seemed 
easier and more consistent that extending the custom loglevel string parser.


Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH] lavc/cfhd: added interlaced frame decoding

2018-03-19 Thread Paul B Mahol
On 3/19/18, Gagandeep Singh  wrote:
> On Sat, Mar 17, 2018 at 5:00 PM, Carl Eugen Hoyos 
> wrote:
>

Wrong way.

Post patch against master ffmpeg, not against previous patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel