[FFmpeg-devel] [PATCH] lavc/videotoolbox: fix threaded decoding

2018-02-02 Thread Rodger Combs
AVHWAccel.end_frame can run on a worker thread. The assumption of the
frame threading code is that the worker thread will change the AVFrame
image data, not the AVFrame fields. So the AVFrame fields are not synced
back to the main thread. But this breaks videotoolbox due to its special
requirements (everything else is fine). It actually wants to update
AVFrame fields.

The actual videotoolbox frame is now stored in the dummy AVBufferRef, so
it mimics what happens in non-videotoolbox cases. (Changing the
AVBufferRef contents is a bit like changing the image data.) The
post_process callback copies that reference to the proper AVFrame field.

Based on a patch by wm4.
---
 libavcodec/h264dec.c  |  3 ---
 libavcodec/videotoolbox.c | 68 +++
 libavcodec/vt_internal.h  |  1 -
 3 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 8c9c6d9f3b..7494c7a8f2 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -838,9 +838,6 @@ static int output_frame(H264Context *h, AVFrame *dst, 
H264Picture *srcp)
 AVFrame *src = srcp->f;
 int ret;
 
-if (src->format == AV_PIX_FMT_VIDEOTOOLBOX && src->buf[0]->size == 1)
-return AVERROR_INVALIDDATA;
-
 ret = av_frame_ref(dst, src);
 if (ret < 0)
 return ret;
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index afec1edf3f..f82c31c5df 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -45,8 +45,10 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' };
 
 static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
 {
-CVPixelBufferRef cv_buffer = (CVImageBufferRef)data;
+CVPixelBufferRef cv_buffer = *(CVPixelBufferRef *)data;
 CVPixelBufferRelease(cv_buffer);
+
+av_free(data);
 }
 
 static int videotoolbox_buffer_copy(VTContext *vtctx,
@@ -69,19 +71,47 @@ static int videotoolbox_buffer_copy(VTContext *vtctx,
 return 0;
 }
 
+static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame)
+{
+CVPixelBufferRef ref = *(CVPixelBufferRef *)frame->buf[0]->data;
+
+if (!ref) {
+av_log(avctx, AV_LOG_ERROR, "No frame decoded?\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+frame->data[3] = (uint8_t*)ref;
+
+return 0;
+}
+
 int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
 {
+size_t  size = sizeof(CVPixelBufferRef);
+uint8_t*data = NULL;
+AVBufferRef *buf = NULL;
 int ret = ff_attach_decode_data(frame);
+FrameDecodeData *fdd;
 if (ret < 0)
 return ret;
 
+data = av_mallocz(size);
+if (!data)
+return AVERROR(ENOMEM);
+buf = av_buffer_create(data, size, videotoolbox_buffer_release, NULL, 0);
+if (!buf) {
+av_freep();
+return AVERROR(ENOMEM);
+}
+frame->buf[0] = buf;
+
+fdd = (FrameDecodeData*)frame->private_ref->data;
+fdd->post_process = videotoolbox_postproc_frame;
+
 frame->width  = avctx->width;
 frame->height = avctx->height;
 frame->format = avctx->pix_fmt;
-frame->buf[0] = av_buffer_alloc(1);
-
-if (!frame->buf[0])
-return AVERROR(ENOMEM);
 
 return 0;
 }
@@ -285,20 +315,24 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 return data;
 }
 
-int ff_videotoolbox_buffer_create(VTContext *vtctx, AVFrame *frame)
+static int videotoolbox_set_frame(AVCodecContext *avctx, AVFrame *frame)
 {
-av_buffer_unref(>buf[0]);
-
-frame->buf[0] = av_buffer_create((uint8_t*)vtctx->frame,
- sizeof(vtctx->frame),
- videotoolbox_buffer_release,
- NULL,
- AV_BUFFER_FLAG_READONLY);
-if (!frame->buf[0]) {
-return AVERROR(ENOMEM);
+VTContext *vtctx = avctx->internal->hwaccel_priv_data;
+if (!frame->buf[0] || frame->data[3]) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
+
+if (*ref) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: frame already set?\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
 }
 
-frame->data[3] = (uint8_t*)vtctx->frame;
+*ref = vtctx->frame;
 vtctx->frame = NULL;
 
 return 0;
@@ -406,7 +440,7 @@ static int videotoolbox_buffer_create(AVCodecContext 
*avctx, AVFrame *frame)
 AVHWFramesContext *cached_frames;
 int ret;
 
-ret = ff_videotoolbox_buffer_create(vtctx, frame);
+ret = videotoolbox_set_frame(avctx, frame);
 if (ret < 0)
 return ret;
 
diff --git a/libavcodec/vt_internal.h b/libavcodec/vt_internal.h
index 929fe423fc..fb64735b8c 100644
--- a/libavcodec/vt_internal.h
+++ b/libavcodec/vt_internal.h
@@ -46,7 +46,6 @@ typedef 

Re: [FFmpeg-devel] [PATCH 4/4] af_silencedetect : fix missing log silence_end at EOS

2018-02-02 Thread Michael Niedermayer
On Fri, Feb 02, 2018 at 10:59:51AM +, Gaullier Nicolas wrote:
> Attached patch fixes missing log of "silence_end" when the silence continue 
> until the end of the stream.
> Nicolas Gaullier

>  af_silencedetect.c |   14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 12dc8501a25c838eb7f0d4fadc70aa5d6244231e  
> 0004-avfilter-af_silencedetect-fix-missing-log-silence_en.patch
> From c9909a0454b393a08ee42dabb51b7b5cebbb02ed Mon Sep 17 00:00:00 2001
> From: nicolas gaullier 
> Date: Fri, 2 Feb 2018 11:31:01 +0100
> Subject: [PATCH 4/4] avfilter/af_silencedetect : fix missing log silence_end
>  at EOS
> 
> ---
>  libavfilter/af_silencedetect.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
> index fedbed8113..ea7e15d0bc 100644
> --- a/libavfilter/af_silencedetect.c
> +++ b/libavfilter/af_silencedetect.c
> @@ -41,6 +41,7 @@ typedef struct SilenceDetectContext {
>  int independant_channels;   ///< number of entries in following arrays 
> (always 1 in mono mode)
>  int64_t *nb_null_samples;   ///< (array) current number of continuous 
> zero samples
>  int64_t *start; ///< (array) if silence is detected, this 
> value contains the time of the first zero sample (default/unset = INT64_MIN)
> +int64_t frame_end;  ///< pts of the end of the current frame 
> (used to compute duration of silence at EOS)
>  int last_sample_rate;   ///< last sample rate to check for sample 
> rate changes
>  AVRational time_base;   ///< time_base
>  
> @@ -90,10 +91,12 @@ static av_always_inline void update(SilenceDetectContext 
> *s, AVFrame *insamples,
>  }
>  } else {
>  if (s->start[channel] > INT64_MIN) {
> -int64_t end_pts = insamples->pts;
> +int64_t end_pts = insamples ? insamples->pts : s->frame_end;
>  int64_t duration_ts = end_pts - s->start[channel];
> -set_meta(insamples, s->mono ? channel + 1 : 0, "silence_end", 
> av_ts2timestr(end_pts, >time_base));
> -set_meta(insamples, s->mono ? channel + 1 : 0, 
> "silence_duration", av_ts2timestr(duration_ts, >time_base));
> +if (insamples) {
> +set_meta(insamples, s->mono ? channel + 1 : 0, 
> "silence_end", av_ts2timestr(end_pts, >time_base));
> +set_meta(insamples, s->mono ? channel + 1 : 0, 
> "silence_duration", av_ts2timestr(duration_ts, >time_base));
> +}
>  if (s->mono)
>  av_log(s, AV_LOG_INFO, "channel: %d | ", channel);
>  av_log(s, AV_LOG_INFO, "silence_end: %s | silence_duration: 
> %s\n",

> @@ -172,6 +175,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *insamples)
>  }
>  s->last_sample_rate = srate;
>  s->time_base = inlink->time_base;
> +s->frame_end = insamples->pts + (int64_t)((double)insamples->nb_samples 
> / srate / av_q2d(s->time_base) + .5);

please use av_rescale* or something to avoid using double/float which
can result in differences between platforms



[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] [PATCH] avcodec: do not use init_static_data on some codecs

2018-02-02 Thread Michael Niedermayer
On Sat, Feb 03, 2018 at 01:36:37AM +0700, Muhammad Faiz wrote:
> They don't modify AVCodec, no needs to call it at register. They will be
> wasteful if these codecs are unused. Instead, call static data initialization
> at codecs' init.
> 
> Benchmark:
> old: 51281340 decicycles in avcodec_register_all,   1 runs,  0 skips
> new:  6738960 decicycles in avcodec_register_all,   1 runs,  0 skips
> 
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/jpeg2000dec.c | 16 +---
>  libavcodec/qdmc.c|  7 +--
>  libavcodec/wmavoice.c|  7 +--
>  3 files changed, 19 insertions(+), 11 deletions(-)

LGTM
 
it would be better though if this would happen for all
init_static_data() without the need for extra code per codec

thx

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

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


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


Re: [FFmpeg-devel] [PATCH 2/4] af_silencedetect : fix accuracy of silence_start

2018-02-02 Thread Michael Niedermayer
On Fri, Feb 02, 2018 at 11:01:20AM +, Gaullier Nicolas wrote:
> (attachement + email object fixed : sorry about that x2)
> Attached patch fixes accuracy of silence_start.
> The benefit is mostly noticeable when the silence starts at the very 
> beginning (ie. silence_start=0 exactly).
> Nicolas Gaullier

>  af_silencedetect.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 0847308d6116f153553a9dab288eecaf8804cfe6  
> 0002-avfilter-af_silencedetect-fix-silence_start-accuracy.patch
> From a8780b9c7132b80cd0f0f3cb99fc34bf38874f34 Mon Sep 17 00:00:00 2001
> From: nicolas gaullier 
> Date: Fri, 2 Feb 2018 11:14:47 +0100
> Subject: [PATCH 2/4] avfilter/af_silencedetect : fix silence_start accuracy

this breaks fate

make -j12 fate-filter-metadata-silencedetect
TESTfilter-metadata-silencedetect
--- ./tests/ref/fate/filter-metadata-silencedetect  2018-02-03 
00:37:40.522808340 +0100
+++ tests/data/fate/filter-metadata-silencedetect   2018-02-03 
02:57:28.310985048 +0100
@@ -4,9 +4,9 @@
 pkt_pts=960
 pkt_pts=1280
 pkt_pts=1600
-pkt_pts=1920|tag:lavfi.silence_start=0.02
+pkt_pts=1920|tag:lavfi.silence_start=0.0351875
 pkt_pts=2240
-pkt_pts=2560|tag:lavfi.silence_end=0.16|tag:lavfi.silence_duration=0.14
+pkt_pts=2560|tag:lavfi.silence_end=0.16|tag:lavfi.silence_duration=0.124813
 pkt_pts=2880
 pkt_pts=3200
 pkt_pts=3520


If the changes are intended the reference must be updated by the patch causing
the changes

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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


[FFmpeg-devel] Fix ctts_index calculation

2018-02-02 Thread 王消寒

From bb376fd2de5da5f9ecdef41621a579252b899d7d Mon Sep 17 00:00:00 2001
From: Xiaohan Wang 
Date: Fri, 2 Feb 2018 17:33:56 -0800
Subject: [PATCH] Fix ctts_index calculation

An index should never be equal to the count. Hence we must make sure
*ctts_index < ctts_count.
---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5adba52e08..f0bd3e3623 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3148,7 +3148,7 @@ static int find_prev_closest_index(AVStream *st,
 *ctts_index = 0;
 *ctts_sample = 0;
 for (index_ctts_count = 0; index_ctts_count < *index; index_ctts_count++) {
-if (*ctts_index < ctts_count) {
+if (*ctts_index < ctts_count - 1) {
 (*ctts_sample)++;
 if (ctts_data[*ctts_index].count == *ctts_sample) {
 (*ctts_index)++;
-- 
2.16.0.rc1.238.g530d649a79-goog

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


Re: [FFmpeg-devel] [PATCH] avcodec/codec_desc: sort codec_descriptors

2018-02-02 Thread Michael Niedermayer
On Sat, Feb 03, 2018 at 02:03:49AM +0100, Michael Niedermayer wrote:
> On Sat, Feb 03, 2018 at 01:35:34AM +0700, Muhammad Faiz wrote:
> > Use bsearch on avcodec_descriptor_get().
> > 
> > Signed-off-by: Muhammad Faiz 
> > ---
> >  libavcodec/codec_desc.c | 1103 
> > ---
> >  1 file changed, 563 insertions(+), 540 deletions(-)
> 
> breaks fate
> 
> make V=2 fate-api-flac
> [...]
> Test api-flac failed. Look at tests/data/fate/api-flac.err for details.
> channel layout: stereo, sample rate: 8000
> unsorted codec_id 'rv60' and 'vc1'.
> Assertion 0 failed at libavcodec/codec_desc.c:3123
> Aborted (core dumped)
> make: *** [fate-api-flac] Error 134

please ignore this, this seems to have been an interaction with another patch

this alone doesnt fail

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH] avcodec/codec_desc: sort codec_descriptors

2018-02-02 Thread Michael Niedermayer
On Sat, Feb 03, 2018 at 01:35:34AM +0700, Muhammad Faiz wrote:
> Use bsearch on avcodec_descriptor_get().
> 
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/codec_desc.c | 1103 
> ---
>  1 file changed, 563 insertions(+), 540 deletions(-)

breaks fate

make V=2 fate-api-flac
[...]
Test api-flac failed. Look at tests/data/fate/api-flac.err for details.
channel layout: stereo, sample rate: 8000
unsorted codec_id 'rv60' and 'vc1'.
Assertion 0 failed at libavcodec/codec_desc.c:3123
Aborted (core dumped)
make: *** [fate-api-flac] Error 134


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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Muhammad Faiz
On Sat, Feb 3, 2018 at 6:34 AM, Hendrik Leppkes  wrote:
> Am 02.02.2018 11:58 nachm. schrieb "Muhammad Faiz" :
>
> On Sat, Feb 3, 2018 at 1:55 AM, Hendrik Leppkes  wrote:
>> On Fri, Feb 2, 2018 at 7:49 PM, Muhammad Faiz  wrote:
>>> On Fri, Feb 2, 2018 at 10:23 PM, Josh de Kock  wrote:

> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
>
>> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
>> Also replace linked list with an array.
>> ---
>> configure  |   12 +-
>> doc/APIchanges |4 +
>> libavcodec/.gitignore  |2 +
>> libavcodec/allcodecs.c | 1473 --
> --
>> libavcodec/avcodec.h   |   31 +
>> libavcodec/parser.c|   84 ++-
>> libavcodec/utils.c |  112 
>> libavcodec/version.h   |3 +
>> 8 files changed, 971 insertions(+), 750 deletions(-)
>>
>
> I have a plan to sort codecs based on name and codec_id (which overlap
> with this patch). Is it OK if I overtake this?
> If it is not OK, I will wait until this patchset pushed.
>

 I am unsure why you would need to sort codecs.
>>>
>>> For performance reason.
>>
>> Performance of what?
>
> avcodec_find_decoder/encoder (by using bsearch).
>
>
> Considering you can have multiple of those for any given codec Id and order
> matters, that seems like a risky idea, or a rather complex one at least.
> Perhaps not the first (or second) place to start optimization.

I've thought about it.

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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Hendrik Leppkes
Am 02.02.2018 11:58 nachm. schrieb "Muhammad Faiz" :

On Sat, Feb 3, 2018 at 1:55 AM, Hendrik Leppkes  wrote:
> On Fri, Feb 2, 2018 at 7:49 PM, Muhammad Faiz  wrote:
>> On Fri, Feb 2, 2018 at 10:23 PM, Josh de Kock  wrote:
>>>
 On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:

> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
> Also replace linked list with an array.
> ---
> configure  |   12 +-
> doc/APIchanges |4 +
> libavcodec/.gitignore  |2 +
> libavcodec/allcodecs.c | 1473 --
--
> libavcodec/avcodec.h   |   31 +
> libavcodec/parser.c|   84 ++-
> libavcodec/utils.c |  112 
> libavcodec/version.h   |3 +
> 8 files changed, 971 insertions(+), 750 deletions(-)
>

 I have a plan to sort codecs based on name and codec_id (which overlap
 with this patch). Is it OK if I overtake this?
 If it is not OK, I will wait until this patchset pushed.

>>>
>>> I am unsure why you would need to sort codecs.
>>
>> For performance reason.
>
> Performance of what?

avcodec_find_decoder/encoder (by using bsearch).


Considering you can have multiple of those for any given codec Id and order
matters, that seems like a risky idea, or a rather complex one at least.
Perhaps not the first (or second) place to start optimization.

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


[FFmpeg-devel] [PATCH] Fix crash in join filter

2018-02-02 Thread Nikolas Bowe
Previously if ff_outlink_frame_wanted() returned 0 it could dereference a null 
pointer when trying to read nb_samples.
---
 libavfilter/af_join.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index cf5131e8dc..4f86e13558 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -485,6 +485,9 @@ static int activate(AVFilterContext *ctx)
 return 0;
 }
 }
+if (!s->input_frames[0]) {
+return 0;
+}
 }
 
 nb_samples = s->input_frames[0]->nb_samples;
-- 
2.16.0.rc1.238.g530d649a79-goog

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


Re: [FFmpeg-devel] [PATCH] avcodec/ffv1: Support for RGBA64 and GBRAP16

2018-02-02 Thread Michael Niedermayer
On Thu, Feb 01, 2018 at 01:43:00PM +0100, Jerome Martinez wrote:
> Add support for 16-bit/component RGB with Alpha encoding and decoding in
> FFV1, both RGBA64 and GBRAP16 for encoding, GBRAP16 for decoding.
> 
> Resulting bitstream was tested about lossless encoding/decoding by the
> compression from DPX to FFV1 then decompression from FFV1 to DPX, see
> commands below (resulting framemd5 hashes are all same).
> Resulting bitstream is decodable by another decoder (with same resulting
> framemd5 hash).
> Resulting bitstream passed through a conformance checker compared to current
> FFV1 specification IETF draft.
> 
> About the patch:
> - some modified lines are not used (the ones not used when f->use32bit is
> 1), but it makes the code more coherent (especially because decode_rgb_frame
> signature is same for both 16-bit and 32-bit version) and prepares the
> support of RGBA with 10/12/14 bits/component.
> - GBRAP16 was chosen for decoding because GBRP16 is already used when no
> alpha, and the code is more prepared for planar pix_fmt when bit depth is
> >8.
> - "s->transparency = desc->nb_components == 4 || desc->nb_components == 2;"
> is a copy of a line a bit above about the detection of transparency, I
> preferred to reuse it as is even if "YA" 16-bit/component is not (yet)
> supported.
> 
> FFmpeg commands used for tests:
> ./ffmpeg -i in.dpx -c:v ffv1 out.mkv
> ./ffmpeg -i in.dpx -pix_fmt gbrap16 -strict -2 -c:v ffv1 out2.mkv
> ./ffmpeg -i out.mkv out.dpx
> 
> ./ffmpeg -i in.dpx -f framemd5 in.dpx.framemd5
> ./ffmpeg -i out.mkv -pix_fmt rgba64be -f framemd5 out.mkv.framemd5
> ./ffmpeg -i out2.mkv -pix_fmt rgba64be -f framemd5 out2.mkv.framemd5
> ./ffmpeg -i out.dpx -f framemd5 out.dpx.framemd5
> 
> Test file used (renamed to in.dpx):
> https://mediaarea.net/temp/uncropped_DPX_4K_16bit_Overscan15pros.dpx

I would prefer if the algorithm would be tuned to 16bit data before
adding more formats to the encoder which require all decoders to support
them.

Dont you agree that this would be the better strategy ?

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Muhammad Faiz
On Sat, Feb 3, 2018 at 1:55 AM, Hendrik Leppkes  wrote:
> On Fri, Feb 2, 2018 at 7:49 PM, Muhammad Faiz  wrote:
>> On Fri, Feb 2, 2018 at 10:23 PM, Josh de Kock  wrote:
>>>
 On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:

> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
> Also replace linked list with an array.
> ---
> configure  |   12 +-
> doc/APIchanges |4 +
> libavcodec/.gitignore  |2 +
> libavcodec/allcodecs.c | 1473 
> 
> libavcodec/avcodec.h   |   31 +
> libavcodec/parser.c|   84 ++-
> libavcodec/utils.c |  112 
> libavcodec/version.h   |3 +
> 8 files changed, 971 insertions(+), 750 deletions(-)
>

 I have a plan to sort codecs based on name and codec_id (which overlap
 with this patch). Is it OK if I overtake this?
 If it is not OK, I will wait until this patchset pushed.

>>>
>>> I am unsure why you would need to sort codecs.
>>
>> For performance reason.
>
> Performance of what?

avcodec_find_decoder/encoder (by using bsearch).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] fail to seek key video packet

2018-02-02 Thread Moritz Barsnick
On Fri, Feb 02, 2018 at 12:02:29 -0300, James Almer wrote:
> > I use following command to test ffmpeg-2.8.1:
> 
> This list is for development of ffmpeg, not for user support or bug reports.
> 
> Use the ffmpeg-user list for user support, and http://trac.ffmpeg.org/
> to report bugs.

And please don't expect anyone to help debug issues with ffmpeg-2.8.1,
or even accept a bug report against it.

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


Re: [FFmpeg-devel] [PATCH v4] avcodec/libopus: support disabling phase inversion.

2018-02-02 Thread Moritz Barsnick
On Thu, Feb 01, 2018 at 22:47:55 +0100, Menno de Gier wrote:
> From: Menno 
> 
> Fix crash on decoder options.

I don't think this was meant to be the final commit message? If you
want to add remarks to your patch in the email, add them directly after
"---" there:

> Signed-off-by: Menno 
> ---

*here*

>  doc/encoders.texi   |  5 +

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


Re: [FFmpeg-devel] [PATCH] FFV1: make RGB48 support as non-experimental

2018-02-02 Thread Michael Niedermayer
On Thu, Feb 01, 2018 at 01:51:17PM +0100, Jerome Martinez wrote:
> On 05/01/2018 11:18, Jerome Martinez wrote:
> >1 year without RGB48 related patches, tested by a couple of users, tested
> >with a FFV1 conformance checker, I suggest that FFV1 RGB48 support in
> >FFmpeg does not mandate anymore the user to add " -strict experimental" on
> >the command line during encoding.
> 
> Sorry, I missed the GBRP16 part.
> I tested the encoding through GBRP16 pix_fmt (instead of RGB48 pix_fmt), and
> it works fine too.
> Additional patch for removing the need of " -strict experimental" for GBRP16
> too.

>  ffv1enc.c |4 
>  1 file changed, 4 deletions(-)
> 1af1e3f7fb3a0e866285623d6f5f1e65bfcebba0  
> 0001-avcodec-ffv1enc-mark-RGB48-support-as-non-experiment.patch
> From 511e036499f716b14fed7ec07d2d8ccf18936444 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martinez?= 
> Date: Thu, 1 Feb 2018 13:15:54 +0100
> Subject: [PATCH] avcodec/ffv1enc: mark RGB48 support as non-experimental
> 
> Remove the 2nd mark, 1st mark was removed in 58e16a4
> ---
>  libavcodec/ffv1enc.c | 4 
>  1 file changed, 4 deletions(-)

will apply

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams

2018-02-02 Thread Michael Niedermayer
On Thu, Feb 01, 2018 at 07:52:55PM +0530, Gyan Doshi wrote:
> On 1/29/2018 6:53 PM, Gyan Doshi wrote:
> >
> >On 1/29/2018 3:47 PM, Carl Eugen Hoyos wrote:
> >
> >>How did you test this patch?
> >
> >By remuxing with patched ffmpeg and then checking with ffprobe, but not
> >ffplay!
> ...
> >Sorry, I'll rework and submit.
> 
> Revised and tested patch attached.

>  mpegenc.c |   17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 21908814c802dffad710828d1e5ec27168586636  
> v2-0001-avformat-mpegenc-accept-PCM_DVD-streams.patch
> From 78757309bbfbc9d9e48aabd6babc9529f83d5950 Mon Sep 17 00:00:00 2001
> From: Gyan Doshi 
> Date: Thu, 1 Feb 2018 19:12:03 +0530
> Subject: [PATCH v2] avformat/mpegenc - accept PCM_DVD streams
> 
> PCM_S16BE stream packets in MPEG-PS have a 3-byte header
> and recognized as PCM_DVD by the demuxer which prevents
> their proper remuxing in MPEG-1/2 PS.
> ---
>  libavformat/mpegenc.c | 17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
> index c77c3dfe41..598df662f4 100644
> --- a/libavformat/mpegenc.c
> +++ b/libavformat/mpegenc.c
> @@ -353,7 +353,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
>  if (!s->is_mpeg2 &&
>  (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
>   st->codecpar->codec_id == AV_CODEC_ID_DTS ||
> - st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE))
> + st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ||
> + st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD))
>   av_log(ctx, AV_LOG_WARNING,
>  "%s in MPEG-1 system streams is not widely 
> supported, "
>  "consider using the vob or the dvd muxer "
> @@ -363,7 +364,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
>  stream->id = ac3_id++;
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_DTS) {
>  stream->id = dts_id++;
> -} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) {
> +} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ||
> +   st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
> +if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD)
> +av_log(ctx, AV_LOG_WARNING, "Only 16-bit LPCM streams 
> are supported.\n");
>  stream->id = lpcm_id++;
>  for (j = 0; j < 4; j++) {
>  if (lpcm_freq_tab[j] == st->codecpar->sample_rate)
> @@ -1150,8 +1154,17 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, 
> AVPacket *pkt)
>  return AVERROR(ENOMEM);
>  pkt_desc->pts= pts;
>  pkt_desc->dts= dts;
> +
> +if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
> +/* Skip first 3 bytes of packet data, which comprise PCM header
> +   and will be written fresh by this muxer. */
> +buf += 3;
> +size -= 3;

Can this be reached with size < 3 ?
if so it would probably do something bad


> +}
> +
>  pkt_desc->unwritten_size =
>  pkt_desc->size   = size;
> +
>  if (!stream->predecode_packet)
>  stream->predecode_packet = pkt_desc;
>  stream->next_packet = _desc->next;
> -- 
> 2.11.1.windows.1
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] [PATCH 3/4] avformat/mpegenc - accept PCM_DVD streams

