Re: [FFmpeg-devel] [PATCH v3 1/2] dxva: wait until D3D11 buffer copies are done before submitting them

2020-08-14 Thread Steve Lhomme

On 2020-08-13 1:01, Soft Works wrote:



-Original Message-
From: ffmpeg-devel  On Behalf Of
Steve Lhomme
Sent: Wednesday, August 12, 2020 2:05 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] dxva: wait until D3D11 buffer
copies are done before submitting them

On 2020-08-11 12:43, Steve Lhomme wrote:

Sorry if you seem to know all the answers already, but I don't and
so I have to investigate.


Last year, I had literally worked this down to death. I followed
every slightest hint from countless searches, read through hundreds
of discussions, driven because I was unwilling to believe that
up-/downloading of video textures with
D3D11 can't be done equally fast as with D3D9.
(the big picture was the implementation of D3D11 support for
QuickSync where the slowdown played a much bigger role than with
D3D11VA decoders only).
Eventually I landed at some internal Nvidia presentation, some talks
with MS guys and some source code discussion deep inside a 3D game
engine (not a no-name). It really bugs me that I didn't properly note
the references, but from somewhere in between I was able to gather
solid evidence about what is legal to do and what Is not. Based on
that, followed several iterations to find the optimal way for doing
the texture transfer. As I had implemented
D3D11 support for QuickSync, this got pretty complicated because with
a full transcoding pipeline, all parts (decoder, encoder and filters)
can (and usually will) request textures. Only the latest Intel
Drivers can work with array textures everywhere (e.g. VPP), so I also
needed to add support for non-array texture allocation. The patch
you've seen is the result of weeks of intensive work (a small but
crucial part of it) - even when it may not look like that.



Sorry if you seem to know all the answers already


Obviously, I don't know all the answers, but all the answers I have
given were correct. And when I didn't have an answer I always
respectfully said that your situation might be different.
And I didn't reply by implying that you would have done your work by
trial-and-error or most likely invalid assumptions or deductions.


I still don't know how you are actually operating this and thus I
also cannot tell what might or might not work in your case.
All I can tell is that the procedure that I have described (1-2-3-4)
can work rock-solid for multi-threaded DX11 texture transfer when
it's done in the same way as I've shown.
And believe it or not - I would still be happy when it would be of
any use for you...


Even though the discussion is heated (fitting with the weather here) I
don't mind. I learned some stuff and it pushed me to dig deeper. I
can't just accept your word for it. I need something solid if I'm
going to remove a lock that helped me so far.

So I'm currently tooling VLC to be able to bring the decoder to its
knees and find out what it can and cannot do safely. So far I can
still see decoding artifacts when I don't a lock, which would mean I
still need the mutex, for the reasons given in the previous mail.


A follow-up on this. Using ID3D10Multithread seems to be enough to have
mostly thread safe ID3D11Device/ID3D11DeviceContext/etc. Even the
decoding with its odd API seem to know what to do when submitted
different buffers.

I did not manage to saturate the GPU but I much bigger decoding
speed/throughput to validate the errors I got before. Many of them were
due to VLC dropping data because of odd timing.

Now I still have some threading issues. For example for deinterlacing we
create a ID3D11VideoProcessor to handle the deinterlacing. And we create it
after the decoding started (as the deinterlacing can be enabled/disabled
dynamically). Without the mutex in the decoder it crashes on
ID3D11VideoDevice::CreateVideoProcessor() and
ID3D11VideoContext::SubmitDecoderBuffers() as they are being called
simultaneously. If I add the mutex between the decoder and just this filter
(not the rendering side) it works fine.

So I guess I'm stuck with the mutex for the time being.


At an earlier stage I had considered the idea of adding those video
processors as ffmpeg hardware filters, but due to the vast amount of
different use cases, platforms and hw accelerations we support,
I had made the decision that we do all filtering either by CPU or in the
hw context of the en-coder, but never in the hw context of the de-coder,
so I don't have any experience with DX11 video processors.

Maybe a too obvious idea: How about activating the mutex use only for
a short time during the process of adding the video processor?


This doesn't seem feasable, even with a callback system. You don't know 
when it's safe to enable/disable it.


By the way the origin of the mutex was on Windows Phones. It's probably 
related to the fact that some phones only decode to 
DXGI_FORMAT_I420_OPAQUE which cannot be used for rendering. The only way 
to use the decoded surface is to convert it (to NV12) via a 
VideoProcessor. So in this case

Re: [FFmpeg-devel] [PATCH] lavfi: check the validity of formats lists.

2020-08-14 Thread Michael Niedermayer
On Thu, Aug 13, 2020 at 01:20:28PM +0200, Nicolas George wrote:
> Part of the code expect valid lists, in particular no duplicates.
> These tests allow to catch bugs in filters (unlikely but possible)
> and to give a clear message when the error comes from the user
> ((a)formats) or the application (buffersink).
> 
> Signed-off-by: Nicolas George 
> ---
>  libavfilter/avfiltergraph.c | 50 ++
>  libavfilter/formats.c   | 71 +
>  libavfilter/formats.h   | 28 +++
>  3 files changed, 149 insertions(+)

this 
ffplay -nostats mm-short.mpg -t 1 -af volume=replaygain=track,ebur128 -nodisp 
-autoexit

gets stuck with the patch, seems not depend on the input sample

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavfi: check the validity of formats lists.

2020-08-14 Thread Nicolas George
Michael Niedermayer (12020-08-14):
> this 
> ffplay -nostats mm-short.mpg -t 1 -af volume=replaygain=track,ebur128 -nodisp 
> -autoexit
> 
> gets stuck with the patch, seems not depend on the input sample

Thanks for the testing.

It reveals two bugs in ffplay:

- On buffersink, it sets both channel_layouts to { stereo } and
  channel_counts to { 2 }, which is redundant and should not be done,
  although it is not properly documented.

- audio_thread() exits, but ffplay does not.

I can both fix and mitigate the first problem, but I am not familiar
enough with the workings of ffplay to fix the threading issue, and it
should be fixed too, because this check is not the only possible cause
for a failure at this point.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/dpx: Read alternative frame rate from television header

2020-08-14 Thread Harry Mallon
Signed-off-by: Harry Mallon 
---
 libavcodec/dpx.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index b1833ed9ef..694deb27c5 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -216,10 +216,22 @@ static int decode_frame(AVCodecContext *avctx,
 else
 avctx->sample_aspect_ratio = (AVRational){ 0, 1 };

+/* preferred frame rate from Motion-picture film header */
 if (offset >= 1724 + 4) {
 buf = avpkt->data + 1724;
 i = read32(&buf, endian);
-if(i) {
+if(i && i != 0x) {
+AVRational q = av_d2q(av_int2float(i), 4096);
+if (q.num > 0 && q.den > 0)
+avctx->framerate = q;
+}
+}
+
+/* alternative frame rate from television header */
+if (!(avctx->framerate.num && avctx->framerate.den) && offset >=
1940 + 4) {
+buf = avpkt->data + 1940;
+i = read32(&buf, endian);
+if(i && i != 0x) {
 AVRational q = av_d2q(av_int2float(i), 4096);
 if (q.num > 0 && q.den > 0)
 avctx->framerate = q;
-- 
2.28.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] fix memory leak in qsvenc.c

2020-08-14 Thread Linjie Fu
On Thu, Aug 13, 2020 at 10:15 AM Alex Pokotilo  wrote:
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Seems reasonable, any special reason to reorder av_freep(&sync)?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] dnn/native: add log error message

2020-08-14 Thread Ting Fu
Signed-off-by: Ting Fu 
---
 libavfilter/dnn/dnn_backend_native.c  | 74 +++
 libavfilter/dnn/dnn_backend_native.h  |  5 ++
 .../dnn/dnn_backend_native_layer_avgpool.c|  2 +-
 .../dnn/dnn_backend_native_layer_avgpool.h|  2 +-
 .../dnn/dnn_backend_native_layer_conv2d.c |  2 +-
 .../dnn/dnn_backend_native_layer_conv2d.h |  2 +-
 .../dnn_backend_native_layer_depth2space.c|  2 +-
 .../dnn_backend_native_layer_depth2space.h|  2 +-
 .../dnn/dnn_backend_native_layer_mathbinary.c | 10 ++-
 .../dnn/dnn_backend_native_layer_mathbinary.h |  2 +-
 .../dnn/dnn_backend_native_layer_mathunary.c  | 10 ++-
 .../dnn/dnn_backend_native_layer_mathunary.h  |  2 +-
 .../dnn/dnn_backend_native_layer_maximum.c|  2 +-
 .../dnn/dnn_backend_native_layer_maximum.h|  2 +-
 .../dnn/dnn_backend_native_layer_pad.c|  2 +-
 .../dnn/dnn_backend_native_layer_pad.h|  2 +-
 libavfilter/dnn/dnn_backend_native_layers.h   |  2 +-
 17 files changed, 90 insertions(+), 35 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index adc652a2c4..6ddffa54af 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,15 +28,30 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
 
+static const AVClass dnn_native_class = {
+.class_name = "dnn_native",
+.item_name  = av_default_item_name,
+.option = NULL,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
+NetworkContext network_ctx = {
+.class  = &dnn_native_class,
+};
+
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
+NetworkContext *ctx = network->log_ctx;
 
 for (int i = 0; i < network->operands_num; ++i) {
 DnnOperand *oprd = &network->operands[i];
 if (strcmp(oprd->name, input_name) == 0) {
-if (oprd->type != DOT_INPUT)
+if (oprd->type != DOT_INPUT) {
+av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is 
not input node\n", input_name);
 return DNN_ERROR;
+}
 input->dt = oprd->data_type;
 av_assert0(oprd->dims[0] == 1);
 input->height = oprd->dims[1];
@@ -47,30 +62,37 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 }
 
 // do not find the input operand
+av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name);
 return DNN_ERROR;
 }
 
 static DNNReturnType set_input_output_native(void *model, DNNData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
 {
 ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
+NetworkContext *ctx = network->log_ctx;
 DnnOperand *oprd = NULL;
 
-if (network->layers_num <= 0 || network->operands_num <= 0)
+if (network->layers_num <= 0 || network->operands_num <= 0) {
+av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n");
 return DNN_ERROR;
+}
 
 /* inputs */
 for (int i = 0; i < network->operands_num; ++i) {
 oprd = &network->operands[i];
 if (strcmp(oprd->name, input_name) == 0) {
-if (oprd->type != DOT_INPUT)
+if (oprd->type != DOT_INPUT) {
+av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is 
not input node\n", input_name);
 return DNN_ERROR;
+}
 break;
 }
 oprd = NULL;
 }
-
-if (!oprd)
+if (!oprd) {
+av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", 
input_name);
 return DNN_ERROR;
+}
 
 oprd->dims[0] = 1;
 oprd->dims[1] = input->height;
@@ -79,11 +101,15 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData *input, const
 
 av_freep(&oprd->data);
 oprd->length = calculate_operand_data_length(oprd);
-if (oprd->length <= 0)
+if (oprd->length <= 0) {
+av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n");
 return DNN_ERROR;
+}
 oprd->data = av_malloc(oprd->length);
-if (!oprd->data)
+if (!oprd->data) {
+av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for input data\n");
 return DNN_ERROR;
+}
 
 input->data = oprd->data;
 
@@ -91,8 +117,10 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData *input, const
 network->nb_output = 0;
 av_freep(&network->output_indexes);
 network->output_indexes = av_mallocz_array(nb_output, 
sizeof(*network->output_indexes));
-if (!network->output_indexes)
+if (!network->output_indexes) {
+av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for output\n");
 return DNN_ERROR;
+}
 
 for (uint32_t i = 0; i < nb_output; ++i) {
 const cha

Re: [FFmpeg-devel] [PATCH v2] doc/developer: origin of tables should be documented.

2020-08-14 Thread Jean-Baptiste Kempf
On Wed, 12 Aug 2020, at 14:38, Alexander Strasser wrote:
> On 2020-08-12 12:32 +0200, Jean-Baptiste Kempf wrote:
> > On Wed, 12 Aug 2020, at 00:29, Alexander Strasser wrote:
> > > Definitions of non-obvious data should have a short comment
> > > explaining their origin.
> > >
> > > If the data is of mathematical origin, you can document that
> > > or use code snippets or pseudo-code. If the data was gained
> > > empirically, describe the methods used. If the data was taken
> > > from a document like a specification, reference the section
> > > and/or table number. A link can also be used, if there is a
> > > stable source and there are no better ways.
> > >
> > > If you generated the data with a program, consider including
> > > the source code in FFmpeg and reference it in the comment.
> > >
> > > Typical examples are tables of numbers. Here is one:
> > >
> > > 
> > >
> > >
> > > I feel it could well be improved, though I wasn't able to do it
> > > myself :( Maybe others can help.
> >
> > What about RE values?
> 
> All in all it's same as Nicolas' proposal: The convention is to
> document the origin of the data. It says should, which is not must.

SHOULD can mean "really mandatory, besides exceptions", so I would soften it, 
to explain common sense must be shared, like "if origin is mathematical or 
specification", or similar.

But I like your version.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/4] lavfi/buffersink: remove redundant channel layouts.

2020-08-14 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/buffersink.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 76a46f6678..c58daf6124 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -62,6 +62,28 @@ typedef struct BufferSinkContext {
 
 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
 
+static void cleanup_redundant_layouts(AVFilterContext *ctx)
+{
+BufferSinkContext *buf = ctx->priv;
+int nb_layouts = NB_ITEMS(buf->channel_layouts);
+int nb_counts = NB_ITEMS(buf->channel_counts);
+int l, lc, c, n;
+
+for (l = lc = 0; l < nb_layouts; l++) {
+n = av_get_channel_layout_nb_channels(buf->channel_layouts[l]);
+for (c = 0; c < nb_counts; c++)
+if (n == buf->channel_counts[c])
+break;
+if (c < nb_counts)
+av_log(ctx, AV_LOG_WARNING,
+   "Removing channel layout 0x%"PRIx64", redundant with %d 
channels\n",
+   buf->channel_layouts[l], buf->channel_counts[c]);
+else
+buf->channel_layouts[lc++] = buf->channel_layouts[l];
+}
+buf->channel_layouts_size = lc * sizeof(*buf->channel_layouts);
+}
+
 int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame 
*frame)
 {
 return av_buffersink_get_frame_flags(ctx, frame, 0);
@@ -253,6 +275,7 @@ static int asink_query_formats(AVFilterContext *ctx)
 
 if (buf->channel_layouts_size || buf->channel_counts_size ||
 buf->all_channel_counts) {
+cleanup_redundant_layouts(ctx);
 for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
 if ((ret = ff_add_channel_layout(&layouts, 
buf->channel_layouts[i])) < 0)
 return ret;
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/4] lavfi/buffersink: clearly document that the Params struct are unused.

2020-08-14 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/buffersink.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 2ec821c685..c0e6b5386f 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -61,7 +61,7 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, 
AVFrame *frame, int flag
 
 #if FF_API_NEXT
 /**
- * Struct to use for initializing a buffersink context.
+ * Deprecated and unused struct to use for initializing a buffersink context.
  */
 typedef struct AVBufferSinkParams {
 const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, 
terminated by AV_PIX_FMT_NONE
@@ -76,7 +76,7 @@ attribute_deprecated
 AVBufferSinkParams *av_buffersink_params_alloc(void);
 
 /**
- * Struct to use for initializing an abuffersink context.
+ * Deprecated and unused struct to use for initializing an abuffersink context.
  */
 typedef struct AVABufferSinkParams {
 const enum AVSampleFormat *sample_fmts; ///< list of allowed sample 
formats, terminated by AV_SAMPLE_FMT_NONE
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/4] lavfi/buffersink: add a summary documentation of the API.

2020-08-14 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/buffersink.h | 36 
 1 file changed, 36 insertions(+)

diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index c0e6b5386f..65d0cca747 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -31,6 +31,42 @@
  * @defgroup lavfi_buffersink Buffer sink API
  * @ingroup lavfi
  * @{
+ *
+ * The buffersink and abuffersink filters are there to connect filter graphs
+ * to applications. They have a single input, connected to the graph, and no
+ * output. Frames must be extracted using av_buffersink_get_frame() or
+ * av_buffersink_get_samples().
+ *
+ * The format negotiated by the graph during configuration can be obtained
+ * using the accessor functions:
+ * - av_buffersink_get_time_base(),
+ * - av_buffersink_get_format(),
+ * - av_buffersink_get_frame_rate(),
+ * - av_buffersink_get_w(),
+ * - av_buffersink_get_h(),
+ * - av_buffersink_get_sample_aspect_ratio(),
+ * - av_buffersink_get_channels(),
+ * - av_buffersink_get_channel_layout(),
+ * - av_buffersink_get_sample_rate().
+ *
+ * The format can be constrained by setting options, using av_opt_set() and
+ * related functions with the AV_OPT_SEARCH_CHILDREN flag.
+ *  - pix_fmts (int list),
+ *  - sample_fmts (int list),
+ *  - sample_rates (int list),
+ *  - channel_layouts (int64_t),
+ *  - channel_counts (int list),
+ *  - all_channel_counts (bool).
+ * Most of these options are of type binary, and should be set using
+ * av_opt_set_int_list() or av_opt_set_bin(). If they are not set, all
+ * corresponding formats are accepted.
+ *
+ * As a special case, if neither channel_layouts nor channel_counts is set,
+ * all valid channel layouts are accepted, but channel counts without a
+ * layout are not, unless all_channel_counts is set.
+ * Also, channel_layouts must not contain a channel layout already accepted
+ * by a value in channel_counts; for example, if channel_counts contains 2,
+ * then channel_layouts must not contain stereo.
  */
 
 /**
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/4] ffplay: do not set redundant channel count on abuffersink.

2020-08-14 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 fftools/ffplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index d673b8049a..6c9c041e9a 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2008,7 +2008,7 @@ static int configure_audio_filters(VideoState *is, const 
char *afilters, int for
 
 if (force_output_format) {
 channel_layouts[0] = is->audio_tgt.channel_layout;
-channels   [0] = is->audio_tgt.channels;
+channels   [0] = is->audio_tgt.channel_layout ? -1 : 
is->audio_tgt.channels;
 sample_rates   [0] = is->audio_tgt.freq;
 if ((ret = av_opt_set_int(filt_asink, "all_channel_counts", 0, 
AV_OPT_SEARCH_CHILDREN)) < 0)
 goto end;
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Jean-Baptiste Kempf
Heya,

Curiosity: Since it seems to be SSSE3, does it work on both 32bits and 64bits 
CPU?

Best,

On Thu, 13 Aug 2020, at 18:23, Paul B Mahol wrote:
> Hi,
> 
> patch attached.
> 
> Please review and/or benchmark, especially .asm file.
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> *Attachments:*
>  * 0001-avcodec-cfhd-add-x86-SIMD.patch

--
Jean-Baptiste Kempf -  President
+33 672 704 734
 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 2/3] vaapi_encode: Rewrite slice/tile support

2020-08-14 Thread Linjie Fu
On Fri, Aug 14, 2020 at 5:51 AM Mark Thompson  wrote:
>
> This precalculates all of the information we will need to define slice
> and tile positions at init time rather than rebuilding some of it with
> every slice.  The control of tiles is generalised to match slices, so that
> arbitrary tile and slice layouts are possible within the constraint that
> slices can't cross tile boundaries (which comes from how VAAPI handles
> slices and tiles).  Support for the EQUAL_MULTI_ROWS slice structure fits
> easily into this, so it is added at the same time.

Some inputs for EQUAL_MULTI_ROWS slice structure, I believe there are
some discussions in libva and hw behavior team. To be honest, I don't think
the current notation/comment is suitable for what the hw could do.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2] avcodec/dpx: Read alternative frame rate from television header

2020-08-14 Thread Harry Mallon
Signed-off-by: Harry Mallon 
---
 libavcodec/dpx.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c
index b1833ed9ef..7e3ac0af2e 100644
--- a/libavcodec/dpx.c
+++ b/libavcodec/dpx.c
@@ -216,10 +216,23 @@ static int decode_frame(AVCodecContext *avctx,
 else
 avctx->sample_aspect_ratio = (AVRational){ 0, 1 };

+/* preferred frame rate from Motion-picture film header */
 if (offset >= 1724 + 4) {
 buf = avpkt->data + 1724;
 i = read32(&buf, endian);
-if(i) {
+if(i && i != 0x) {
+AVRational q = av_d2q(av_int2float(i), 4096);
+if (q.num > 0 && q.den > 0)
+avctx->framerate = q;
+}
+}
+
+/* alternative frame rate from television header */
+if (offset >= 1940 + 4 &&
+!(avctx->framerate.num && avctx->framerate.den)) {
+buf = avpkt->data + 1940;
+i = read32(&buf, endian);
+if(i && i != 0x) {
 AVRational q = av_d2q(av_int2float(i), 4096);
 if (q.num > 0 && q.den > 0)
 avctx->framerate = q;
-- 
2.28.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary: add floormod support

2020-08-14 Thread Mingyu Yin
Signed-off-by: Mingyu Yin 
---
 .../dnn/dnn_backend_native_layer_mathbinary.c   | 17 +
 .../dnn/dnn_backend_native_layer_mathbinary.h   |  1 +
 tests/dnn/dnn-layer-mathbinary-test.c   |  5 +
 tools/python/convert_from_tensorflow.py |  2 +-
 tools/python/convert_header.py  |  2 +-
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
index dd42c329a9..6876aaf2c6 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
@@ -175,6 +175,23 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, 
const int32_t *input_ope
 }
 }
 return 0;
+case DMBO_FLOORMOD:
+if (params->input0_broadcast) {
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(params->v) % (int)(src[i]);
+}
+} else if (params->input1_broadcast) {
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(src[i]) % (int)(params->v);
+}
+} else {
+const DnnOperand *input1 = &operands[input_operand_indexes[1]];
+const float *src1 = input1->data;
+for (int i = 0; i < dims_count; ++i) {
+dst[i] = (int)(src[i]) % (int)(src1[i]);
+}
+}
+return 0;
 default:
 return -1;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h 
b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
index 0acf3b0ea0..9525685afa 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
@@ -36,6 +36,7 @@ typedef enum {
 DMBO_MUL = 2,
 DMBO_REALDIV = 3,
 DMBO_MINIMUM = 4,
+DMBO_FLOORMOD = 5,
 DMBO_COUNT
 } DNNMathBinaryOperation;
 
diff --git a/tests/dnn/dnn-layer-mathbinary-test.c 
b/tests/dnn/dnn-layer-mathbinary-test.c
index e7f8f8557c..e5f6a12939 100644
--- a/tests/dnn/dnn-layer-mathbinary-test.c
+++ b/tests/dnn/dnn-layer-mathbinary-test.c
@@ -40,6 +40,8 @@ static float get_expected(float f1, float f2, 
DNNMathBinaryOperation op)
 return f1 / f2;
 case DMBO_MINIMUM:
 return (f1 < f2) ? f1 : f2;
+case DMBO_FLOORMOD:
+return (int)(f1) % (int)(f2);
 default:
 av_assert0(!"not supported yet");
 return 0.f;
@@ -205,5 +207,8 @@ int main(int argc, char **argv)
 if (test(DMBO_MINIMUM))
 return 1;
 
+if (test(DMBO_FLOORMOD))
+return 1;
+
 return 0;
 }
diff --git a/tools/python/convert_from_tensorflow.py 
b/tools/python/convert_from_tensorflow.py
index 65fdbc5d43..2ed0f66829 100644
--- a/tools/python/convert_from_tensorflow.py
+++ b/tools/python/convert_from_tensorflow.py
@@ -71,7 +71,7 @@ class TFConverter:
 self.conv2d_scope_names = set()
 self.conv2d_scopename_inputname_dict = {}
 self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 
'Maximum':4, 'MathBinary':5, 'MathUnary':6}
-self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
'Minimum':4}
+self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
'Minimum':4, 'FloorMod':5}
 self.mathun2code  = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10,
 'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14, 'Round':15}
diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py
index 747c8776eb..782a6341f9 100644
--- a/tools/python/convert_header.py
+++ b/tools/python/convert_header.py
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
 major = 1
 
 # increase minor when we don't have to re-convert the model file
-minor = 21
+minor = 22
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH, RFC] lavc/hevcdec: add invalid for skip_frame to skip invalid nalus before IRAP

2020-08-14 Thread Linjie Fu
Add "-skip_frame invalid" option to allow user to request decoder to skip
invalid nalus before an IRAP.

This would benefit decoding pipeline of bitstreams who didn't start from
an IRAP frame. NULL pointer pointing to missing reference may lead to
unexpected hang issues[1] in sub-level like hardware decoding.

Fixing the hang in driver is the first correct thing. Besides, adding a check
in nalu parsing and skip frames until we got the first IRAP would be another
good choice to be more robust for error tolerance.

Also this needs worker thread to update the skip_frames field in time.

[1] https://github.com/intel/media-driver/issues/992

Signed-off-by: Linjie Fu 
---
Request for comments:
The purpose is to allow decoder to skip frames until an IRAP has arrived, 
however
not sure whether we already had this in ffmpeg, hence submit a patch and
request for comments.

Skip logic identical for AVDISCARD_NONKEY in decode_nal_unit().

 libavcodec/avcodec.h   | 1 +
 libavcodec/hevcdec.c   | 5 -
 libavcodec/options_table.h | 1 +
 libavcodec/pthread_frame.c | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c91b2fd169..376d7f4d6d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -233,6 +233,7 @@ enum AVDiscard{
 AVDISCARD_BIDIR   = 16, ///< discard all bidirectional frames
 AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
 AVDISCARD_NONKEY  = 32, ///< discard all frames except keyframes
+AVDISCARD_INVALID = 33, ///< discard invalid packets like NALs before IRAP
 AVDISCARD_ALL = 48, ///< discard all
 };
 
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index b77df8d89f..78658fd537 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -539,8 +539,11 @@ static int hls_slice_header(HEVCContext *s)
 ff_hevc_clear_refs(s);
 }
 sh->no_output_of_prior_pics_flag = 0;
