[FFmpeg-cvslog] lavfi/formats: rename AVFilterNegotiation.nb to nb_mergers

2021-08-20 Thread Nicolas George
ffmpeg | branch: master | Nicolas George  | Thu Aug 19 
16:58:20 2021 +0200| [24de2b7618cc0ed9e75398750b95a2fe88ccaf8c] | committer: 
Nicolas George

lavfi/formats: rename AVFilterNegotiation.nb to nb_mergers

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=24de2b7618cc0ed9e75398750b95a2fe88ccaf8c
---

 libavfilter/avfiltergraph.c | 6 +++---
 libavfilter/formats.c   | 4 ++--
 libavfilter/formats.h   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 41a91a9bda..8c6d43a0c7 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -465,7 +465,7 @@ static int query_formats(AVFilterGraph *graph, AVClass 
*log_ctx)
 
 neg = ff_filter_get_negotiation(link);
 av_assert0(neg);
-for (neg_step = 1; neg_step < neg->nb; neg_step++) {
+for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) {
 const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
 void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
 void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
@@ -474,7 +474,7 @@ static int query_formats(AVFilterGraph *graph, AVClass 
*log_ctx)
 break;
 }
 }
-for (neg_step = 0; neg_step < neg->nb; neg_step++) {
+for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
 const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
 void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
 void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
@@ -542,7 +542,7 @@ static int query_formats(AVFilterGraph *graph, AVClass 
*log_ctx)
 av_assert0(outlink-> incfg.channel_layouts->refcount > 0);
 av_assert0(outlink->outcfg.channel_layouts->refcount > 0);
 }