2018-02-02 Thread Michael Niedermayer
On Thu, Feb 01, 2018 at 07:52:55PM +0530, Gyan Doshi wrote:
> On 1/29/2018 6:53 PM, Gyan Doshi wrote:
> >
> >On 1/29/2018 3:47 PM, Carl Eugen Hoyos wrote:
> >
> >>How did you test this patch?
> >
> >By remuxing with patched ffmpeg and then checking with ffprobe, but not
> >ffplay!
> ...
> >Sorry, I'll rework and submit.
> 
> Revised and tested patch attached.

>  mpegenc.c |   17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 21908814c802dffad710828d1e5ec27168586636  
> v2-0001-avformat-mpegenc-accept-PCM_DVD-streams.patch
> From 78757309bbfbc9d9e48aabd6babc9529f83d5950 Mon Sep 17 00:00:00 2001
> From: Gyan Doshi 
> Date: Thu, 1 Feb 2018 19:12:03 +0530
> Subject: [PATCH v2] avformat/mpegenc - accept PCM_DVD streams
> 
> PCM_S16BE stream packets in MPEG-PS have a 3-byte header
> and recognized as PCM_DVD by the demuxer which prevents
> their proper remuxing in MPEG-1/2 PS.

its probably a good idea to add a fate test for this too.
(could be in a seperate patch)

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

Those who are best at talking, realize last or never when they are wrong.


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


Re: [FFmpeg-devel] [PATCH v4] avcodec/libopus: support disabling phase inversion.

2018-02-02 Thread Michael Niedermayer
On Thu, Feb 01, 2018 at 10:47:55PM +0100, Menno de Gier wrote:
> From: Menno 
> 
> Fix crash on decoder options.
> 
> Signed-off-by: Menno 

This is not the correct commit message for the patch, that just explains
what is different versus the last posted version

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

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


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


[FFmpeg-devel] [PATCH] avcodec/utvideodec: Fix bytes left check in decode_frame()

2018-02-02 Thread Michael Niedermayer
Fixes: out of array read
Fixes: poc-2017.avi

Found-by: GwanYeong Kim 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/utvideodec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 608c8c4998..1bcd14e74c 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -676,7 +676,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 for (j = 0; j < c->slices; j++) {
 slice_end   = bytestream2_get_le32u();
 if (slice_end < 0 || slice_end < slice_start ||
-bytestream2_get_bytes_left() < slice_end) {
+bytestream2_get_bytes_left() < slice_end + 1024LL) {
 av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
 return AVERROR_INVALIDDATA;
 }
-- 
2.16.1

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


[FFmpeg-devel] [PATCH] libavformat/hls: Support metadata updates from subdemuxers

2018-02-02 Thread rshaffer
From: Richard Shaffer 

If a subdemuxer has the updated metadata event flag set, the metadata is copied
to the corresponding stream. The flag is cleared on the subdemuxer and the
appropriate event flag is set on the stream.
---
This is iteration #2.

In this version, we don't try to copy metadata from subdemuxer streams, only
from the AVFormatContext. The case where metadata is updated on a sub-demuxer
stream would have probably never happened.

The above change made the code that was previously in the
update_metadata_from_subdemuxer function a little simpler. That function was
also kind of ugly, because in one case it read and set flags, and in another it
didn't. It seemed simpler just to move the respective updates into read_header
and read_packet, respectively, so that's what I did.

-Richard

 libavformat/hls.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 9bd54c84cc..c578bf86e3 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1062,6 +1062,7 @@ static void handle_id3(AVIOContext *pb, struct playlist 
*pls)
 /* demuxer not yet opened, defer picture attachment */
 pls->id3_deferred_extra = extra_meta;
 
+ff_id3v2_parse_priv_dict(, _meta);
 av_dict_copy(>ctx->metadata, metadata, 0);
 pls->id3_initial = metadata;
 
@@ -1960,6 +1961,7 @@ static int hls_read_header(AVFormatContext *s)
 if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
 ff_id3v2_parse_apic(pls->ctx, >id3_deferred_extra);
 avformat_queue_attached_pictures(pls->ctx);
+ff_id3v2_parse_priv(pls->ctx, >id3_deferred_extra);
 ff_id3v2_free_extra_meta(>id3_deferred_extra);
 pls->id3_deferred_extra = NULL;
 }