-if (IS_IRAP(s))
+if (IS_IRAP(s)) {
 sh->no_output_of_prior_pics_flag = get_bits1(gb);
+if (s->avctx->skip_frame == AVDISCARD_INVALID)
+s->avctx->skip_frame = AVDISCARD_DEFAULT;
+}
 
 sh->pps_id = get_ue_golomb_long(gb);
 if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 1d0db1b5a4..d52bce5908 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -310,6 +310,7 @@ static const AVOption avcodec_options[] = {
 {"bidir"   , "discard all bidirectional frames",0, 
AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR   }, INT_MIN, INT_MAX, V|D, 
"avdiscard"},
 {"nokey"   , "discard all frames except keyframes", 0, 
AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY  }, INT_MIN, INT_MAX, V|D, 
"avdiscard"},
 {"nointra" , "discard all frames except I frames",  0, 
AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA}, INT_MIN, INT_MAX, V|D, 
"avdiscard"},
+{"invalid" , "discard NALUs before IRAP",   0, 
AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_INVALID }, INT_MIN, INT_MAX, V|D, 
"avdiscard"},
 {"all" , "discard all frames",  0, 
AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, 
"avdiscard"},
 {"bidir_refine", "refine the two motion vectors used in bidirectional 
macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
 #if FF_API_PRIVATE_OPT
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 3255aa9337..302e6149ac 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -259,6 +259,7 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
 
 dst->has_b_frames = src->has_b_frames;
 dst->idct_algo= src->idct_algo;
+dst->skip_frame   = src->skip_frame;
 
 dst->bits_per_coded_sample = src->bits_per_coded_sample;
 dst->sample_aspect_ratio   = src->sample_aspect_ratio;
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor

2020-08-14 Thread Tomas Härdin
tor 2020-08-13 klockan 22:21 +0200 skrev Marton Balint:
> 
> On Thu, 13 Aug 2020, Tomas Härdin wrote:
> 
> > tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon:
> > > Here is an updated patch (now hopefully going with correct email headers).
> > 
> > It would be nice if in the future you either attach the patch or make
> > the entire email the patch itself. I've had to trim these first couple
> > of lines in each of the patches so far, after doing "git am" on the
> > .mbox from saving your messages
> > 
> > > From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001
> > > 
> > > From: Harry Mallon 
> > > Date: Wed, 12 Aug 2020 10:26:23 +0100
> > > Subject: [PATCH v4] avformat/mxfdec: Read video range from 
> > > PictureDescriptor
> > > 
> > > * Capture black_ref, white_ref and color_range and recognise
> > >   full and narrow range.
> > > 
> > > Signed-off-by: Harry Mallon 
> > > ---
> > >  libavformat/mxfdec.c   | 29 +
> > >  tests/ref/fate/mxf-probe-dnxhd |  2 +-
> > >  tests/ref/fate/mxf-probe-dv25  |  2 +-
> > >  3 files changed, 31 insertions(+), 2 deletions(-)
> > 
> > Looks good to me. Running FATE atm, will push in a day if there are no
> > objections.
> 
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf 
> is not detected correctly for some reason.
> 
> The MXF specs seems ambigous:
> 
> Color Range is a Property, whose unsigned 32-bit integer value shall 
> specify the number of distinct values allowed for color difference 
> samples.
> 
> So probably 2^depth color range should also be accepted as full range.

This sounds correct. Do we have any sample using 2^depth-1? If not then
we should just go with 2^depth until such a sample emerges.

/Tomas

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary: add floormod support

2020-08-14 Thread Xu, Guangxin


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Mingyu Yin
> Sent: Friday, August 14, 2020 6:11 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] dnn_backend_native_layer_mathbinary: add
> floormod support
> 
> Signed-off-by: Mingyu Yin 
> ---
>  .../dnn/dnn_backend_native_layer_mathbinary.c   | 17 +
>  .../dnn/dnn_backend_native_layer_mathbinary.h   |  1 +
>  tests/dnn/dnn-layer-mathbinary-test.c   |  5 +
>  tools/python/convert_from_tensorflow.py |  2 +-
>  tools/python/convert_header.py  |  2 +-
>  5 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> index dd42c329a9..6876aaf2c6 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c
> @@ -175,6 +175,23 @@ int dnn_execute_layer_math_binary(DnnOperand
> *operands, const int32_t *input_ope
>  }
>  }
>  return 0;
> +case DMBO_FLOORMOD:
> +if (params->input0_broadcast) {
> +for (int i = 0; i < dims_count; ++i) {
> +dst[i] = (int)(params->v) % (int)(src[i]);
> +}
> +} else if (params->input1_broadcast) {
> +for (int i = 0; i < dims_count; ++i) {
> +dst[i] = (int)(src[i]) % (int)(params->v);
> +}
> +} else {
> +const DnnOperand *input1 = &operands[input_operand_indexes[1]];
> +const float *src1 = input1->data;
> +for (int i = 0; i < dims_count; ++i) {
> +dst[i] = (int)(src[i]) % (int)(src1[i]);
> +}
> +}
Nearly same code as DMBO_SUB.
Only the op is different, how about define a function pass op as a inline 
function.

> +return 0;
>  default:
>  return -1;
>  }
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> index 0acf3b0ea0..9525685afa 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.h
> @@ -36,6 +36,7 @@ typedef enum {
>  DMBO_MUL = 2,
>  DMBO_REALDIV = 3,
>  DMBO_MINIMUM = 4,
> +DMBO_FLOORMOD = 5,
>  DMBO_COUNT
>  } DNNMathBinaryOperation;
> 
> diff --git a/tests/dnn/dnn-layer-mathbinary-test.c b/tests/dnn/dnn-layer-
> mathbinary-test.c
> index e7f8f8557c..e5f6a12939 100644
> --- a/tests/dnn/dnn-layer-mathbinary-test.c
> +++ b/tests/dnn/dnn-layer-mathbinary-test.c
> @@ -40,6 +40,8 @@ static float get_expected(float f1, float f2,
> DNNMathBinaryOperation op)
>  return f1 / f2;
>  case DMBO_MINIMUM:
>  return (f1 < f2) ? f1 : f2;
> +case DMBO_FLOORMOD:
> +return (int)(f1) % (int)(f2);
>  default:
>  av_assert0(!"not supported yet");
>  return 0.f;
> @@ -205,5 +207,8 @@ int main(int argc, char **argv)
>  if (test(DMBO_MINIMUM))
>  return 1;
> 
> +if (test(DMBO_FLOORMOD))
> +return 1;
> +
>  return 0;
>  }
> diff --git a/tools/python/convert_from_tensorflow.py
> b/tools/python/convert_from_tensorflow.py
> index 65fdbc5d43..2ed0f66829 100644
> --- a/tools/python/convert_from_tensorflow.py
> +++ b/tools/python/convert_from_tensorflow.py
> @@ -71,7 +71,7 @@ class TFConverter:
>  self.conv2d_scope_names = set()
>  self.conv2d_scopename_inputname_dict = {}
>  self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 
> 'Maximum':4,
> 'MathBinary':5, 'MathUnary':6}
> -self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 
> 'Minimum':4}
> +self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3,
> + 'Minimum':4, 'FloorMod':5}
>  self.mathun2code  = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
>  'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10,
>  'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14, 'Round':15} 
> diff --git
> a/tools/python/convert_header.py b/tools/python/convert_header.py index
> 747c8776eb..782a6341f9 100644
> --- a/tools/python/convert_header.py
> +++ b/tools/python/convert_header.py
> @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE'
>  major = 1
> 
>  # increase minor when we don't have to re-convert the model file -minor = 21
> +minor = 22
> --
> 2.17.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org
> with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse options in openvino backend

2020-08-14 Thread Xu, Guangxin


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: Friday, August 14, 2020 9:50 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse options
> in openvino backend
> 
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/dnn/dnn_backend_openvino.c | 37
> +-
>  1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> b/libavfilter/dnn/dnn_backend_openvino.c
> index d343bf2..478e151 100644
> --- a/libavfilter/dnn/dnn_backend_openvino.c
> +++ b/libavfilter/dnn/dnn_backend_openvino.c
> @@ -26,8 +26,14 @@
>  #include "dnn_backend_openvino.h"
>  #include "libavformat/avio.h"
>  #include "libavutil/avassert.h"
> +#include "libavutil/avstring.h"
>  #include 
> 
> +typedef struct OVOptions{
> +uint32_t batch_size;
> +uint32_t req_num;
> +} OVOptions;
> +
>  typedef struct OVModel{
>  ie_core_t *core;
>  ie_network_t *network;
> @@ -36,6 +42,7 @@ typedef struct OVModel{
>  ie_blob_t *input_blob;
>  ie_blob_t **output_blobs;
>  uint32_t nb_output;
> +OVOptions options;
>  } OVModel;
> 
>  static DNNDataType precision_to_datatype(precision_e precision) @@ -50,6
> +57,32 @@ static DNNDataType precision_to_datatype(precision_e precision)
>  }
>  }
> 
> +static int parse_options_ov(OVOptions *to, const char *from) {
> +AVDictionary *dict = NULL;
> +AVDictionaryEntry *opt = NULL;
> +int err = av_dict_parse_string(&dict, from, "=", "&", 0);
> +if (err < 0) {
> +av_dict_free(&dict);
This may not needed.

> +return err;
> +}
> +
> +opt = av_dict_get(dict, "nireq", opt, AV_DICT_MATCH_CASE);
> +if (opt != NULL)
> +to->req_num = atoi(opt->value);
> +else
> +to->req_num = 1;
> +
> +opt = av_dict_get(dict, "batch", opt, AV_DICT_MATCH_CASE);
> +if (opt != NULL)
> +to->batch_size = atoi(opt->value);
> +else
> +to->batch_size = 1;
How about a function like this.
Int dict_get_int(const AVDictionary *m, const char *key, int default_value)

> +
> +av_dict_free(&dict);
> +return 0;
> +}
> +
>  static DNNReturnType get_input_ov(void *model, DNNData *input, const char
> *input_name)  {
>  OVModel *ov_model = (OVModel *)model; @@ -171,6 +204,9 @@
> DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char
> *options)
>  if (!ov_model)
>  goto err;
> 
> +model->options = options;
> +parse_options_ov(&ov_model->options, model->options);
Check error?