-for (neg_step = 0; neg_step < neg->nb; neg_step++) {
+for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
 const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
 void *ia = FF_FIELD_AT(void *, m->offset, inlink->incfg);
 void *ib = FF_FIELD_AT(void *, m->offset, inlink->outcfg);
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 9e39d65a3c..ca85b4094b 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -327,14 +327,14 @@ static const AVFilterFormatsMerger mergers_audio[] = {
 };
 
 static const AVFilterNegotiation negotiate_video = {
-.nb = FF_ARRAY_ELEMS(mergers_video),
+.nb_mergers = FF_ARRAY_ELEMS(mergers_video),
 .mergers = mergers_video,
 .conversion_filter = "scale",
 .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
 };
 
 static const AVFilterNegotiation negotiate_audio = {
-.nb = FF_ARRAY_ELEMS(mergers_audio),
+.nb_mergers = FF_ARRAY_ELEMS(mergers_audio),
 .mergers = mergers_audio,
 .conversion_filter = "aresample",
 .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts),
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index a9cfa14e95..d94977a3aa 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -322,7 +322,7 @@ typedef struct AVFilterFormatMerger {
 } AVFilterFormatsMerger;
 
 typedef struct AVFilterNegotiation {
-unsigned nb;
+unsigned nb_mergers;
 const AVFilterFormatsMerger *mergers;
 const char *conversion_filter;
 unsigned conversion_opts_offset;

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

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


[FFmpeg-cvslog] lavfi/formats: document the negotiation process

2021-08-20 Thread Nicolas George
ffmpeg | branch: master | Nicolas George  | Thu Aug 19 
17:12:57 2021 +0200| [b06f12b68b397f9bf9ee991e850095b0330cb3dc] | committer: 
Nicolas George

lavfi/formats: document the negotiation process

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b06f12b68b397f9bf9ee991e850095b0330cb3dc
---

 libavfilter/formats.h | 85 +++
 1 file changed, 85 insertions(+)

diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index d94977a3aa..7c8258ed08 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -321,6 +321,91 @@ typedef struct AVFilterFormatMerger {
 int (*can_merge)(const void *a, const void *b);
 } AVFilterFormatsMerger;
 
+/**
+ * Callbacks and properties to describe the steps of a format negotiation.
+ *
+ * The steps are:
+ *
+ * 1. query_formats(): call the callbacks on all filter to set lists of
+ * supported formats.
+ * When links on a filter must eventually have the same
+ * format, the lists of supported formats are the same
+ * object in memory.
+ * See:
+ * 
http://www.normalesup.org/~george/articles/format_negotiation_in_libavfilter/#12
+ *
+ *
+ * 2. query_formats(): merge lists of supported formats or insert automatic
+ * conversion filters.
+ * Compute the intersection of the lists of supported
+ * formats on the ends of links. If it succeeds, replace
+ * both objects with the intersection everywhere they
+ * are referenced.
+ * If the intersection is empty, insert an automatic
+ * conversion filter.
+ * If several formats are negotiated at once (format,
+ * rate, layout), only merge if all three can be, since
+ * the conversion filter can convert all three at once.
+ * This process goes on as long as progress is made.
+ * See:
+ * 
http://www.normalesup.org/~george/articles/format_negotiation_in_libavfilter/#14
+ * 
http://www.normalesup.org/~george/articles/format_negotiation_in_libavfilter/#29
+ *
+ * 3. reduce_formats(): try to reduce format conversion within filters.
+ *  For each link where there is only one supported
+ *  formats on output, for each output of the connected
+ *  filter, if the media type is the same and said
+ *  format is supported, keep only this one.
+ *  This process goes on as long as progress is made.
+ *  Rationale: conversion filters will set a large list
+ *  of supported formats on outputs but users will
+ *  expect the output to be as close as possible as the
+ *  input (examples: scale without changing the pixel
+ *  format, resample without changint the layout).
+ *  FIXME: this can probably be done by merging the
+ *  input and output lists instead of re-implementing
+ *  the logic.
+ *
+ * 4. swap_sample_fmts():
+ *swap_samplerates():
+ *swap_channel_layouts(): For each filter with an input with only one
+ *supported format, when outputs have several
+ *supported formats, put the best one with
+ *reference to the input at the beginning of the
+ *list, to prepare it for being picked up by
+ *pick_formats().
+ *The best format is the one that is most
+ *similar to the input while not losing too much
+ *information.
+ *This process need to run only once.
+ *FIXME: reduce_formats() operates on all inputs
+ *with a single format, swap_*() operates on the
+ *first one only: check if the difference makes
+ *sense.
+ *TODO: the swapping done for one filter can
+ *override the swapping done for another filter
+ *connected to the same list of formats, maybe
+ *it would be better to compute a total score
+ *for all connected filters and use the score to
+ *pick the format instead of just swapping.
+ *TODO: make the similarity logic available as
+ *public functions in libavutil.
+ *
+ * 5. pick_formats(): Choose one format from the lists of supported forma

[FFmpeg-cvslog] lavfi/formats: cosmetic: move negotiation stuff at the end

2021-08-20 Thread Nicolas George
ffmpeg | branch: master | Nicolas George  | Thu Aug 19 
17:09:21 2021 +0200| [703c3c4151bf47a03ddf168f67a8b1a46834c791] | committer: 
Nicolas George

lavfi/formats: cosmetic: move negotiation stuff at the end

It was between AVFilterFormats and AVFilterChannelLayouts.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=703c3c4151bf47a03ddf168f67a8b1a46834c791
---

 libavfilter/formats.h | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index ed513c265a..a9cfa14e95 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -69,21 +69,6 @@ struct AVFilterFormats {
 struct AVFilterFormats ***refs; ///< references to this list
 };
 
-typedef struct AVFilterFormatMerger {
-unsigned offset;
-int (*merge)(void *a, void *b);
-int (*can_merge)(const void *a, const void *b);
-} AVFilterFormatsMerger;
-
-typedef struct AVFilterNegotiation {
-unsigned nb;
-const AVFilterFormatsMerger *mergers;
-const char *conversion_filter;
-unsigned conversion_opts_offset;
-} AVFilterNegotiation;
-
-const AVFilterNegotiation *ff_filter_get_negotiation(AVFilterLink *link);
-
 /**
  * A list of supported channel layouts.
  *
@@ -330,4 +315,19 @@ int ff_formats_check_sample_rates(void *log, const 
AVFilterFormats *fmts);
  */
 int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts 
*fmts);
 
+typedef struct AVFilterFormatMerger {
+unsigned offset;
+int (*merge)(void *a, void *b);
+int (*can_merge)(const void *a, const void *b);
+} AVFilterFormatsMerger;
+
+typedef struct AVFilterNegotiation {
+unsigned nb;
+const AVFilterFormatsMerger *mergers;
+const char *conversion_filter;
+unsigned conversion_opts_offset;
+} AVFilterNegotiation;
+
+const AVFilterNegotiation *ff_filter_get_negotiation(AVFilterLink *link);
+
 #endif /* AVFILTER_FORMATS_H */

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

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


[FFmpeg-cvslog] avfilter/vf_colorcorrect: fix average analyze mode and add minmax mode

2021-08-20 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Aug 20 10:54:30 
2021 +0200| [d5b3e0403ee2eceac5f38455c0c23fef415bc69c] | committer: Paul B Mahol

avfilter/vf_colorcorrect: fix average analyze mode and add minmax mode

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5b3e0403ee2eceac5f38455c0c23fef415bc69c
---

 doc/filters.texi  |  2 +-
 libavfilter/vf_colorcorrect.c | 99 +++
 2 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index f8d99b7171..480cab706c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8227,7 +8227,7 @@ Default value is 1.
 
 @item analyze
 If set to anything other than @code{manual} it will analyze every frame and 
use derived
-parameters for filtering output frame. Can be @code{manual} or @code{average}.
+parameters for filtering output frame. Can be @code{manual} or @code{average} 
or @code{minmax}.
 Default value is @code{manual}.
 @end table
 
diff --git a/libavfilter/vf_colorcorrect.c b/libavfilter/vf_colorcorrect.c
index f28409fa44..e76ed96504 100644
--- a/libavfilter/vf_colorcorrect.c
+++ b/libavfilter/vf_colorcorrect.c
@@ -30,6 +30,7 @@
 typedef enum AnalyzeMode {
 MANUAL,
 AVERAGE,
+MINMAX,
 NB_ANALYZE
 } AnalyzeMode;
 
@@ -48,7 +49,7 @@ typedef struct ColorCorrectContext {
 int planeheight[4];
 int planewidth[4];
 
-float (*analyzeret)[2];
+float (*analyzeret)[4];
 
 int (*do_analyze)(AVFilterContext *s, void *arg,
   int jobnr, int nb_jobs);
@@ -81,8 +82,8 @@ static int average_slice8(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_job
 vptr += vlinesize;
 }
 
-s->analyzeret[jobnr][0] = imax * sum_u / (float)((slice_end - slice_start) 
* width) - 0.5f;
-s->analyzeret[jobnr][1] = imax * sum_v / (float)((slice_end - slice_start) 
* width) - 0.5f;
+s->analyzeret[jobnr][0] = s->analyzeret[jobnr][2] = imax * sum_u / 
(float)((slice_end - slice_start) * width) - 0.5f;
+s->analyzeret[jobnr][1] = s->analyzeret[jobnr][3] = imax * sum_v / 
(float)((slice_end - slice_start) * width) - 0.5f;
 
 return 0;
 }
@@ -112,8 +113,80 @@ static int average_slice16(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_jo
 vptr += vlinesize;
 }
 
-s->analyzeret[jobnr][0] = imax * sum_u / (float)((slice_end - slice_start) 
* width) - 0.5f;
-s->analyzeret[jobnr][1] = imax * sum_v / (float)((slice_end - slice_start) 
* width) - 0.5f;
+s->analyzeret[jobnr][0] = s->analyzeret[jobnr][2] = imax * sum_u / 
(float)((slice_end - slice_start) * width) - 0.5f;
+s->analyzeret[jobnr][1] = s->analyzeret[jobnr][3] = imax * sum_v / 
(float)((slice_end - slice_start) * width) - 0.5f;
+
+return 0;
+}
+
+static int minmax_slice8(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ColorCorrectContext *s = ctx->priv;
+AVFrame *frame = arg;
+const float imax = s->imax;
+const int width = s->planewidth[1];
+const int height = s->planeheight[1];
+const int slice_start = (height * jobnr) / nb_jobs;
+const int slice_end = (height * (jobnr + 1)) / nb_jobs;
+const int ulinesize = frame->linesize[1];
+const int vlinesize = frame->linesize[2];
+const uint8_t *uptr = (const uint8_t *)frame->data[1] + slice_start * 
ulinesize;
+const uint8_t *vptr = (const uint8_t *)frame->data[2] + slice_start * 
vlinesize;
+int min_u = 255, min_v = 255;
+int max_u = 0, max_v = 0;
+
+for (int y = slice_start; y < slice_end; y++) {
+for (int x = 0; x < width; x++) {
+min_u = FFMIN(min_u, uptr[x]);
+min_v = FFMIN(min_v, vptr[x]);
+max_u = FFMAX(max_u, uptr[x]);
+max_v = FFMAX(max_v, vptr[x]);
+}
+
+uptr += ulinesize;
+vptr += vlinesize;
+}
+
+s->analyzeret[jobnr][0] = imax * min_u - 0.5f;
+s->analyzeret[jobnr][1] = imax * min_v - 0.5f;
+s->analyzeret[jobnr][2] = imax * max_u - 0.5f;
+s->analyzeret[jobnr][3] = imax * max_v - 0.5f;
+
+return 0;
+}
+
+static int minmax_slice16(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+ColorCorrectContext *s = ctx->priv;
+AVFrame *frame = arg;
+const float imax = s->imax;
+const int width = s->planewidth[1];
+const int height = s->planeheight[1];
+const int slice_start = (height * jobnr) / nb_jobs;
+const int slice_end = (height * (jobnr + 1)) / nb_jobs;
+const int ulinesize = frame->linesize[1] / 2;
+const int vlinesize = frame->linesize[2] / 2;
+const uint16_t *uptr = (const uint16_t *)frame->data[1] + slice_start * 
ulinesize;
+const uint16_t *vptr = (const uint16_t *)frame->data[2] + slice_start * 
vlinesize;
+int min_u = INT_MAX, min_v = INT_MAX;
+int max_u = INT_MIN, max_v = INT_MIN;
+
+for (int y = slice_start; y < slice_end; y++) {
+for (int x = 0; x < width; x++) {
+min_u = FFMIN(min_u, uptr[x]);
+min_

[FFmpeg-cvslog] avfilter/avfiltergraph: Don't use AVClass * for logcontext

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Aug 20 05:33:23 2021 +0200| [29bf3fafa0c46b6fbb205bc878fd3bcb6aa0d8cb] | 
committer: Andreas Rheinhardt

avfilter/avfiltergraph: Don't use AVClass * for logcontext

Forgotten in 57fa314090ab006808911fd790053b534749aa53.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=29bf3fafa0c46b6fbb205bc878fd3bcb6aa0d8cb
---

 libavfilter/avfiltergraph.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 8c6d43a0c7..13c81a5f4a 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -208,7 +208,7 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph 
*graph,
  *
  * @return >= 0 in case of success, a negative value otherwise
  */
-static int graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
+static int graph_check_validity(AVFilterGraph *graph, void *log_ctx)
 {
 AVFilterContext *filt;
 int i, j;
@@ -246,7 +246,7 @@ static int graph_check_validity(AVFilterGraph *graph, 
AVClass *log_ctx)
  *
  * @return >= 0 in case of success, a negative value otherwise
  */
-static int graph_config_links(AVFilterGraph *graph, AVClass *log_ctx)
+static int graph_config_links(AVFilterGraph *graph, void *log_ctx)
 {
 AVFilterContext *filt;
 int i, ret;
@@ -263,7 +263,7 @@ static int graph_config_links(AVFilterGraph *graph, AVClass 
*log_ctx)
 return 0;
 }
 
-static int graph_check_links(AVFilterGraph *graph, AVClass *log_ctx)
+static int graph_check_links(AVFilterGraph *graph, void *log_ctx)
 {
 AVFilterContext *f;
 AVFilterLink *l;
@@ -427,7 +427,7 @@ static int formats_declared(AVFilterContext *f)
  *  was made and the negotiation is stuck;
  *  a negative error code if some other error happened
  */
-static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
+static int query_formats(AVFilterGraph *graph, void *log_ctx)
 {
 int i, j, ret;
 int converter_count = 0;
@@ -1107,7 +1107,7 @@ static int pick_formats(AVFilterGraph *graph)
 /**
  * Configure the formats of all the links in the graph.
  */
-static int graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
+static int graph_config_formats(AVFilterGraph *graph, void *log_ctx)
 {
 int ret;
 
@@ -1135,8 +1135,7 @@ static int graph_config_formats(AVFilterGraph *graph, 
AVClass *log_ctx)
 return 0;
 }
 
-static int graph_config_pointers(AVFilterGraph *graph,
- AVClass *log_ctx)
+static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
 {
 unsigned i, j;
 int sink_links_count = 0, n = 0;

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

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


[FFmpeg-cvslog] avcodec/h264_parser: Fix undefined left shift

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue May 26 20:26:28 2020 +0200| [c83a7dd25fdf9636e7e5da3fad5e0d82035b9c86] | 
committer: Andreas Rheinhardt

avcodec/h264_parser: Fix undefined left shift

Use an uint32_t for the NAL unit size of an AVC H.264 NAL unit instead
of an int as a left shift of a signed value is undefined behaviour
if the result doesn't fit into the target type.

Also make the log message never output negative lengths.

Fixes: left shift of 16711968 by 8 places cannot be represented in type 'int'
Fixes: 
36601/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6581933285965824

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c83a7dd25fdf9636e7e5da3fad5e0d82035b9c86
---

 libavcodec/h264_parser.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index d3c56cc188..01ea016409 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -83,12 +83,13 @@ static int h264_find_frame_end(H264ParseContext *p, const 
uint8_t *buf,
 
 for (i = 0; i < buf_size; i++) {
 if (i >= next_avc) {
-int nalsize = 0;
+uint32_t nalsize = 0;
 i = next_avc;
 for (j = 0; j < p->nal_length_size; j++)
 nalsize = (nalsize << 8) | buf[i++];
-if (nalsize <= 0 || nalsize > buf_size - i) {
-av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %d 
remaining %d\n", nalsize, buf_size - i);
+if (!nalsize || nalsize > buf_size - i) {
+av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %"PRIu32" "
+   "remaining %d\n", nalsize, buf_size - i);
 return buf_size;
 }
 next_avc = i + nalsize;

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

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


[FFmpeg-cvslog] fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Aug 12 17:35:37 2021 +0200| [d53d48c7993fe2e9ffcc4a638ebd2f4c5273c144] | 
committer: Andreas Rheinhardt

fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads

Besides being nicer code this also has the advantage of not making
assumptions about the internal implementation: While it is documented
that the AVFilter.inputs and AVFilter.outputs arrays are terminated
by a zeroed sentinel, one is not allowed to infer that one can just
check avfilter_pad_get_name(padarray, i) to see whether one has reached
the sentinel:
It could be that the pointer to the string is contained
in a different structure than AVFilterPad that needs to be accessed
first: return pad->struct->string.
It could be that for small strings an internal buffer in
AVFilterPad is used (to avoid a relocation) whereas for longer strings
an external string is used; this is useful to avoid relocations:
return pad->string_ptr ? pad->string_ptr : pad->interal_string
Or it could be that the name has a default value:
return pad->name ? pad->name : "default"
(This actually made sense for us because the name of most of our
AVFilterPads is just "default"; doing so would save lots of relocations.)

The only thing one is allowed to infer from the existence of the
sentinel is that one is allowed to use avfilter_pad_count() to get
the number of pads. Therefore it is used.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d53d48c7993fe2e9ffcc4a638ebd2f4c5273c144
---

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

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6d0bcd6085..96d38803df 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1707,12 +1707,14 @@ int show_filters(void *optctx, const char *opt, const 
char *arg)
 while ((filter = av_filter_iterate(&opaque))) {
 descr_cur = descr;
 for (i = 0; i < 2; i++) {
+unsigned nb_pads;
 if (i) {
 *(descr_cur++) = '-';
 *(descr_cur++) = '>';
 }
 pad = i ? filter->outputs : filter->inputs;
-for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) {
+nb_pads = avfilter_pad_count(pad);
+for (j = 0; j < nb_pads; j++) {
 if (descr_cur >= descr + sizeof(descr) - 4)
 break;
 *(descr_cur++) = 
get_media_type_char(avfilter_pad_get_type(pad, j));

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

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


[FFmpeg-cvslog] fftools/cmdutils: Switch to avfilter_filter_pad_count()

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Aug 15 07:36:43 2021 +0200| [8f72bb866e47bcb57586608086c77cf0a2e2f21a] | 
committer: Andreas Rheinhardt

fftools/cmdutils: Switch to avfilter_filter_pad_count()

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f72bb866e47bcb57586608086c77cf0a2e2f21a
---

 fftools/cmdutils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 96d38803df..2dd035a7cf 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1713,7 +1713,7 @@ int show_filters(void *optctx, const char *opt, const 
char *arg)
 *(descr_cur++) = '>';
 }
 pad = i ? filter->outputs : filter->inputs;
-nb_pads = avfilter_pad_count(pad);
+nb_pads = avfilter_filter_pad_count(filter, i);
 for (j = 0; j < nb_pads; j++) {
 if (descr_cur >= descr + sizeof(descr) - 4)
 break;
@@ -1949,7 +1949,7 @@ static void show_help_filter(const char *name)
 printf("slice threading supported\n");
 
 printf("Inputs:\n");
-count = avfilter_pad_count(f->inputs);
+count = avfilter_filter_pad_count(f, 0);
 for (i = 0; i < count; i++) {
 printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
media_type_string(avfilter_pad_get_type(f->inputs, i)));
@@ -1960,7 +1960,7 @@ static void show_help_filter(const char *name)
 printf("none (source filter)\n");
 
 printf("Outputs:\n");
-count = avfilter_pad_count(f->outputs);
+count = avfilter_filter_pad_count(f, 1);
 for (i = 0; i < count; i++) {
 printf("   #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, 
i),
media_type_string(avfilter_pad_get_type(f->outputs, i)));

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

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


[FFmpeg-cvslog] avfilter/avfilter: Add avfilter_filter_pad_count()

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Aug 15 07:32:05 2021 +0200| [7c5f998196d101a661d802aa48dd62dd93d1fb3d] | 
committer: Andreas Rheinhardt

avfilter/avfilter: Add avfilter_filter_pad_count()

It is intended as replacement for avfilter_pad_count(). In contrast to
the latter, it avoids a loop.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c5f998196d101a661d802aa48dd62dd93d1fb3d
---

 doc/APIchanges | 3 +++
 libavfilter/avfilter.c | 5 +
 libavfilter/avfilter.h | 5 +
 libavfilter/version.h  | 2 +-
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 393ae68fa7..72c5fae125 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2021-08-20 - xx - lavfi 8.3.100 - avfilter.H
+  Add avfilter_filter_pad_count() as a replacement for avfilter_pad_count().
+
 2021-08-17 - xx - lavu 57.4.101 - opt.h
   av_opt_copy() now guarantees that allocated src and dst options
   don't alias each other even on error.
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index a869a76b71..b5f5616fde 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -556,6 +556,11 @@ int avfilter_pad_count(const AVFilterPad *pads)
 av_assert0(!"AVFilterPad list not from a filter");
 }
 
+unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
+{
+return is_output ? filter->nb_outputs : filter->nb_inputs;
+}
+
 static const char *default_filter_name(void *filter_ctx)
 {
 AVFilterContext *ctx = filter_ctx;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 5025fafdc5..3a0f0b7926 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -325,6 +325,11 @@ typedef struct AVFilter {
 int (*activate)(AVFilterContext *ctx);
 } AVFilter;
 
+/**
+ * Get the number of elements in an AVFilter's inputs or outputs array.
+ */
+unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output);
+
 /**
  * Process multiple parts of the frame concurrently.
  */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 67f2a5883c..cb4c19cf05 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   8
-#define LIBAVFILTER_VERSION_MINOR   2
+#define LIBAVFILTER_VERSION_MINOR   3
 #define LIBAVFILTER_VERSION_MICRO 100
 
 

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

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


[FFmpeg-cvslog] avfilter/avfilter: Deprecate avfilter_pad_count()

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Aug 12 15:21:57 2021 +0200| [e88db774d8c3905fc664446914202f66ebc1a140] | 
committer: Andreas Rheinhardt

avfilter/avfilter: Deprecate avfilter_pad_count()

It is unnecessary as the number of static inputs and outputs can now
be directly read via AVFilter.nb_(in|out)puts.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e88db774d8c3905fc664446914202f66ebc1a140
---

 doc/APIchanges | 1 +
 libavfilter/avfilter.c | 2 ++
 libavfilter/avfilter.h | 5 +
 libavfilter/version.h  | 3 +++
 4 files changed, 11 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 72c5fae125..fe7b874881 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -16,6 +16,7 @@ API changes, most recent first:
 
 2021-08-20 - xx - lavfi 8.3.100 - avfilter.H
   Add avfilter_filter_pad_count() as a replacement for avfilter_pad_count().
+  Deprecate avfilter_pad_count().
 
 2021-08-17 - xx - lavu 57.4.101 - opt.h
   av_opt_copy() now guarantees that allocated src and dst options
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index b5f5616fde..28123655d6 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -538,6 +538,7 @@ int avfilter_process_command(AVFilterContext *filter, const 
char *cmd, const cha
 return AVERROR(ENOSYS);
 }
 
+#if FF_API_PAD_COUNT
 int avfilter_pad_count(const AVFilterPad *pads)
 {
 const AVFilter *filter;
@@ -555,6 +556,7 @@ int avfilter_pad_count(const AVFilterPad *pads)
 
 av_assert0(!"AVFilterPad list not from a filter");
 }
+#endif
 
 unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
 {
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 3a0f0b7926..69ecb0186d 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -70,10 +70,15 @@ typedef struct AVFilterPad AVFilterPad;
 typedef struct AVFilterFormats AVFilterFormats;
 typedef struct AVFilterChannelLayouts AVFilterChannelLayouts;
 
+#if FF_API_PAD_COUNT
 /**
  * Get the number of elements in an AVFilter's inputs or outputs array.
+ *
+ * @deprecated Use avfilter_filter_pad_count() instead.
  */
+attribute_deprecated
 int avfilter_pad_count(const AVFilterPad *pads);
+#endif
 
 /**
  * Get the name of an AVFilterPad.
diff --git a/libavfilter/version.h b/libavfilter/version.h
index cb4c19cf05..bcd27aa6e8 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -56,5 +56,8 @@
 #ifndef FF_API_BUFFERSINK_ALLOC
 #define FF_API_BUFFERSINK_ALLOC (LIBAVFILTER_VERSION_MAJOR < 9)
 #endif
+#ifndef FF_API_PAD_COUNT
+#define FF_API_PAD_COUNT(LIBAVFILTER_VERSION_MAJOR < 9)
+#endif
 
 #endif /* AVFILTER_VERSION_H */

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

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


[FFmpeg-cvslog] avfilter/formats: Avoid redundant counter

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Aug 15 09:44:59 2021 +0200| [79595024ed887e2f473ec21ad3596af2c3fc4041] | 
committer: Andreas Rheinhardt

avfilter/formats: Avoid redundant counter

The ff_set_common_(formats|channel_layouts|samplerates) have to free
their list in case it doesn't have an owner; therefore they tracked
whether they attached it to an owner. But the list's refcount already
contains such a counter, so we don't have to keep track of whether we
have attached the list to an owner.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79595024ed887e2f473ec21ad3596af2c3fc4041
---

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

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index ca85b4094b..8a92ff0d57 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -623,7 +623,7 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 }
 
 #define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn) \
-int count = 0, i;   \
+int i;  \
 \
 if (!fmts)  \
 return AVERROR(ENOMEM); \
@@ -634,7 +634,6 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 if (ret < 0) {  \
 return ret; \
 }   \
-count++;\
 }   \
 }   \
 for (i = 0; i < ctx->nb_outputs; i++) { \
@@ -643,13 +642,11 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 if (ret < 0) {  \
 return ret; \
 }   \
-count++;\
 }   \
 }   \
 \
-if (!count) {   \
+if (!fmts->refcount)\
 unref_fn(&fmts);\
-}   \
 \
 return 0;
 

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

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


[FFmpeg-cvslog] avfilter/formats: Don't set samplerate or channel count on video links

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Aug 15 10:15:09 2021 +0200| [4f46c3cf5c78cac303bf4c9877e8544f0e512449] | 
committer: Andreas Rheinhardt

avfilter/formats: Don't set samplerate or channel count on video links

This currently happens by accident in a few filters that use
ff_set_common_(samplerates|channel_layouts) like afir (if the response
option is set) or agraphmonitor (due to the default code in
avfiltergraph.c). So change those functions to make sure it does no
longer happen.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f46c3cf5c78cac303bf4c9877e8544f0e512449
---

 libavfilter/formats.c | 16 ++--
 libavfilter/formats.h |  6 +++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 8a92ff0d57..1bf7d36195 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -622,14 +622,16 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 FORMATS_CHANGEREF(oldref, newref);
 }
 
-#define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn) \
+#define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn) \
 int i;  \
 \
 if (!fmts)  \
 return AVERROR(ENOMEM); \
 \
 for (i = 0; i < ctx->nb_inputs; i++) {  \
-if (ctx->inputs[i] && !ctx->inputs[i]->outcfg.fmts) {   \
+AVFilterLink *const link = ctx->inputs[i];  \
+if (link && !link->outcfg.fmts &&   \
+(media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) 
{ \
 int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts);   \
 if (ret < 0) {  \
 return ret; \
@@ -637,7 +639,9 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 }   \
 }   \
 for (i = 0; i < ctx->nb_outputs; i++) { \
-if (ctx->outputs[i] && !ctx->outputs[i]->incfg.fmts) {  \
+AVFilterLink *const link = ctx->outputs[i]; \
+if (link && !link->incfg.fmts &&\
+(media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) 
{ \
 int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts);   \
 if (ret < 0) {  \
 return ret; \
@@ -653,7 +657,7 @@ void ff_formats_changeref(AVFilterFormats **oldref, 
AVFilterFormats **newref)
 int ff_set_common_channel_layouts(AVFilterContext *ctx,
   AVFilterChannelLayouts *channel_layouts)
 {
-SET_COMMON_FORMATS(ctx, channel_layouts,
+SET_COMMON_FORMATS(ctx, channel_layouts, AVMEDIA_TYPE_AUDIO,
ff_channel_layouts_ref, ff_channel_layouts_unref);
 }
 
@@ -671,7 +675,7 @@ int ff_set_common_all_channel_counts(AVFilterContext *ctx)
 int ff_set_common_samplerates(AVFilterContext *ctx,
   AVFilterFormats *samplerates)
 {
-SET_COMMON_FORMATS(ctx, samplerates,
+SET_COMMON_FORMATS(ctx, samplerates, AVMEDIA_TYPE_AUDIO,
ff_formats_ref, ff_formats_unref);
 }
 
@@ -693,7 +697,7 @@ int ff_set_common_all_samplerates(AVFilterContext *ctx)
  */
 int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
 {
-SET_COMMON_FORMATS(ctx, formats,
+SET_COMMON_FORMATS(ctx, formats, AVMEDIA_TYPE_UNKNOWN,
ff_formats_ref, ff_formats_unref);
 }
 
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 7c8258ed08..471cb42bc4 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -129,9 +129,9 @@ av_warn_unused_result
 AVFilterChannelLayouts *ff_make_format64_list(const int64_t *fmts);
 
 /**
- * A helper for query_formats() which sets all links to the same list of 
channel
- * layouts/sample rates. If there are no links hooked to this filter, the list
- * is freed.
+ * Helpers for query_formats() which set all free audio links to the same list
+ * of channel layouts/sample rates. If there are no links hooked to this list,
+ * the list is freed.
  */
 av_warn_unused_result
 int ff_set_common_channel_layouts(AVFilterContext *ctx,

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

To unsubscribe,

[FFmpeg-cvslog] avfilter/avfiltergraph: Remove dead checks

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Aug 15 10:26:06 2021 +0200| [3969c2abfb29c230cfce2ebfdcaaf6d0f0266b30] | 
committer: Andreas Rheinhardt

avfilter/avfiltergraph: Remove dead checks

These checks emit warnings in case the channel layouts lists are
inconsistent; yet since 69f5f6ea375950b4845b241ee27054bfc8f00343
a function that is called earlier errors out if they are inconsistent.

Reviewed-by: Nicolas George 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3969c2abfb29c230cfce2ebfdcaaf6d0f0266b30
---

 libavfilter/avfiltergraph.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 13c81a5f4a..383d9c5478 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -295,21 +295,6 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph 
*graph, const char *nam
 return NULL;
 }
 
-static void sanitize_channel_layouts(void *log, AVFilterChannelLayouts *l)
-{
-if (!l)
-return;
-if (l->nb_channel_layouts) {
-if (l->all_layouts || l->all_counts)
-av_log(log, AV_LOG_WARNING, "All layouts set on non-empty list\n");
-l->all_layouts = l->all_counts = 0;
-} else {
-if (l->all_counts && !l->all_layouts)
-av_log(log, AV_LOG_WARNING, "All counts without all layouts\n");
-l->all_layouts = 1;
-}
-}
-
 static int filter_link_check_formats(void *log, AVFilterLink *link, 
AVFilterFormatsConfig *cfg)
 {
 int ret;
@@ -359,7 +344,7 @@ static int filter_check_formats(AVFilterContext *ctx)
 
 static int filter_query_formats(AVFilterContext *ctx)
 {
-int ret, i;
+int ret;
 AVFilterFormats *formats;
 AVFilterChannelLayouts *chlayouts;
 enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs 
[0]->type :
@@ -376,11 +361,6 @@ static int filter_query_formats(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 
-for (i = 0; i < ctx->nb_inputs; i++)
-sanitize_channel_layouts(ctx, ctx->inputs[i]->outcfg.channel_layouts);
-for (i = 0; i < ctx->nb_outputs; i++)
-sanitize_channel_layouts(ctx, ctx->outputs[i]->incfg.channel_layouts);
-
 formats = ff_all_formats(type);
 if ((ret = ff_set_common_formats(ctx, formats)) < 0)
 return ret;

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

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


[FFmpeg-cvslog] doc/examples/encode_video: add explanations in comments.

2021-08-20 Thread Nicolas George
ffmpeg | branch: master | Nicolas George  | Mon Aug 16 
15:05:59 2021 +0200| [1698cd8422c8a363e25dd94beb61c0a6d68bd67c] | committer: 
Nicolas George

doc/examples/encode_video: add explanations in comments.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1698cd8422c8a363e25dd94beb61c0a6d68bd67c
---

 doc/examples/encode_video.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/doc/examples/encode_video.c b/doc/examples/encode_video.c
index 908eb203d5..939ed68324 100644
--- a/doc/examples/encode_video.c
+++ b/doc/examples/encode_video.c
@@ -155,12 +155,25 @@ int main(int argc, char **argv)
 for (i = 0; i < 25; i++) {
 fflush(stdout);
 
-/* make sure the frame data is writable */
+/* Make sure the frame data is writable.
+   On the first round, the frame is fresh from av_frame_get_buffer()
+   and therefore we know it is writable.
+   But on the next rounds, encode() will have called
+   avcodec_send_frame(), and the codec may have kept a reference to
+   the frame in its internal structures, that makes the frame
+   unwritable.
+   av_frame_make_writable() checks that and allocates a new buffer
+   for the frame only if necessary.
+ */
 ret = av_frame_make_writable(frame);
 if (ret < 0)
 exit(1);
 
-/* prepare a dummy image */
+/* Prepare a dummy image.
+   In real code, this is where you would have your own logic for
+   filling the frame. FFmpeg does not care what you put in the
+   frame.
+ */
 /* Y */
 for (y = 0; y < c->height; y++) {
 for (x = 0; x < c->width; x++) {
@@ -185,7 +198,12 @@ int main(int argc, char **argv)
 /* flush the encoder */
 encode(c, NULL, pkt, f);
 
-/* add sequence end code to have a real MPEG file */
+/* Add sequence end code to have a real MPEG file.
+   It makes only sense because this tiny examples writes packets
+   directly. This is called "elementary stream" and only works for some
+   codecs. To create a valid file, you usually need to write packets
+   into a proper file format or protocol; see muxing.c.
+ */
 if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == 
AV_CODEC_ID_MPEG2VIDEO)
 fwrite(endcode, 1, sizeof(endcode), f);
 fclose(f);

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

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


[FFmpeg-cvslog] lavc/aarch64: move transpose_4x8H to neon.S

2021-08-20 Thread Mikhail Nitenko
ffmpeg | branch: master | Mikhail Nitenko  | Fri Aug 20 
00:07:59 2021 +0300| [756d2e087a73c1e1ebe9647e085a1f5c90fa87de] | committer: 
Martin Storsjö

lavc/aarch64: move transpose_4x8H to neon.S

transpose_4x8H was declared in vp9lpf_16bpp_neon, however this macro is
not unique to vp9 and could be used elsewhere.

Signed-off-by: Mikhail Nitenko 
Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=756d2e087a73c1e1ebe9647e085a1f5c90fa87de
---

 libavcodec/aarch64/neon.S  | 13 +
 libavcodec/aarch64/vp9lpf_16bpp_neon.S | 12 
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavcodec/aarch64/neon.S b/libavcodec/aarch64/neon.S
index 0fddbecae3..1ad32c359d 100644
--- a/libavcodec/aarch64/neon.S
+++ b/libavcodec/aarch64/neon.S
@@ -109,12 +109,25 @@
 trn2\r5\().4H,  \r0\().4H,  \r1\().4H
 trn1\r6\().4H,  \r2\().4H,  \r3\().4H
 trn2\r7\().4H,  \r2\().4H,  \r3\().4H
+
 trn1\r0\().2S,  \r4\().2S,  \r6\().2S
 trn2\r2\().2S,  \r4\().2S,  \r6\().2S
 trn1\r1\().2S,  \r5\().2S,  \r7\().2S
 trn2\r3\().2S,  \r5\().2S,  \r7\().2S
 .endm
 
+.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7
+trn1\t4\().8H,  \r0\().8H,  \r1\().8H
+trn2\t5\().8H,  \r0\().8H,  \r1\().8H
+trn1\t6\().8H,  \r2\().8H,  \r3\().8H
+trn2\t7\().8H,  \r2\().8H,  \r3\().8H
+
+trn1\r0\().4S,  \t4\().4S,  \t6\().4S
+trn2\r2\().4S,  \t4\().4S,  \t6\().4S
+trn1\r1\().4S,  \t5\().4S,  \t7\().4S
+trn2\r3\().4S,  \t5\().4S,  \t7\().4S
+.endm
+
 .macro  transpose_8x8H  r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
 trn1\r8\().8H,  \r0\().8H,  \r1\().8H
 trn2\r9\().8H,  \r0\().8H,  \r1\().8H
diff --git a/libavcodec/aarch64/vp9lpf_16bpp_neon.S 
b/libavcodec/aarch64/vp9lpf_16bpp_neon.S
index 9075f3d406..9869614a29 100644
--- a/libavcodec/aarch64/vp9lpf_16bpp_neon.S
+++ b/libavcodec/aarch64/vp9lpf_16bpp_neon.S
@@ -22,18 +22,6 @@
 #include "neon.S"
 
 
-.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7
-trn1\t4\().8h,  \r0\().8h,  \r1\().8h
-trn2\t5\().8h,  \r0\().8h,  \r1\().8h
-trn1\t6\().8h,  \r2\().8h,  \r3\().8h
-trn2\t7\().8h,  \r2\().8h,  \r3\().8h
-
-trn1\r0\().4s,  \t4\().4s,  \t6\().4s
-trn2\r2\().4s,  \t4\().4s,  \t6\().4s
-trn1\r1\().4s,  \t5\().4s,  \t7\().4s
-trn2\r3\().4s,  \t5\().4s,  \t7\().4s
-.endm
-
 // The input to and output from this macro is in the registers v16-v31,
 // and v0-v7 are used as scratch registers.
 // p7 = v16 .. p3 = v20, p0 = v23, q0 = v24, q3 = v27, q7 = v31

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

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


[FFmpeg-cvslog] lavc/aarch64: h264, add chroma loop filters for 10bit

2021-08-20 Thread Mikhail Nitenko
ffmpeg | branch: master | Mikhail Nitenko  | Fri Aug 20 
00:08:00 2021 +0300| [43ca887bc2edaaa7dbcf40798f5345dda871cbe2] | committer: 
Martin Storsjö

lavc/aarch64: h264, add chroma loop filters for 10bit

Benchmarks: A53 A72
h264_h_loop_filter_chroma422_10bpp_c:  282.7   114.2
h264_h_loop_filter_chroma422_10bpp_neon:   109.578.5
h264_h_loop_filter_chroma_10bpp_c: 165.081.5
h264_h_loop_filter_chroma_10bpp_neon:  120.076.7
h264_h_loop_filter_chroma_intra422_10bpp_c:323.7   124.2
h264_h_loop_filter_chroma_intra422_10bpp_neon: 155.0   102.7
h264_h_loop_filter_chroma_intra_10bpp_c:   121.049.5
h264_h_loop_filter_chroma_intra_10bpp_neon: 79.753.7
h264_h_loop_filter_chroma_mbaff422_10bpp_c:188.575.0
h264_h_loop_filter_chroma_mbaff422_10bpp_neon: 120.075.5
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_c:  116.746.0
h264_h_loop_filter_chroma_mbaff_intra422_10bpp_neon:79.753.7
h264_h_loop_filter_chroma_mbaff_intra_10bpp_c:  63.027.2
h264_h_loop_filter_chroma_mbaff_intra_10bpp_neon:   48.534.0
h264_v_loop_filter_chroma_10bpp_c: 258.7   135.5
h264_v_loop_filter_chroma_10bpp_neon:   71.251.0
h264_v_loop_filter_chroma_intra_10bpp_c:   158.070.7
h264_v_loop_filter_chroma_intra_10bpp_neon: 48.731.5

Signed-off-by: Mikhail Nitenko 
Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43ca887bc2edaaa7dbcf40798f5345dda871cbe2
---

 libavcodec/aarch64/h264dsp_init_aarch64.c |  37 +
 libavcodec/aarch64/h264dsp_neon.S | 255 ++
 2 files changed, 292 insertions(+)

diff --git a/libavcodec/aarch64/h264dsp_init_aarch64.c 
b/libavcodec/aarch64/h264dsp_init_aarch64.c
index cbaf8d31eb..6bf3ecb8a1 100644
--- a/libavcodec/aarch64/h264dsp_init_aarch64.c
+++ b/libavcodec/aarch64/h264dsp_init_aarch64.c
@@ -83,6 +83,29 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int 
*block_offset,
  int16_t *block, int stride,
  const uint8_t nnzc[5 * 8]);
 
+void ff_h264_v_loop_filter_luma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_luma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+int beta, int8_t *tc0);
+void ff_h264_v_loop_filter_luma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, 
int alpha,
+  int beta);
+void ff_h264_h_loop_filter_luma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, 
int alpha,
+  int beta);
+void ff_h264_v_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+  int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int 
alpha,
+  int beta, int8_t *tc0);
+void ff_h264_h_loop_filter_chroma422_neon_10(uint8_t *pix, ptrdiff_t stride, 
int alpha,
+ int beta, int8_t *tc0);
+void ff_h264_v_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride,
+int alpha, int beta);
+void ff_h264_h_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride,
+int alpha, int beta);
+void ff_h264_h_loop_filter_chroma422_intra_neon_10(uint8_t *pix, ptrdiff_t 
stride,
+   int alpha, int beta);
+void ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10(uint8_t *pix, ptrdiff_t 
stride,
+  int alpha, int beta);
+
 av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth,
  const int chroma_format_idc)
 {
@@ -125,5 +148,19 @@ av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, 
const int bit_depth,
 c->h264_idct8_add   = ff_h264_idct8_add_neon;
 c->h264_idct8_dc_add= ff_h264_idct8_dc_add_neon;
 c->h264_idct8_add4  = ff_h264_idct8_add4_neon;
+} else if (have_neon(cpu_flags) && bit_depth == 10) {
+c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon_10;
+c->h264_v_loop_filter_chroma_intra = 
ff_h264_v_loop_filter_chroma_intra_neon_10;
+
+if (chroma_format_idc <= 1) {
+c->h264_h_loop_filter_chroma = 
ff_h264_h_loop_filter_chroma_neon_10;
+c->h264_h_loop_filter_chroma_intra = 
ff_h264_h_loop_filter_chroma_intra_neon_10;
+c->h264_h_loop_filter_chroma_mbaff_intra = 
ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10;
+} else {
+ 

[FFmpeg-cvslog] lavc/aarch64: add pred functions for 10-bit

2021-08-20 Thread Mikhail Nitenko
ffmpeg | branch: master | Mikhail Nitenko  | Fri Aug 20 
00:00:38 2021 +0300| [d3e56b56ae2193f3709d541aabba3ccc7e3f61a6] | committer: 
Martin Storsjö

lavc/aarch64: add pred functions for 10-bit

Benchmarks:A53 A72
pred8x8_dc_10_c:   64.249.5
pred8x8_dc_10_neon:62.053.7
pred8x8_dc_128_10_c:   26.014.0
pred8x8_dc_128_10_neon:30.717.5
pred8x8_horizontal_10_c:   60.027.7
pred8x8_horizontal_10_neon:38.034.0
pred8x8_left_dc_10_c:  42.527.5
pred8x8_left_dc_10_neon:   51.041.2
pred8x8_mad_cow_dc_0l0_10_c:   55.737.2
pred8x8_mad_cow_dc_0l0_10_neon:50.235.2
pred8x8_mad_cow_dc_0lt_10_c:   89.267.0
pred8x8_mad_cow_dc_0lt_10_neon:52.246.7
pred8x8_mad_cow_dc_l0t_10_c:   74.751.0
pred8x8_mad_cow_dc_l0t_10_neon:50.545.2
pred8x8_mad_cow_dc_l00_10_c:   58.038.0
pred8x8_mad_cow_dc_l00_10_neon:42.537.5
pred8x8_plane_10_c:   354.0   288.7
pred8x8_plane_10_neon:141.0   101.2
pred8x8_top_dc_10_c:   44.530.5
pred8x8_top_dc_10_neon:40.031.0
pred8x8_vertical_10_c: 27.514.5
pred8x8_vertical_10_neon:  21.017.5
pred16x16_plane_10_c:1242.0  1070.5
pred16x16_plane_10_neon:  324.0   196.7

Signed-off-by: Mikhail Nitenko 
Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d3e56b56ae2193f3709d541aabba3ccc7e3f61a6
---

 libavcodec/aarch64/h264pred_init.c |  40 -
 libavcodec/aarch64/h264pred_neon.S | 304 -
 2 files changed, 337 insertions(+), 7 deletions(-)

diff --git a/libavcodec/aarch64/h264pred_init.c 
b/libavcodec/aarch64/h264pred_init.c
index 325a86bfcd..0ae8f70d23 100644
--- a/libavcodec/aarch64/h264pred_init.c
+++ b/libavcodec/aarch64/h264pred_init.c
@@ -45,10 +45,23 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride);
 void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride);
 void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride);
 
-void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
-void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride);
-void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride);
 void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_plane_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+
+void ff_pred8x8_vert_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_hor_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_plane_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_128_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_left_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_l0t_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_0lt_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_l00_dc_neon_10(uint8_t *src, ptrdiff_t stride);
+void ff_pred8x8_0l0_dc_neon_10(uint8_t *src, ptrdiff_t stride);
 
 static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
 const int bit_depth,
@@ -84,10 +97,31 @@ static av_cold void h264_pred_init_neon(H264PredContext *h, 
int codec_id,
 h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon;
 }
 if (bit_depth == 10) {
+if (chroma_format_idc <= 1) {
+h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon_10;
+h->pred8x8[HOR_PRED8x8  ] = ff_pred8x8_hor_neon_10;
+if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
+h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon_10;
+h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon_10;
+if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
+codec_id != AV_CODEC_ID_VP8) {
+h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon_10;
+h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon_10;
+h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = 
ff_pred8x8_l0t_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = 
ff_pred8x8_0lt_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = 
ff_pred8x8_l00_dc_neon_10;
+h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = 
ff_pred8x8_0l0_dc_neon_10;
+}
+}
+
 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10;
 h->pred16x16[VERT_PRED8x8   ] = ff_pred16x16_vert_neon_10;
 h->pred16x16[HOR_PRED8x

[FFmpeg-cvslog] avfilter/vf_convolution: Add mem_internal.h for DECLARE_ALIGNED

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Aug 20 04:26:05 2021 +0200| [78a4a76c8509c7c6fd919d2dde032defe1695111] | 
committer: Andreas Rheinhardt

avfilter/vf_convolution: Add mem_internal.h for DECLARE_ALIGNED

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78a4a76c8509c7c6fd919d2dde032defe1695111
---

 libavfilter/vf_convolution.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 5d889affa6..9824edd452 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -22,6 +22,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"

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

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


[FFmpeg-cvslog] doc/filters.texi: Correct asegment example

2021-08-20 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Tue Aug 17 02:43:02 2021 +0200| [a1094eaa304efcf11c8da027c7e02978c7a9792a] | 
committer: Andreas Rheinhardt

doc/filters.texi: Correct asegment example

Reviewed-by: Paul B Mahol 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a1094eaa304efcf11c8da027c7e02978c7a9792a
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 480cab706c..a5752c4d6e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25715,7 +25715,7 @@ Split input audio stream into three output audio 
streams, starting at start of i
 and storing that in 1st output audio stream, then following at 60th second and 
storing than in 2nd
 output audio stream, and last after 150th second of input audio stream store 
in 3rd output audio stream:
 @example
-asegment=timestamps="60 | 150"
+asegment=timestamps="60|150"
 @end example
 
 @end itemize

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

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