@@ -1986,6 +1988,13 @@ static int hls_read_header(AVFormatContext *s)
 if (ret < 0)
 goto fail;
 
+/*
+ * Copy any metadata from playlist to main streams, but do not set
+ * event flags.
+ */
+if (pls->n_main_streams)
+av_dict_copy(>main_streams[0]->metadata, pls->ctx->metadata, 
0);
+
 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO);
 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO);
 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE);
@@ -2170,6 +2179,17 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 
+// If sub-demuxer reports updated metadata, copy it to the first stream
+// and set its AVSTREAM_EVENT_FLAG_METADATA_UPDATED flag.
+if (pls->ctx->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
+if (pls->n_main_streams) {
+st = pls->main_streams[0];
+av_dict_copy(>metadata, pls->ctx->metadata, 0);
+st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+}
+pls->ctx->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
+}
+
 /* check if noheader flag has been cleared by the subdemuxer */
 if (pls->has_noheader_flag && !(pls->ctx->ctx_flags & 
AVFMTCTX_NOHEADER)) {
 pls->has_noheader_flag = 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] [PATCH] ffprobe: Initialize coded_width/height

2018-02-02 Thread James Almer
On 2/2/2018 5:20 PM, Derek Buitenhuis wrote:
> On 2/2/2018 7:46 PM, James Almer wrote:
>> Pushed as is. Removing the two lines after printing bogus values for
>> four releases is imo not nice. For starters, it can't be backported.
>>
>> They will be removed alongside AVStream->codec in the future.
> 
> fftools/ffprobe.c:2918:1: error: unknown type name 
> 'FF_DISABLE_DEPRECATION_WARNINGS'
> 
> - Derek

What system? Works on Windows, apparently because compat/w32pthreads.h
pulls it, So guess I'll just remove it.

Sorry for the breakage.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize coded_width/height

2018-02-02 Thread Derek Buitenhuis
On 2/2/2018 7:46 PM, James Almer wrote:
> Pushed as is. Removing the two lines after printing bogus values for
> four releases is imo not nice. For starters, it can't be backported.
> 
> They will be removed alongside AVStream->codec in the future.

fftools/ffprobe.c:2918:1: error: unknown type name 
'FF_DISABLE_DEPRECATION_WARNINGS'

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


Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize coded_width/height

2018-02-02 Thread James Almer
On 1/25/2018 3:26 AM, Li, Zhong wrote:
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>> Behalf
>>> Of Hendrik Leppkes
>>> Sent: Friday, January 19, 2018 6:10 PM
>>> To: FFmpeg development discussions and patches
>>> 
>>> Subject: Re: [FFmpeg-devel] [PATCH] ffprobe: Initialize
>>> coded_width/height
>>>
>>> On Fri, Jan 19, 2018 at 6:05 AM, Zhong Li  wrote:
 coded_width/height are unnitialized and will be overwritten by
 dec_ctx->width/height in avcodec_open2()

 This fixes tiket #6958.

 Signed-off-by: Zhong Li 
 ---
  fftools/ffprobe.c | 6 ++
  1 file changed, 6 insertions(+)

 diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index
 0e7a771..233760d 100644
 --- a/fftools/ffprobe.c
 +++ b/fftools/ffprobe.c
 @@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w,
>>> AVFormatContext *fmt_ctx, int stream_id
  case AVMEDIA_TYPE_VIDEO:
  print_int("width",par->width);
  print_int("height",   par->height);
 +#if FF_API_LAVF_AVCTX
  if (dec_ctx) {
  print_int("coded_width",  dec_ctx->coded_width);
  print_int("coded_height", dec_ctx->coded_height);
  }
 +#endif
  print_int("has_b_frames", par->video_delay);
  sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
  if (sar.den) {
 @@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile,
 const char *filename)

  ist->dec_ctx->pkt_timebase = stream->time_base;
  ist->dec_ctx->framerate = stream->avg_frame_rate;
 +#if FF_API_LAVF_AVCTX
 +ist->dec_ctx->coded_width =
>>> stream->codec->coded_width;
 +ist->dec_ctx->coded_height =
>>> stream->codec->coded_height;
 +#endif

  if (avcodec_open2(ist->dec_ctx, codec, ) < 0) {
  av_log(NULL, AV_LOG_WARNING, "Could not open
>>> codec
 for input stream %d\n",
>>>
>>> Lets not write new code based on deprecated API.
>>>
>>> - Hendrik
>>
>> Refer the discussion on https://patchwork.ffmpeg.org/patch/7342/
> 
> Ping? 
> I am also ok just remove these two line to print coded_w/h (If this is the 
> best way, I can update this patch), then we can close this ticket.

Pushed as is. Removing the two lines after printing bogus values for
four releases is imo not nice. For starters, it can't be backported.

They will be removed alongside AVStream->codec in the future.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v4 7/7] lavc/bsf: make BSF iteration the same as other iterators

2018-02-02 Thread Josh de Kock
---
 fftools/cmdutils.c |  2 +-
 libavcodec/avcodec.h   |  6 +-
 libavcodec/bitstream_filter.c  |  4 ++--
 libavcodec/bitstream_filters.c | 29 ++---
 4 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 9ecc51b..0b06ccc 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1586,7 +1586,7 @@ int show_bsfs(void *optctx, const char *opt, const char 
*arg)
 void *opaque = NULL;
 
 printf("Bitstream filters:\n");
-while ((bsf = av_bsf_next()))
+while ((bsf = av_bsf_iterate()))
 printf("%s\n", bsf->name);
 printf("\n");
 return 0;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 99f5fb9..c41779a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5728,7 +5728,7 @@ attribute_deprecated
 void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
 /**
  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
- * is deprecated. Use av_bsf_next() from the new bitstream filtering API (using
+ * is deprecated. Use av_bsf_iterate() from the new bitstream filtering API 
(using
  * AVBSFContext).
  */
 attribute_deprecated
@@ -5750,7 +5750,11 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char 
*name);
  * @return the next registered bitstream filter or NULL when the iteration is
  * finished
  */
+const AVBitStreamFilter *av_bsf_iterate(void **opaque);
+#if FF_API_NEXT
+attribute_deprecated
 const AVBitStreamFilter *av_bsf_next(void **opaque);
+#endif
 
 /**
  * Allocate a context for a given bitstream filter. The caller must fill in the
diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c
index ed1cf33..ca11ed3 100644
--- a/libavcodec/bitstream_filter.c
+++ b/libavcodec/bitstream_filter.c
@@ -34,9 +34,9 @@ const AVBitStreamFilter *av_bitstream_filter_next(const 
AVBitStreamFilter *f)
 void *opaque = NULL;
 
 while (filter != f)
-filter = av_bsf_next();
+filter = av_bsf_iterate();
 
-return av_bsf_next();
+return av_bsf_iterate();
 }
 
 void av_register_bitstream_filter(AVBitStreamFilter *bsf)
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 7b0cb50..338ef82 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -52,7 +52,7 @@ extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
 
 #include "libavcodec/bsf_list.c"
 
-const AVBitStreamFilter *av_bsf_next(void **opaque)
+const AVBitStreamFilter *av_bsf_iterate(void **opaque)
 {
 uintptr_t i = (uintptr_t)*opaque;
 const AVBitStreamFilter *f = bitstream_filters[i];
@@ -63,12 +63,18 @@ const AVBitStreamFilter *av_bsf_next(void **opaque)
 return f;
 }
 
+#if FF_API_NEXT
+const AVBitStreamFilter *av_bsf_next(void **opaque) {
+return av_bsf_iterate(opaque);
+}
+#endif
+
 const AVBitStreamFilter *av_bsf_get_by_name(const char *name)
 {
-int i;
+const AVBitStreamFilter *f = NULL;
+void *i = 0;
 
-for (i = 0; bitstream_filters[i]; i++) {
-const AVBitStreamFilter *f = bitstream_filters[i];
+while ((f = av_bsf_iterate())) {
 if (!strcmp(f->name, name))
 return f;
 }
@@ -78,19 +84,20 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char 
*name)
 
 const AVClass *ff_bsf_child_class_next(const AVClass *prev)
 {
-int i;
+const AVBitStreamFilter *f = NULL;
+void *i = 0;
 
 /* find the filter that corresponds to prev */
-for (i = 0; prev && bitstream_filters[i]; i++) {
-if (bitstream_filters[i]->priv_class == prev) {
-i++;
+while (prev && (f = av_bsf_iterate())) {
+if (f->priv_class == prev) {
 break;
 }
 }
 
 /* find next filter with priv options */
-for (; bitstream_filters[i]; i++)
-if (bitstream_filters[i]->priv_class)
-return bitstream_filters[i]->priv_class;
+while ((f = av_bsf_iterate())) {
+if (f->priv_class)
+return f->priv_class;
+}
 return NULL;
 }
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v4 6/7] cmdutils: make use of new iteration APIs

2018-02-02 Thread Josh de Kock
---
 fftools/cmdutils.c | 122 +++--
 1 file changed, 43 insertions(+), 79 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6920ca0..9ecc51b 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"
@@ -1275,34 +1267,24 @@ static int show_formats_devices(void *optctx, const 
char *opt, const char *arg,
 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())) { \
+if ((!name || strcmp(type->name, name) < 0) &&  \
+strcmp(type->name, last_name) > 0) {\
+name  = type->name; \
+long_name = type->long_name;\
+encode= 1;  \
+}   \
+}   \
+} } while(0)
+
+x(av_muxer_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS && 
!device_only);
+x(av_outdev_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS);
+x(av_demuxer_iterate, ifmt, muxdemuxers != SHOW_MUXERS && 
!device_only);
+x(av_indev_iterate, ifmt, muxdemuxers != SHOW_MUXERS);
+#undef x
 if (!name)
 break;
 last_name = name;