> +
>  status = ie_core_create("", &ov_model->core);
>  if (status != OK)
>  goto err;
> @@ -186,7 +222,6 @@ DNNModel *ff_dnn_load_model_ov(const char
> *model_filename, const char *options)
>  model->model = (void *)ov_model;
>  model->set_input_output = &set_input_output_ov;
>  model->get_input = &get_input_ov;
> -model->options = options;
> 
>  return model;
> 
> --
> 2.7.4
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org
> with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/14/20, Paul B Mahol  wrote:
> On 8/13/20, Paul B Mahol  wrote:
>> Hi,
>>
>> patch attached.
>>
>> Please review and/or benchmark, especially .asm file.
>>
>
> Updated patch attached.
>

Sorry, wrong patch.

New patch attached.


0001-avcodec-cfhd-add-x86-SIMD.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/13/20, Paul B Mahol  wrote:
> Hi,
>
> patch attached.
>
> Please review and/or benchmark, especially .asm file.
>

Updated patch attached.


0001-avcodec-cfhd-add-x86-SIMD.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse options in openvino backend

2020-08-14 Thread Alexander Strasser


Am 14. August 2020 14:07:23 MESZ schrieb "Xu, Guangxin" :
>
>
>> -Original Message-
>> From: ffmpeg-devel  On Behalf Of
>Guo,
>> Yejun
>> Sent: Friday, August 14, 2020 9:50 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse
>options
>> in openvino backend
>> 
>> Signed-off-by: Guo, Yejun 
>> ---
>>  libavfilter/dnn/dnn_backend_openvino.c | 37
>> +-
>>  1 file changed, 36 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavfilter/dnn/dnn_backend_openvino.c
>> b/libavfilter/dnn/dnn_backend_openvino.c
>> index d343bf2..478e151 100644
>> --- a/libavfilter/dnn/dnn_backend_openvino.c
>> +++ b/libavfilter/dnn/dnn_backend_openvino.c
>> @@ -26,8 +26,14 @@
>>  #include "dnn_backend_openvino.h"
>>  #include "libavformat/avio.h"
>>  #include "libavutil/avassert.h"
>> +#include "libavutil/avstring.h"
>>  #include 
>> 
>> +typedef struct OVOptions{
>> +uint32_t batch_size;
>> +uint32_t req_num;
>> +} OVOptions;
>> +
>>  typedef struct OVModel{
>>  ie_core_t *core;
>>  ie_network_t *network;
>> @@ -36,6 +42,7 @@ typedef struct OVModel{
>>  ie_blob_t *input_blob;
>>  ie_blob_t **output_blobs;
>>  uint32_t nb_output;
>> +OVOptions options;
>>  } OVModel;
>> 
>>  static DNNDataType precision_to_datatype(precision_e precision) @@
>-50,6
>> +57,32 @@ static DNNDataType precision_to_datatype(precision_e
>precision)
>>  }
>>  }
>> 
>> +static int parse_options_ov(OVOptions *to, const char *from) {
>> +AVDictionary *dict = NULL;
>> +AVDictionaryEntry *opt = NULL;
>> +int err = av_dict_parse_string(&dict, from, "=", "&", 0);
>> +if (err < 0) {
>> +av_dict_free(&dict);
>This may not needed.
>
>> +return err;
>> +}
>> +
>> +opt = av_dict_get(dict, "nireq", opt, AV_DICT_MATCH_CASE);
>> +if (opt != NULL)
>> +to->req_num = atoi(opt->value);
>> +else
>> +to->req_num = 1;
>> +
>> +opt = av_dict_get(dict, "batch", opt, AV_DICT_MATCH_CASE);
>> +if (opt != NULL)
>> +to->batch_size = atoi(opt->value);
>> +else
>> +to->batch_size = 1;
>How about a function like this.
>Int dict_get_int(const AVDictionary *m, const char *key, int
>default_value)

If we parse the options ourselves (as opposed to pass a string into an external 
library function) we should look into using AVOptions. Else we will slowly but 
for sure create a usability nightmare.

Can't look into the code right now, but I think it should be possible to use 
AVOptions somehow.

Other opinions in this?


[...]

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Derek Buitenhuis
>> Updated patch attached.
>>
> 
> Sorry, wrong patch.

I would expect any SIMD patch to include benchmarks showing it
is actually faster.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/mpegts: parse for AC-3 descriptor 6A

2020-08-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegts.c | 53 ++--
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index f71f18a5..72cc72a 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2075,16 +2075,57 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 break;
 case 0x6a: /* ac-3_descriptor */
 {
-int component_type_flag = get8(pp, desc_end) & (1 << 7);
-if (component_type_flag) {
-int component_type = get8(pp, desc_end);
-int service_type_mask = 0x38;  // 0b00111000
-int service_type = ((component_type & service_type_mask) >> 3);
+AVDVBAC3Descriptor desc6a;
+uint8_t buf;
+
+if (desc_end - *pp < 1)
+return AVERROR_INVALIDDATA;
+
+buf = get8(pp, desc_end);
+desc6a.component_type_flag = (buf >> 7) & 0x1;
+desc6a.bsid_flag   = (buf >> 6) & 0x1;
+desc6a.mainid_flag = (buf >> 5) & 0x1;
+desc6a.asvc_flag   = (buf >> 4) & 0x1;
+
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "Stream[0x%x] 
AC-3(6a):", st->id);
+if (desc6a.component_type_flag) {
+int service_type;
+int number_of_channels;
+desc6a.component_type = get8(pp, desc_end);
+service_type = ((desc6a.component_type >> 3) & 0x7);
 if (service_type == 0x02 /* 0b010 */) {
 st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
-av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track 
disposition for id %u: %u\n", st->id, st->disposition);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG,
+   " disposition: 0x%x", st->disposition);
+}
+number_of_channels = desc6a.component_type & 0x7;
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " component_type: 
0x%x number_of_channels: %u",
+desc6a.component_type, number_of_channels);
+}
+if (desc6a.bsid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.bsid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " bsid: %u", 
desc6a.bsid);
+}
+if (desc6a.mainid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.mainid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " mainid: %u", 
desc6a.mainid);
+}
+if (desc6a.asvc_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
 }
+desc6a.asvc = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " asvc: %u", 
desc6a.asvc);
 }
+if (desc6a.component_type_flag || desc6a.bsid_flag ||
+desc6a.mainid_flag || desc6a.asvc_flag)
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "\n");
 }
 break;
 case 0x7a: /* enhanced_ac-3_descriptor */
-- 
1.8.3.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/mpegtsenc: support DVB 6A descriptor for AC-3

2020-08-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegts.h| 16 +++
 libavformat/mpegtsenc.c | 76 +
 2 files changed, 92 insertions(+)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index fe10b38..951aa61 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -175,6 +175,22 @@ typedef struct Mp4Descr {
 SLConfigDescr sl;
 } Mp4Descr;
 
+/*
+ * ETSI 300 468 descriptor 0x6A(AC-3)
+ * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
+ */
+typedef struct AVDVBAC3Descriptor {
+uint8_t  component_type_flag;
+uint8_t  bsid_flag;
+uint8_t  mainid_flag;
+uint8_t  asvc_flag;
+uint8_t  reserved_flags;
+uint8_t  component_type;
+uint8_t  bsid;
+uint8_t  mainid;
+uint8_t  asvc;
+} AVDVBAC3Descriptor;
+
 /**
  * Parse an MPEG-2 descriptor
  * @param[in] fcFormat context (used for logging only)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 718ddab..9529f51 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -27,6 +27,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 
+#include "libavcodec/ac3_parser_internal.h"
 #include "libavcodec/internal.h"
 
 #include "avformat.h"
@@ -244,6 +245,8 @@ typedef struct MpegTSWriteStream {
 /* For Opus */
 int opus_queued_samples;
 int opus_pending_trim_start;
+
+AVDVBAC3Descriptor *desc6a;
 } MpegTSWriteStream;
 
 static void mpegts_write_pat(AVFormatContext *s)
@@ -486,9 +489,28 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AVMEDIA_TYPE_AUDIO:
 if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
 if (codec_id == AV_CODEC_ID_AC3) {
+AVDVBAC3Descriptor *desc6a = ts_st->desc6a;
+
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
+if (desc6a) {
+int len = 1 +
+  !!(desc6a->component_type_flag) +
+  !!(desc6a->bsid_flag) +
+  !!(desc6a->mainid_flag) +
+  !!(desc6a->asvc_flag);
+
+*q++ = len;
+*q++ = desc6a->component_type_flag << 7 | 
desc6a->bsid_flag << 6 |
+   desc6a->mainid_flag << 5 | 
desc6a->asvc_flag << 4;
+
+if (desc6a->component_type_flag) *q++ = 
desc6a->component_type;
+if (desc6a->bsid_flag)   *q++ = desc6a->bsid;
+if (desc6a->mainid_flag) *q++ = desc6a->mainid;
+if (desc6a->asvc_flag)   *q++ = desc6a->asvc;
+} else {
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
+}
 } else if (codec_id == AV_CODEC_ID_EAC3) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
@@ -1843,6 +1865,59 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
  * need to count the samples of that too! */
 av_log(s, AV_LOG_WARNING, "Got MPEG-TS formatted Opus data, 
unhandled");
 }
+} else if (st->codecpar->codec_id == AV_CODEC_ID_AC3 && !ts_st->desc6a) {
+uint8_t number_of_channels_flag;
+uint8_t service_type_flag;
+uint8_t full_service_flag = 1;
+AC3HeaderInfo *hdr = NULL;
+AVDVBAC3Descriptor *desc6a;
+
+if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) >= 0) {
+desc6a = av_mallocz(sizeof(*desc6a));
+if (!desc6a)
+return AVERROR(ENOMEM);
+
+service_type_flag = hdr->bitstream_mode;
+switch (hdr->channel_mode) {
+case AC3_CHMODE_DUALMONO:
+number_of_channels_flag = 1;
+break;
+case AC3_CHMODE_MONO:
+number_of_channels_flag = 0;
+break;
+case AC3_CHMODE_STEREO:
+if (hdr->dolby_surround_mode == AC3_DSURMOD_ON)
+number_of_channels_flag = 3;
+else
+number_of_channels_flag = 2;
+break;
+case AC3_CHMODE_3F:
+case AC3_CHMODE_2F1R:
+case AC3_CHMODE_3F1R:
+case AC3_CHMODE_2F2R:
+case AC3_CHMODE_3F2R:
+number_of_channels_flag = 4;
+break;
+default: /* reserved */
+number_of_channels_flag = 7;
+break;
+}
+
+if (service_type_flag  == 1 || service_type_flag == 4 ||
+(service_type_flag == 7 && !number_of_c

[FFmpeg-devel] [PATCH] avformat/av1dec: inline obu_read_data() and obu_prefetch() into obu_get_packet()

2020-08-14 Thread James Almer
They don't really help making the demuxer more readable.

Signed-off-by: James Almer 
---
 libavformat/av1dec.c | 56 +---
 1 file changed, 21 insertions(+), 35 deletions(-)

diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 0693e40ac1..c06f5303f5 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -382,60 +382,46 @@ static int obu_read_header(AVFormatContext *s)
 return read_header(s, &c->framerate, &c->bsf, c);
 }
 
-static int obu_prefetch(AVFormatContext *s, uint8_t* dest)
+static int obu_get_packet(AVFormatContext *s, AVPacket *pkt)
 {
 ObuContext *c = s->priv_data;
+uint8_t header[MAX_OBU_HEADER_SIZE];
+int64_t obu_size;
 int size = av_fifo_space(c->fifo);
+int ret, len, type;
+
 av_fifo_generic_write(c->fifo, s->pb, size,
   (int (*)(void*, void*, int))avio_read);
 size = av_fifo_size(c->fifo);
-if (size > 0) {
-av_fifo_generic_peek(c->fifo, dest, size, NULL);
+if (!size)
+return 0;
+
+av_fifo_generic_peek(c->fifo, header, size, NULL);
+
+len = read_obu_with_size(header, size, &obu_size, &type);
+if (len < 0) {
+av_log(c, AV_LOG_ERROR, "Failed to read obu\n");
+return len;
 }
-return size;
-}
 
-static int obu_read_data(AVFormatContext *s, AVPacket *pkt, int len)
-{
-int size, left;
-ObuContext *c = s->priv_data;
-int ret = av_new_packet(pkt, len);
+ret = av_new_packet(pkt, len);
 if (ret < 0) {
 av_log(c, AV_LOG_ERROR, "Failed to allocate packet for obu\n");
 return ret;
 }
-size = FFMIN(av_fifo_size(c->fifo), len);
+size = FFMIN(size, len);
 av_fifo_generic_read(c->fifo, pkt->data, size, NULL);
-left = len - size;
-if (left > 0) {
-ret = avio_read(s->pb, pkt->data + size, left);
-if (ret != left) {
-av_log(c, AV_LOG_ERROR, "Failed to read %d frome file\n", left);
+len -= size;
+if (len > 0) {
+ret = avio_read(s->pb, pkt->data + size, len);
+if (ret != len) {
+av_log(c, AV_LOG_ERROR, "Failed to read %d frome file\n", len);
 return ret < 0 ? ret : AVERROR_INVALIDDATA;
 }
 }
 return 0;
 }
 
-static int obu_get_packet(AVFormatContext *s, AVPacket *pkt)
-{
-ObuContext *c = s->priv_data;
-int64_t obu_size;
-int ret, type;
-uint8_t header[MAX_OBU_HEADER_SIZE];
-
-ret = obu_prefetch(s, header);
-if (!ret)
-return 0;
-
-ret = read_obu_with_size(header, ret, &obu_size, &type);
-if (ret < 0) {
-av_log(c, AV_LOG_ERROR, "Failed to read obu\n");
-return ret;
-}
-return obu_read_data(s, pkt, ret);
-}
-
 static int obu_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 ObuContext *c = s->priv_data;
-- 
2.27.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Lynne
Aug 13, 2020, 18:23 by one...@gmail.com:

> Hi,
>
> patch attached.
>
> Please review and/or benchmark, especially .asm file.
>

I took a look. Its just the horizontal pass of an inverse 2-6 idwt with 
clipping.
The code is so simple I wasn't able to find any obvious ways to improve it,
except perhaps replacing the "mov xq, 0" with "xor xq, xq", since I think
xor is more universally recognized by x86 CPUs as "zeroing a register" so it'll
just allocate a pre-zeroed one. I could be wrong though, its what everyone uses.
Maybe call it idwt_26_horiz instead of a vague horiz_filter, since that's what 
it is?

Its also called on a per-line basis in a loop with 1 call, and 3 adds 
everywhere.
You could easily incorporate the loop into the function to reduce call
overhead if you want to (and I think you should look into it, but I won't block
the patch just for that). Registers might be a tight fit on 32-bit systems then,
but even using the stack should be faster than a hot function call.

Aside from those nitpicks, LGTM.

SIMDing the remaining DSP function (interlaced_vertical_filter) should help a 
lot
too, though that function is pretty much trivial, since its just an average + 
deinterleave.
That function should 100% have its 3-line loop incorporated into it, however, 
as you'll
definitely have no shortage of registers, even on 32bit systems.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: support DVB 6A descriptor for AC-3

2020-08-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
Sorry, fix for the patch order for fate test

 libavformat/mpegts.h| 16 +++
 libavformat/mpegtsenc.c | 76 +
 2 files changed, 92 insertions(+)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index fe10b38..951aa61 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -175,6 +175,22 @@ typedef struct Mp4Descr {
 SLConfigDescr sl;
 } Mp4Descr;
 
+/*
+ * ETSI 300 468 descriptor 0x6A(AC-3)
+ * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
+ */
+typedef struct AVDVBAC3Descriptor {
+uint8_t  component_type_flag;
+uint8_t  bsid_flag;
+uint8_t  mainid_flag;
+uint8_t  asvc_flag;
+uint8_t  reserved_flags;
+uint8_t  component_type;
+uint8_t  bsid;
+uint8_t  mainid;
+uint8_t  asvc;
+} AVDVBAC3Descriptor;
+
 /**
  * Parse an MPEG-2 descriptor
  * @param[in] fcFormat context (used for logging only)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 718ddab..e9ac08d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -27,6 +27,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 
+#include "libavcodec/ac3_parser_internal.h"
 #include "libavcodec/internal.h"
 
 #include "avformat.h"
@@ -244,6 +245,8 @@ typedef struct MpegTSWriteStream {
 /* For Opus */
 int opus_queued_samples;
 int opus_pending_trim_start;
+
+AVDVBAC3Descriptor *desc6a;
 } MpegTSWriteStream;
 
 static void mpegts_write_pat(AVFormatContext *s)
@@ -486,9 +489,28 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AVMEDIA_TYPE_AUDIO:
 if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
 if (codec_id == AV_CODEC_ID_AC3) {
+AVDVBAC3Descriptor *desc6a = ts_st->desc6a;
+
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
+if (desc6a) {
+int len = 1 +
+  !!(desc6a->component_type_flag) +
+  !!(desc6a->bsid_flag) +
+  !!(desc6a->mainid_flag) +
+  !!(desc6a->asvc_flag);
+
+*q++ = len;
+*q++ = desc6a->component_type_flag << 7 | 
desc6a->bsid_flag << 6 |
+   desc6a->mainid_flag << 5 | 
desc6a->asvc_flag << 4;
+
+if (desc6a->component_type_flag) *q++ = 
desc6a->component_type;
+if (desc6a->bsid_flag)   *q++ = desc6a->bsid;
+if (desc6a->mainid_flag) *q++ = desc6a->mainid;
+if (desc6a->asvc_flag)   *q++ = desc6a->asvc;
+} else {
 *q++=1; // 1 byte, all flags sets to 0
 *q++=0; // omit all fields...
+}
 } else if (codec_id == AV_CODEC_ID_EAC3) {
 *q++=0x7a; // EAC3 descriptor see A038 DVB SI
 *q++=1; // 1 byte, all flags sets to 0
@@ -1843,6 +1865,59 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
  * need to count the samples of that too! */
 av_log(s, AV_LOG_WARNING, "Got MPEG-TS formatted Opus data, 
unhandled");
 }
+} else if (st->codecpar->codec_id == AV_CODEC_ID_AC3 && !ts_st->desc6a) {
+uint8_t number_of_channels_flag;
+uint8_t service_type_flag;
+uint8_t full_service_flag = 1;
+AC3HeaderInfo *hdr = NULL;
+AVDVBAC3Descriptor *desc6a;
+
+if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) >= 0) {
+desc6a = av_mallocz(sizeof(*desc6a));
+if (!desc6a)
+return AVERROR(ENOMEM);
+
+service_type_flag = hdr->bitstream_mode;
+switch (hdr->channel_mode) {
+case AC3_CHMODE_DUALMONO:
+number_of_channels_flag = 1;
+break;
+case AC3_CHMODE_MONO:
+number_of_channels_flag = 0;
+break;
+case AC3_CHMODE_STEREO:
+if (hdr->dolby_surround_mode == AC3_DSURMOD_ON)
+number_of_channels_flag = 3;
+else
+number_of_channels_flag = 2;
+break;
+case AC3_CHMODE_3F:
+case AC3_CHMODE_2F1R:
+case AC3_CHMODE_3F1R:
+case AC3_CHMODE_2F2R:
+case AC3_CHMODE_3F2R:
+number_of_channels_flag = 4;
+break;
+default: /* reserved */
+number_of_channels_flag = 7;
+break;
+}
+
+if (service_type_flag  == 1 || service_type_flag == 4 ||
+ 

[FFmpeg-devel] [PATCH 2/2] avformat/mpegts: parse for AC-3 descriptor 6A

2020-08-14 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/mpegts.c | 53 ++--
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index f71f18a5..72cc72a 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2075,16 +2075,57 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 break;
 case 0x6a: /* ac-3_descriptor */
 {
-int component_type_flag = get8(pp, desc_end) & (1 << 7);
-if (component_type_flag) {
-int component_type = get8(pp, desc_end);
-int service_type_mask = 0x38;  // 0b00111000
-int service_type = ((component_type & service_type_mask) >> 3);
+AVDVBAC3Descriptor desc6a;
+uint8_t buf;
+
+if (desc_end - *pp < 1)
+return AVERROR_INVALIDDATA;
+
+buf = get8(pp, desc_end);
+desc6a.component_type_flag = (buf >> 7) & 0x1;
+desc6a.bsid_flag   = (buf >> 6) & 0x1;
+desc6a.mainid_flag = (buf >> 5) & 0x1;
+desc6a.asvc_flag   = (buf >> 4) & 0x1;
+
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "Stream[0x%x] 
AC-3(6a):", st->id);
+if (desc6a.component_type_flag) {
+int service_type;
+int number_of_channels;
+desc6a.component_type = get8(pp, desc_end);
+service_type = ((desc6a.component_type >> 3) & 0x7);
 if (service_type == 0x02 /* 0b010 */) {
 st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
-av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track 
disposition for id %u: %u\n", st->id, st->disposition);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG,
+   " disposition: 0x%x", st->disposition);
+}
+number_of_channels = desc6a.component_type & 0x7;
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " component_type: 
0x%x number_of_channels: %u",
+desc6a.component_type, number_of_channels);
+}
+if (desc6a.bsid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.bsid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " bsid: %u", 
desc6a.bsid);
+}
+if (desc6a.mainid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.mainid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " mainid: %u", 
desc6a.mainid);
+}
+if (desc6a.asvc_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
 }
+desc6a.asvc = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " asvc: %u", 
desc6a.asvc);
 }
+if (desc6a.component_type_flag || desc6a.bsid_flag ||
+desc6a.mainid_flag || desc6a.asvc_flag)
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "\n");
 }
 break;
 case 0x7a: /* enhanced_ac-3_descriptor */
-- 
1.8.3.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegtsenc: support DVB 6A descriptor for AC-3

2020-08-14 Thread Andreas Rheinhardt
lance.lmw...@gmail.com:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavformat/mpegts.h| 16 +++
>  libavformat/mpegtsenc.c | 76 
> +
>  2 files changed, 92 insertions(+)
> 
> diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
> index fe10b38..951aa61 100644
> --- a/libavformat/mpegts.h
> +++ b/libavformat/mpegts.h
> @@ -175,6 +175,22 @@ typedef struct Mp4Descr {
>  SLConfigDescr sl;
>  } Mp4Descr;
>  
> +/*
> + * ETSI 300 468 descriptor 0x6A(AC-3)
> + * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
> + */
> +typedef struct AVDVBAC3Descriptor {
> +uint8_t  component_type_flag;
> +uint8_t  bsid_flag;
> +uint8_t  mainid_flag;
> +uint8_t  asvc_flag;
> +uint8_t  reserved_flags;
> +uint8_t  component_type;
> +uint8_t  bsid;
> +uint8_t  mainid;
> +uint8_t  asvc;
> +} AVDVBAC3Descriptor;
> +

This is not a public struct, ergo it shouldn't have an AV prefix.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegtsenc: support DVB 6A descriptor for AC-3

2020-08-14 Thread lance . lmwang
On Fri, Aug 14, 2020 at 04:33:03PM +0200, Andreas Rheinhardt wrote:
> lance.lmw...@gmail.com:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavformat/mpegts.h| 16 +++
> >  libavformat/mpegtsenc.c | 76 
> > +
> >  2 files changed, 92 insertions(+)
> > 
> > diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
> > index fe10b38..951aa61 100644
> > --- a/libavformat/mpegts.h
> > +++ b/libavformat/mpegts.h
> > @@ -175,6 +175,22 @@ typedef struct Mp4Descr {
> >  SLConfigDescr sl;
> >  } Mp4Descr;
> >  
> > +/*
> > + * ETSI 300 468 descriptor 0x6A(AC-3)
> > + * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
> > + */
> > +typedef struct AVDVBAC3Descriptor {
> > +uint8_t  component_type_flag;
> > +uint8_t  bsid_flag;
> > +uint8_t  mainid_flag;
> > +uint8_t  asvc_flag;
> > +uint8_t  reserved_flags;
> > +uint8_t  component_type;
> > +uint8_t  bsid;
> > +uint8_t  mainid;
> > +uint8_t  asvc;
> > +} AVDVBAC3Descriptor;
> > +
> 
> This is not a public struct, ergo it shouldn't have an AV prefix.

OK, will remove the AV prefix.

> 
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/utils: calculate frame number of HEVC if the framerate > 30FPS

2020-08-14 Thread lance . lmwang
On Fri, Jul 17, 2020 at 09:26:38PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> ---
>  libavcodec/internal.h |  3 ++-
>  libavcodec/nvenc.c|  2 +-
>  libavcodec/utils.c| 13 -
>  3 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 0a1c0a1..4c34d7d 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -382,6 +382,7 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t 
> prefix_len,
>   * Check AVFrame for S12M timecode side data and allocate and fill TC SEI 
> message with timecode info
>   *
>   * @param frame  Raw frame to get S12M timecode side data from
> + * @param rate   The frame rate
>   * @param prefix_len Number of bytes to allocate before SEI message
>   * @param data   Pointer to a variable to store allocated memory
>   *   Upon return the variable will hold NULL on error or if 
> frame has no S12M timecode info.
> @@ -390,7 +391,7 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t 
> prefix_len,
>   * @param sei_size   Pointer to a variable to store generated SEI message 
> length
>   * @return   Zero on success, negative error code on failure
>   */
> -int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
> +int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t 
> prefix_len,
>   void **data, size_t *sei_size);
>  
>  /**
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index c6740c1..45a7b60 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -2218,7 +2218,7 @@ static int nvenc_send_frame(AVCodecContext *avctx, 
> const AVFrame *frame)
>  void *tc_data = NULL;
>  size_t tc_size = 0;
>  
> -if (ff_alloc_timecode_sei(frame, 0, (void**)&tc_data, &tc_size) 
> < 0) {
> +if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, 
> (void**)&tc_data, &tc_size) < 0) {
>  av_log(ctx, AV_LOG_ERROR, "Not enough memory for timecode 
> sei, skipping\n");
>  }
>  
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 2ece34f..51c4067 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2254,7 +2254,7 @@ static unsigned bcd2uint(uint8_t bcd)
>  return low + 10*high;
>  }
>  
> -int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
> +int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t 
> prefix_len,
>   void **data, size_t *sei_size)
>  {
>  AVFrameSideData *sd = NULL;
> @@ -2290,6 +2290,17 @@ int ff_alloc_timecode_sei(const AVFrame *frame, size_t 
> prefix_len,
>  unsigned ff   = bcd2uint(tcsmpte>>24 & 0x3f);// 6-bit frames
>  unsigned drop = tcsmpte & 1<<30 && !0;  // 1-bit drop if not 
> arbitrary bit
>  
> +/* Calculate frame number of HEVC by SMPTE ST 12-1:2014 Sec 12.2 if 
> rate > 30FPS */
> +if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
> +unsigned pc;
> +ff *= 2;
> +if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
> +pc = !!(tcsmpte & 1 << 7);
> +else
> +pc = !!(tcsmpte & 1 << 23);
> +ff = (ff + pc) & 0x7f;
> +}
> +
>  put_bits(&pb, 1, 1); // clock_timestamp_flag
>  put_bits(&pb, 1, 1); // units_field_based_flag
>  put_bits(&pb, 5, 0); // counting_type
> -- 
> 2.9.4

ping the patch.


> 

-- 
Thanks,
Limin Wang
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/14/20, Derek Buitenhuis  wrote:
>>> Updated patch attached.
>>>
>>
>> Sorry, wrong patch.
>
> I would expect any SIMD patch to include benchmarks showing it
> is actually faster.

It is faster, but I have only Celeron CPU to test.

>
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec: split off A53 Closed Caption parsing code into its own file

2020-08-14 Thread James Almer
On 8/10/2020 12:49 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  configure |  1 +
>  libavcodec/Makefile   |  1 +
>  libavcodec/atsc_a53.c | 76 +++
>  libavcodec/atsc_a53.h | 39 ++
>  4 files changed, 117 insertions(+)
>  create mode 100644 libavcodec/atsc_a53.c
>  create mode 100644 libavcodec/atsc_a53.h

Will apply patchset soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Derek Buitenhuis
On 14/08/2020 16:37, Paul B Mahol wrote:
>> I would expect any SIMD patch to include benchmarks showing it
>> is actually faster.
> It is faster, but I have only Celeron CPU to test.

I can't tell if you're trolling or not, but that doesn't
change the standards...

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] ffmpeg: add disable_all_auto_conversion_filters option.

2020-08-14 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 doc/ffmpeg.texi | 5 +
 fftools/ffmpeg.h| 1 +
 fftools/ffmpeg_filter.c | 2 ++
 fftools/ffmpeg_opt.c| 3 +++
 4 files changed, 11 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 267ddfe8b5..1603431d56 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1746,6 +1746,11 @@ this buffer, in packets, for the matching output stream.
 The default value of this option should be high enough for most uses, so only
 touch this option if you are sure that you need it.
 
+@item -disable_all_auto_conversion_filters (@emph{global})
+Disable automatically inserting conversion filters in all filter graphs,
+including those defined by @option{-vf}, @option{-af},
+@option{-filter_complex} and @option{-lavfi}.
+
 @end table
 
 As a special exception, you can use a bitmap subtitle stream as input: it
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6e3f2545c7..acd297c8e8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -613,6 +613,7 @@ extern char *videotoolbox_pixfmt;
 extern int filter_nbthreads;
 extern int filter_complex_nbthreads;
 extern int vstats_version;
+extern int disable_all_auto_conversion_filters;
 
 extern const AVIOInterruptCB int_cb;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 4784e8a575..8721403d7a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1104,6 +1104,8 @@ int configure_filtergraph(FilterGraph *fg)
 configure_output_filter(fg, fg->outputs[i], cur);
 avfilter_inout_free(&outputs);
 
+if (disable_all_auto_conversion_filters)
+avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
 if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
 goto fail;
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 853550a142..e6131dac97 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -172,6 +172,7 @@ float max_error_rate  = 2.0/3;
 int filter_nbthreads = 0;
 int filter_complex_nbthreads = 0;
 int vstats_version = 2;
+int disable_all_auto_conversion_filters = 0;
 
 
 static int intra_only = 0;
@@ -3545,6 +3546,8 @@ const OptionDef options[] = {
 "create a complex filtergraph", "graph_description" },
 { "filter_complex_script", HAS_ARG | OPT_EXPERT, { 
.func_arg = opt_filter_complex_script },
 "read complex filtergraph description from a file", "filename" },
+{ "disable_all_auto_conversion_filters", OPT_BOOL | OPT_EXPERT,  { 
&disable_all_auto_conversion_filters },
+"create a complex filtergraph", "graph_description" },
 { "stats",  OPT_BOOL,{ 
&print_stats },
 "print progress report during encoding", },
 { "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT |
-- 
2.28.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] fate: disable automatic conversions on most filter tests.

2020-08-14 Thread Nicolas George
Explicitly insert the scale or aresample filter where it would
have been inserted by the negotiation.

If a conversion is needed in a test, we want to know about it.
If the negotiation changes and makes new conversion necessary,
we want to know about it even more.

Signed-off-by: Nicolas George 
---
 tests/fate-run.sh   |   4 +-
 tests/fate/filter-audio.mak | 112 ++--
 tests/fate/filter-video.mak | 350 ++--
 3 files changed, 235 insertions(+), 231 deletions(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 414ac6f825..7456216e9c 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -388,7 +388,7 @@ video_filter(){
 label=${test#filter-}
 raw_src="${target_path}/tests/vsynth1/%02d.pgm"
 printf '%-20s' $label
-ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
+ffmpeg $DEC_OPTS -disable_all_auto_conversion_filters -f image2 -vcodec 
pgmyuv -i $raw_src \
 $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut 
md5:
 }
 
@@ -416,7 +416,7 @@ pixfmts(){
 outertest=$test
 for pix_fmt in $pix_fmts; do
 test=$pix_fmt
-video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" 
-pix_fmt $pix_fmt -frames:v $nframes
+video_filter 
"${prefilter_chain}scale,format=$pix_fmt,$filter=$filter_args" -pix_fmt 
$pix_fmt -frames:v $nframes
 done
 
 rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 79b1536df0..5dfafcccad 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -1,54 +1,56 @@
+NOCONV=-disable_all_auto_conversion_filters
+
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, ADELAY, WAV, PCM_S16LE, PCM_S16LE, 
WAV) += fate-filter-adelay
 fate-filter-adelay: tests/data/asynth-44100-2.wav
 fate-filter-adelay: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-adelay: CMD = framecrc -i $(SRC) -af adelay=42
+fate-filter-adelay: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,adelay=42,aresample
 
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, AECHO, WAV, PCM_S16LE, PCM_S16LE, WAV) 
+= fate-filter-aecho
 fate-filter-aecho: tests/data/asynth-44100-2.wav
 fate-filter-aecho: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aecho: CMD = framecrc -i $(SRC) -af aecho=0.5:0.5:32:0.5
+fate-filter-aecho: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aecho=0.5:0.5:32:0.5,aresample
 
 FATE_FILTER_AEMPHASIS += fate-filter-aemphasis-50fm
 fate-filter-aemphasis-50fm: tests/data/asynth-44100-2.wav
 fate-filter-aemphasis-50fm: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aemphasis-50fm: CMD = framecrc -i $(SRC) -af 
aemphasis=1:5:reproduction:50fm
+fate-filter-aemphasis-50fm: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aemphasis=1:5:reproduction:50fm,aresample
 
 FATE_FILTER_AEMPHASIS += fate-filter-aemphasis-75kf
 fate-filter-aemphasis-75kf: tests/data/asynth-44100-2.wav
 fate-filter-aemphasis-75kf: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aemphasis-75kf: CMD = framecrc -i $(SRC) -af 
aemphasis=2:8:reproduction:75kf
+fate-filter-aemphasis-75kf: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aemphasis=2:8:reproduction:75kf,aresample
 
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, AEMPHASIS, WAV, PCM_S16LE, PCM_S16LE, 
WAV) += $(FATE_FILTER_AEMPHASIS)
 
 FATE_FILTER_AFADE += fate-filter-afade-qsin
 fate-filter-afade-qsin: tests/data/asynth-44100-2.wav
 fate-filter-afade-qsin: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-afade-qsin: CMD = framecrc -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=qsin
+fate-filter-afade-qsin: CMD = framecrc $(NOCONV) -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=qsin
 
 FATE_FILTER_AFADE += fate-filter-afade-iqsin
 fate-filter-afade-iqsin: tests/data/asynth-44100-2.wav
 fate-filter-afade-iqsin: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-afade-iqsin: CMD = framecrc -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=iqsin
+fate-filter-afade-iqsin: CMD = framecrc $(NOCONV) -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=iqsin
 
 FATE_FILTER_AFADE += fate-filter-afade-esin
 fate-filter-afade-esin: tests/data/asynth-44100-2.wav
 fate-filter-afade-esin: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-afade-esin: CMD = framecrc -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=esin