@@ -1442,7 +1424,8 @@ static char get_media_type_char(enum AVMediaType type)
 static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
 int encoder)
 {
-while ((prev = av_codec_next(prev))) {
+void *i = 0;
+while ((prev = av_codec_iterate())) {
 if (prev->id == id &&
 (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
 return prev;
@@ -2116,7 +2099,7 @@ double get_rotation(AVStream *st)
 }
 
 #if CONFIG_AVDEVICE
-static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
+static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
 {
 int ret, i;
 AVDeviceInfoList *device_list = NULL;
@@ -2131,7 +2114,7 @@ static int print_device_sources(AVInputFormat *fmt, 
AVDictionary *opts)
 goto fail;
 }
 
-if ((ret = avdevice_list_input_sources(fmt, NULL, opts, _list)) < 
0) {
+if ((ret = avdevice_list_input_sources((AVInputFormat*)fmt, NULL, opts, 
_list)) < 0) {
 printf("Cannot list sources.\n");
 goto fail;
 }
@@ -2146,7 +2129,7 @@ static int print_device_sources(AVInputFormat *fmt, 
AVDictionary *opts)
 return ret;
 }
 
-static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
+static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts)
 {
 int ret, i;
 AVDeviceInfoList *device_list = NULL;
@@ -2161,7 +2144,7 @@ static int print_device_sinks(AVOutputFormat *fmt, 
AVDictionary *opts)
 goto fail;
 }
 
-if ((ret = 

[FFmpeg-devel] [PATCH v4 5/7] lavd: add new API for iterating input and output devices

2018-02-02 Thread Josh de Kock
This also adds an avpriv function to register devices in
libavformat
---
 Makefile |   3 +-
 configure|  27 +--
 libavdevice/.gitignore   |   2 +
 libavdevice/alldevices.c | 181 ---
 libavdevice/avdevice.c   |  46 
 libavdevice/avdevice.h   |  28 
 libavdevice/version.h|   4 ++
 libavformat/allformats.c |  45 +++-
 libavformat/format.c |   8 +++
 libavformat/internal.h   |   7 ++
 10 files changed, 255 insertions(+), 96 deletions(-)
 create mode 100644 libavdevice/.gitignore

diff --git a/Makefile b/Makefile
index 0cd0a1d..bb93b69 100644
--- a/Makefile
+++ b/Makefile
@@ -144,7 +144,8 @@ distclean:: clean
version.h libavutil/ffversion.h libavcodec/codec_names.h \
libavcodec/bsf_list.c libavformat/protocol_list.c \
libavcodec/codec_list.c libavcodec/parser_list.c \
-   libavformat/muxer_list.c libavformat/demuxer_list.c
+   libavformat/muxer_list.c libavformat/demuxer_list.c \
+   libavdevice/indev_list.c libavdevice/outdev_list.c
 ifeq ($(SRC_LINK),src)
$(RM) src
 endif
diff --git a/configure b/configure
index d6d7980..040b848 100755
--- a/configure
+++ b/configure
@@ -568,6 +568,12 @@ add_suffix(){
 for v; do echo ${v}${suffix}; done
 }
 
+remove_suffix(){
+suffix=$1
+shift
+for v; do echo ${v%$suffix}; done
+}
+
 set_all(){
 value=$1
 shift
@@ -3523,17 +3529,18 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
-INDEV_LIST=$(find_thingsindev_IN  libavdevice/alldevices.c)
 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
 
 find_things_extern(){
 thing=$1
 pattern=$2
 file=$source_path/$3
-sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
+out=${4:-$thing}
+sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
 }
 
+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)
 DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat 
libavformat/allformats.c)
 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
@@ -7025,7 +7032,17 @@ print_enabled_components(){
 shift 3
 echo "static const $struct_name * const $name[] = {" > $TMPH
 for c in $*; do
-enabled $c && printf "_%s,\n" $c >> $TMPH
+if enabled $c; then
+case $name in
+indev_list)
+c=$(add_suffix _demuxer $(remove_suffix _indev $c))
+;;
+outdev_list)
+c=$(add_suffix _muxer $(remove_suffix _outdev $c))
+;;
+esac
+printf "_%s,\n" $c >> $TMPH
+fi
 done
 echo "NULL };" >> $TMPH
 cp_if_changed $TMPH $file
@@ -7034,6 +7051,8 @@ print_enabled_components(){
 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
+print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list 
$INDEV_LIST
+print_enabled_components libavdevice/outdev_list.c AVOutputFormat outdev_list 
$OUTDEV_LIST
 print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list 
$DEMUXER_LIST
 print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list 
$MUXER_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
diff --git a/libavdevice/.gitignore b/libavdevice/.gitignore
new file mode 100644
index 000..08ac3eb
--- /dev/null
+++ b/libavdevice/.gitignore
@@ -0,0 +1,2 @@
+/indev_list.c
+/outdev_list.c
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index b767b6a..8b58aa1 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -22,57 +22,152 @@
 #include "libavutil/thread.h"
 #include "avdevice.h"
 
-#define REGISTER_OUTDEV(X, x)   \
-{   \
-extern AVOutputFormat ff_##x##_muxer;   \
-if (CONFIG_##X##_OUTDEV)\
-av_register_output_format(_##x##_muxer); \
+#if FF_API_NEXT
+#include "libavformat/internal.h"
+#endif
+
+/* devices */
+extern AVInputFormat  ff_alsa_demuxer;
+extern AVOutputFormat ff_alsa_muxer;
+extern AVInputFormat  ff_avfoundation_demuxer;
+extern AVInputFormat  

[FFmpeg-devel] [PATCH v4 4/7] lavf: move fifo test muxer into separate file

2018-02-02 Thread Josh de Kock
This fixes the fate-fifo-muxer test.
---
 libavformat/Makefile   |   2 +-
 libavformat/allformats.c   |   1 +
 libavformat/fifo_test.c| 150 +
 libavformat/tests/fifo_muxer.c | 115 +--
 4 files changed, 154 insertions(+), 114 deletions(-)
 create mode 100644 libavformat/fifo_test.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index de0de92..e0bb8ae 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -163,7 +163,7 @@ OBJS-$(CONFIG_EAC3_MUXER)+= rawenc.o
 OBJS-$(CONFIG_EPAF_DEMUXER)  += epafdec.o pcm.o
 OBJS-$(CONFIG_FFMETADATA_DEMUXER)+= ffmetadec.o
 OBJS-$(CONFIG_FFMETADATA_MUXER)  += ffmetaenc.o
-OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
+OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o fifo_test.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
 OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0f198d5..09c4213 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -125,6 +125,7 @@ extern AVOutputFormat ff_f4v_muxer;
 extern AVInputFormat  ff_ffmetadata_demuxer;
 extern AVOutputFormat ff_ffmetadata_muxer;
 extern AVOutputFormat ff_fifo_muxer;
+extern AVOutputFormat ff_fifo_test_muxer;
 extern AVInputFormat  ff_filmstrip_demuxer;
 extern AVOutputFormat ff_filmstrip_muxer;
 extern AVInputFormat  ff_fits_demuxer;
diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c
new file mode 100644
index 000..b86195b
--- /dev/null
+++ b/libavformat/fifo_test.c
@@ -0,0 +1,150 @@
+/*
+ * FIFO test pseudo-muxer
+ * Copyright (c) 2016 Jan Sebechlebsky
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavutil/opt.h"
+#include "libavutil/time.h"
+#include "libavutil/avassert.h"
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+#include "libavformat/network.h"
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+#define MAX_TST_PACKETS 128
+#define SLEEPTIME_50_MS 5
+#define SLEEPTIME_10_MS 1
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+/* This is structure of data sent in packets to
+ * failing muxer */
+typedef struct FailingMuxerPacketData {
+int ret; /* return value of write_packet call*/
+int recover_after;   /* set ret to zero after this number of recovery 
attempts */
+unsigned sleep_time; /* sleep for this long in write_packet to simulate 
long I/O operation */
+} FailingMuxerPacketData;
+
+
+typedef struct FailingMuxerContext {
+AVClass *class;
+int write_header_ret;
+int write_trailer_ret;
+/* If non-zero, summary of processed packets will be printed in deinit */
+int print_deinit_summary;
+
+int flush_count;
+int pts_written[MAX_TST_PACKETS];
+int pts_written_nr;
+} FailingMuxerContext;
+
+static int failing_write_header(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_header_ret;
+}
+
+static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+int ret = 0;
+if (!pkt) {
+ctx->flush_count++;
+} else {
+FailingMuxerPacketData *data = (FailingMuxerPacketData*) pkt->data;
+
+if (!data->recover_after) {
+data->ret = 0;
+} else {
+data->recover_after--;
+}
+
+ret = data->ret;
+
+if (data->sleep_time) {
+int64_t slept = 0;
+while (slept < data->sleep_time) {
+if (ff_check_interrupt(>interrupt_callback))
+return AVERROR_EXIT;
+av_usleep(SLEEPTIME_10_MS);
+slept += SLEEPTIME_10_MS;
+}
+}
+
+if (!ret) {
+ctx->pts_written[ctx->pts_written_nr++] = pkt->pts;
+av_packet_unref(pkt);
+}
+}
+return ret;
+}
+
+static int failing_write_trailer(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_trailer_ret;
+}
+
+static void 

[FFmpeg-devel] [PATCH v4 3/7] lavf: add new API for iterating muxers and demuxers

2018-02-02 Thread Josh de Kock
---
 Makefile |   3 +-
 configure|   6 +-
 doc/APIchanges   |   7 +-
 libavformat/.gitignore   |   2 +
 libavformat/allformats.c | 866 ---
 libavformat/avformat.h   |  31 ++
 libavformat/format.c |  68 +---
 libavformat/version.h|   3 +
 8 files changed, 566 insertions(+), 420 deletions(-)

diff --git a/Makefile b/Makefile
index 1d1c886..0cd0a1d 100644
--- a/Makefile
+++ b/Makefile
@@ -143,7 +143,8 @@ distclean:: clean
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \
libavcodec/bsf_list.c libavformat/protocol_list.c \
-   libavcodec/codec_list.c libavcodec/parser_list.c
+   libavcodec/codec_list.c libavcodec/parser_list.c \
+   libavformat/muxer_list.c libavformat/demuxer_list.c
 ifeq ($(SRC_LINK),src)
$(RM) src
 endif
diff --git a/configure b/configure
index e8795d8..d6d7980 100755
--- a/configure
+++ b/configure
@@ -3523,8 +3523,6 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
-DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
 INDEV_LIST=$(find_thingsindev_IN  libavdevice/alldevices.c)
 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
@@ -3536,6 +3534,8 @@ find_things_extern(){
 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
 }
 
+MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
+DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat 
libavformat/allformats.c)
 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
 DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
 CODEC_LIST="
@@ -7034,6 +7034,8 @@ print_enabled_components(){
 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
+print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list 
$DEMUXER_LIST
+print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list 
$MUXER_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
 
 # Settings for pkg-config files
diff --git a/doc/APIchanges b/doc/APIchanges
index 77da22c..2a12f22 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,7 +15,12 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
-2018-01-xx - xxx - lavc 58.9.100 - avcodec.h
+2018-xx-xx - xxx - lavf 58.9.100 - avformat.h
+  Deprecate use of av_register_input_format(), av_register_output_format(),
+  avformat_register_all(), av_iformat_next(), av_oformat_next().
+  Add av_demuxer_iterate(), and av_muxer_iterate().
+
+2018-xx-xx - xxx - lavc 58.9.100 - avcodec.h
   Deprecate use of avcodec_register(), avcodec_register_all(), and
   av_codec_next(). Add av_codec_iterate().
 
diff --git a/libavformat/.gitignore b/libavformat/.gitignore
index cdc24b7..fb70c12 100644
--- a/libavformat/.gitignore
+++ b/libavformat/.gitignore
@@ -1 +1,3 @@
 /protocol_list.c
+/muxer_list.c
+/demuxer_list.c
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 83ed766..0f198d5 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -26,370 +26,528 @@
 #include "url.h"
 #include "version.h"
 
-#define REGISTER_MUXER(X, x)\
-{   \
-extern AVOutputFormat ff_##x##_muxer;   \
-if (CONFIG_##X##_MUXER) \
-av_register_output_format(_##x##_muxer); \
-}
+/* (de)muxers */
+extern AVOutputFormat ff_a64_muxer;
+extern AVInputFormat  ff_aa_demuxer;
+extern AVInputFormat  ff_aac_demuxer;
+extern AVInputFormat  ff_ac3_demuxer;
+extern AVOutputFormat ff_ac3_muxer;
+extern AVInputFormat  ff_acm_demuxer;
+extern AVInputFormat  ff_act_demuxer;
+extern AVInputFormat  ff_adf_demuxer;
+extern AVInputFormat  ff_adp_demuxer;
+extern AVInputFormat  ff_ads_demuxer;
+extern AVOutputFormat ff_adts_muxer;
+extern AVInputFormat  ff_adx_demuxer;
+extern AVOutputFormat ff_adx_muxer;
+extern AVInputFormat  ff_aea_demuxer;
+extern AVInputFormat  ff_afc_demuxer;
+extern AVInputFormat  ff_aiff_demuxer;
+extern AVOutputFormat ff_aiff_muxer;
+extern AVInputFormat  ff_aix_demuxer;
+extern AVInputFormat  ff_amr_demuxer;
+extern AVOutputFormat ff_amr_muxer;
+extern AVInputFormat  ff_amrnb_demuxer;
+extern AVInputFormat  

[FFmpeg-devel] [PATCH v4 1/7] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Josh de Kock
Based on an unfinished patch by atomnuker.
---
 Makefile   |3 +-
 configure  |   12 +-
 doc/APIchanges |4 +
 libavcodec/.gitignore  |2 +
 libavcodec/allcodecs.c | 1473 
 libavcodec/avcodec.h   |   31 +
 libavcodec/parser.c|   84 ++-
 libavcodec/utils.c |  112 
 libavcodec/version.h   |3 +
 9 files changed, 973 insertions(+), 751 deletions(-)

diff --git a/Makefile b/Makefile
index 9defdde..1d1c886 100644
--- a/Makefile
+++ b/Makefile
@@ -142,7 +142,8 @@ distclean:: clean
$(RM) .version avversion.h config.asm config.h mapfile  \
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \
-   libavcodec/bsf_list.c libavformat/protocol_list.c
+   libavcodec/bsf_list.c libavformat/protocol_list.c \
+   libavcodec/codec_list.c libavcodec/parser_list.c
 ifeq ($(SRC_LINK),src)
$(RM) src
 endif
diff --git a/configure b/configure
index 0b01a22..e8795d8 100755
--- a/configure
+++ b/configure
@@ -3523,9 +3523,6 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-ENCODER_LIST=$(find_things  encoder  ENC  libavcodec/allcodecs.c)
-DECODER_LIST=$(find_things  decoder  DEC  libavcodec/allcodecs.c)
-PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
 MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
 DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
@@ -3539,6 +3536,13 @@ find_things_extern(){
 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
 }
 
+ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
+DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
+CODEC_LIST="
+$ENCODER_LIST
+$DECODER_LIST
+"
+PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c)
 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter 
libavcodec/bitstream_filters.c)
 HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol 
libavformat/protocols.c)
@@ -7027,6 +7031,8 @@ print_enabled_components(){
 cp_if_changed $TMPH $file
 }
 
+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
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
 
diff --git a/doc/APIchanges b/doc/APIchanges
index 6185545..77da22c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-01-xx - xxx - lavc 58.9.100 - avcodec.h
+  Deprecate use of avcodec_register(), avcodec_register_all(), and
+  av_codec_next(). Add av_codec_iterate().
+
 2018-01-xx - xxx - lavf 58.7.100 - avformat.h
   Deprecate AVFormatContext filename field which had limited length, use the
   new dynamically allocated url field instead.
diff --git a/libavcodec/.gitignore b/libavcodec/.gitignore
index 77a2ab1..28814f7 100644
--- a/libavcodec/.gitignore
+++ b/libavcodec/.gitignore
@@ -2,3 +2,5 @@
 /*_tables.c
 /*_tables.h
 /bsf_list.c
+/codec_list.c
+/parser_list.c
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ed1e7ab..c15547a 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -29,641 +29,864 @@
 #include "avcodec.h"
 #include "version.h"
 
-#define REGISTER_ENCODER(X, x)  \
-{   \
-extern AVCodec ff_##x##_encoder;\
-if (CONFIG_##X##_ENCODER)   \
-avcodec_register(_##x##_encoder);\
-}
+extern AVCodec ff_a64multi_encoder;
+extern AVCodec ff_a64multi5_encoder;
+extern AVCodec ff_aasc_decoder;
+extern AVCodec ff_aic_decoder;
+extern AVCodec ff_alias_pix_encoder;
+extern AVCodec ff_alias_pix_decoder;
+extern AVCodec ff_amv_encoder;
+extern AVCodec ff_amv_decoder;
+extern AVCodec ff_anm_decoder;
+extern AVCodec ff_ansi_decoder;
+extern AVCodec ff_apng_encoder;
+extern AVCodec ff_apng_decoder;
+extern AVCodec ff_asv1_encoder;
+extern AVCodec ff_asv1_decoder;
+extern AVCodec ff_asv2_encoder;
+extern AVCodec ff_asv2_decoder;
+extern AVCodec ff_aura_decoder;
+extern AVCodec ff_aura2_decoder;
+extern AVCodec ff_avrp_encoder;
+extern AVCodec ff_avrp_decoder;
+extern AVCodec ff_avrn_decoder;
+extern AVCodec ff_avs_decoder;
+extern AVCodec ff_avui_encoder;
+extern AVCodec ff_avui_decoder;
+extern AVCodec 

[FFmpeg-devel] [PATCH v4 2/7] lavf/rtp: replace linked list with array

2018-02-02 Thread Josh de Kock
---
 libavformat/allformats.c |   4 --
 libavformat/rdt.c|   9 +---
 libavformat/rdt.h|   5 --
 libavformat/rtpdec.c | 138 ++-
 libavformat/rtpdec.h |  25 +++--
 5 files changed, 100 insertions(+), 81 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ec84096..83ed766 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -282,10 +282,6 @@ static void register_all(void)
 REGISTER_DEMUXER (SDR2, sdr2);
 REGISTER_DEMUXER (SDS,  sds);
 REGISTER_DEMUXER (SDX,  sdx);
-#if CONFIG_RTPDEC
-ff_register_rtp_dynamic_payload_handlers();
-ff_register_rdt_dynamic_payload_handlers();
-#endif
 REGISTER_DEMUXER (SEGAFILM, segafilm);
 REGISTER_MUXER   (SEGMENT,  segment);
 REGISTER_MUXER   (SEGMENT,  stream_segment);
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index b69827f..31a32ff 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -554,7 +554,7 @@ rdt_close_context (PayloadContext *rdt)
 }
 
 #define RDT_HANDLER(n, s, t) \
-static RTPDynamicProtocolHandler rdt_ ## n ## _handler = { \
+RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
 .enc_name = s, \
 .codec_type   = t, \
 .codec_id = AV_CODEC_ID_NONE, \
@@ -570,10 +570,3 @@ RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", 
AVMEDIA_TYPE_AUDIO);
 RDT_HANDLER(video,  "x-pn-realvideo",AVMEDIA_TYPE_VIDEO);
 RDT_HANDLER(audio,  "x-pn-realaudio",AVMEDIA_TYPE_AUDIO);
 
-void ff_register_rdt_dynamic_payload_handlers(void)
-{
-ff_register_dynamic_payload_handler(_video_handler);
-ff_register_dynamic_payload_handler(_audio_handler);
-ff_register_dynamic_payload_handler(_live_video_handler);
-ff_register_dynamic_payload_handler(_live_audio_handler);
-}
diff --git a/libavformat/rdt.h b/libavformat/rdt.h
index ce6026f..2480565 100644
--- a/libavformat/rdt.h
+++ b/libavformat/rdt.h
@@ -60,11 +60,6 @@ void ff_rdt_calc_response_and_checksum(char response[41], 
char chksum[9],
const char *challenge);
 
 /**
- * Register RDT-related dynamic payload handlers with our cache.
- */
-void ff_register_rdt_dynamic_payload_handlers(void);
-
-/**
  * Add subscription information to Subscribe parameter string.
  *
  * @param cmd string to write the subscription information into.
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 4acb1ca..6499e27 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -69,88 +69,104 @@ static RTPDynamicProtocolHandler t140_dynamic_handler = { 
/* RFC 4103 */
 .codec_id   = AV_CODEC_ID_TEXT,
 };
 
-static RTPDynamicProtocolHandler *rtp_first_dynamic_payload_handler = NULL;
+extern RTPDynamicProtocolHandler ff_rdt_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_audio_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_audio_handler;
+
+static const RTPDynamicProtocolHandler *rtp_dynamic_protocol_handler_list[] = {
+/* rtp */
+_ac3_dynamic_handler,
+_amr_nb_dynamic_handler,
+_amr_wb_dynamic_handler,
+_dv_dynamic_handler,
+_g726_16_dynamic_handler,
+_g726_24_dynamic_handler,
+_g726_32_dynamic_handler,
+_g726_40_dynamic_handler,
+_g726le_16_dynamic_handler,
+_g726le_24_dynamic_handler,
+_g726le_32_dynamic_handler,
+_g726le_40_dynamic_handler,
+_h261_dynamic_handler,
+_h263_1998_dynamic_handler,
+_h263_2000_dynamic_handler,
+_h263_rfc2190_dynamic_handler,
+_h264_dynamic_handler,
+_hevc_dynamic_handler,
+_ilbc_dynamic_handler,
+_jpeg_dynamic_handler,
+_mp4a_latm_dynamic_handler,
+_mp4v_es_dynamic_handler,
+_mpeg_audio_dynamic_handler,
+_mpeg_audio_robust_dynamic_handler,
+_mpeg_video_dynamic_handler,
+_mpeg4_generic_dynamic_handler,
+_mpegts_dynamic_handler,
+_ms_rtp_asf_pfa_handler,
+_ms_rtp_asf_pfv_handler,
+_qcelp_dynamic_handler,
+_qdm2_dynamic_handler,
+_qt_rtp_aud_handler,
+_qt_rtp_vid_handler,
+_quicktime_rtp_aud_handler,
+_quicktime_rtp_vid_handler,
+_rfc4175_rtp_handler,
+_svq3_dynamic_handler,
+_theora_dynamic_handler,
+_vc2hq_dynamic_handler,
+_vorbis_dynamic_handler,
+_vp8_dynamic_handler,
+_vp9_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+_mp3_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+/* rdt */
+_rdt_video_handler,
+_rdt_audio_handler,
+_rdt_live_video_handler,
+_rdt_live_audio_handler,
+NULL,
+};
 
-void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
+const RTPDynamicProtocolHandler *ff_rtp_handler_iterate(void **opaque)
 {
-handler->next = rtp_first_dynamic_payload_handler;
-

Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.

2018-02-02 Thread Richard Shaffer
On Fri, Feb 2, 2018 at 5:52 AM, James Almer  wrote:
> On 2/1/2018 11:37 PM, rshaf...@tunein.com wrote:
>> From: Richard Shaffer 
>>
>> While rare, ID3 tags may be inserted between ADTS frames. This change enables
>> parsing them and setting the appropriate metadata updated event flag.
>> ---
>> I have encountered a streaming provider that I must support which does this.
>> There are indications that it isn't totally off the wall, and that it does
>> happen in the wild:
>> * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/
>>   (See specifically sections 3 and 4.)
>> * https://github.com/video-dev/hls.js/issues/508
>>
>> That being said, the providers that do this are in the minority. It seems 
>> most
>> streaming providers will do one of the following:
>>  1. If using .aac segments inside of HLS, use the #EXTINF for text metadata 
>> and
>> use an ID3 tag at the head of the segment for things like timing 
>> metadata.
>>  2. If streaming raw AAC over HTTP, use Icy metadata.
>>
>> Aside from comments on the code, I'd be interested in any opinion about 
>> whether
>> this is something that should or should not be supported in libavformat.
>>
>> Thanks,
>>
>> -Richard
>
> Can you provide a sample and add a fate test for this? To avoid
> regressions in the future. This demuxer still needs some work.
>
> Use the new probetags() function you added in your other id3v2 test if
> the tags between samples in the file are the only ones, or if they
> differ in some way from the ones at the beginning of the file, so
> ffprobe will report them instead.
> Alternatively, see fate-adts-demux in tests/fate/demux.mak

Oh, somebody did merge that test. How cool.

I don't think we can test this with ffprobe, though. It will just read
tags at the head of the file and not in the middle.

I have at least one sample that's ok for me to share. I'll work on a
separate patch to add a fate test.

-Richard

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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Hendrik Leppkes
On Fri, Feb 2, 2018 at 7:49 PM, Muhammad Faiz  wrote:
> On Fri, Feb 2, 2018 at 10:23 PM, Josh de Kock  wrote:
>>
>>> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
>>>
 On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
 Also replace linked list with an array.
 ---
 configure  |   12 +-
 doc/APIchanges |4 +
 libavcodec/.gitignore  |2 +
 libavcodec/allcodecs.c | 1473 
 
 libavcodec/avcodec.h   |   31 +
 libavcodec/parser.c|   84 ++-
 libavcodec/utils.c |  112 
 libavcodec/version.h   |3 +
 8 files changed, 971 insertions(+), 750 deletions(-)

>>>
>>> I have a plan to sort codecs based on name and codec_id (which overlap
>>> with this patch). Is it OK if I overtake this?
>>> If it is not OK, I will wait until this patchset pushed.
>>>
>>
>> I am unsure why you would need to sort codecs.
>
> For performance reason.

Performance of what?

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


Re: [FFmpeg-devel] [PATCH] avcodec: do not use init_static_data on some codecs

2018-02-02 Thread wm4
On Sat,  3 Feb 2018 01:36:37 +0700
Muhammad Faiz  wrote:

> They don't modify AVCodec, no needs to call it at register. They will be
> wasteful if these codecs are unused. Instead, call static data initialization
> at codecs' init.
> 
> Benchmark:
> old: 51281340 decicycles in avcodec_register_all,   1 runs,  0 skips
> new:  6738960 decicycles in avcodec_register_all,   1 runs,  0 skips
> 
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/jpeg2000dec.c | 16 +---
>  libavcodec/qdmc.c|  7 +--
>  libavcodec/wmavoice.c|  7 +--
>  3 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 01fe4b3949..4cf8a2880c 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/thread.h"
>  #include "avcodec.h"
>  #include "bytestream.h"
>  #include "internal.h"
> @@ -2142,10 +2143,18 @@ static int jp2_find_codestream(Jpeg2000DecoderContext 
> *s)
>  return 0;
>  }
>  
> +static av_cold void jpeg2000_init_static_data(void)
> +{
> +ff_jpeg2000_init_tier1_luts();
> +ff_mqc_init_context_tables();
> +}
> +
>  static av_cold int jpeg2000_decode_init(AVCodecContext *avctx)
>  {
> +static AVOnce init_static_once = AV_ONCE_INIT;
>  Jpeg2000DecoderContext *s = avctx->priv_data;
>  
> +ff_thread_once(_static_once, jpeg2000_init_static_data);
>  ff_jpeg2000dsp_init(>dsp);
>  
>  return 0;
> @@ -2223,12 +2232,6 @@ end:
>  return ret;
>  }
>  
> -static av_cold void jpeg2000_init_static_data(AVCodec *codec)
> -{
> -ff_jpeg2000_init_tier1_luts();
> -ff_mqc_init_context_tables();
> -}
> -
>  #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
>  #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
>  
> @@ -2252,7 +2255,6 @@ AVCodec ff_jpeg2000_decoder = {
>  .id   = AV_CODEC_ID_JPEG2000,
>  .capabilities = AV_CODEC_CAP_SLICE_THREADS | 
> AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_DR1,
>  .priv_data_size   = sizeof(Jpeg2000DecoderContext),
> -.init_static_data = jpeg2000_init_static_data,
>  .init = jpeg2000_decode_init,
>  .decode   = jpeg2000_decode_frame,
>  .priv_class   = _class,
> diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
> index 1c8952b97b..f1f86accd8 100644
> --- a/libavcodec/qdmc.c
> +++ b/libavcodec/qdmc.c
> @@ -26,6 +26,7 @@
>  #define BITSTREAM_READER_LE
>  
>  #include "libavutil/channel_layout.h"
> +#include "libavutil/thread.h"
>  
>  #include "avcodec.h"
>  #include "bytestream.h"
> @@ -204,7 +205,7 @@ static const uint8_t phase_diff_codes[] = {
> INIT_VLC_LE | INIT_VLC_USE_NEW_STATIC); \
>  } while (0)
>  
> -static av_cold void qdmc_init_static_data(AVCodec *codec)
> +static av_cold void qdmc_init_static_data(void)
>  {
>  int i;
>  
> @@ -250,10 +251,13 @@ static void make_noises(QDMCContext *s)
>  
>  static av_cold int qdmc_decode_init(AVCodecContext *avctx)
>  {
> +static AVOnce init_static_once = AV_ONCE_INIT;
>  QDMCContext *s = avctx->priv_data;
>  int fft_size, fft_order, size, g, j, x;
>  GetByteContext b;
>  
> +ff_thread_once(_static_once, qdmc_init_static_data);
> +
>  if (!avctx->extradata || (avctx->extradata_size < 48)) {
>  av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n");
>  return AVERROR_INVALIDDATA;
> @@ -775,7 +779,6 @@ AVCodec ff_qdmc_decoder = {
>  .id   = AV_CODEC_ID_QDMC,
>  .priv_data_size   = sizeof(QDMCContext),
>  .init = qdmc_decode_init,
> -.init_static_data = qdmc_init_static_data,
>  .close= qdmc_decode_close,
>  .decode   = qdmc_decode_frame,
>  .flush= qdmc_flush,
> diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
> index 3f86d0da35..444e303b0d 100644
> --- a/libavcodec/wmavoice.c
> +++ b/libavcodec/wmavoice.c
> @@ -30,6 +30,7 @@
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/float_dsp.h"
>  #include "libavutil/mem.h"
> +#include "libavutil/thread.h"
>  #include "avcodec.h"
>  #include "internal.h"
>  #include "get_bits.h"
> @@ -310,7 +311,7 @@ static av_cold int decode_vbmtree(GetBitContext *gb, 
> int8_t vbm_tree[25])
>  return 0;
>  }
>  
> -static av_cold void wmavoice_init_static_data(AVCodec *codec)
> +static av_cold void wmavoice_init_static_data(void)
>  {
>  static const uint8_t bits[] = {
>   2,  2,  2,  4,  4,  4,
> @@ -365,9 +366,12 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx)
>   */
>  static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
>  {
> +static AVOnce init_static_once = AV_ONCE_INIT;
>  int n, flags, pitch_range, lsp16_flag;
>  WMAVoiceContext *s = ctx->priv_data;
>  
> +

Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Josh de Kock
On Fri, Feb 2, 2018, at 6:53 PM, James Almer wrote:
> On 2/2/2018 12:23 PM, Josh de Kock wrote:
> > 
> >> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
> >>
> >>> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
> >>> Also replace linked list with an array.
> >>> ---
> >>> configure  |   12 +-
> >>> doc/APIchanges |4 +
> >>> libavcodec/.gitignore  |2 +
> >>> libavcodec/allcodecs.c | 1473 
> >>> 
> >>> libavcodec/avcodec.h   |   31 +
> >>> libavcodec/parser.c|   84 ++-
> >>> libavcodec/utils.c |  112 
> >>> libavcodec/version.h   |3 +
> >>> 8 files changed, 971 insertions(+), 750 deletions(-)
> >>>
> >>
> >> I have a plan to sort codecs based on name and codec_id (which overlap
> >> with this patch). Is it OK if I overtake this?
> >> If it is not OK, I will wait until this patchset pushed.
> >>
> > 
> > I am unsure why you would need to sort codecs. The point of my patches is 
> > to bring the rest of ffmpeg up to the bsf iteration api (which abstracts 
> > internals away from the user).
> 
> Doesn't bsf use next() and not iterate()?

It does but it doesn't really make sense to use _next when all the other _next 
functions dont work like bsf. I was contemplating whether I should rename the 
bsf api to use _iterate as well (i.e. deprecate current name, rename current 
functions, and have a function with the old names calling the new names).

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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread James Almer
On 2/2/2018 12:23 PM, Josh de Kock wrote:
> 
>> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
>>
>>> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
>>> Also replace linked list with an array.
>>> ---
>>> configure  |   12 +-
>>> doc/APIchanges |4 +
>>> libavcodec/.gitignore  |2 +
>>> libavcodec/allcodecs.c | 1473 
>>> 
>>> libavcodec/avcodec.h   |   31 +
>>> libavcodec/parser.c|   84 ++-
>>> libavcodec/utils.c |  112 
>>> libavcodec/version.h   |3 +
>>> 8 files changed, 971 insertions(+), 750 deletions(-)
>>>
>>
>> I have a plan to sort codecs based on name and codec_id (which overlap
>> with this patch). Is it OK if I overtake this?
>> If it is not OK, I will wait until this patchset pushed.
>>
> 
> I am unsure why you would need to sort codecs. The point of my patches is to 
> bring the rest of ffmpeg up to the bsf iteration api (which abstracts 
> internals away from the user).

Doesn't bsf use next() and not iterate()?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Muhammad Faiz
On Fri, Feb 2, 2018 at 10:23 PM, Josh de Kock  wrote:
>
>> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
>>
>>> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
>>> Also replace linked list with an array.
>>> ---
>>> configure  |   12 +-
>>> doc/APIchanges |4 +
>>> libavcodec/.gitignore  |2 +
>>> libavcodec/allcodecs.c | 1473 
>>> 
>>> libavcodec/avcodec.h   |   31 +
>>> libavcodec/parser.c|   84 ++-
>>> libavcodec/utils.c |  112 
>>> libavcodec/version.h   |3 +
>>> 8 files changed, 971 insertions(+), 750 deletions(-)
>>>
>>
>> I have a plan to sort codecs based on name and codec_id (which overlap
>> with this patch). Is it OK if I overtake this?
>> If it is not OK, I will wait until this patchset pushed.
>>
>
> I am unsure why you would need to sort codecs.

For performance reason.

>The point of my patches is to bring 
> the rest of ffmpeg up to the bsf iteration api (which abstracts internals 
> away from the user). I planned on doing lavfi as well, but how the build 
> system worked with filter names made it awkward. Hence me submitting these 
> patches without a lavfi counterpart (I stills haven’t worked out the best way 
> to do it yet). The way you’ve done your static initialisation of lavfi seems 
> like a backwards way to do it, and would make overalls consistency difficult 
> (something quite desirable, which my patches work towards).

Imho, av*iterate things are less elegant than av*next. But, the change
actually is not based on elegance, but based on performance (av*next
requires initialization of next pointer).

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


Re: [FFmpeg-devel] [PATCH v2] avfilter: sort filter list

2018-02-02 Thread Muhammad Faiz
On Fri, Feb 2, 2018 at 5:36 PM, Nicolas George  wrote:
> Muhammad Faiz (2018-02-02):
>> Move REGISTER_FILTER to FILTER_TABLE in configure.
>> Replace linked list with static table, and sort it.
>> Use bsearch() on avfilter_get_by_name().
>> Deprecate avfilter_register_all(), avfilter_register(), and
>> avfilter_next().
>> Add avfilter_iterate() as a replacement for avfilter_next().
>
> I'll be explicit: unless discussed otherwise, I oppose this patch as
> long as it is not part of a series that applies the same treatment to
> all components (codecs, parsers, formats).

Yeah, probably no needs to rush on this.

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


[FFmpeg-devel] [PATCH] avcodec: do not use init_static_data on some codecs

2018-02-02 Thread Muhammad Faiz
They don't modify AVCodec, no needs to call it at register. They will be
wasteful if these codecs are unused. Instead, call static data initialization
at codecs' init.

Benchmark:
old: 51281340 decicycles in avcodec_register_all,   1 runs,  0 skips
new:  6738960 decicycles in avcodec_register_all,   1 runs,  0 skips

Signed-off-by: Muhammad Faiz 
---
 libavcodec/jpeg2000dec.c | 16 +---
 libavcodec/qdmc.c|  7 +--
 libavcodec/wmavoice.c|  7 +--
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 01fe4b3949..4cf8a2880c 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -34,6 +34,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
@@ -2142,10 +2143,18 @@ static int jp2_find_codestream(Jpeg2000DecoderContext 
*s)
 return 0;
 }
 
+static av_cold void jpeg2000_init_static_data(void)
+{
+ff_jpeg2000_init_tier1_luts();
+ff_mqc_init_context_tables();
+}
+
 static av_cold int jpeg2000_decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 Jpeg2000DecoderContext *s = avctx->priv_data;
 
+ff_thread_once(_static_once, jpeg2000_init_static_data);
 ff_jpeg2000dsp_init(>dsp);
 
 return 0;
@@ -2223,12 +2232,6 @@ end:
 return ret;
 }
 
-static av_cold void jpeg2000_init_static_data(AVCodec *codec)
-{
-ff_jpeg2000_init_tier1_luts();
-ff_mqc_init_context_tables();
-}
-
 #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
@@ -2252,7 +2255,6 @@ AVCodec ff_jpeg2000_decoder = {
 .id   = AV_CODEC_ID_JPEG2000,
 .capabilities = AV_CODEC_CAP_SLICE_THREADS | 
AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_DR1,
 .priv_data_size   = sizeof(Jpeg2000DecoderContext),
-.init_static_data = jpeg2000_init_static_data,
 .init = jpeg2000_decode_init,
 .decode   = jpeg2000_decode_frame,
 .priv_class   = _class,
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
index 1c8952b97b..f1f86accd8 100644
--- a/libavcodec/qdmc.c
+++ b/libavcodec/qdmc.c
@@ -26,6 +26,7 @@
 #define BITSTREAM_READER_LE
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
@@ -204,7 +205,7 @@ static const uint8_t phase_diff_codes[] = {
INIT_VLC_LE | INIT_VLC_USE_NEW_STATIC); \
 } while (0)
 
-static av_cold void qdmc_init_static_data(AVCodec *codec)
+static av_cold void qdmc_init_static_data(void)
 {
 int i;
 
@@ -250,10 +251,13 @@ static void make_noises(QDMCContext *s)
 
 static av_cold int qdmc_decode_init(AVCodecContext *avctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 QDMCContext *s = avctx->priv_data;
 int fft_size, fft_order, size, g, j, x;
 GetByteContext b;
 
+ff_thread_once(_static_once, qdmc_init_static_data);
+
 if (!avctx->extradata || (avctx->extradata_size < 48)) {
 av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n");
 return AVERROR_INVALIDDATA;
@@ -775,7 +779,6 @@ AVCodec ff_qdmc_decoder = {
 .id   = AV_CODEC_ID_QDMC,
 .priv_data_size   = sizeof(QDMCContext),
 .init = qdmc_decode_init,
-.init_static_data = qdmc_init_static_data,
 .close= qdmc_decode_close,
 .decode   = qdmc_decode_frame,
 .flush= qdmc_flush,
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 3f86d0da35..444e303b0d 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -30,6 +30,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
@@ -310,7 +311,7 @@ static av_cold int decode_vbmtree(GetBitContext *gb, int8_t 
vbm_tree[25])
 return 0;
 }
 
-static av_cold void wmavoice_init_static_data(AVCodec *codec)
+static av_cold void wmavoice_init_static_data(void)
 {
 static const uint8_t bits[] = {
  2,  2,  2,  4,  4,  4,
@@ -365,9 +366,12 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx)
  */
 static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
 {
+static AVOnce init_static_once = AV_ONCE_INIT;
 int n, flags, pitch_range, lsp16_flag;
 WMAVoiceContext *s = ctx->priv_data;
 
+ff_thread_once(_static_once, wmavoice_init_static_data);
+
 /**
  * Extradata layout:
  * - byte  0-18: WMAPro-in-WMAVoice extradata (see wmaprodec.c),
@@ -1991,7 +1995,6 @@ AVCodec ff_wmavoice_decoder = {
 .id   = AV_CODEC_ID_WMAVOICE,
 .priv_data_size   = sizeof(WMAVoiceContext),
 .init = wmavoice_decode_init,
-  

[FFmpeg-devel] [PATCH] avcodec/codec_desc: sort codec_descriptors

2018-02-02 Thread Muhammad Faiz
Use bsearch on avcodec_descriptor_get().

Signed-off-by: Muhammad Faiz 
---
 libavcodec/codec_desc.c | 1103 ---
 1 file changed, 563 insertions(+), 540 deletions(-)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index c3688de1d6..1e5d715416 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -21,8 +21,10 @@
 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
+#include "libavutil/thread.h"
 #include "avcodec.h"
 #include "profiles.h"
 #include "version.h"
@@ -90,6 +92,28 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
 {
+.id= AV_CODEC_ID_LJPEG,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "ljpeg",
+.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
+.id= AV_CODEC_ID_SP5X,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "sp5x",
+.long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+},
+{
+.id= AV_CODEC_ID_JPEGLS,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "jpegls",
+.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_MPEG4,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "mpeg4",
@@ -161,14 +185,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_LOSSY,
 },
 {
-.id= AV_CODEC_ID_SVG,
-.type  = AVMEDIA_TYPE_VIDEO,
-.name  = "svg",
-.long_name = NULL_IF_CONFIG_SMALL("Scalable Vector Graphics"),
-.props = AV_CODEC_PROP_LOSSLESS,
-.mime_types= MT("image/svg+xml"),
-},
-{
 .id= AV_CODEC_ID_SVQ1,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "svq1",
@@ -408,13 +424,6 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_LOSSLESS,
 },
 {
-.id= AV_CODEC_ID_SNOW,
-.type  = AVMEDIA_TYPE_VIDEO,
-.name  = "snow",
-.long_name = NULL_IF_CONFIG_SMALL("Snow"),
-.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
-},
-{
 .id= AV_CODEC_ID_TSCC,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "tscc",
@@ -450,6 +459,50 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_LOSSY,
 },
 {
+.id= AV_CODEC_ID_PNG,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "png",
+.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) 
image"),
+.props = AV_CODEC_PROP_LOSSLESS,
+.mime_types= MT("image/png"),
+},
+{
+.id= AV_CODEC_ID_PPM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "ppm",
+.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
+.id= AV_CODEC_ID_PBM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pbm",
+.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
+.id= AV_CODEC_ID_PGM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pgm",
+.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
+.id= AV_CODEC_ID_PGMYUV,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pgmyuv",
+.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) 
image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
+.id= AV_CODEC_ID_PAM,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "pam",
+.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+.mime_types= MT("image/x-portable-pixmap"),
+},
+{
 .id= AV_CODEC_ID_FFVHUFF,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "ffvhuff",
@@ -638,6 +691,14 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_LOSSY,
 },
 {
+.id= AV_CODEC_ID_TARGA,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "targa",
+.long_name 

Re: [FFmpeg-devel] [PATCH 1/2] swscale: fix dithers table for DITHER_COPY macro

2018-02-02 Thread Mateusz
W dniu 24.10.2017 o 10:02, Mateusz pisze:
> The Bayer matrix 8x8 used in DITHER_COPY macro is table dithers[5].
> Remaining dithers[] matrixes are generated from this matrix by
> downshift or upshift.
> 
> This patch fixes dithers[6] and dithers[7] matrixes -- they were
> too dark.
> 
> Signed-off-by: Mateusz Brzostek 
> ---
>  libswscale/swscale_unscaled.c | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)

ping 2

I've attached simple C program that generates all dithers[] tables
from dithers[5] table. There are 512 numbers to check, so it is simpler
to generate all tables, copy result to source file and use 'git diff'
to check them all.

It's time to finally fix DITHER_COPY macro and maybe optionally copy 
the changes to release 3.4.2.

Mateusz
#include 
#include 

const uint8_t dithers5[8][8] = {
  {  18, 34, 30, 46, 17, 33, 29, 45,},
  {  50,  2, 62, 14, 49,  1, 61, 13,},
  {  26, 42, 22, 38, 25, 41, 21, 37,},
  {  58, 10, 54,  6, 57,  9, 53,  5,},
  {  16, 32, 28, 44, 19, 35, 31, 47,},
  {  48,  0, 60, 12, 51,  3, 63, 15,},
  {  24, 40, 20, 36, 27, 43, 23, 39,},
  {  56,  8, 52,  4, 59, 11, 55,  7,},
};

int main() {
for (int b = 0; b < 8; b++) {
for (int y = 0; y < 8; y++) {
printf("  { ");
for (int x = 0; x < 8; x++)
printf("%3d,", b <= 5 ? dithers5[y][x] >> (5-b) : 
dithers5[y][x] << (b-5));
printf("},\n");
}
printf("},{\n");
}
return 0;
}
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Josh de Kock
> On 2 Feb 2018, at 15:41, Rostislav Pehlivanov  wrote:
> 
>> On 31 January 2018 at 20:25, Josh de Kock  wrote:
>> 
>> Also replace linked list with an array.
>> ---
>> configure  |   12 +-
>> doc/APIchanges |4 +
>> libavcodec/.gitignore  |2 +
>> libavcodec/allcodecs.c | 1473 --
>> --
>> libavcodec/avcodec.h   |   31 +
>> libavcodec/parser.c|   84 ++-
>> libavcodec/utils.c |  112 
>> libavcodec/version.h   |3 +
>> 8 files changed, 971 insertions(+), 750 deletions(-)
> 
> 
> I'd appreciate some credit, I did write most of the patch :)

I rewrote the lavc patch from scratch since I couldn’t getting yours to work, 
but I can credit your for the idea/original version or something. Just ping me 
on irc

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


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Rostislav Pehlivanov
On 31 January 2018 at 20:25, Josh de Kock  wrote:

> Also replace linked list with an array.
> ---
>  configure  |   12 +-
>  doc/APIchanges |4 +
>  libavcodec/.gitignore  |2 +
>  libavcodec/allcodecs.c | 1473 --
> --
>  libavcodec/avcodec.h   |   31 +
>  libavcodec/parser.c|   84 ++-
>  libavcodec/utils.c |  112 
>  libavcodec/version.h   |3 +
>  8 files changed, 971 insertions(+), 750 deletions(-)


I'd appreciate some credit, I did write most of the patch :)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/6] lavc: add new API for iterating codecs and codec parsers

2018-02-02 Thread Josh de Kock

> On 1 Feb 2018, at 18:51, Muhammad Faiz  wrote:
> 
>> On Thu, Feb 1, 2018 at 3:25 AM, Josh de Kock  wrote:
>> Also replace linked list with an array.
>> ---
>> configure  |   12 +-
>> doc/APIchanges |4 +
>> libavcodec/.gitignore  |2 +
>> libavcodec/allcodecs.c | 1473 
>> 
>> libavcodec/avcodec.h   |   31 +
>> libavcodec/parser.c|   84 ++-
>> libavcodec/utils.c |  112 
>> libavcodec/version.h   |3 +
>> 8 files changed, 971 insertions(+), 750 deletions(-)
>> 
> 
> I have a plan to sort codecs based on name and codec_id (which overlap
> with this patch). Is it OK if I overtake this?
> If it is not OK, I will wait until this patchset pushed.
> 

I am unsure why you would need to sort codecs. The point of my patches is to 
bring the rest of ffmpeg up to the bsf iteration api (which abstracts internals 
away from the user). I planned on doing lavfi as well, but how the build system 
worked with filter names made it awkward. Hence me submitting these patches 
without a lavfi counterpart (I stills haven’t worked out the best way to do it 
yet). The way you’ve done your static initialisation of lavfi seems like a 
backwards way to do it, and would make overalls consistency difficult 
(something quite desirable, which my patches work towards).

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


Re: [FFmpeg-devel] fail to build ffmpeg with icc 14

2018-02-02 Thread James Almer
On 2/2/2018 12:04 PM, wm4 wrote:
> On Fri, 2 Feb 2018 21:50:00 +0800 (CST)
> qw  wrote:
> 
>> Hi,
>>
>>
>> I use the following command to build ffmpeg:
>>
>>
>> ./configure --cc=/opt/intel/bin/icc --enable-version3 --enable-asm 
>> --enable-avfilter --disable-static --enable-shared --enable-gpl 
>> --enable-nonfree --prefix=/usr/local/ --extra-cflags='-I/usr/local/include 
>> --extra-ldflags='-L/usr/local/lib --enable-stripping
>> make
>>
>>
>> But I fail to compile ffmpeg, and error message is shown as below:
>>
>>
>> icc: command line warning #10121: overriding '-std=gnu99' with '-std=c99'
>> libavutil/cpu.c(48): error: identifier "ATOMIC_VAR_INIT" is undefined
>>   static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
>> ^
> 
> Maybe we need to force c11? Could you try to add -std=c11 or -std=gnu11
> to CFLAGS?

That's already done in configure, and either a compat or a dummy
stdatomic header is added if the compiler doesn't fully support c11
atomics. There's no way for ATOMIC_VAR_INIT to be undefined.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] fail to seek key video packet

2018-02-02 Thread James Almer
On 2/2/2018 11:30 AM, qw wrote:
> Hi,
> 
> 
> I use following command to test ffmpeg-2.8.1:

This list is for development of ffmpeg, not for user support or bug reports.

Use the ffmpeg-user list for user support, and http://trac.ffmpeg.org/
to report bugs.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] fail to build ffmpeg with icc 14

2018-02-02 Thread wm4
On Fri, 2 Feb 2018 21:50:00 +0800 (CST)
qw  wrote:

> Hi,
> 
> 
> I use the following command to build ffmpeg:
> 
> 
> ./configure --cc=/opt/intel/bin/icc --enable-version3 --enable-asm 
> --enable-avfilter --disable-static --enable-shared --enable-gpl 
> --enable-nonfree --prefix=/usr/local/ --extra-cflags='-I/usr/local/include 
> --extra-ldflags='-L/usr/local/lib --enable-stripping
> make
> 
> 
> But I fail to compile ffmpeg, and error message is shown as below:
> 
> 
> icc: command line warning #10121: overriding '-std=gnu99' with '-std=c99'
> libavutil/cpu.c(48): error: identifier "ATOMIC_VAR_INIT" is undefined
>   static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
> ^

Maybe we need to force c11? Could you try to add -std=c11 or -std=gnu11
to CFLAGS?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] fail to seek key video packet

2018-02-02 Thread qw
Hi,


I use following command to test ffmpeg-2.8.1:


ffmpeg -debug_ts -ss 10 -t 1 -i hanma.ts -f null /dev/null




ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
  built with icc (ICC) 14.0.2 20140120
  configuration: --cc=/opt/intel/bin/icc --enable-version3 --enable-asm 
--enable-yasm --enable-avfilter --disable-static --enable-shared --enable-gpl 
--enable-nonfree --prefix=/usr/local/ --extra-cflags='-I/usr/local/include 
--extra-ldflags=-L/usr/local/lib' --enable-memalign-hack --enable-stripping
  libavutil  54. 31.100 / 54. 31.100
  libavcodec 56. 60.100 / 56. 60.100
  libavformat56. 40.101 / 56. 40.101
  libavdevice56.  4.100 / 56.  4.100
  libavfilter 5. 40.101 /  5. 40.101
  libswscale  3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc53.  3.100 / 53.  3.100
Input #0, mpegts, from './sampleClips/jd-testClips/clips03/hanma.ts':
  Duration: 00:02:39.78, start: 1.40, bitrate: 10913 kb/s
  Program 1 
Metadata:
  service_name: Service01
  service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 
0x001B), yuv420p, 1280x720 [SAR 3:4 DAR 4:3], 24 fps, 24 tbr, 90k tbn, 48 tbc
Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, 
fltp, 192 kb/s
Output #0, null, to '/dev/null':
  Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 
3:4 DAR 4:3], q=2-31, 200 kb/s, 24 fps, 24 tbn, 24 tbc
Metadata:
  encoder : Lavc56.60.100 rawvideo
Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
  encoder : Lavc56.60.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
  Stream #0:1 -> #0:1 (ac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
demuxer -> ist_index:1 type:audio next_dts:NOPTS next_dts_time:NOPTS 
next_pts:NOPTS next_pts_time:NOPTS pkt_pts:1024560 pkt_pts_time:11.384 
pkt_dts:1024560 pkt_dts_time:11.384 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:1 type:audio pkt_pts:-1440 pkt_pts_time:-0.016 
pkt_dts:-1440 pkt_dts_time:-0.016 off:-1140 off_time:-11.4
encoder <- type:audio frame_pts:0 frame_pts_time:0 time_base:1/48000
encoder -> type:audio pkt_pts:0 pkt_pts_time:0 pkt_dts:0 pkt_dts_time:0
muxer <- type:audio pkt_pts:0 pkt_pts_time:0 pkt_dts:0 pkt_dts_time:0 size:3072
demuxer -> ist_index:1 type:audio next_dts:16000 next_dts_time:0.016 
next_pts:16000 next_pts_time:0.016 pkt_pts:1027440 pkt_pts_time:11.416 
pkt_dts:1027440 pkt_dts_time:11.416 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:1 type:audio pkt_pts:1440 pkt_pts_time:0.016 
pkt_dts:1440 pkt_dts_time:0.016 off:-1140 off_time:-11.4
encoder <- type:audio frame_pts:768 frame_pts_time:0.016 time_base:1/48000
encoder -> type:audio pkt_pts:768 pkt_pts_time:0.016 pkt_dts:768 
pkt_dts_time:0.016
muxer <- type:audio pkt_pts:768 pkt_pts_time:0.016 pkt_dts:768 
pkt_dts_time:0.016 size:6144
demuxer -> ist_index:1 type:audio next_dts:48000 next_dts_time:0.048 
next_pts:48000 next_pts_time:0.048 pkt_pts:1030320 pkt_pts_time:11.448 
pkt_dts:1030320 pkt_dts_time:11.448 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:1 type:audio pkt_pts:4320 pkt_pts_time:0.048 
pkt_dts:4320 pkt_dts_time:0.048 off:-1140 off_time:-11.4
encoder <- type:audio frame_pts:2304 frame_pts_time:0.048 time_base:1/48000
encoder -> type:audio pkt_pts:2304 pkt_pts_time:0.048 pkt_dts:2304 
pkt_dts_time:0.048
muxer <- type:audio pkt_pts:2304 pkt_pts_time:0.048 pkt_dts:2304 
pkt_dts_time:0.048 size:6144
demuxer -> ist_index:0 type:video next_dts:NOPTS next_dts_time:NOPTS 
next_pts:NOPTS next_pts_time:NOPTS pkt_pts:1026000 pkt_pts_time:11.4 
pkt_dts:1026000 pkt_dts_time:11.4 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:0 type:video pkt_pts:0 pkt_pts_time:0 pkt_dts:0 
pkt_dts_time:0 off:-1140 off_time:-11.4
demuxer -> ist_index:0 type:video next_dts:41667 next_dts_time:0.041667 
next_pts:0 next_pts_time:0 pkt_pts:1029750 pkt_pts_time:11.4417 pkt_dts:1029750 
pkt_dts_time:11.4417 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:0 type:video pkt_pts:3750 pkt_pts_time:0.0416667 
pkt_dts:3750 pkt_dts_time:0.0416667 off:-1140 off_time:-11.4
[h264 @ 0x1bdbda0] Missing reference picture, default is 0
[h264 @ 0x1bdbda0] decode_slice_header error
demuxer -> ist_index:0 type:video next_dts:83334 next_dts_time:0.083334 
next_pts:0 next_pts_time:0 pkt_pts:1033500 pkt_pts_time:11.4833 pkt_dts:1033500 
pkt_dts_time:11.4833 off:-1140 off_time:-11.4
demuxer+ffmpeg -> ist_index:0 type:video pkt_pts:7500 pkt_pts_time:0.083 
pkt_dts:7500 pkt_dts_time:0.083 off:-1140 off_time:-11.4
demuxer -> ist_index:1 type:audio next_dts:8 next_dts_time:0.08 
next_pts:8 next_pts_time:0.08 pkt_pts:1033200 pkt_pts_time:11.48 
pkt_dts:1033200 pkt_dts_time:11.48 off:-1140 off_time:-11.4

Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.

2018-02-02 Thread James Almer
On 2/1/2018 11:37 PM, rshaf...@tunein.com wrote:
> From: Richard Shaffer 
> 
> While rare, ID3 tags may be inserted between ADTS frames. This change enables
> parsing them and setting the appropriate metadata updated event flag.
> ---
> I have encountered a streaming provider that I must support which does this.
> There are indications that it isn't totally off the wall, and that it does
> happen in the wild:
> * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/
>   (See specifically sections 3 and 4.)
> * https://github.com/video-dev/hls.js/issues/508
> 
> That being said, the providers that do this are in the minority. It seems most
> streaming providers will do one of the following:
>  1. If using .aac segments inside of HLS, use the #EXTINF for text metadata 
> and
> use an ID3 tag at the head of the segment for things like timing metadata.
>  2. If streaming raw AAC over HTTP, use Icy metadata.
> 
> Aside from comments on the code, I'd be interested in any opinion about 
> whether
> this is something that should or should not be supported in libavformat.
> 
> Thanks,
> 
> -Richard

Can you provide a sample and add a fate test for this? To avoid
regressions in the future. This demuxer still needs some work.

Use the new probetags() function you added in your other id3v2 test if
the tags between samples in the file are the only ones, or if they
differ in some way from the ones at the beginning of the file, so
ffprobe will report them instead.
Alternatively, see fate-adts-demux in tests/fate/demux.mak
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] fail to build ffmpeg with icc 14

2018-02-02 Thread qw
Hi,


I use the following command to build ffmpeg:


./configure --cc=/opt/intel/bin/icc --enable-version3 --enable-asm 
--enable-avfilter --disable-static --enable-shared --enable-gpl 
--enable-nonfree --prefix=/usr/local/ --extra-cflags='-I/usr/local/include 
--extra-ldflags='-L/usr/local/lib --enable-stripping
make


But I fail to compile ffmpeg, and error message is shown as below:


icc: command line warning #10121: overriding '-std=gnu99' with '-std=c99'
libavutil/cpu.c(48): error: identifier "ATOMIC_VAR_INIT" is undefined
  static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
^


libavutil/cpu.c(48): error: function call is not allowed in a constant 
expression
  static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
^


compilation aborted for libavutil/cpu.c (code 2)
make: *** [libavutil/cpu.o] Error 2
make: *** Waiting for unfinished jobs
In file included from /opt/intel/include/xmmintrin.h(24),
 from /opt/intel/include/emmintrin.h(39),
 from /opt/intel/include/pmmintrin.h(21),
 from /opt/intel/include/tmmintrin.h(14),
 from /opt/intel/include/smmintrin.h(23),
 from /opt/intel/include/nmmintrin.h(24),
 from /opt/intel/include/wmmintrin.h(23),
 from /opt/intel/include/immintrin.h(14),
 from libavutil/x86/intmath.h(30),
 from libavutil/intmath.h(33),
 from libavutil/common.h(106),
 from libavutil/display.h(25),
 from libavutil/display.c(25):
/opt/intel/include/mmintrin.h(162): warning #2959: function prototype is 
missing the argument types
  extern __m64 __ICL_INTRINCC _mm_setzero_si64();
  ^
Why?


Thanks


Regards


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


Re: [FFmpeg-devel] [PATCH] libavformat/hls: Support metadata updates from subdemuxers

2018-02-02 Thread wm4
On Thu, 1 Feb 2018 23:50:02 -0800
Richard Shaffer  wrote:

> On Thu, Feb 1, 2018 at 10:18 PM, wm4  wrote:
> > On Thu,  1 Feb 2018 18:44:34 -0800
> > rshaf...@tunein.com wrote:
> >  
> >> From: Richard Shaffer 
> >>
> >> If a subdemuxer has the updated metadata event flag set, the metadata is 
> >> copied
> >> to the corresponding stream. The flag is cleared on the subdemuxer and the
> >> appropriate event flag is set on the stream.
> >> ---
> >> This is semi-related to a patch I recently sent to enable parsing ID3 tags 
> >> from
> >> .aac files between ADTS headers. However, it may be generically useful for
> >> other segment formats that support metadata updates.
> >>
> >> -Richard
> >>
> >>  libavformat/hls.c | 38 ++
> >>  1 file changed, 38 insertions(+)
> >>
> >> diff --git a/libavformat/hls.c b/libavformat/hls.c
> >> index 9bd54c84cc..e48845de34 100644
> >> --- a/libavformat/hls.c
> >> +++ b/libavformat/hls.c
> >> @@ -1062,6 +1062,7 @@ static void handle_id3(AVIOContext *pb, struct 
> >> playlist *pls)
> >>  /* demuxer not yet opened, defer picture attachment */
> >>  pls->id3_deferred_extra = extra_meta;
> >>
> >> +ff_id3v2_parse_priv_dict(, _meta);
> >>  av_dict_copy(>ctx->metadata, metadata, 0);
> >>  pls->id3_initial = metadata;
> >>
> >> @@ -1589,6 +1590,34 @@ static void 
> >> add_metadata_from_renditions(AVFormatContext *s, struct playlist *pl
> >>  }
> >>  }
> >>
> >> +/* update metadata on main streams, if necessary */
> >> +static void update_metadata_from_subdemuxer(struct playlist *pls, int 
> >> ignore_flags) {  
> >
> > Normally we put the { on a separate line for functions.  
> 
> I knew that but forgot. I'll fix it in the next iteration.
> 
> >  
> >> +int i;
> >> +
> >> +if (pls->n_main_streams) {
> >> +AVStream *st = pls->main_streams[0];
> >> +if (ignore_flags) {
> >> +av_dict_copy(>metadata, pls->ctx->metadata, 0);
> >> +} else if (pls->ctx->event_flags & 
> >> AVFMT_EVENT_FLAG_METADATA_UPDATED) {
> >> +av_dict_copy(>metadata, pls->ctx->metadata, 0);
> >> +pls->ctx->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
> >> +st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
> >> +}  
> >
> > I don't get understand this: why only stream 0? Isn't this done below
> > already?  
> 
> The code above copies metadata from pls->ctx->metadata, but the code
> below copies from pls->ctx->streams[i]->metadata for each stream in
> the subdemuxer. I think this currently would only apply to oggvorbis
> and nut demuxers. Maybe it's not a relevant use case for those, in
> which case I could just remove the for loop. I could also add a
> comment so that it's clear without having to look three times at the
> code.

Yeah, it was hard to spot. If it'll be effectively dead code, I'd say
it's better to just remove this. Nobody is going to try to use ogg or
nut fragments with HLS.

> >  
> >> +}
> >> +
> >> +for (i = 0; i < pls->ctx->nb_streams; i++) {
> >> +AVStream *ist = pls->ctx->streams[i];
> >> +AVStream *st = pls->main_streams[i];
> >> +if (ignore_flags) {
> >> +av_dict_copy(>metadata, ist->metadata, 0);
> >> +} else if (ist->event_flags & 
> >> AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
> >> +av_dict_copy(>metadata, ist->metadata, 0);
> >> +ist->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
> >> +st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
> >> +}
> >> +}
> >> +}  
> >
> > Like mentioned in the other patch, av_dict_copy not clearing the target
> > dict might be unintended.  
> 
> The intention is to not remove existing keys in the metadata, but only
> update keys that are new or changed. We do also set metadata in
> add_stream_to_programs and add_metadata_from_renditions. Presumably we
> don't want to delete that. This also seems to be the behavior when we
> have updated data from other demuxers or Icy, so I wanted to implement
> the same behavior here.

Fine.

> >  
> >> +
> >>  /* if timestamp was in valid range: returns 1 and sets seq_no
> >>   * if not: returns 0 and sets seq_no to closest segment */
> >>  static int find_timestamp_in_playlist(HLSContext *c, struct playlist *pls,
> >> @@ -1960,6 +1989,7 @@ static int hls_read_header(AVFormatContext *s)
> >>  if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
> >>  ff_id3v2_parse_apic(pls->ctx, >id3_deferred_extra);
> >>  avformat_queue_attached_pictures(pls->ctx);
> >> +ff_id3v2_parse_priv(pls->ctx, >id3_deferred_extra);
> >>  ff_id3v2_free_extra_meta(>id3_deferred_extra);
> >>  pls->id3_deferred_extra = NULL;
> >>  }
> >> @@ -1986,6 +2016,12 @@ static int hls_read_header(AVFormatContext *s)
> >>   

Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.

2018-02-02 Thread wm4
On Fri, 2 Feb 2018 00:06:47 -0800
Richard Shaffer  wrote:

> On Thu, Feb 1, 2018 at 10:02 PM, wm4  wrote:
> > On Thu,  1 Feb 2018 18:37:45 -0800
> > rshaf...@tunein.com wrote:
> >  
> >> From: Richard Shaffer 
> >>
> >> While rare, ID3 tags may be inserted between ADTS frames. This change 
> >> enables
> >> parsing them and setting the appropriate metadata updated event flag.
> >> ---
> >> I have encountered a streaming provider that I must support which does 
> >> this.
> >> There are indications that it isn't totally off the wall, and that it does
> >> happen in the wild:
> >> * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/
> >>   (See specifically sections 3 and 4.)
> >> * https://github.com/video-dev/hls.js/issues/508
> >>
> >> That being said, the providers that do this are in the minority. It seems 
> >> most
> >> streaming providers will do one of the following:
> >>  1. If using .aac segments inside of HLS, use the #EXTINF for text 
> >> metadata and
> >> use an ID3 tag at the head of the segment for things like timing 
> >> metadata.
> >>  2. If streaming raw AAC over HTTP, use Icy metadata.
> >>
> >> Aside from comments on the code, I'd be interested in any opinion about 
> >> whether
> >> this is something that should or should not be supported in libavformat.
> >>
> >> Thanks,
> >>
> >> -Richard
> >>
> >>  libavformat/aacdec.c | 45 +++--
> >>  1 file changed, 43 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> >> index 36d558ff54..5ec706bdc7 100644
> >> --- a/libavformat/aacdec.c
> >> +++ b/libavformat/aacdec.c
> >> @@ -22,8 +22,10 @@
> >>
> >>  #include "libavutil/intreadwrite.h"
> >>  #include "avformat.h"
> >> +#include "avio_internal.h"
> >>  #include "internal.h"
> >>  #include "id3v1.h"
> >> +#include "id3v2.h"
> >>  #include "apetag.h"
> >>
> >>  #define ADTS_HEADER_SIZE 7
> >> @@ -116,13 +118,52 @@ static int adts_aac_read_header(AVFormatContext *s)
> >>  return 0;
> >>  }
> >>
> >> +static int handle_id3(AVFormatContext *s, AVPacket *pkt)
> >> +{
> >> +AVDictionary *metadata = NULL;
> >> +AVIOContext ioctx;
> >> +ID3v2ExtraMeta *id3v2_extra_meta = NULL;
> >> +int ret;
> >> +
> >> +ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - 
> >> pkt->size);
> >> +if (ret < 0) {
> >> +av_packet_unref(pkt);
> >> +return ret;
> >> +}
> >> +
> >> +ffio_init_context(, pkt->data, pkt->size, 0, NULL, NULL, NULL, 
> >> NULL);
> >> +ff_id3v2_read_dict(, , ID3v2_DEFAULT_MAGIC, 
> >> _extra_meta);
> >> +if ((ret = ff_id3v2_parse_priv_dict(, _extra_meta)) < 
> >> 0)
> >> +goto error;
> >> +
> >> +if (metadata) {
> >> +if ((ret = av_dict_copy(>metadata, metadata, 0)) < 0)
> >> +goto error;  
> >
> > AFAIK that would merge the existing metadata with the new one (i.e. not
> > delete entries that are in the new metadata). But not sure if this is
> > intended, or how exactly it should work. Intuitively I'd say it should
> > completely replace previous ID3v2s.  
> 
> That's right:
> * If new metadata has a key that already exists in metadata, the old
> value will be replaced.
> * If new metadata has a key that doesn't exist in metadata, it will be added.
> * Any other keys/values already in old metadata will be preserved.
> 
> This seems to be the behavior of Icy as well as other demuxers that
> support updates. I think it's slightly better to update this way
> rather than completely replacing the entire dictionary, but I don't
> feel too strongly about it.

Feels a bit strange to me. But maybe it's better to be consistent with
existing behavior, and also it's likely that tag updates use the same
tag keys. So I'm fine with this currently.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] af_silencedetect : fix accuracy of silence_start

2018-02-02 Thread Gaullier Nicolas
(attachement + email object fixed : sorry about that x2)
Attached patch fixes accuracy of silence_start.
The benefit is mostly noticeable when the silence starts at the very beginning 
(ie. silence_start=0 exactly).
Nicolas Gaullier


0002-avfilter-af_silencedetect-fix-silence_start-accuracy.patch
Description: 0002-avfilter-af_silencedetect-fix-silence_start-accuracy.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] af_silencedetect : fix accuracy of silence_start)

2018-02-02 Thread Gaullier Nicolas
(email object fixed : sorry about that)
Attached patch fixes accuracy of silence_start.
The benefit is mostly noticeable when the silence starts at the very beginning 
(ie. silence_start=0 exactly).
Nicolas Gaullier
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 4/4] af_silencedetect : fix missing log silence_end at EOS

2018-02-02 Thread Gaullier Nicolas
Attached patch fixes missing log of "silence_end" when the silence continue 
until the end of the stream.
Nicolas Gaullier


0004-avfilter-af_silencedetect-fix-missing-log-silence_en.patch
Description: 0004-avfilter-af_silencedetect-fix-missing-log-silence_en.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/4] af_silencedetect : add mono mode

2018-02-02 Thread Gaullier Nicolas
Hi!
Attached patch adds a "mono mode", I mean detection of silence in any of the 
channels (instead of all of them simultaneously).
The channel number is detected and logged, and side metadata names are suffixed 
with the channel number (NB: in non-mono mode, the logging and metadata remain 
unchanged).
This first patch includes minor technical changes to prepare the following 
patches, I apologize but I thought it was the best way to present this set of 
patches.
Thank you for the review
Nicolas Gaullier


0001-avfilter-af_silencedetect-add-mono-mode.patch
Description: 0001-avfilter-af_silencedetect-add-mono-mode.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/4] af_silencedetect : fix when silence_start=0

2018-02-02 Thread Gaullier Nicolas
Attached patch fixes silence_start=0 meaning "no silence start"
Nicolas Gaullier


0003-avfilter-af_silencedetect-fix-silence_start-0-meanin.patch
Description: 0003-avfilter-af_silencedetect-fix-silence_start-0-meanin.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] af_silencedetect : add mono mode

2018-02-02 Thread Gaullier Nicolas
Attached patch fixes accuracy of silence_start.
The benefit is mostly noticeable when the silence starts at the very beginning 
(ie. silence_start=0 exactly).
Nicolas Gaullier


0002-avfilter-af_silencedetect-fix-silence_start-accuracy.patch
Description: 0002-avfilter-af_silencedetect-fix-silence_start-accuracy.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avfilter: sort filter list

2018-02-02 Thread Nicolas George
Muhammad Faiz (2018-02-02):
> Move REGISTER_FILTER to FILTER_TABLE in configure.
> Replace linked list with static table, and sort it.
> Use bsearch() on avfilter_get_by_name().
> Deprecate avfilter_register_all(), avfilter_register(), and
> avfilter_next().
> Add avfilter_iterate() as a replacement for avfilter_next().

I'll be explicit: unless discussed otherwise, I oppose this patch as
long as it is not part of a series that applies the same treatment to
all components (codecs, parsers, formats).

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH v2] avfilter: sort filter list

2018-02-02 Thread Muhammad Faiz
Move REGISTER_FILTER to FILTER_TABLE in configure.
Replace linked list with static table, and sort it.
Use bsearch() on avfilter_get_by_name().
Deprecate avfilter_register_all(), avfilter_register(), and
avfilter_next().
Add avfilter_iterate() as a replacement for avfilter_next().

Signed-off-by: Muhammad Faiz 
---
 Makefile |   5 +-
 configure| 428 -
 doc/APIchanges   |   4 +
 libavfilter/allfilters.c | 441 ++-
 libavfilter/avfilter.c   |  65 ++-
 libavfilter/avfilter.h   |  20 ++-
 libavfilter/buffersink.c |   4 +-
 libavfilter/version.h|  10 +-
 tests/checkasm/Makefile  |   2 +-
 9 files changed, 532 insertions(+), 447 deletions(-)

diff --git a/Makefile b/Makefile
index 9defddebfd..6427abafb5 100644
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,7 @@ CONFIGURABLE_COMPONENTS = 
  \
 $(SRC_PATH)/libavformat/protocols.c \
 
 config.h: ffbuild/.config
-ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
+ffbuild/.config: $(CONFIGURABLE_COMPONENTS) $(SRC_PATH)/configure
@-tput bold 2>/dev/null
@-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n'
@-tput sgr0 2>/dev/null
@@ -142,7 +142,8 @@ distclean:: clean
$(RM) .version avversion.h config.asm config.h mapfile  \
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \
-   libavcodec/bsf_list.c libavformat/protocol_list.c
+   libavcodec/bsf_list.c libavformat/protocol_list.c \
+   libavfilter/filter_list.c
 ifeq ($(SRC_LINK),src)
$(RM) src
 endif
diff --git a/configure b/configure
index fcfa7aa442..a11798625e 100755
--- a/configure
+++ b/configure
@@ -3177,6 +3177,381 @@ unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
 
 # filters
+FILTER_TABLE="
+abench  af
+acompressor af
+acontrast   af
+acopy   af
+acrossfade  af
+acrusheraf
+adelay  af
+aecho   af
+aemphasis   af
+aeval   af
+afade   af
+afftfiltaf
+afiraf
+aformat af
+agate   af
+aiiraf
+ainterleave af
+alimiteraf
+allpass af
+aloop   af
+amerge  af
+ametadata   af
+amixaf
+anequalizer af
+anull   af
+apadaf
+aperms  af
+aphaser af
+apulsator   af
+arealtime   af
+aresample   af
+areverseaf
+aselect af
+asendcmdaf
+asetnsamplesaf
+asetpts af
+asetrateaf
+asettb  af
+ashowinfo   af
+asidedata   af
+asplit  af
+astats  af
+astreamselect   af
+atempo  af
+atrim   af
+azmqaf
+bandpassaf
+bandreject  af
+bassaf
+biquad  af
+bs2baf
+channelmap  af
+channelsplitaf
+chorus  af
+compand af
+compensationdelay   af
+crossfeed   af
+crystalizer af
+dcshift af
+dynaudnorm  af
+earwax  af
+ebur128 af
+equalizer   af
+extrastereo af
+firequalizeraf
+flanger af
+haasaf
+hdcdaf
+headphone   af
+highpassaf
+joinaf
+ladspa  af
+loudnormaf
+lowpass af
+lv2 af
+mcompandaf
+pan af
+replaygain  af
+resampleaf
+rubberband  af
+sidechaincompress   af
+sidechaingate   af
+silencedetect   af
+silenceremove   af
+sofalizer   af
+stereotools af
+stereowiden af
+superequalizer  af
+surroundaf
+treble  af
+tremolo af
+vibrato af
+volume  af
+volumedetectaf
+aevalsrcasrc
+anoisesrc   asrc
+anullsrcasrc
+flite   asrc
+hilbert asrc
+sineasrc
+anullsink   asink
+alphaextractvf
+alphamerge  vf
+ass vf
+atadenoise  vf
+avgblur

Re: [FFmpeg-devel] [PATCH] libavformat/aac: Parse ID3 tags between ADTS frames.

2018-02-02 Thread Richard Shaffer
On Thu, Feb 1, 2018 at 10:02 PM, wm4  wrote:
> On Thu,  1 Feb 2018 18:37:45 -0800
> rshaf...@tunein.com wrote:
>
>> From: Richard Shaffer 
>>
>> While rare, ID3 tags may be inserted between ADTS frames. This change enables
>> parsing them and setting the appropriate metadata updated event flag.
>> ---
>> I have encountered a streaming provider that I must support which does this.
>> There are indications that it isn't totally off the wall, and that it does
>> happen in the wild:
>> * https://www.w3.org/TR/mse-byte-stream-format-mpeg-audio/
>>   (See specifically sections 3 and 4.)
>> * https://github.com/video-dev/hls.js/issues/508
>>
>> That being said, the providers that do this are in the minority. It seems 
>> most
>> streaming providers will do one of the following:
>>  1. If using .aac segments inside of HLS, use the #EXTINF for text metadata 
>> and
>> use an ID3 tag at the head of the segment for things like timing 
>> metadata.
>>  2. If streaming raw AAC over HTTP, use Icy metadata.
>>
>> Aside from comments on the code, I'd be interested in any opinion about 
>> whether
>> this is something that should or should not be supported in libavformat.
>>
>> Thanks,
>>
>> -Richard
>>
>>  libavformat/aacdec.c | 45 +++--
>>  1 file changed, 43 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
>> index 36d558ff54..5ec706bdc7 100644
>> --- a/libavformat/aacdec.c
>> +++ b/libavformat/aacdec.c
>> @@ -22,8 +22,10 @@
>>
>>  #include "libavutil/intreadwrite.h"
>>  #include "avformat.h"
>> +#include "avio_internal.h"
>>  #include "internal.h"
>>  #include "id3v1.h"
>> +#include "id3v2.h"
>>  #include "apetag.h"
>>
>>  #define ADTS_HEADER_SIZE 7
>> @@ -116,13 +118,52 @@ static int adts_aac_read_header(AVFormatContext *s)
>>  return 0;
>>  }
>>
>> +static int handle_id3(AVFormatContext *s, AVPacket *pkt)
>> +{
>> +AVDictionary *metadata = NULL;
>> +AVIOContext ioctx;
>> +ID3v2ExtraMeta *id3v2_extra_meta = NULL;
>> +int ret;
>> +
>> +ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - 
>> pkt->size);
>> +if (ret < 0) {
>> +av_packet_unref(pkt);
>> +return ret;
>> +}
>> +
>> +ffio_init_context(, pkt->data, pkt->size, 0, NULL, NULL, NULL, 
>> NULL);
>> +ff_id3v2_read_dict(, , ID3v2_DEFAULT_MAGIC, 
>> _extra_meta);
>> +if ((ret = ff_id3v2_parse_priv_dict(, _extra_meta)) < 0)
>> +goto error;
>> +
>> +if (metadata) {
>> +if ((ret = av_dict_copy(>metadata, metadata, 0)) < 0)
>> +goto error;
>
> AFAIK that would merge the existing metadata with the new one (i.e. not
> delete entries that are in the new metadata). But not sure if this is
> intended, or how exactly it should work. Intuitively I'd say it should
> completely replace previous ID3v2s.

That's right:
* If new metadata has a key that already exists in metadata, the old
value will be replaced.
* If new metadata has a key that doesn't exist in metadata, it will be added.
* Any other keys/values already in old metadata will be preserved.

This seems to be the behavior of Icy as well as other demuxers that
support updates. I think it's slightly better to update this way
rather than completely replacing the entire dictionary, but I don't
feel too strongly about it.

>
>> +s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
>> +}
>> +
>> +error:
>> +av_packet_unref(pkt);
>> +ff_id3v2_free_extra_meta(_extra_meta);
>> +av_dict_free();
>> +
>> +return ret;
>> +}
>> +
>>  static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt)
>>  {
>>  int ret, fsize;
>>
>> -ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE);
>> +ret = av_get_packet(s->pb, pkt, FFMAX(ID3v2_HEADER_SIZE, 
>> ADTS_HEADER_SIZE));
>> +
>> +if (ret >= ID3v2_HEADER_SIZE && ff_id3v2_match(pkt->data, 
>> ID3v2_DEFAULT_MAGIC)) {
>> +if ((ret = handle_id3(s, pkt)) >= 0)
>> +ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE);
>> +}
>> +
>>  if (ret < 0)
>>  return ret;
>> +
>>  if (ret < ADTS_HEADER_SIZE) {
>>  av_packet_unref(pkt);
>>  return AVERROR(EIO);
>> @@ -139,7 +180,7 @@ static int adts_aac_read_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  return AVERROR_INVALIDDATA;
>>  }
>>
>> -ret = av_append_packet(s->pb, pkt, fsize - ADTS_HEADER_SIZE);
>> +ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
>>  if (ret < 0)
>>  av_packet_unref(pkt);
>>
>
> I think that's the right approach. The demuxer should filter out such
> tags, and exporting them to the API user is a good idea too.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org