+fate-filter-afade-esin: CMD = framecrc $(NOCONV) -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=esin
 
 FATE_FILTER_AFADE += fate-filter-afade-hsin
 fate-filter-afade-hsin: tests/data/asynth-44100-2.wav
 fate-filter-afade-hsin: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-afade-hsin: CMD = framecrc -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=hsin
+fate-filter-afade-hsin: CMD = framecrc $(NOCONV) -i $(SRC) -af 
afade=t=in:ss=0:d=2:curve=hsin
 
 FATE_FILTER_AFADE += fate-filter-afade-exp
 fate-filter-afade-exp: tests/data/asynth-44100-2.wav
 fate-filter-afade-exp: SRC = $(TARGET

Re: [FFmpeg-devel] [PATCH 1/3] avformat/mlvdec: Check for existence of AVIOContext before using it

2020-08-14 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> The mlv demuxer supports input split into multiple files; if invalid
> data is encountered when parsing one of the subsequent files, that file
> is closed. But at this point some index entries belonging to this file
> might already have been added. In this case, the read_packet function
> might try to use the AVIOContext (which is NULL) to read data which will
> of course crash. This commit fixes this.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> As an alternative to patches 1 and 3 one could also just error out if
> one of the subsequent files is bad.
> 
>  libavformat/mlvdec.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
> index 03aed71024..7c7ced7f76 100644
> --- a/libavformat/mlvdec.c
> +++ b/libavformat/mlvdec.c
> @@ -411,6 +411,10 @@ static int read_packet(AVFormatContext *avctx, AVPacket 
> *pkt)
>  }
>  
>  pb = mlv->pb[st->index_entries[index].size];
> +if (!pb) {
> +ret = FFERROR_REDO;
> +goto next_packet;
> +}
>  avio_seek(pb, st->index_entries[index].pos, SEEK_SET);
>  
>  avio_skip(pb, 4); // blockType
> @@ -439,12 +443,14 @@ static int read_packet(AVFormatContext *avctx, AVPacket 
> *pkt)
>  pkt->stream_index = mlv->stream_index;
>  pkt->pts = mlv->pts;
>  
> +ret = 0;
> +next_packet:
>  mlv->stream_index++;
>  if (mlv->stream_index == avctx->nb_streams) {
>  mlv->stream_index = 0;
>  mlv->pts++;
>  }
> -return 0;
> +return ret;
>  }
>  
>  static int read_seek(AVFormatContext *avctx, int stream_index, int64_t 
> timestamp, int flags)
> 
Will apply this patchset tomorrow unless there are objections.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] swresample/rematrix: handle 22.2 as a 9 channel layout

2020-08-14 Thread Michael Niedermayer
On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> This is as far as 22.2 follows the same channel order as
> WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> 
> After LFE2 the side channels would follow, but that offset of
> one stops us from utilizing them without further tweaks.
> 
> This change was verified by using swresample to downmix to 5.1,
> and then feeding that to WASAPI.
> ---
>  libswresample/rematrix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

probably ok

[...]
-- 
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
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/14/20, Derek Buitenhuis  wrote:
> On 14/08/2020 16:37, Paul B Mahol wrote:
>>> I would expect any SIMD patch to include benchmarks showing it
>>> is actually faster.
>> It is faster, but I have only Celeron CPU to test.
>
> I can't tell if you're trolling or not, but that doesn't
> change the standards...

You are not being helpful at all.
I clearly asked for testers to give their benchmarks as mine are
little relevant.

>
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/14/20, Derek Buitenhuis  wrote:
> On 14/08/2020 16:37, Paul B Mahol wrote:
>>> I would expect any SIMD patch to include benchmarks showing it
>>> is actually faster.
>> It is faster, but I have only Celeron CPU to test.
>
> I can't tell if you're trolling or not, but that doesn't
> change the standards...

You are not being helpful at all.
I clearly asked for testers to give their benchmarks as mine are
little relevant.

>
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Derek Buitenhuis
On 14/08/2020 18:36, Paul B Mahol wrote:
> You are not being helpful at all.

It's called having basic standards for commit messages.

> I clearly asked for testers to give their benchmarks as mine are
> little relevant.

You did not. Feel free to point out where you did, because I cannnot
find it.

Anyway, it is still useful to include benchmarks from your own CPU,
considering you developed and tested it, and determined it was useful
to send.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 2/3] [RFC] lavfmt: add FLIF demuxing support

2020-08-14 Thread Nicolas George
Anamitra Ghorui (12020-08-14):
> This patch removes a redundant class member mentioned in v3, and 
> skips iCCP metadata segments.
> 
> Signed-off-by: Anamitra Ghorui 
> ---
>  Changelog|   3 +-

>  configure| 250 ---

Looks like you have a lot of spurious changes. You should probably
proofread your patches somewhat before sending them.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avutil/opt: Restore NULL input handling to set_string_video_rate()

2020-08-14 Thread Michael Niedermayer
On Thu, Aug 13, 2020 at 12:41:26PM +0100, Jack Haughton wrote:
> Commit a500b975 removed NULL input handling from this function,
> moving the check higher up the call tree in one branch. However,
> there is another call to set_string_video_rate() which may pass
> NULL, and future users of the function may not be clear that
> a NULL check is required. This patch restores the NULL check to
> avoid these problems.
> ---
>  libavutil/opt.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply

thx

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

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


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread James Almer
On 8/14/2020 2:44 PM, Derek Buitenhuis wrote:
> On 14/08/2020 18:36, Paul B Mahol wrote:
>> You are not being helpful at all.
> 
> It's called having basic standards for commit messages.
> 
>> I clearly asked for testers to give their benchmarks as mine are
>> little relevant.
> 
> You did not. Feel free to point out where you did, because I cannnot
> find it.

On the very first email from this thread, he said "Please review and/or
benchmark, especially .asm file". He did not state his benchmarks were
irrelevant at first, but he did ask others for theirs.

> 
> Anyway, it is still useful to include benchmarks from your own CPU,
> considering you developed and tested it, and determined it was useful
> to send.
> 
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, RFC] lavc/hevcdec: add invalid for skip_frame to skip invalid nalus before IRAP

2020-08-14 Thread Mark Thompson

On 14/08/2020 11:35, Linjie Fu wrote:

Add "-skip_frame invalid" option to allow user to request decoder to skip
invalid nalus before an IRAP.

This would benefit decoding pipeline of bitstreams who didn't start from
an IRAP frame. NULL pointer pointing to missing reference may lead to
unexpected hang issues[1] in sub-level like hardware decoding.

Fixing the hang in driver is the first correct thing. Besides, adding a check
in nalu parsing and skip frames until we got the first IRAP would be another
good choice to be more robust for error tolerance.

Also this needs worker thread to update the skip_frames field in time.

[1] https://github.com/intel/media-driver/issues/992


H.265 has a standard mechanism for dealing with missing reference pictures, 
which is defined in 8.3.3.  That doesn't directly apply for the case here (it's 
intended for RASL pictures), but a conformant decoder must be implementing it 
somewhere - can the Intel driver use that?

Trying to eliminate this case entirely is not going to work - being able to 
splice intra-refresh streams at any point depends on sensible behaviour for 
missing references, and streams containing errors due to packet loss can always 
happen.



Signed-off-by: Linjie Fu 
---
Request for comments:
The purpose is to allow decoder to skip frames until an IRAP has arrived, 
however
not sure whether we already had this in ffmpeg, hence submit a patch and
request for comments.

Skip logic identical for AVDISCARD_NONKEY in decode_nal_unit(). >
  libavcodec/avcodec.h   | 1 +
  libavcodec/hevcdec.c   | 5 -
  libavcodec/options_table.h | 1 +
  libavcodec/pthread_frame.c | 1 +
  4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c91b2fd169..376d7f4d6d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -233,6 +233,7 @@ enum AVDiscard{
  AVDISCARD_BIDIR   = 16, ///< discard all bidirectional frames
  AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
  AVDISCARD_NONKEY  = 32, ///< discard all frames except keyframes
+AVDISCARD_INVALID = 33, ///< discard invalid packets like NALs before IRAP


IMO INVALID is not a good name to use here - such packets are perfectly valid 
in cases like intra-refresh.

"before" would need to be clarified - RADL frames can definitely be thought of as 
"before" the associated IRAP picture, but this wouldn't be discarding them.

Also, it should probably avoid using H.265-specific terminology for the 
explanation in the generic header.


  AVDISCARD_ALL = 48, ///< discard all
  };
  
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c

index b77df8d89f..78658fd537 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -539,8 +539,11 @@ static int hls_slice_header(HEVCContext *s)
  ff_hevc_clear_refs(s);
  }
  sh->no_output_of_prior_pics_flag = 0;
-if (IS_IRAP(s))
+if (IS_IRAP(s)) {
  sh->no_output_of_prior_pics_flag = get_bits1(gb);
+if (s->avctx->skip_frame == AVDISCARD_INVALID)
+s->avctx->skip_frame = AVDISCARD_DEFAULT;
+}
  
  sh->pps_id = get_ue_golomb_long(gb);

  if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 1d0db1b5a4..d52bce5908 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -310,6 +310,7 @@ static const AVOption avcodec_options[] = {
  {"bidir"   , "discard all bidirectional frames",0, AV_OPT_TYPE_CONST, {.i64 
= AVDISCARD_BIDIR   }, INT_MIN, INT_MAX, V|D, "avdiscard"},
  {"nokey"   , "discard all frames except keyframes", 0, AV_OPT_TYPE_CONST, {.i64 
= AVDISCARD_NONKEY  }, INT_MIN, INT_MAX, V|D, "avdiscard"},
  {"nointra" , "discard all frames except I frames",  0, AV_OPT_TYPE_CONST, {.i64 
= AVDISCARD_NONINTRA}, INT_MIN, INT_MAX, V|D, "avdiscard"},
+{"invalid" , "discard NALUs before IRAP",   0, AV_OPT_TYPE_CONST, {.i64 
= AVDISCARD_INVALID }, INT_MIN, INT_MAX, V|D, "avdiscard"},
  {"all" , "discard all frames",  0, AV_OPT_TYPE_CONST, {.i64 
= AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"},
  {"bidir_refine", "refine the two motion vectors used in bidirectional 
macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
  #if FF_API_PRIVATE_OPT
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 3255aa9337..302e6149ac 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -259,6 +259,7 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
  
  dst->has_b_frames = src->has_b_frames;

  dst->idct_algo= src->idct_algo;
+dst->skip_frame   = src->skip_frame;
  
  dst->bits_per_coded_sample = src->bits_per_coded_sample;

  dst->sample_aspect_ratio   = src->sample_aspect_ratio;



- Mark

Re: [FFmpeg-devel] [PATCH] avutil/opt: Restore NULL input handling to set_string_video_rate()

2020-08-14 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Thu, Aug 13, 2020 at 12:41:26PM +0100, Jack Haughton wrote:
>> Commit a500b975 removed NULL input handling from this function,
>> moving the check higher up the call tree in one branch. However,
>> there is another call to set_string_video_rate() which may pass
>> NULL, and future users of the function may not be clear that
>> a NULL check is required. This patch restores the NULL check to
>> avoid these problems.
>> ---
>>  libavutil/opt.c | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> will apply
> 
> thx
> 
But is a NULL default value actually invalid/nonsense? I think not. See
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/267444.html

I can send a patch implementing this if others agree with my reasoning.

- Andreas


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Derek Buitenhuis
On 14/08/2020 19:01, James Almer wrote:
> On the very first email from this thread, he said "Please review and/or
> benchmark, especially .asm file". He did not state his benchmarks were
> irrelevant at first, but he did ask others for theirs.

Resending because I accidentally replied to James instead of the list. Woops.

I guess it was not clear to me this is not the initial thread, since it is not
a v2 patch, and no other thread is titled this, or seems to include SIMD? 
Perhaps
I missed it.

I still cannot actually locate any benchmarks in the various CFHD threads. If 
any were
done, as would be needed, to, like... test ones own SIMD code, they should be 
included
in the commit messages.

(Nice that we still silently ignore various insults from Paul thrown around by 
the way.)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 2/3] vaapi_encode: Rewrite slice/tile support

2020-08-14 Thread Mark Thompson

On 14/08/2020 10:30, Linjie Fu wrote:

On Fri, Aug 14, 2020 at 5:51 AM Mark Thompson  wrote:


This precalculates all of the information we will need to define slice
and tile positions at init time rather than rebuilding some of it with
every slice.  The control of tiles is generalised to match slices, so that
arbitrary tile and slice layouts are possible within the constraint that
slices can't cross tile boundaries (which comes from how VAAPI handles
slices and tiles).  Support for the EQUAL_MULTI_ROWS slice structure fits
easily into this, so it is added at the same time.


Some inputs for EQUAL_MULTI_ROWS slice structure, I believe there are
some discussions in libva and hw behavior team. To be honest, I don't think
the current notation/comment is suitable for what the hw could do.


I'm not sure what you mean here.  If some hardware needs a different slice 
structure then a new one will need to be defined and implemented?

Even if you don't have any current hardware using it, it is likely to be useful 
in the not-too-distant future given that it is the VP9/AV1 uniform tiling mode.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] fate: disable automatic conversions on most filter tests.

2020-08-14 Thread Mark Thompson

On 14/08/2020 18:14, Nicolas George wrote:

Explicitly insert the scale or aresample filter where it would
have been inserted by the negotiation.

If a conversion is needed in a test, we want to know about it.
If the negotiation changes and makes new conversion necessary,
we want to know about it even more.

Signed-off-by: Nicolas George 
---
  tests/fate-run.sh   |   4 +-
  tests/fate/filter-audio.mak | 112 ++--
  tests/fate/filter-video.mak | 350 ++--
  3 files changed, 235 insertions(+), 231 deletions(-)


I like it, this is a good idea.


diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 414ac6f825..7456216e9c 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -388,7 +388,7 @@ video_filter(){
  label=${test#filter-}
  raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  printf '%-20s' $label
-ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
+ffmpeg $DEC_OPTS -disable_all_auto_conversion_filters -f image2 -vcodec 
pgmyuv -i $raw_src \
  $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f 
nut md5:
  }
  
@@ -416,7 +416,7 @@ pixfmts(){

  outertest=$test
  for pix_fmt in $pix_fmts; do
  test=$pix_fmt
-video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" 
-pix_fmt $pix_fmt -frames:v $nframes
+video_filter 
"${prefilter_chain}scale,format=$pix_fmt,$filter=$filter_args" -pix_fmt 
$pix_fmt -frames:v $nframes
  done
  
  rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts

diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 79b1536df0..5dfafcccad 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -1,54 +1,56 @@
+NOCONV=-disable_all_auto_conversion_filters


Adding this variable to the command line of large numbers of tests is not very 
fun, because it's not relevant to the test definition itself.

Is it possible that it might be better to split some of the commands into multiple forms if there 
are some tests which still want autoconversion?  Depending on which variant is more common, 
"framecrc_autoconv" or "framecrc_noconv".

(Alternatively: how many tests /do/ want autoconversion?  The option could be 
added in the top-level ffmpeg() function and then disabled selectively in 
tests.)


+
  FATE_AFILTER-$(call FILTERDEMDECENCMUX, ADELAY, WAV, PCM_S16LE, PCM_S16LE, 
WAV) += fate-filter-adelay
  fate-filter-adelay: tests/data/asynth-44100-2.wav
  fate-filter-adelay: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-adelay: CMD = framecrc -i $(SRC) -af adelay=42
+fate-filter-adelay: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,adelay=42,aresample
  
  FATE_AFILTER-$(call FILTERDEMDECENCMUX, AECHO, WAV, PCM_S16LE, PCM_S16LE, WAV) += fate-filter-aecho

  fate-filter-aecho: tests/data/asynth-44100-2.wav
  fate-filter-aecho: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aecho: CMD = framecrc -i $(SRC) -af aecho=0.5:0.5:32:0.5
+fate-filter-aecho: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aecho=0.5:0.5:32:0.5,aresample
  
  FATE_FILTER_AEMPHASIS += fate-filter-aemphasis-50fm

  fate-filter-aemphasis-50fm: tests/data/asynth-44100-2.wav
  fate-filter-aemphasis-50fm: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aemphasis-50fm: CMD = framecrc -i $(SRC) -af 
aemphasis=1:5:reproduction:50fm
+fate-filter-aemphasis-50fm: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aemphasis=1:5:reproduction:50fm,aresample
  
  FATE_FILTER_AEMPHASIS += fate-filter-aemphasis-75kf

  fate-filter-aemphasis-75kf: tests/data/asynth-44100-2.wav
  fate-filter-aemphasis-75kf: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
-fate-filter-aemphasis-75kf: CMD = framecrc -i $(SRC) -af 
aemphasis=2:8:reproduction:75kf
+fate-filter-aemphasis-75kf: CMD = framecrc $(NOCONV) -i $(SRC) -af 
aresample,aemphasis=2:8:reproduction:75kf,aresample


(Not something to change in this patch, but the way that some of these tests 
are resampling on both input and output is rather suggesting that they could be 
written more nicely.)


...


Thanks,

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] ffmpeg: add disable_all_auto_conversion_filters option.

2020-08-14 Thread Mark Thompson

On 14/08/2020 18:14, Nicolas George wrote:

Signed-off-by: Nicolas George 
---
  doc/ffmpeg.texi | 5 +
  fftools/ffmpeg.h| 1 +
  fftools/ffmpeg_filter.c | 2 ++
  fftools/ffmpeg_opt.c| 3 +++
  4 files changed, 11 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 267ddfe8b5..1603431d56 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1746,6 +1746,11 @@ this buffer, in packets, for the matching output stream.
  The default value of this option should be high enough for most uses, so only
  touch this option if you are sure that you need it.
  
+@item -disable_all_auto_conversion_filters (@emph{global})

+Disable automatically inserting conversion filters in all filter graphs,
+including those defined by @option{-vf}, @option{-af},
+@option{-filter_complex} and @option{-lavfi}.


The relation to the existing -autorotate and -autoscale options is confusing - 
those aren't disabled by this (because they are applied differently), but it 
sounds like they would be.

I'm not sure how to make this better.  Maybe it should be called "-autoconvert" 
to match and then override the others?


+
  @end table
  
  As a special exception, you can use a bitmap subtitle stream as input: it

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6e3f2545c7..acd297c8e8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -613,6 +613,7 @@ extern char *videotoolbox_pixfmt;
  extern int filter_nbthreads;
  extern int filter_complex_nbthreads;
  extern int vstats_version;
+extern int disable_all_auto_conversion_filters;
  
  extern const AVIOInterruptCB int_cb;
  
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c

index 4784e8a575..8721403d7a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1104,6 +1104,8 @@ int configure_filtergraph(FilterGraph *fg)
  configure_output_filter(fg, fg->outputs[i], cur);
  avfilter_inout_free(&outputs);
  
+if (disable_all_auto_conversion_filters)

+avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);
  if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
  goto fail;
  
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c

index 853550a142..e6131dac97 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -172,6 +172,7 @@ float max_error_rate  = 2.0/3;
  int filter_nbthreads = 0;
  int filter_complex_nbthreads = 0;
  int vstats_version = 2;
+int disable_all_auto_conversion_filters = 0;
  
  
  static int intra_only = 0;

@@ -3545,6 +3546,8 @@ const OptionDef options[] = {
  "create a complex filtergraph", "graph_description" },
  { "filter_complex_script", HAS_ARG | OPT_EXPERT, { 
.func_arg = opt_filter_complex_script },
  "read complex filtergraph description from a file", "filename" },
+{ "disable_all_auto_conversion_filters", OPT_BOOL | OPT_EXPERT,  { 
&disable_all_auto_conversion_filters },
+"create a complex filtergraph", "graph_description" },


The help strings here looks suspiciously similar to the -filter_complex ones...


  { "stats",  OPT_BOOL,{ 
&print_stats },
  "print progress report during encoding", },
  { "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT |



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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Paul B Mahol
On 8/14/20, Derek Buitenhuis  wrote:
> On 14/08/2020 19:01, James Almer wrote:
>> On the very first email from this thread, he said "Please review and/or
>> benchmark, especially .asm file". He did not state his benchmarks were
>> irrelevant at first, but he did ask others for theirs.
>
> Resending because I accidentally replied to James instead of the list.
> Woops.
>
> I guess it was not clear to me this is not the initial thread, since it is
> not
> a v2 patch, and no other thread is titled this, or seems to include SIMD?
> Perhaps
> I missed it.
>
> I still cannot actually locate any benchmarks in the various CFHD threads.
> If any were
> done, as would be needed, to, like... test ones own SIMD code, they should
> be included
> in the commit messages.

Results differs between various CPUs and environments and also depends on
encoded file resolution and quality.

With my local patch I get overall several percent speed increase with
only horiz_filter SSE2 applied.
I also work on vert_filter SSE2 code, which currently give big speedup
with lowest quality encodings and higher resolutions.

For example:

best quality 1080 60fps progressive yuv422p10 with additonal WIP
vertical filter:
cpuflags 0 speed : 0x243x realtime
cpuflags sse2 speed: 0x353x realtime

worst quality 1080 60fps progressive yuv422p10 with additional WIP
vertical filter:
cpuflags 0 speed: 0x348x realtime
cpuflags sse2 speed: 0x811x realtime

Also I want reviews to be technical as possible, i have not sent this patch
to listen to bad remarks but to get more improvements in assembly code
if possible.

If you are not assembly developer and are not willing to test patches better to
stay away from this thread.

>
> (Nice that we still silently ignore various insults from Paul thrown around
> by the way.)

What specific insults in this thread?

>
> - Derek
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/cfhd: add x86 SIMD

2020-08-14 Thread Derek Buitenhuis
On 14/08/2020 20:13, Paul B Mahol wrote:
>> Resending because I accidentally replied to James instead of the list.
>> Woops.
>>
>> I guess it was not clear to me this is not the initial thread, since it is
>> not
>> a v2 patch, and no other thread is titled this, or seems to include SIMD?
>> Perhaps
>> I missed it.
>>
>> I still cannot actually locate any benchmarks in the various CFHD threads.
>> If any were
>> done, as would be needed, to, like... test ones own SIMD code, they should
>> be included
>> in the commit messages.
> Results differs between various CPUs and environments and also depends on
> encoded file resolution and quality.

Well, yes. That never stopped anyone from providing information.

> With my local patch I get overall several percent speed increase with
> only horiz_filter SSE2 applied.
> I also work on vert_filter SSE2 code, which currently give big speedup
> with lowest quality encodings and higher resolutions.
> 
> For example:
> 
> best quality 1080 60fps progressive yuv422p10 with additonal WIP
> vertical filter:
> cpuflags 0 speed : 0x243x realtime
> cpuflags sse2 speed: 0x353x realtime
> 
> worst quality 1080 60fps progressive yuv422p10 with additional WIP
> vertical filter:
> cpuflags 0 speed: 0x348x realtime
> cpuflags sse2 speed: 0x811x realtime

Thanks for finally providing some numbers. They should be in the commit
messgae.

> Also I want reviews to be technical as possible, i have not sent this patch
> to listen to bad remarks but to get more improvements in assembly code
> if possible.

Reviews of commit messages and methodolody or lack there of are valid reviews.

> If you are not assembly developer and are not willing to test patches better 
> to
> stay away from this thread.

See below


> 
>> (Nice that we still silently ignore various insults from Paul thrown around
>> by the way.)
> What specific insults in this thread?

You wrote one just in this email, calling an ask for a better commit message and
actual benchmarks "bad remarks", and previous wrote "You are not being helpful 
at all.".

See also above: "If you are not assembly developer and are not willing to test 
patches better to
stay away from this thread."

Frankly, it's disgusting that this community prefers to silently ignore your 
(and others,
but lately, mostly your) abusive and unfriendly conduct.

I have nothing more to say. Have a good weekend.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegts: parse for AC-3 descriptor 6A

2020-08-14 Thread Marton Balint



On Fri, 14 Aug 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 


I don't think this patch fits into libavformat. I am not a fan of dumping 
the descriptor data with AV_LOG_DEBUG, because libavformat is not a 
stream analyzer. Also I don't see much benefit of parsing the whole 
descriptor, when you are not doing anything with the parsed value.


Sorry, but I think we are better off if we not apply this.

Regards,
Marton




Signed-off-by: Limin Wang 
---
libavformat/mpegts.c | 53 ++--
1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index f71f18a5..72cc72a 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2075,16 +2075,57 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
break;
case 0x6a: /* ac-3_descriptor */
{
-int component_type_flag = get8(pp, desc_end) & (1 << 7);
-if (component_type_flag) {
-int component_type = get8(pp, desc_end);
-int service_type_mask = 0x38;  // 0b00111000
-int service_type = ((component_type & service_type_mask) >> 3);
+AVDVBAC3Descriptor desc6a;
+uint8_t buf;
+
+if (desc_end - *pp < 1)
+return AVERROR_INVALIDDATA;
+
+buf = get8(pp, desc_end);
+desc6a.component_type_flag = (buf >> 7) & 0x1;
+desc6a.bsid_flag   = (buf >> 6) & 0x1;
+desc6a.mainid_flag = (buf >> 5) & 0x1;
+desc6a.asvc_flag   = (buf >> 4) & 0x1;
+
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "Stream[0x%x] AC-3(6a):", 
st->id);
+if (desc6a.component_type_flag) {
+int service_type;
+int number_of_channels;
+desc6a.component_type = get8(pp, desc_end);
+service_type = ((desc6a.component_type >> 3) & 0x7);
if (service_type == 0x02 /* 0b010 */) {
st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
-av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track disposition for 
id %u: %u\n", st->id, st->disposition);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG,
+   " disposition: 0x%x", st->disposition);
+}
+number_of_channels = desc6a.component_type & 0x7;
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " component_type: 0x%x 
number_of_channels: %u",
+desc6a.component_type, number_of_channels);
+}
+if (desc6a.bsid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.bsid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " bsid: %u", 
desc6a.bsid);
+}
+if (desc6a.mainid_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
+}
+desc6a.mainid = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " mainid: %u", 
desc6a.mainid);
+}
+if (desc6a.asvc_flag) {
+if (desc_end - *pp < 1) {
+return AVERROR_INVALIDDATA;
}
+desc6a.asvc = get8(pp, desc_end);
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " asvc: %u", 
desc6a.asvc);
}
+if (desc6a.component_type_flag || desc6a.bsid_flag ||
+desc6a.mainid_flag || desc6a.asvc_flag)
+av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "\n");
}
break;
case 0x7a: /* enhanced_ac-3_descriptor */
--
1.8.3.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mpegtsenc: support DVB 6A descriptor for AC-3

2020-08-14 Thread Marton Balint



On Fri, 14 Aug 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
Sorry, fix for the patch order for fate test

libavformat/mpegts.h| 16 +++
libavformat/mpegtsenc.c | 76 +


I think the ac3_parser dependency of the mpegts muxer should be added to 
configure.



2 files changed, 92 insertions(+)

diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index fe10b38..951aa61 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -175,6 +175,22 @@ typedef struct Mp4Descr {
SLConfigDescr sl;
} Mp4Descr;

+/*
+ * ETSI 300 468 descriptor 0x6A(AC-3)
+ * Refer to: ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
+ */
+typedef struct AVDVBAC3Descriptor {
+uint8_t  component_type_flag;
+uint8_t  bsid_flag;
+uint8_t  mainid_flag;
+uint8_t  asvc_flag;
+uint8_t  reserved_flags;
+uint8_t  component_type;
+uint8_t  bsid;
+uint8_t  mainid;
+uint8_t  asvc;
+} AVDVBAC3Descriptor;


As others suggested, remove AV prefix.


+
/**
 * Parse an MPEG-2 descriptor
 * @param[in] fcFormat context (used for logging only)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 718ddab..e9ac08d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -27,6 +27,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"

+#include "libavcodec/ac3_parser_internal.h"
#include "libavcodec/internal.h"

#include "avformat.h"
@@ -244,6 +245,8 @@ typedef struct MpegTSWriteStream {
/* For Opus */
int opus_queued_samples;
int opus_pending_trim_start;
+
+AVDVBAC3Descriptor *desc6a;


Sorry, can you name the variable dvb_ac3_desc or something? This 6a still 
does not speak for itself...



} MpegTSWriteStream;

static void mpegts_write_pat(AVFormatContext *s)
@@ -486,9 +489,28 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
case AVMEDIA_TYPE_AUDIO:
if (ts->flags & MPEGTS_FLAG_SYSTEM_B) {
if (codec_id == AV_CODEC_ID_AC3) {
+AVDVBAC3Descriptor *desc6a = ts_st->desc6a;
+
 *q++=0x6a; // AC3 descriptor see A038 DVB SI
+if (desc6a) {
+int len = 1 +
+  !!(desc6a->component_type_flag) +
+  !!(desc6a->bsid_flag) +
+  !!(desc6a->mainid_flag) +
+  !!(desc6a->asvc_flag);
+
+*q++ = len;
+*q++ = desc6a->component_type_flag << 7 | desc6a->bsid_flag 
<< 6 |
+   desc6a->mainid_flag << 5 | desc6a->asvc_flag 
<< 4;
+
+if (desc6a->component_type_flag) *q++ = 
desc6a->component_type;
+if (desc6a->bsid_flag)   *q++ = desc6a->bsid;
+if (desc6a->mainid_flag) *q++ = desc6a->mainid;
+if (desc6a->asvc_flag)   *q++ = desc6a->asvc;
+} else {
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...


I think these two lines are small enough to reindent in the same patch.


+}
} else if (codec_id == AV_CODEC_ID_EAC3) {
*q++=0x7a; // EAC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
@@ -1843,6 +1865,59 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 * need to count the samples of that too! */
av_log(s, AV_LOG_WARNING, "Got MPEG-TS formatted Opus data, 
unhandled");
}
+} else if (st->codecpar->codec_id == AV_CODEC_ID_AC3 && !ts_st->desc6a) {
+uint8_t number_of_channels_flag;
+uint8_t service_type_flag;
+uint8_t full_service_flag = 1;
+AC3HeaderInfo *hdr = NULL;
+AVDVBAC3Descriptor *desc6a;


push most of these initializers one level down


+
+if (avpriv_ac3_parse_header(&hdr, pkt->data, pkt->size) >= 0) {


Aren't you leaking hdr in the return path and at the end of this block?


+desc6a = av_mallocz(sizeof(*desc6a));
+if (!desc6a)
+return AVERROR(ENOMEM);
+
+service_type_flag = hdr->bitstream_mode;
+switch (hdr->channel_mode) {
+case AC3_CHMODE_DUALMONO:
+number_of_channels_flag = 1;
+break;
+case AC3_CHMODE_MONO:
+number_of_channels_flag = 0;
+break;
+case AC3_CHMODE_STEREO:
+if (hdr->dolby_surround_mode == AC3_DSURMOD_ON)
+number_of_channels_flag = 3;
+else
+number_of_channels_flag = 2;
+break;
+c

[FFmpeg-devel] [PATCH] avformat/hls: Fix memleak when url is empty

2020-08-14 Thread Andreas Rheinhardt
Fixes Coverity ID 1465888.

Signed-off-by: Andreas Rheinhardt 
---
Why does this code actually not check the return value of
ff_make_absolute_url()?

 libavformat/hls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 84f0a5f323..4a3e0d6842 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -311,8 +311,10 @@ static struct playlist *new_playlist(HLSContext *c, const 
char *url,
 return NULL;
 reset_packet(&pls->pkt);
 ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
-if (!pls->url[0])
+if (!pls->url[0]) {
+av_free(pls);
 return NULL;
+}
 pls->seek_timestamp = AV_NOPTS_VALUE;
 
 pls->is_id3_timestamped = -1;
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] avformat/hls: Remove redundant resetting of AVPacket

2020-08-14 Thread Andreas Rheinhardt
av_read_frame() already returns blank packets on error.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/hls.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 4a3e0d6842..8217c5ede4 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2162,7 +2162,6 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0) {
 if (!avio_feof(&pls->pb) && ret != AVERROR_EOF)
 return ret;
-reset_packet(&pls->pkt);
 break;
 } else {
 /* stream_index check prevents matching picture 
attachments etc. */
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] avformat/hls: Use av_init_pkt() directly

2020-08-14 Thread Andreas Rheinhardt
and remove reset_packet(). The packet's data pointer is already zeroed,
so the only thing that reset_packet() does that av_init_pkt() doesn't is
redundant.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/hls.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 8217c5ede4..3ab07f1b3f 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -293,28 +293,18 @@ static void free_rendition_list(HLSContext *c)
 c->n_renditions = 0;
 }
 
-/*
- * Used to reset a statically allocated AVPacket to a clean state,
- * containing no data.
- */
-static void reset_packet(AVPacket *pkt)
-{
-av_init_packet(pkt);
-pkt->data = NULL;
-}
-
 static struct playlist *new_playlist(HLSContext *c, const char *url,
  const char *base)
 {
 struct playlist *pls = av_mallocz(sizeof(struct playlist));
 if (!pls)
 return NULL;
-reset_packet(&pls->pkt);
 ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
 if (!pls->url[0]) {
 av_free(pls);
 return NULL;
 }
+av_init_packet(&pls->pkt);
 pls->seek_timestamp = AV_NOPTS_VALUE;
 
 pls->is_id3_timestamped = -1;
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4] avformat/mxfdec: Read video range from PictureDescriptor

2020-08-14 Thread Harry Mallon



> On 14 Aug 2020, at 11:53, Tomas Härdin  wrote:
> 
> tor 2020-08-13 klockan 22:21 +0200 skrev Marton Balint:
>> 
>> On Thu, 13 Aug 2020, Tomas Härdin wrote:
>> 
>>> tor 2020-08-13 klockan 11:04 +0100 skrev Harry Mallon:
 Here is an updated patch (now hopefully going with correct email headers).
>>> 
>>> It would be nice if in the future you either attach the patch or make
>>> the entire email the patch itself. I've had to trim these first couple
>>> of lines in each of the patches so far, after doing "git am" on the
>>> .mbox from saving your messages
>>> 
 From 5866d0dc5536a6ea3f6a899c3d09f19df083c16a Mon Sep 17 00:00:00 2001
 
 From: Harry Mallon 
 Date: Wed, 12 Aug 2020 10:26:23 +0100
 Subject: [PATCH v4] avformat/mxfdec: Read video range from 
 PictureDescriptor
 
 * Capture black_ref, white_ref and color_range and recognise
  full and narrow range.
 
 Signed-off-by: Harry Mallon 
 ---
 libavformat/mxfdec.c   | 29 +
 tests/ref/fate/mxf-probe-dnxhd |  2 +-
 tests/ref/fate/mxf-probe-dv25  |  2 +-
 3 files changed, 31 insertions(+), 2 deletions(-)
>>> 
>>> Looks good to me. Running FATE atm, will push in a day if there are no
>>> objections.
>> 
>> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4328/01_Bad_Frame_2.24.mxf 
>> is not detected correctly for some reason.
>> 
>> The MXF specs seems ambigous:
>> 
>> Color Range is a Property, whose unsigned 32-bit integer value shall 
>> specify the number of distinct values allowed for color difference 
>> samples.
>> 
>> So probably 2^depth color range should also be accepted as full range.
> 
> This sounds correct. Do we have any sample using 2^depth-1? If not then
> we should just go with 2^depth until such a sample emerges.
> 
> /Tomas

I based it on what mxfenc.c already did, I can try to find some other samples.

Harry

> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 2/3] [RFC] lavfmt: add FLIF demuxing support

2020-08-14 Thread Anamitra Ghorui
This patch removes a redundant class member mentioned in v3, and 
skips iCCP metadata segments.

Signed-off-by: Anamitra Ghorui 
---
 Changelog|   3 +-
 configure| 250 ---
 doc/general.texi |   2 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/flifdec.c| 431 +++
 6 files changed, 526 insertions(+), 162 deletions(-)
 create mode 100644 libavformat/flifdec.c

diff --git a/Changelog b/Changelog
index 1efc768387..daae1cc485 100644
--- a/Changelog
+++ b/Changelog
@@ -14,7 +14,8 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
-
+- FLIF16 decoder
+- FLIF demuxer
 
 version 4.3:
 - v360 filter
diff --git a/configure b/configure
index d4a1fea9ce..a702997c71 100755
--- a/configure
+++ b/configure
@@ -253,11 +253,8 @@ External library support:
   --enable-libopenh264 enable H.264 encoding via OpenH264 [no]
   --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
   --enable-libopenmpt  enable decoding tracked files via libopenmpt [no]
-  --enable-libopenvino enable OpenVINO as a DNN module backend
-   for DNN based filters like dnn_processing [no]
   --enable-libopus enable Opus de/encoding via libopus [no]
   --enable-libpulseenable Pulseaudio input via libpulse [no]
-  --enable-librabbitmq enable RabbitMQ library [no]
   --enable-librav1eenable AV1 encoding via rav1e [no]
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
@@ -269,7 +266,6 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
-  --enable-libsvtav1   enable AV1 encoding via SVT [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -307,7 +303,6 @@ External library support:
   --enable-mbedtls enable mbedTLS, needed for https support
if openssl, gnutls or libtls is not used [no]
   --enable-mediacodec  enable Android MediaCodec support [no]
-  --enable-mediafoundation enable encoding via MediaFoundation [auto]
   --enable-libmysofa   enable libmysofa, needed for sofalizer filter [no]
   --enable-openal  enable OpenAL 1.1 capture support [no]
   --enable-opencl  enable OpenCL processing [no]
@@ -1671,7 +1666,7 @@ COMPONENT_LIST="
 "
 
 EXAMPLE_LIST="
-avio_list_dir_example
+avio_dir_cmd_example
 avio_reading_example
 decode_audio_example
 decode_video_example
@@ -1708,7 +1703,6 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
 libxcb_shape
 libxcb_xfixes
 lzma
-mediafoundation
 schannel
 sdl2
 securetransport
@@ -1744,6 +1738,7 @@ EXTERNAL_LIBRARY_VERSION3_LIST="
 liblensfun
 libopencore_amrnb
 libopencore_amrwb
+libvmaf
 libvo_amrwbenc
 mbedtls
 rkmpp
@@ -1792,10 +1787,8 @@ EXTERNAL_LIBRARY_LIST="
 libopenh264
 libopenjpeg
 libopenmpt
-libopenvino
 libopus
 libpulse
-librabbitmq
 librav1e
 librsvg
 librtmp
@@ -1806,13 +1799,11 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
-libsvtav1
 libtensorflow
 libtesseract
 libtheora
 libtwolame
 libv4l2
-libvmaf
 libvorbis
 libvpx
 libwavpack
@@ -2557,7 +2548,7 @@ mips64r6_deps="mips"
 mipsfpu_deps="mips"
 mipsdsp_deps="mips"
 mipsdspr2_deps="mips"
-mmi_deps_any="loongson2 loongson3"
+mmi_deps="mips"
 msa_deps="mipsfpu"
 msa2_deps="msa"
 
@@ -2626,7 +2617,7 @@ cbs_mpeg2_select="cbs"
 cbs_vp9_select="cbs"
 dct_select="rdft"
 dirac_parse_select="golomb"
-dnn_suggest="libtensorflow libopenvino"
+dnn_suggest="libtensorflow"
 error_resilience_select="me_cmp"
 faandct_deps="faan"
 faandct_select="fdctdsp"
@@ -2798,14 +2789,11 @@ msmpeg4v3_decoder_select="h263_decoder"
 msmpeg4v3_encoder_select="h263_encoder"
 mss2_decoder_select="mpegvideo qpeldsp vc1_decoder"
 mts2_decoder_select="mss34dsp"
-mv30_decoder_select="aandcttables blockdsp"
 mvha_decoder_deps="zlib"
-mvha_decoder_select="llviddsp"
 mwsc_decoder_deps="zlib"
 mxpeg_decoder_select="mjpeg_decoder"
 nellymoser_decoder_select="mdct sinewin"
 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
-notchlc_decoder_select="lzf"
 nuv_decoder_select="idctdsp lzo"
 on2avc_decoder_select="mdct"
 opus_decoder_deps="swresample"
@@ -3020,8 +3008,6 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # hardware-accelerated codecs
-mediafoundation_deps="mftransform_h MFCreateAlignedMe

[FFmpeg-devel] [PATCH v4 3/3] [RFC] lavc: add codec entries for FLIF

2020-08-14 Thread Anamitra Ghorui
Signed-off-by: Anamitra Ghorui 
---
 libavcodec/codec_desc.c | 7 +++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 0ae6aee63b..11acb91b76 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1784,6 +1784,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_FLIF16,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "flif16",
+.long_name = NULL_IF_CONFIG_SMALL("FLIF16 (Free Lossless Image 
Format)"),
+.props = AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 896ecb0ce0..5c4f2dd7d0 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -296,6 +296,7 @@ enum AVCodecID {
 AV_CODEC_ID_MV30,
 AV_CODEC_ID_NOTCHLC,
 AV_CODEC_ID_PFM,
+AV_CODEC_ID_FLIF16,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
-- 
2.28.0


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/3] [RFC] lavc: add FLIF decoding support

2020-08-14 Thread Anamitra Ghorui
Patches need to be self contained. Didn't notice that before. Will
repost.

Regards,
Anamitra

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 3/3] [RFC] Update documentation and configure script for FLIF

2020-08-14 Thread Anamitra Ghorui
Signed-off-by: Anamitra Ghorui 
---
 Changelog| 3 ++-
 configure| 1 +
 doc/general.texi | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 1efc768387..77b8f46a19 100644
--- a/Changelog
+++ b/Changelog
@@ -14,7 +14,8 @@ version :
 - ADPCM Argonaut Games encoder
 - Argonaut Games ASF muxer
 - AV1 Low overhead bitstream format demuxer
-
+- FLIF16 decoder
+- FLIF16 demuxer
 
 version 4.3:
 - v360 filter
diff --git a/configure b/configure
index d4a1fea9ce..ae8d003010 100755
--- a/configure
+++ b/configure
@@ -3300,6 +3300,7 @@ eac3_demuxer_select="ac3_parser"
 f4v_muxer_select="mov_muxer"
 fifo_muxer_deps="threads"
 flac_demuxer_select="flac_parser"
+flif_demuxer_select="zlib exif"
 flv_muxer_select="aac_adtstoasc_bsf"
 gxf_muxer_select="pcm_rechunk_bsf"
 hds_muxer_select="flv_muxer"
diff --git a/doc/general.texi b/doc/general.texi
index 4fcc497244..1144538dcd 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -904,6 +904,8 @@ following image formats are supported:
 @item Flash Screen Video v2  @tab  X  @tab  X
 @item Flash Video (FLV)  @tab  X  @tab  X
 @tab Sorenson H.263 used in Flash
+@item FLIF (Free Lossless Image Format @tab @tab  X
+@tab Precursor to JPEG XL and FUIF
 @item FM Screen Capture Codec  @tab @tab  X
 @item Forward Uncompressed   @tab @tab  X
 @item Fraps  @tab @tab  X
-- 
2.28.0


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 2/3] [RFC] lavfmt: add FLIF demuxing support

2020-08-14 Thread Anamitra Ghorui
This patch removes a redundant class member mentioned in v3, and 
skips iCCP metadata segments.

Signed-off-by: Anamitra Ghorui 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/flifdec.c| 431 +++
 libavformat/version.h|   2 +-
 4 files changed, 434 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/flifdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cbb33fe37c..73cd23221c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -192,6 +192,7 @@ OBJS-$(CONFIG_FLAC_DEMUXER)  += flacdec.o 
rawdec.o \
 OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o flacenc_header.o \
 vorbiscomment.o
 OBJS-$(CONFIG_FLIC_DEMUXER)  += flic.o
+OBJS-$(CONFIG_FLIF_DEMUXER)+= flifdec.o
 OBJS-$(CONFIG_FLV_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_LIVE_FLV_DEMUXER)  += flvdec.o
 OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0aa9dd7198..d003889b6f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -150,6 +150,7 @@ extern AVOutputFormat ff_fits_muxer;
 extern AVInputFormat  ff_flac_demuxer;
 extern AVOutputFormat ff_flac_muxer;
 extern AVInputFormat  ff_flic_demuxer;
+extern AVInputFormat  ff_flif_demuxer;
 extern AVInputFormat  ff_flv_demuxer;
 extern AVOutputFormat ff_flv_muxer;
 extern AVInputFormat  ff_live_flv_demuxer;
diff --git a/libavformat/flifdec.c b/libavformat/flifdec.c
new file mode 100644
index 00..1fccca5373
--- /dev/null
+++ b/libavformat/flifdec.c
@@ -0,0 +1,431 @@
+/*
+ * FLIF16 demuxer
+ * Copyright (c) 2020 Anamitra Ghorui 
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * FLIF demuxer.
+ */
+
+#include "avformat.h"
+#include "libavutil/common.h"
+#include "libavutil/bprint.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "internal.h"
+#include "libavcodec/exif.h"
+
+#include "libavcodec/flif16.h"
+#include "libavcodec/flif16_rangecoder.h"
+
+#include "config.h"
+
+#if CONFIG_ZLIB
+#include 
+#endif
+
+/*
+ * FLIF's reference encoder currently encodes metadata as a raw DEFLATE stream
+ * (RFC 1951). In order to decode a raw deflate stream using Zlib, inflateInit2
+ * must be used with windowBits being between -8 .. -15.
+ */
+#define ZLIB_WINDOW_BITS -15
+#define BUF_SIZE 4096
+
+typedef struct FLIFDemuxContext {
+#if CONFIG_ZLIB
+z_stream stream;
+uint8_t active;
+#endif
+} FLIFDemuxContext;
+
+
+#if CONFIG_ZLIB
+static int flif_inflate(FLIFDemuxContext *s, uint8_t *buf, int buf_size,
+uint8_t **out_buf, int *out_buf_size)
+{
+int ret;
+z_stream *stream = &s->stream;
+
+if (!s->active) {
+s->active = 1;
+stream->zalloc   = Z_NULL;
+stream->zfree= Z_NULL;
+stream->opaque   = Z_NULL;
+stream->avail_in = 0;
+stream->next_in  = Z_NULL;
+ret = inflateInit2(stream, ZLIB_WINDOW_BITS);
+
+if (ret != Z_OK)
+return ret;
+
+*out_buf_size = buf_size;
+*out_buf = av_realloc_f(*out_buf, *out_buf_size, 1);
+if (!*out_buf)
+return AVERROR(ENOMEM);
+}
+
+stream->next_in  = buf;
+stream->avail_in = buf_size;
+
+do {
+while (stream->total_out >= (*out_buf_size - 1)) {
+*out_buf = av_realloc_f(*out_buf, (*out_buf_size) * 2, 1);
+if (!*out_buf)
+return AVERROR(ENOMEM);
+*out_buf_size *= 2;
+}
+
+stream->next_out  = *out_buf + stream->total_out;
+stream->avail_out = *out_buf_size - stream->total_out - 1;
+ 
+ret = inflate(stream, Z_PARTIAL_FLUSH);
+
+switch (ret) {
+case Z_NEED_DICT:
+case Z_DATA_ERROR:
+(void)inflateEnd(stream);
+return AVERROR_INVALIDDATA;
+case Z_MEM_ERROR:
+(void)inflateEnd(stream);
+return AVERROR(ENOMEM);
+}
+} while (stream->avail_in > 0);
+
+if (ret == Z_STREAM_END) {
+s->active = 0;
+(*out_buf)[stream->total_out] = '\0';
+(void) infl

Re: [FFmpeg-devel] [PATCH] libavformat/mpeg.c: Initialize the buffer uses to read the PTS.

2020-08-14 Thread Michael Niedermayer
On Thu, Aug 13, 2020 at 02:21:55PM -0700, Thierry Foucu wrote:
> Fixed an Use-of-uninitialized-value
> ---
>  libavformat/mpeg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index 265b2bd1ad..15a768e6e8 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -146,7 +146,7 @@ static int mpegps_read_header(AVFormatContext *s)
>  
>  static int64_t get_pts(AVIOContext *pb, int c)
>  {
> -uint8_t buf[5];
> +uint8_t buf[5] = {};
>  
>  buf[0] = c < 0 ? avio_r8(pb) : c;
>  avio_read(pb, buf + 1, 4);

this avoids the uninitialized use but it doenst return the correct value
ill post a different solution

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/mpeg: Check avio_read() return value in get_pts()

2020-08-14 Thread Michael Niedermayer
Found-by: Thierry Foucu 
Fixes: Use-of-uninitialized-value
Signed-off-by: Michael Niedermayer 
---
 libavformat/mpeg.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 265b2bd1ad..a5e17925ce 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -147,9 +147,12 @@ static int mpegps_read_header(AVFormatContext *s)
 static int64_t get_pts(AVIOContext *pb, int c)
 {
 uint8_t buf[5];
+int ret;
 
 buf[0] = c < 0 ? avio_r8(pb) : c;
-avio_read(pb, buf + 1, 4);
+ret = avio_read(pb, buf + 1, 4);
+if (ret < 4)
+return AV_NOPTS_VALUE;
 
 return ff_parse_pes_pts(buf);
 }
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mpeg: Check avio_read() return value in get_pts()

2020-08-14 Thread Thierry Foucu
On Fri, Aug 14, 2020, 4:08 PM Michael Niedermayer 
wrote:

> Found-by: Thierry Foucu 
> Fixes: Use-of-uninitialized-value
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mpeg.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index 265b2bd1ad..a5e17925ce 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -147,9 +147,12 @@ static int mpegps_read_header(AVFormatContext *s)
>  static int64_t get_pts(AVIOContext *pb, int c)
>  {
>  uint8_t buf[5];
> +int ret;
>
>  buf[0] = c < 0 ? avio_r8(pb) : c;
> -avio_read(pb, buf + 1, 4);
> +ret = avio_read(pb, buf + 1, 4);
> +if (ret < 4)
> +return AV_NOPTS_VALUE;
>
>  return ff_parse_pes_pts(buf);
>  }
> --
> 2.17.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".





Thanks.

I though also about this solution. This works as well.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegts: parse for AC-3 descriptor 6A

2020-08-14 Thread lance . lmwang
On Fri, Aug 14, 2020 at 10:08:06PM +0200, Marton Balint wrote:
> 
> 
> On Fri, 14 Aug 2020, lance.lmw...@gmail.com wrote:
> 
> > From: Limin Wang 
> 
> I don't think this patch fits into libavformat. I am not a fan of dumping
> the descriptor data with AV_LOG_DEBUG, because libavformat is not a stream
> analyzer. Also I don't see much benefit of parsing the whole descriptor,
> when you are not doing anything with the parsed value.
> 
> Sorry, but I think we are better off if we not apply this.

We can get the audio channels and channel_layout by the descriptor
from demuxer, it's always used by IRD. But I'm not sure whether it's 
make sense to add them for no sample rate and bitrate here. So now I
use it help to check next patch result without using stream analyzer.

> 
> Regards,
> Marton
> 
> 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> > libavformat/mpegts.c | 53 
> > ++--
> > 1 file changed, 47 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index f71f18a5..72cc72a 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2075,16 +2075,57 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
> > AVStream *st, int stream_type
> > break;
> > case 0x6a: /* ac-3_descriptor */
> > {
> > -int component_type_flag = get8(pp, desc_end) & (1 << 7);
> > -if (component_type_flag) {
> > -int component_type = get8(pp, desc_end);
> > -int service_type_mask = 0x38;  // 0b00111000
> > -int service_type = ((component_type & service_type_mask) 
> > >> 3);
> > +AVDVBAC3Descriptor desc6a;
> > +uint8_t buf;
> > +
> > +if (desc_end - *pp < 1)
> > +return AVERROR_INVALIDDATA;
> > +
> > +buf = get8(pp, desc_end);
> > +desc6a.component_type_flag = (buf >> 7) & 0x1;
> > +desc6a.bsid_flag   = (buf >> 6) & 0x1;
> > +desc6a.mainid_flag = (buf >> 5) & 0x1;
> > +desc6a.asvc_flag   = (buf >> 4) & 0x1;
> > +
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "Stream[0x%x] 
> > AC-3(6a):", st->id);
> > +if (desc6a.component_type_flag) {
> > +int service_type;
> > +int number_of_channels;
> > +desc6a.component_type = get8(pp, desc_end);
> > +service_type = ((desc6a.component_type >> 3) & 0x7);
> > if (service_type == 0x02 /* 0b010 */) {
> > st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
> > -av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "New track 
> > disposition for id %u: %u\n", st->id, st->disposition);
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG,
> > +   " disposition: 0x%x", st->disposition);
> > +}
> > +number_of_channels = desc6a.component_type & 0x7;
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " 
> > component_type: 0x%x number_of_channels: %u",
> > +desc6a.component_type, number_of_channels);
> > +}
> > +if (desc6a.bsid_flag) {
> > +if (desc_end - *pp < 1) {
> > +return AVERROR_INVALIDDATA;
> > +}
> > +desc6a.bsid = get8(pp, desc_end);
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " bsid: %u", 
> > desc6a.bsid);
> > +}
> > +if (desc6a.mainid_flag) {
> > +if (desc_end - *pp < 1) {
> > +return AVERROR_INVALIDDATA;
> > +}
> > +desc6a.mainid = get8(pp, desc_end);
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " mainid: %u", 
> > desc6a.mainid);
> > +}
> > +if (desc6a.asvc_flag) {
> > +if (desc_end - *pp < 1) {
> > +return AVERROR_INVALIDDATA;
> > }
> > +desc6a.asvc = get8(pp, desc_end);
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, " asvc: %u", 
> > desc6a.asvc);
> > }
> > +if (desc6a.component_type_flag || desc6a.bsid_flag ||
> > +desc6a.mainid_flag || desc6a.asvc_flag)
> > +av_log(ts ? ts->stream : fc, AV_LOG_DEBUG, "\n");
> > }
> > break;
> > case 0x7a: /* enhanced_ac-3_descriptor */
> > -- 
> > 1.8.3.1
> > 
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffm

[FFmpeg-devel] [PATCH 4/7] avfilter/formats: Avoid code duplication when merging samplerates

2020-08-14 Thread Andreas Rheinhardt
by adapting the MERGE_FORMATS() so that only one instance of the
MERGE_REF() macro needs to exist in ff_merge_samplerates().

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 4efbcbebfe..e8a43a434d 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -56,12 +56,21 @@ do {
   \
 
 /**
  * Add all formats common to a and b to a, add b's refs to a and destroy b.
+ * If empty_allowed is set and one of a,b->nb is zero, the lists are
+ * merged; otherwise, it is treated as error.
  */
-#define MERGE_FORMATS(a, b, fmts, nb, type, fail_statement)\
+#define MERGE_FORMATS(a, b, fmts, nb, type, fail_statement, empty_allowed) \
 do {   
 \
 int i, j, k = 0;   \
 void *tmp; \

 \
+if (empty_allowed) {   \
+if (!a->nb || !b->nb) {\
+if (!a->nb)\
+FFSWAP(type *, a, b);  \
+goto merge_ref;\
+}  \
+}  \
 for (i = 0; i < a->nb; i++)
 \
 for (j = 0; j < b->nb; j++)
 \
 if (a->fmts[i] == b->fmts[j]) {
 \
@@ -77,6 +86,7 @@ do {
 if (tmp)   \
 a->fmts = tmp; \

 \
+merge_ref: \
 MERGE_REF(a, b, fmts, type, fail_statement);   \
 } while (0)
 
@@ -114,7 +124,7 @@ AVFilterFormats *ff_merge_formats(AVFilterFormats *a, 
AVFilterFormats *b,
 if (alpha2 > alpha1 || chroma2 > chroma1)
 return NULL;
 
-MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, return NULL;);
+MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, return NULL;, 0);
 
 return a;
 }
@@ -124,16 +134,8 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats *a,
 {
 if (a == b) return a;
 
-if (a->nb_formats && b->nb_formats) {
-MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, return 
NULL;);
-return a;
-} else if (a->nb_formats) {
-MERGE_REF(a, b, formats, AVFilterFormats, return NULL;);
-return a;
-} else {
-MERGE_REF(b, a, formats, AVFilterFormats, return NULL;);
-return b;
-}
+MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, return NULL;, 1);
+return a;
 }
 
 AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a,
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/7] avfilter/formats: Resize potentially oversized arrays

2020-08-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index c370f7f91c..4efbcbebfe 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -60,6 +60,7 @@ do {  
 \
 #define MERGE_FORMATS(a, b, fmts, nb, type, fail_statement)\
 do {   
 \
 int i, j, k = 0;   \
+void *tmp; \

 \
 for (i = 0; i < a->nb; i++)
 \
 for (j = 0; j < b->nb; j++)
 \
@@ -72,6 +73,9 @@ do {
 if (!k)\
 { fail_statement } \
 a->nb = k; \
+tmp = av_realloc_array(a->fmts, a->nb, sizeof(*a->fmts));  \
+if (tmp)   \
+a->fmts = tmp; \

 \
 MERGE_REF(a, b, fmts, type, fail_statement);   \
 } while (0)
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/7] avfilter/formats: Avoid allocations when merging formats and samplerates

2020-08-14 Thread Andreas Rheinhardt
This is the analogue of cfc65520324ae640299bd321ef88ae76dcee6f78 for
formats and samplerates; in contrast to said commit, one can avoid
allocating a new array for formats as well (the complications of the
generic channel layouts made this impossible for channel layouts).

This commit also starts to move the line continuation '\' chars to the
left to keep them in line with MERGE_REF() as well as with the 80 lines
limit.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 85 ---
 1 file changed, 24 insertions(+), 61 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 1df0c347f9..c370f7f91c 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -33,11 +33,17 @@
 
 /**
  * Add all refs from a to ret and destroy a.
- * ret->refs must have enough spare room left for this.
  */
-#define MERGE_REF_NO_ALLOC(ret, a, fmts)   \
+#define MERGE_REF(ret, a, fmts, type, fail_statement)  \
 do {   \
+type ***tmp;   \
 int i; \
+   \
+if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount,   \
+ sizeof(*tmp   \
+{ fail_statement } \
+ret->refs = tmp;   \
+   \
 for (i = 0; i < a->refcount; i ++) {   \
 ret->refs[ret->refcount] = a->refs[i]; \
 *ret->refs[ret->refcount++] = ret; \
@@ -48,57 +54,31 @@ do {
   \
 av_freep(&a);  \
 } while (0)
 
-#define MERGE_REF(ret, a, fmts, type, fail_statement)  \
-do {   \
-type ***tmp;   \
-   \
-if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount,   \
- sizeof(*tmp   \
-{ fail_statement } \
-ret->refs = tmp;   \
-MERGE_REF_NO_ALLOC(ret, a, fmts);  \
-} while (0)
-
 /**
- * Add all formats common for a and b to ret, copy the refs and destroy
- * a and b.
+ * Add all formats common to a and b to a, add b's refs to a and destroy b.
  */
-#define MERGE_FORMATS(ret, a, b, fmts, nb, type, fail) 
 \
+#define MERGE_FORMATS(a, b, fmts, nb, type, fail_statement)\
 do {   
 \
-int i, j, k = 0, count = a->nb;
 \
-type ***tmp;   
 \
-   
 \
-if (!(ret = av_mallocz(sizeof(*ret 
 \
-goto fail; 
 \
+int i, j, k = 0;   \

 \
-if (count) {   
 \
-if (!(ret->fmts = av_malloc_array(count, sizeof(*ret->fmts 
 \
-goto fail; 
 \
 for (i = 0; i < a->nb; i++)
 \
 for (j = 0; j < b->nb; j++)
 \
 if (a->fmts[i] == b->fmts[j]) {
 \
-ret->fmts[k++] = a->fmts[i];   
 \
+a->fmts[k++] = a->fmts[i]; \
 break; 
 \
 }  
 \
-}  
 \
-ret->nb = k;   
 \
-/* check that there was at least one common format */  
 \
-if (!ret->nb) 

[FFmpeg-devel] [PATCH 1/7] avfilter/formats: Make check for buffer overflow redundant

2020-08-14 Thread Andreas Rheinhardt
and remove the redundant check.

This check for whether the allocated buffer is sufficient has been added
in commit 1cbf7fb4345a3e5b7791d483241bf4759bde4ece (merging commit
5775a1832c4165e6acc1d307004b38701bb463f4). It is not sufficient to
detect invalid input lists (namely lists with duplicates); its only use
is to avoid buffer overflows. And this can be achieved by simpler means:
Make sure that one allocates space for so many elements as the outer loop
ranges over and break out of the inner loop if a match has been found.
For valid input without duplicates, no further match will be found anyway.

This change will temporarily make the allocated formats array larger
than before and larger than necessary; this will be fixed in a later
commit that avoids the allocation altogether.

If a check for duplicates in the lists is deemed necessary, it should be
done properly somewhere else.

Finally, the error message that is removed in this commit used
__FUNCTION__, which is a GCC extension (C99 added __func__ for this).
So this commit removes a warning when compiling in -pedantic mode.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 04b8c7cc39..1df0c347f9 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -65,7 +65,7 @@ do {  
 \
  */
 #define MERGE_FORMATS(ret, a, b, fmts, nb, type, fail) 
 \
 do {   
 \
-int i, j, k = 0, count = FFMIN(a->nb, b->nb);  
 \
+int i, j, k = 0, count = a->nb;
 \
 type ***tmp;   
 \

 \
 if (!(ret = av_mallocz(sizeof(*ret 
 \
@@ -77,13 +77,8 @@ do {
 for (i = 0; i < a->nb; i++)
 \
 for (j = 0; j < b->nb; j++)
 \
 if (a->fmts[i] == b->fmts[j]) {
 \
-if(k >= FFMIN(a->nb, b->nb)){  
 \
-av_log(NULL, AV_LOG_ERROR, "Duplicate formats in %s 
detected\n", __FUNCTION__); \
-av_free(ret->fmts);
 \
-av_free(ret);  
 \
-return NULL;   
 \
-}  
 \
 ret->fmts[k++] = a->fmts[i];   
 \
+break; 
 \
 }  
 \
 }  
 \
 ret->nb = k;   
 \
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 6/7] avfilter/formats: Always keep longer references list when merging lists

2020-08-14 Thread Andreas Rheinhardt
This means that one only needs to update the shorter list of references.

Signed-off-by: Andreas Rheinhardt 
---
I doubt that this optimizations is worth the additional complexity. I
have just added it for you to decide.

 libavfilter/formats.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 9788357952..4ac690ea8a 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -33,12 +33,23 @@
 
 /**
  * Add all refs from a to ret and destroy a.
+ * The macro may swap ret and a internally, but the combined list is in ret.
+ * If preserve_fmts is set, the fmts array is preserved when swapping.
  */
-#define MERGE_REF(ret, a, fmts, type, fail_statement)  \
+#define MERGE_REF(ret, a, fmts, type, preserve_fmts, fail_statement)   \
 do {   \
 type ***tmp;   \
 int i; \
\
+if (ret->refcount < a->refcount) { \
+FFSWAP(type *, ret, a);\
+if (preserve_fmts) {   \
+FFSWAP(type, *ret, *a);\
+FFSWAP(unsigned, ret->refcount, a->refcount);  \
+FFSWAP(type ***, ret->refs, a->refs);  \
+}  \
+}  \
+   \
 if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount,   \
  sizeof(*tmp   \
 { fail_statement } \
@@ -60,6 +71,7 @@ do {  
 \
  * the formats are compatible.
  * If empty_allowed is set and one of a,b->nb is zero, the lists are
  * merged; otherwise, it is treated as error.
+ * The macro may swap a and b internally, but the combined list is in a.
  */
 #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed)  \
 do {   
 \
@@ -94,7 +106,7 @@ do {
 a->fmts = tmp; \

 \
 merge_ref: \
-MERGE_REF(a, b, fmts, type, return AVERROR(ENOMEM););  \
+MERGE_REF(a, b, fmts, type, 1, return AVERROR(ENOMEM););   \
 } while (0)
 
 static int merge_formats_internal(AVFilterFormats *a, AVFilterFormats *b,
@@ -199,7 +211,8 @@ int ff_merge_channel_layouts(AVFilterChannelLayouts *a,
 return 0;
 b->nb_channel_layouts = j;
 }
-MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, return 
AVERROR(ENOMEM););
+MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts,
+  1, return AVERROR(ENOMEM););
 return 1;
 }
 
@@ -248,10 +261,7 @@ int ff_merge_channel_layouts(AVFilterChannelLayouts *a,
 return 0;
 }
 
-if (a->refcount > b->refcount)
-FFSWAP(AVFilterChannelLayouts *, a, b);
-
-MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts,
+MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, 0,
   { av_free(channel_layouts); return AVERROR(ENOMEM); });
 av_freep(&b->channel_layouts);
 b->channel_layouts= channel_layouts;
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 5/7] avfilter/formats: Factor checking for mergeability out of ff_merge_*

2020-08-14 Thread Andreas Rheinhardt
The callers of the ff_merge_*() functions fall into two categories with
quite different needs:

One caller is can_merge_formats() which only wants to test for mergeability
without it merging anything. In order to do so, it duplicates the lists
it intends to test and resets their owners so that they are not modified
by ff_merge_*(). It also means that it needs to receive the merged list
(and not only an int containing whether the lists are mergeable) to
properly free it.

The other callers want the lists to be actually merged. But given the
fact that ff_merge_*() automatically updates the owners of the lists,
they only want the information whether the merge succeeded or not; they
don't want a link to the new list.

Therefore this commit splits these functions in two: ff_merge_*() for
the latter callers and ff_can_merge_*() for the former.
ff_merge_*() doesn't need to return a pointer to the combined list at all
and hence these functions have been modified to return an int, which
allows to distinguish between incompability and memory allocation failures.

ff_can_merge_*() meanwhile doesn't modify its arguments at all obviating
the need for copies. This in turn implies that there is no reason to
return a pointer to the new list, as nothing needs to be freed. These
functions therefore return an int as well. This allowed to completely
remove can_merge_formats() in avfiltergraph.c.

Notice that no ff_can_merge_channel_layouts() has been created, because
there is currently no caller for this. It could be added if needed.

Signed-off-by: Andreas Rheinhardt 
---
If neither a nor b had references (which happens iff the call came from
can_merge_refs()), the earlier code would allocate a references array
for zero elements which in turn leads to an allocation of one byte.
This commit avoids said allocation completely.

This led to thousands of failing FATE-tests when it was tried in [1]
to return NULL when the allocation of zero bytes is requested.
(The nut muxer also tries to allocate an array of zero elements (for its
chapters) and it is the next biggest source of such allocations.) 

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260430.html

 libavfilter/avfiltergraph.c | 129 ++--
 libavfilter/formats.c   |  91 +
 libavfilter/formats.h   |  44 ++--
 3 files changed, 120 insertions(+), 144 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 681c519ef0..eebaa4c358 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -372,61 +372,6 @@ static int formats_declared(AVFilterContext *f)
 return 1;
 }
 
-static AVFilterFormats *clone_filter_formats(AVFilterFormats *arg)
-{
-AVFilterFormats *a = av_memdup(arg, sizeof(*arg));
-if (a) {
-a->refcount = 0;
-a->refs = NULL;
-a->formats  = av_memdup(a->formats, sizeof(*a->formats) * 
a->nb_formats);
-if (!a->formats && arg->formats)
-av_freep(&a);
-}
-return a;
-}
-
-static int can_merge_formats(AVFilterFormats *a_arg,
- AVFilterFormats *b_arg,
- enum AVMediaType type,
- int is_sample_rate)
-{
-AVFilterFormats *a, *b, *ret;
-if (a_arg == b_arg)
-return 1;
-a = clone_filter_formats(a_arg);
-b = clone_filter_formats(b_arg);
-
-if (!a || !b) {
-if (a)
-av_freep(&a->formats);
-if (b)
-av_freep(&b->formats);
-
-av_freep(&a);
-av_freep(&b);
-
-return 0;
-}
-
-if (is_sample_rate) {
-ret = ff_merge_samplerates(a, b);
-} else {
-ret = ff_merge_formats(a, b, type);
-}
-if (ret) {
-av_freep(&ret->formats);
-av_freep(&ret->refs);
-av_freep(&ret);
-return 1;
-} else {
-av_freep(&a->formats);
-av_freep(&b->formats);
-av_freep(&a);
-av_freep(&b);
-return 0;
-}
-}
-
 /**
  * Perform one round of query_formats() and merging formats lists on the
  * filter graph.
@@ -473,45 +418,40 @@ static int query_formats(AVFilterGraph *graph, AVClass 
*log_ctx)
 
 if (link->in_formats != link->out_formats
 && link->in_formats && link->out_formats)
-if (!can_merge_formats(link->in_formats, link->out_formats,
-  link->type, 0))
+if (!ff_can_merge_formats(link->in_formats, link->out_formats,
+  link->type))
 convert_needed = 1;
 if (link->type == AVMEDIA_TYPE_AUDIO) {
 if (link->in_samplerates != link->out_samplerates
 && link->in_samplerates && link->out_samplerates)
-if (!can_merge_formats(link->in_samplerates,
-   link->out_samplerates,
-

[FFmpeg-devel] [PATCH 7/7] avfilter/formats: Cosmetics

2020-08-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 4ac690ea8a..71060f5f50 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -74,10 +74,10 @@ do {
   \
  * The macro may swap a and b internally, but the combined list is in a.
  */
 #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed)  \
-do {   
 \
+do {   \
 int i, j, k = 0;   \
 void *tmp; \
-   
 \
+   \
 if (empty_allowed) {   \
 if (!a->nb || !b->nb) {\
 if (check) \
@@ -87,14 +87,14 @@ do {
 goto merge_ref;\
 }  \
 }  \
-for (i = 0; i < a->nb; i++)
 \
-for (j = 0; j < b->nb; j++)
 \
-if (a->fmts[i] == b->fmts[j]) {
 \
+for (i = 0; i < a->nb; i++)\
+for (j = 0; j < b->nb; j++)\
+if (a->fmts[i] == b->fmts[j]) {\
 if (check) \
 return 1;  \
-a->fmts[k++] = a->fmts[i]; \
-break; 
 \
-}  
 \
+a->fmts[k++] = a->fmts[i]; \
+break; \
+}  \
 /* Check that there was at least one common format.\
  * Notice that both a and b are unchanged if not. */   \
 if (!k)\
@@ -104,7 +104,7 @@ do {
 tmp = av_realloc_array(a->fmts, a->nb, sizeof(*a->fmts));  \
 if (tmp)   \
 a->fmts = tmp; \
-   
 \
+   \
 merge_ref: \
 MERGE_REF(a, b, fmts, type, 1, return AVERROR(ENOMEM););   \
 } while (0)
-- 
2.20.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".