[FFmpeg-cvslog] avformat/argo_asf: Use memcpy to copy string without its NUL

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 26 04:07:30 2021 +0200| [3022f7487474ebb2812ae5e05b4be9b40431c20e] | 
committer: Andreas Rheinhardt

avformat/argo_asf: Use memcpy to copy string without its NUL

This avoids a -Wstringop-truncation warning from GCC which takes
issue with the fact that the destination might not be NUL-terminated.

Reviewed-by: Zane van Iperen 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/argo_asf.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 5adafb7230..7e759c7c0c 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -356,25 +356,19 @@ static int argo_asf_write_header(AVFormatContext *s)
 .num_chunks= 1,
 .chunk_offset  = ASF_FILE_HEADER_SIZE
 };
+const char *name = ctx->name, *end;
+size_t len;
 
 /*
  * If the user specified a name, use it as is. Otherwise take the
  * basename and lop off the extension (if any).
  */
-if (ctx->name) {
-strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
+if (name || !(end = strrchr((name = av_basename(s->url)), '.'))) {
+len = strlen(name);
 } else {
-const char *start = av_basename(s->url);
-const char *end   = strrchr(start, '.');
-size_t  len;
-
-if (end)
-len = end - start;
-else
-len = strlen(start);
-
-memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name)));
+len = end - name;
 }
+memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name)));
 
 chdr.num_blocks= 0;
 chdr.num_samples   = ASF_SAMPLE_COUNT;

___
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] avformat/dv: Set AVFMTCTX_NOHEADER flag

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Aug 28 12:51:14 2021 +0200| [2b787ef766941a7565ac143f52d2f5954b9db6e9] | 
committer: Andreas Rheinhardt

avformat/dv: Set AVFMTCTX_NOHEADER flag

Audio streams are only added when a packet is read.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/dv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 4d27c95d98..77a6ede37b 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -345,6 +345,9 @@ static int dv_init_demux(AVFormatContext *s, DVDemuxContext 
*c)
 c->vst->codecpar->bit_rate   = 2500;
 c->vst->start_time= 0;
 
+/* Audio streams are added later as they are encountered. */
+s->ctx_flags |= AVFMTCTX_NOHEADER;
+
 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/vf_selectivecolor: reduce number of operations with r/g/b/a pointers

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Sep 25 21:10:42 
2021 +0200| [314ee127f3cf29905fbb38998ab2a65de0856f75] | committer: Paul B Mahol

avfilter/vf_selectivecolor: reduce number of operations with r/g/b/a pointers

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

 libavfilter/vf_selectivecolor.c | 41 +
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c
index 9d789a6d8b..398d4bec0d 100644
--- a/libavfilter/vf_selectivecolor.c
+++ b/libavfilter/vf_selectivecolor.c
@@ -322,24 +322,31 @@ static inline int selective_color_##nbits(AVFilterContext 
*ctx, ThreadData *td,
 const int width  = in->width;  
 \
 const int slice_start = (height *  jobnr   ) / nb_jobs;
 \
 const int slice_end   = (height * (jobnr+1)) / nb_jobs;
 \
-const int dst_linesize = out->linesize[0]; 
 \
-const int src_linesize =  in->linesize[0]; 
 \
+const int dst_linesize = out->linesize[0] / ((nbits + 7) / 8); 
 \
+const int src_linesize =  in->linesize[0] / ((nbits + 7) / 8); 
 \
 const uint8_t roffset = s->rgba_map[R];
 \
 const uint8_t goffset = s->rgba_map[G];
 \
 const uint8_t boffset = s->rgba_map[B];
 \
 const uint8_t aoffset = s->rgba_map[A];
 \
+uint##nbits##_t *dst = (uint##nbits##_t *)out->data[0] + slice_start * 
dst_linesize;\
+const uint##nbits##_t *src = (const uint##nbits##_t *)in->data[0] + 
slice_start * src_linesize; \
+const uint##nbits##_t *src_r = (const uint##nbits##_t *)src + roffset; 
 \
+const uint##nbits##_t *src_g = (const uint##nbits##_t *)src + goffset; 
 \
+const uint##nbits##_t *src_b = (const uint##nbits##_t *)src + boffset; 
 \
+const uint##nbits##_t *src_a = (const uint##nbits##_t *)src + aoffset; 
 \
+uint##nbits##_t *dst_r = (uint##nbits##_t *)dst + roffset; 
 \
+uint##nbits##_t *dst_g = (uint##nbits##_t *)dst + goffset; 
 \
+uint##nbits##_t *dst_b = (uint##nbits##_t *)dst + boffset; 
 \
+uint##nbits##_t *dst_a = (uint##nbits##_t *)dst + aoffset; 
 \
 const int mid = 1<<(nbits-1);  
 \
 const int max = (1data[0] + 
y * src_linesize);\
-   
 \
 for (x = 0; x < width * s->step; x += s->step) {   
 \
-const int r = src[x + roffset];
 \
-const int g = src[x + goffset];
 \
-const int b = src[x + boffset];
 \
+const int r = src_r[x];
 \
+const int g = src_g[x];
 \
+const int b = src_b[x];
 \
 const int min_color = FFMIN3(r, g, b); 
 \
 const int max_color = FFMAX3(r, g, b); 
 \
 const int is_white   = (r > mid && g > mid && b > mid);
 \
@@ -382,13 +389,23 @@ static inline int selective_color_##nbits(AVFilterContext 
*ctx, ThreadData *td,
 }  
 \

 \
 if (!direct || adjust_r || adjust_g || adjust_b) { 
 \
-dst[x + roffset] = av_clip_uint##nbits(r + adjust_r);  

[FFmpeg-cvslog] avfilter/vf_selectivecolor: refactor some repeating calculations

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Sep 25 20:48:03 
2021 +0200| [69f4fdd10d7a7657efbf90da1546273538b1e97d] | committer: Paul B Mahol

avfilter/vf_selectivecolor: refactor some repeating calculations

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

 libavfilter/vf_selectivecolor.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c
index ebbba9157f..9d789a6d8b 100644
--- a/libavfilter/vf_selectivecolor.c
+++ b/libavfilter/vf_selectivecolor.c
@@ -328,6 +328,9 @@ static inline int selective_color_##nbits(AVFilterContext 
*ctx, ThreadData *td,
 const uint8_t goffset = s->rgba_map[G];
 \
 const uint8_t boffset = s->rgba_map[B];
 \
 const uint8_t aoffset = s->rgba_map[A];
 \
+const int mid = 1<<(nbits-1);  
 \
+const int max = (1 1<<(nbits-1) && g > 1<<(nbits-1) && b 
> 1<<(nbits-1));  \
+const int is_white   = (r > mid && g > mid && b > mid);
 \
 const int is_neutral = (r || g || b) &&
 \
-   (r != (1

[FFmpeg-cvslog] avfilter/vf_colorbalance: fix min/max check that can never be true

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 11:16:04 
2021 +0200| [7b5df3b545a3829459b9980d632f3002a28948b6] | committer: Paul B Mahol

avfilter/vf_colorbalance: fix min/max check that can never be true

While here change doubles to floats.

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

 libavfilter/vf_colorbalance.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_colorbalance.c b/libavfilter/vf_colorbalance.c
index 23235347e9..8055829adf 100644
--- a/libavfilter/vf_colorbalance.c
+++ b/libavfilter/vf_colorbalance.c
@@ -100,23 +100,23 @@ static float get_component(float v, float l,
 {
 const float a = 4.f, b = 0.333f, scale = 0.7f;
 
-s *= av_clipf((b - l) * a + 0.5f, 0, 1) * scale;
-m *= av_clipf((l - b) * a + 0.5f, 0, 1) * av_clipf((1.0 - l - b) * a + 
0.5f, 0, 1) * scale;
-h *= av_clipf((l + b - 1) * a + 0.5f, 0, 1) * scale;
+s *= av_clipf((b - l) * a + 0.5f, 0.f, 1.f) * scale;
+m *= av_clipf((l - b) * a + 0.5f, 0.f, 1.f) * av_clipf((1.f - l - b) * a + 
0.5f, 0.f, 1.f) * scale;
+h *= av_clipf((l + b - 1) * a + 0.5f, 0.f, 1.f) * scale;
 
 v += s;
 v += m;
 v += h;
 
-return av_clipf(v, 0, 1);
+return av_clipf(v, 0.f, 1.f);
 }
 
 static float hfun(float n, float h, float s, float l)
 {
-float a = s * FFMIN(l, 1. - l);
+float a = s * FFMIN(l, 1.f - l);
 float k = fmodf(n + h / 30.f, 12.f);
 
-return av_clipf(l - a * FFMAX(FFMIN3(k - 3.f, 9.f - k, 1), -1.f), 0, 1);
+return av_clipf(l - a * FFMAX(FFMIN3(k - 3.f, 9.f - k, 1), -1.f), 0.f, 
1.f);
 }
 
 static void preservel(float *r, float *g, float *b, float l)
@@ -125,31 +125,31 @@ static void preservel(float *r, float *g, float *b, float 
l)
 float min = FFMIN3(*r, *g, *b);
 float h, s;
 
-l *= 0.5;
+l *= 0.5f;
 
 if (*r == *g && *g == *b) {
-h = 0.;
+h = 0.f;
 } else if (max == *r) {
-h = 60. * (0. + (*g - *b) / (max - min));
+h = 60.f * (0.f + (*g - *b) / (max - min));
 } else if (max == *g) {
-h = 60. * (2. + (*b - *r) / (max - min));
+h = 60.f * (2.f + (*b - *r) / (max - min));
 } else if (max == *b) {
-h = 60. * (4. + (*r - *g) / (max - min));
+h = 60.f * (4.f + (*r - *g) / (max - min));
 } else {
-h = 0.;
+h = 0.f;
 }
-if (h < 0.)
-h += 360.;
+if (h < 0.f)
+h += 360.f;
 
-if (max == 0. || min == 1.) {
-s = 0.;
+if (max == 1.f || min == 0.f) {
+s = 0.f;
 } else {
-s = (max - min) / (1. - FFABS(2. * l - 1));
+s = (max - min) / (1.f - (FFABS(2.f * l - 1.f)));
 }
 
-*r = hfun(0, h, s, l);
-*g = hfun(8, h, s, l);
-*b = hfun(4, h, s, l);
+*r = hfun(0.f, h, s, l);
+*g = hfun(8.f, h, s, l);
+*b = hfun(4.f, h, s, l);
 }
 
 static int color_balance8_p(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)

___
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_swaprect: Use ff_formats_pixdesc_filter()

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Sep 25 23:38:26 2021 +0200| [aff855148a098c70c0a55c58aeb1205d839ed516] | 
committer: Andreas Rheinhardt

avfilter/vf_swaprect: Use ff_formats_pixdesc_filter()

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

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

 libavfilter/vf_swaprect.c | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_swaprect.c b/libavfilter/vf_swaprect.c
index 4a5f4a12a6..fff9b53dc4 100644
--- a/libavfilter/vf_swaprect.c
+++ b/libavfilter/vf_swaprect.c
@@ -22,7 +22,6 @@
 #include "libavutil/eval.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
 
 #include "avfilter.h"
 #include "formats.h"
@@ -59,16 +58,13 @@ AVFILTER_DEFINE_CLASS(swaprect);
 static int query_formats(AVFilterContext *ctx)
 {
 AVFilterFormats *pix_fmts = NULL;
-int fmt, ret;
-
-for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
-  desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
-  desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) &&
-(ret = ff_add_format(&pix_fmts, fmt)) < 0)
-return ret;
-}
+int ret;
+
+ret = ff_formats_pixdesc_filter(&pix_fmts, 0, AV_PIX_FMT_FLAG_PAL |
+  AV_PIX_FMT_FLAG_HWACCEL |
+  AV_PIX_FMT_FLAG_BITSTREAM);
+if (ret < 0)
+return ret;
 
 return ff_set_common_formats(ctx, pix_fmts);
 }

___
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 reallocations for video in ff_all_formats()

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 26 00:28:19 2021 +0200| [f348a967a35c0946de0d9f6bedb1f4025b09b334] | 
committer: Andreas Rheinhardt

avfilter/formats: Avoid reallocations for video in ff_all_formats()

Up until now, the list of pixfmts is reallocated every time an entry
is added to it; there are currently 196 pixel formats, so this matters:
It causes 5541704 calls to av_realloc_array() in a typical FATE run,
which is the majority for said function (8095768 calls) and even
a large chunk of the calls to av_realloc() itself (12589508 calls).

Fix this by using ff_formats_pixdesc_filter() instead.

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

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

 libavfilter/formats.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 59ea966424..1d2a51c0af 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -435,11 +435,7 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type)
 AVFilterFormats *ret = NULL;
 
 if (type == AVMEDIA_TYPE_VIDEO) {
-const AVPixFmtDescriptor *desc = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-if (ff_add_format(&ret, av_pix_fmt_desc_get_id(desc)) < 0)
-return NULL;
-}
+return ff_formats_pixdesc_filter(0, 0);
 } else if (type == AVMEDIA_TYPE_AUDIO) {
 enum AVSampleFormat fmt = 0;
 while (av_get_sample_fmt_name(fmt)) {

___
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: Make ff_formats_pixdesc_filter return AVFilterFormats*

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 26 00:09:16 2021 +0200| [99feb59cf7ea9d6753502d76110ced96f128dac6] | 
committer: Andreas Rheinhardt

avfilter/formats: Make ff_formats_pixdesc_filter return AVFilterFormats*

Up until now, it has returned the AVFilterFormats list via
an AVFilterFormats** parameter; the actual return value was an int
that was always AVERROR(ENOMEM) on error. The AVFilterFormats**
argument was a pure output parameter which was only documented
by naming the parameter rfmts. Yet nevertheless all callers
initialized the underlying AVFilterFormats* to NULL.

This commit changes this to return a pointer to AVFilterFormats
directly. This is more in line with the API in general, as it
allows to avoid checks for intermediate values.

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

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

 libavfilter/formats.c   |  9 -
 libavfilter/formats.h   |  2 +-
 libavfilter/vf_copy.c   |  9 +
 libavfilter/vf_crop.c   |  8 ++--
 libavfilter/vf_detelecine.c | 13 -
 libavfilter/vf_fieldhint.c  | 13 -
 libavfilter/vf_hwdownload.c |  9 -
 libavfilter/vf_il.c | 10 ++
 libavfilter/vf_mix.c| 13 -
 libavfilter/vf_stack.c  | 13 -
 libavfilter/vf_swaprect.c   | 13 -
 libavfilter/vf_telecine.c   | 15 +--
 libavfilter/vf_untile.c | 15 +--
 libavfilter/vf_weave.c  | 10 ++
 14 files changed, 46 insertions(+), 106 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 1bf7d36195..59ea966424 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -452,7 +452,7 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type)
 return ret;
 }
 
-int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned 
rej)
+AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej)
 {
 unsigned nb_formats, fmt, flags;
 AVFilterFormats *formats = NULL;
@@ -476,18 +476,17 @@ int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, 
unsigned want, unsigned r
 }
 if (formats) {
 av_assert0(formats->nb_formats == nb_formats);
-*rfmts = formats;
-return 0;
+return formats;
 }
 formats = av_mallocz(sizeof(*formats));
 if (!formats)
-return AVERROR(ENOMEM);
+return NULL;
 formats->nb_formats = nb_formats;
 if (nb_formats) {
 formats->formats = av_malloc_array(nb_formats, 
sizeof(*formats->formats));
 if (!formats->formats) {
 av_freep(&formats);
-return AVERROR(ENOMEM);
+return NULL;
 }
 }
 }
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index 471cb42bc4..42fe068765 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -230,7 +230,7 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type);
  * properties
  */
 av_warn_unused_result
-int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned 
rej);
+AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej);
 
 //* format is software, non-planar with sub-sampling
 #define FF_PIX_FMT_FLAG_SW_FLAT_SUB (1 << 24)
diff --git a/libavfilter/vf_copy.c b/libavfilter/vf_copy.c
index 16fbe438a1..0ed61324e7 100644
--- a/libavfilter/vf_copy.c
+++ b/libavfilter/vf_copy.c
@@ -29,14 +29,7 @@
 
 static int query_formats(AVFilterContext *ctx)
 {
-AVFilterFormats *formats = NULL;
-int ret;
-
-ret = ff_formats_pixdesc_filter(&formats, 0,
-AV_PIX_FMT_FLAG_HWACCEL);
-if (ret < 0)
-return ret;
-return ff_set_common_formats(ctx, formats);
+return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
AV_PIX_FMT_FLAG_HWACCEL));
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 76d375cdfc..27ae1b8118 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -93,13 +93,9 @@ typedef struct CropContext {
 
 static int query_formats(AVFilterContext *ctx)
 {
-AVFilterFormats *formats = NULL;
-int ret;
+int reject_flags = AV_PIX_FMT_FLAG_BITSTREAM | FF_PIX_FMT_FLAG_SW_FLAT_SUB;
 
-ret = ff_formats_pixdesc_filter(&formats, 0, AV_PIX_FMT_FLAG_BITSTREAM | 
FF_PIX_FMT_FLAG_SW_FLAT_SUB);
-if (ret < 0)
-return ret;
-return ff_set_common_formats(ctx, formats);
+return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, 
reject_flags));
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
diff --git a/libavfilter/vf_detelecine.c b/libavfilter/vf_detelecine.c
index 7f34a88217..e36e1a6245 100644
--- a/libavfilter/vf_detelecine.c
+++ b/libavfilter/vf_detelecine.c
@@ -124,16 +124,11 @@ static av_c

[FFmpeg-cvslog] avcodec/tests/avcodec: Add basic sanity checks for AVCodec properties

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 05:15:02 2021 +0200| [0d97317429520b97d5817d713d6ffe7de78d0068] | 
committer: Andreas Rheinhardt

avcodec/tests/avcodec: Add basic sanity checks for AVCodec properties

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

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

 libavcodec/tests/avcodec.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c
index 9232647ff0..2b8a9a5d0f 100644
--- a/libavcodec/tests/avcodec.c
+++ b/libavcodec/tests/avcodec.c
@@ -18,12 +18,48 @@
 
 #include "libavcodec/avcodec.h"
 
+static const char *get_type_string(enum AVMediaType type)
+{
+const char *ret = av_get_media_type_string(type);
+return ret ? ret : "unknown";
+}
+
+#define AV_LOG(...) av_log(NULL, AV_LOG_FATAL, __VA_ARGS__)
+#define ERR_INTERNAL(msg, ...)  \
+do {\
+AV_LOG(msg, codec->name __VA_ARGS__);   \
+ret = 1;\
+} while (0)
+#define ERR(msg)   ERR_INTERNAL(msg, )
+#define ERR_EXT(msg, ...)  ERR_INTERNAL(msg, , __VA_ARGS__)
+
 int main(void){
 void *iter = NULL;
 const AVCodec *codec = NULL;
 int ret = 0;
 
 while (codec = av_codec_iterate(&iter)) {
+if (!codec->name) {
+AV_LOG("Codec for format %s has no name\n",
+   avcodec_get_name(codec->id));
+ret = 1;
+continue;
+}
+if (codec->type != AVMEDIA_TYPE_VIDEO &&
+codec->type != AVMEDIA_TYPE_AUDIO &&
+codec->type != AVMEDIA_TYPE_SUBTITLE)
+ERR_EXT("Codec %s has unsupported type %s\n",
+get_type_string(codec->type));
+if (codec->type != AVMEDIA_TYPE_AUDIO) {
+if (codec->channel_layouts || codec->sample_fmts ||
+codec->supported_samplerates)
+ERR("Non-audio codec %s has audio-only fields set\n");
+}
+if (codec->type != AVMEDIA_TYPE_VIDEO) {
+if (codec->pix_fmts || codec->supported_framerates)
+ERR("Non-video codec %s has video-only fields set\n");
+}
+
 if (av_codec_is_encoder(codec)) {
 if (codec->type == AVMEDIA_TYPE_AUDIO) {
 if (!codec->sample_fmts) {

___
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/tests/utils: Rename to avcodec

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 02:27:17 2021 +0200| [136865413c04760aeeda6079002bc3c1f9ae230a] | 
committer: Andreas Rheinhardt

avcodec/tests/utils: Rename to avcodec

The current name comes from a time in which libavcodec/utils.c
contained the whole core of libavcodec.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/Makefile | 4 ++--
 libavcodec/tests/{utils.c => avcodec.c} | 0
 tests/fate/libavcodec.mak   | 8 
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 11873eecae..8012b69f61 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1209,13 +1209,13 @@ SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h 
vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
v4l2_m2m.h
 
-TESTPROGS = avpacket\
+TESTPROGS = avcodec \
+avpacket\
 celp_math   \
 codec_desc  \
 htmlsubtitles   \
 jpeg2000dwt \
 mathops\
-utils   \
 
 TESTPROGS-$(CONFIG_CABAC) += cabac
 TESTPROGS-$(CONFIG_DCT)   += avfft
diff --git a/libavcodec/tests/utils.c b/libavcodec/tests/avcodec.c
similarity index 100%
rename from libavcodec/tests/utils.c
rename to libavcodec/tests/avcodec.c
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 682296914a..aa199e0308 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -79,10 +79,10 @@ FATE_LIBAVCODEC-$(CONFIG_JPEG2000_ENCODER) += fate-j2k-dwt
 fate-j2k-dwt: libavcodec/tests/jpeg2000dwt$(EXESUF)
 fate-j2k-dwt: CMD = run libavcodec/tests/jpeg2000dwt$(EXESUF)
 
-FATE_LIBAVCODEC-yes += fate-libavcodec-utils
-fate-libavcodec-utils: libavcodec/tests/utils$(EXESUF)
-fate-libavcodec-utils: CMD = run libavcodec/tests/utils$(EXESUF)
-fate-libavcodec-utils: CMP = null
+FATE_LIBAVCODEC-yes += fate-libavcodec-avcodec
+fate-libavcodec-avcodec: libavcodec/tests/avcodec$(EXESUF)
+fate-libavcodec-avcodec: CMD = run libavcodec/tests/avcodec$(EXESUF)
+fate-libavcodec-avcodec: CMP = null
 
 FATE_LIBAVCODEC-yes += fate-libavcodec-huffman
 fate-libavcodec-huffman: libavcodec/tests/mjpegenc_huffman$(EXESUF)

___
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/tests/avcodec: Test AVCodec and AVCodecDescriptor consistency

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 02:34:50 2021 +0200| [d77798309fa9527cce3e5811e9cdd85214335846] | 
committer: Andreas Rheinhardt

avcodec/tests/avcodec: Test AVCodec and AVCodecDescriptor consistency

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

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

 libavcodec/tests/avcodec.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c
index 2b8a9a5d0f..24372cfa1f 100644
--- a/libavcodec/tests/avcodec.c
+++ b/libavcodec/tests/avcodec.c
@@ -16,7 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/avcodec.h"
+#include "libavcodec/codec.h"
+#include "libavcodec/codec_desc.h"
 
 static const char *get_type_string(enum AVMediaType type)
 {
@@ -39,6 +40,8 @@ int main(void){
 int ret = 0;
 
 while (codec = av_codec_iterate(&iter)) {
+const AVCodecDescriptor *desc;
+
 if (!codec->name) {
 AV_LOG("Codec for format %s has no name\n",
avcodec_get_name(codec->id));
@@ -68,6 +71,12 @@ int main(void){
 }
 }
 }
+if (!(desc = avcodec_descriptor_get(codec->id))) {
+ERR("Codec %s lacks a corresponding descriptor\n");
+} else if (desc->type != codec->type)
+ERR_EXT("The type of AVCodec %s and its AVCodecDescriptor differ: "
+"%s vs %s\n",
+get_type_string(codec->type), get_type_string(desc->type));
 }
 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] avcodec/tests/avcodec: Check consistency of function pointers

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 03:52:56 2021 +0200| [497c490a4e1689242e7385f04e2bef7408d3a5e2] | 
committer: Andreas Rheinhardt

avcodec/tests/avcodec: Check consistency of function pointers

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

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

 libavcodec/tests/avcodec.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c
index 24372cfa1f..df7e7129a5 100644
--- a/libavcodec/tests/avcodec.c
+++ b/libavcodec/tests/avcodec.c
@@ -41,6 +41,7 @@ int main(void){
 
 while (codec = av_codec_iterate(&iter)) {
 const AVCodecDescriptor *desc;
+int is_decoder, is_encoder;
 
 if (!codec->name) {
 AV_LOG("Codec for format %s has no name\n",
@@ -63,13 +64,33 @@ int main(void){
 ERR("Non-video codec %s has video-only fields set\n");
 }
 
-if (av_codec_is_encoder(codec)) {
+is_decoder = av_codec_is_decoder(codec);
+is_encoder = av_codec_is_encoder(codec);
+if (!!is_decoder + !!is_encoder != 1) {
+ERR("Codec %s is decoder and encoder or neither.\n");
+continue;
+}
+if (is_encoder) {
+if (codec->type == AVMEDIA_TYPE_SUBTITLE ^ !!codec->encode_sub)
+ERR("Encoder %s is both subtitle encoder and not subtitle 
encoder.");
+if (!!codec->encode_sub + !!codec->encode2 + 
!!codec->receive_packet != 1)
+ERR("Encoder %s does not implement exactly one encode API.\n");
+if (codec->update_thread_context || 
codec->update_thread_context_for_user || codec->bsfs)
+ERR("Encoder %s has decoder-only thread functions or bsf.\n");
 if (codec->type == AVMEDIA_TYPE_AUDIO) {
 if (!codec->sample_fmts) {
 av_log(NULL, AV_LOG_FATAL, "Encoder %s is missing the 
sample_fmts field\n", codec->name);
 ret = 1;
 }
 }
+} else {
+if (codec->type == AVMEDIA_TYPE_SUBTITLE && !codec->decode)
+ERR("Subtitle decoder %s does not implement decode 
callback\n");
+if (codec->type == AVMEDIA_TYPE_SUBTITLE && codec->bsfs)
+ERR("Automatic bitstream filtering unsupported for subtitles; "
+"yet decoder %s has it set\n");
+if (!!codec->decode + !!codec->receive_frame != 1)
+ERR("Decoder %s does not implement exactly one decode API.\n");
 }
 if (!(desc = avcodec_descriptor_get(codec->id))) {
 ERR("Codec %s lacks a corresponding descriptor\n");

___
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/j2kenc: Fix AV_OPT_TYPE_CONST offsets

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 04:33:10 2021 +0200| [5aac4b669a4d0e69ad556eedb6305005198a309d] | 
committer: Andreas Rheinhardt

avcodec/j2kenc: Fix AV_OPT_TYPE_CONST offsets

They are supposed to be zero.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/j2kenc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 7ebd6856e0..71010509ec 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1818,11 +1818,11 @@ static const AVOption options[] = {
 { "sop",   "SOP marker",OFFSET(sop),   
AV_OPT_TYPE_INT,   { .i64 = 0   }, 0, 1,   VE, },
 { "eph",   "EPH marker",OFFSET(eph),   
AV_OPT_TYPE_INT,   { .i64 = 0   }, 0, 1,   VE, },
 { "prog",  "Progression Order", OFFSET(prog),  
AV_OPT_TYPE_INT,   { .i64 = 0   }, JPEG2000_PGOD_LRCP, 
JPEG2000_PGOD_CPRL,   VE, "prog" },
-{ "lrcp",  NULL,OFFSET(prog),  
AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_LRCP   }, 0, 0, 
  VE, "prog" },
-{ "rlcp",  NULL,OFFSET(prog),  
AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_RLCP}, 0, 0,
   VE, "prog" },
-{ "rpcl",  NULL,OFFSET(prog),  
AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_RPCL}, 0, 0,
   VE, "prog" },
-{ "pcrl",  NULL,OFFSET(prog),  
AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_PCRL}, 0, 0,
   VE, "prog" },
-{ "cprl",  NULL,OFFSET(prog),  
AV_OPT_TYPE_CONST,   { .i64 = JPEG2000_PGOD_CPRL}, 0, 0,
   VE, "prog" },
+{ "lrcp",  NULL,0, 
AV_OPT_TYPE_CONST,  { .i64 = JPEG2000_PGOD_LRCP }, 0, 0,   VE, 
"prog" },
+{ "rlcp",  NULL,0, 
AV_OPT_TYPE_CONST,  { .i64 = JPEG2000_PGOD_RLCP }, 0, 0,   VE, 
"prog" },
+{ "rpcl",  NULL,0, 
AV_OPT_TYPE_CONST,  { .i64 = JPEG2000_PGOD_RPCL }, 0, 0,   VE, 
"prog" },
+{ "pcrl",  NULL,0, 
AV_OPT_TYPE_CONST,  { .i64 = JPEG2000_PGOD_PCRL }, 0, 0,   VE, 
"prog" },
+{ "cprl",  NULL,0, 
AV_OPT_TYPE_CONST,  { .i64 = JPEG2000_PGOD_CPRL }, 0, 0,   VE, 
"prog" },
 { "layer_rates",   "Layer Rates",   OFFSET(lr_str),
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
 { NULL }
 };

___
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/tests/avcodec: Sanity check AVCodec.priv_data_size

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 04:36:14 2021 +0200| [2b0f29507f40db38e88ec157dcb3acaf43abce65] | 
committer: Andreas Rheinhardt

avcodec/tests/avcodec: Sanity check AVCodec.priv_data_size

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

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

 libavcodec/tests/avcodec.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c
index df7e7129a5..bba6eea77d 100644
--- a/libavcodec/tests/avcodec.c
+++ b/libavcodec/tests/avcodec.c
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/opt.h"
 #include "libavcodec/codec.h"
 #include "libavcodec/codec_desc.h"
 
@@ -34,6 +35,25 @@ do { 
   \
 #define ERR(msg)   ERR_INTERNAL(msg, )
 #define ERR_EXT(msg, ...)  ERR_INTERNAL(msg, , __VA_ARGS__)
 
+static int priv_data_size_wrong(const AVCodec *codec)
+{
+if (codec->priv_data_size < 0 ||
+codec->priv_class && codec->priv_data_size < sizeof(AVClass*))
+return 1;
+if (!codec->priv_class || !codec->priv_class->option)
+return 0;
+for (const AVOption *opt = codec->priv_class->option; opt->name; opt++) {
+if (opt->offset >= codec->priv_data_size ||
+opt->type == AV_OPT_TYPE_CONST && opt->offset != 0 ||
+opt->type != AV_OPT_TYPE_CONST && (opt->offset < sizeof(AVClass*) 
|| opt->offset < 0)) {
+AV_LOG("Option %s offset %d nonsensical\n",
+   opt->name, opt->offset);
+return 1;
+}
+}
+return 0;
+}
+
 int main(void){
 void *iter = NULL;
 const AVCodec *codec = NULL;
@@ -92,6 +112,9 @@ int main(void){
 if (!!codec->decode + !!codec->receive_frame != 1)
 ERR("Decoder %s does not implement exactly one decode API.\n");
 }
+if (priv_data_size_wrong(codec))
+ERR_EXT("Private context of codec %s is impossibly-sized (size 
%d).",
+codec->priv_data_size);
 if (!(desc = avcodec_descriptor_get(codec->id))) {
 ERR("Codec %s lacks a corresponding descriptor\n");
 } else if (desc->type != codec->type)

___
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/avcodec: Remove redundant assert

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 06:28:04 2021 +0200| [29e23ac71dd146df054e4e2fcef1dcef6a56454f] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Remove redundant assert

It is now checked by FATE that no encoder capable of flushing
uses frame threads, so this now redundant runtime check can
be removed.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/avcodec.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 97eb1ec431..5d85ed234b 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -390,9 +390,6 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
"that doesn't support it\n");
 return;
 }
-
-// We haven't implemented flushing for frame-threaded encoders.
-av_assert0(!(caps & AV_CODEC_CAP_FRAME_THREADS));
 }
 
 avci->draining  = 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/avcodec: Simplify check for flushing of bsf

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 03:48:50 2021 +0200| [b9fd9bce7328d8993c33f7892db3f1d58c8be18f] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Simplify check for flushing of bsf

Just check for the existence of the bsf. This is equivalent to
the old criterion of the AVCodecContext being a decoder.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/avcodec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 5d85ed234b..ff3d73e237 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -418,7 +418,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 avctx->pts_correction_last_pts =
 avctx->pts_correction_last_dts = INT64_MIN;
 
-if (av_codec_is_decoder(avctx->codec))
+if (avci->bsf)
 av_bsf_flush(avci->bsf);
 }
 

___
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/avcodec: Make sanity check stricter

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 04:42:50 2021 +0200| [482850992cb12a65b6754d8dee6544e7b4d2f80d] | 
committer: Andreas Rheinhardt

avcodec/avcodec: Make sanity check stricter

If an AVCodec has a private class, its priv_data_size must be > 0
and at the end of a successful call to avcodec_open2()
the AVCodecContext's priv_data must exist and its first element
must be a pointer to said AVClass. This should not be conditional
on priv_data_size being > 0 (which is tested by FATE) or
on the private context having been successfully allocated
(which has to have happened at that point). So remove these
preconditions to make the test stricter.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/avcodec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 2dd7dd84e0..97eb1ec431 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -364,9 +364,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
(AVRational){avctx->ticks_per_frame, 1}));
 #endif
 }
-if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
+if (codec->priv_class)
 av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
-}
 
 end:
 unlock_avcodec(codec);

___
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/tests/avcodec: Check codec caps for consistency

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 06:23:57 2021 +0200| [d6176c1458ea2c9a027d394619c754086827] | 
committer: Andreas Rheinhardt

avcodec/tests/avcodec: Check codec caps for consistency

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

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

 libavcodec/tests/avcodec.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c
index bba6eea77d..5d0ff9432c 100644
--- a/libavcodec/tests/avcodec.c
+++ b/libavcodec/tests/avcodec.c
@@ -19,6 +19,7 @@
 #include "libavutil/opt.h"
 #include "libavcodec/codec.h"
 #include "libavcodec/codec_desc.h"
+#include "libavcodec/internal.h"
 
 static const char *get_type_string(enum AVMediaType type)
 {
@@ -78,11 +79,26 @@ int main(void){
 if (codec->channel_layouts || codec->sample_fmts ||
 codec->supported_samplerates)
 ERR("Non-audio codec %s has audio-only fields set\n");
+if (codec->capabilities & (AV_CODEC_CAP_SMALL_LAST_FRAME |
+   AV_CODEC_CAP_CHANNEL_CONF |
+   AV_CODEC_CAP_VARIABLE_FRAME_SIZE))
+ERR("Non-audio codec %s has audio-only capabilities set\n");
 }
 if (codec->type != AVMEDIA_TYPE_VIDEO) {
 if (codec->pix_fmts || codec->supported_framerates)
 ERR("Non-video codec %s has video-only fields set\n");
+if (codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)
+ERR("Non-video codec %s exports cropping\n");
 }
+if (codec->caps_internal  & FF_CODEC_CAP_SLICE_THREAD_HAS_MF &&
+!(codec->capabilities & AV_CODEC_CAP_SLICE_THREADS))
+ERR("Codec %s wants mainfunction despite not being "
+"slice-threading capable");
+if (codec->caps_internal  & FF_CODEC_CAP_AUTO_THREADS &&
+!(codec->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
+ AV_CODEC_CAP_SLICE_THREADS |
+ AV_CODEC_CAP_OTHER_THREADS)))
+ERR("Codec %s has private-only threading support\n");
 
 is_decoder = av_codec_is_decoder(codec);
 is_encoder = av_codec_is_encoder(codec);
@@ -103,6 +119,19 @@ int main(void){
 ret = 1;
 }
 }
+if (codec->caps_internal & (FF_CODEC_CAP_ALLOCATE_PROGRESS |
+FF_CODEC_CAP_SETS_PKT_DTS |
+FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
+FF_CODEC_CAP_EXPORTS_CROPPING |
+FF_CODEC_CAP_SETS_FRAME_PROPS) ||
+codec->capabilities  & (AV_CODEC_CAP_AVOID_PROBING |
+AV_CODEC_CAP_CHANNEL_CONF  |
+AV_CODEC_CAP_DRAW_HORIZ_BAND |
+AV_CODEC_CAP_SUBFRAMES))
+ERR("Encoder %s has decoder-only capabilities set\n");
+if (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS &&
+codec->capabilities & AV_CODEC_CAP_ENCODER_FLUSH)
+ERR("Frame-threaded encoder %s claims to support flushing\n");
 } else {
 if (codec->type == AVMEDIA_TYPE_SUBTITLE && !codec->decode)
 ERR("Subtitle decoder %s does not implement decode 
callback\n");
@@ -111,6 +140,15 @@ int main(void){
 "yet decoder %s has it set\n");
 if (!!codec->decode + !!codec->receive_frame != 1)
 ERR("Decoder %s does not implement exactly one decode API.\n");
+if (codec->capabilities & (AV_CODEC_CAP_SMALL_LAST_FRAME|
+   AV_CODEC_CAP_VARIABLE_FRAME_SIZE |
+   AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
+   AV_CODEC_CAP_ENCODER_FLUSH))
+ERR("Decoder %s has encoder-only capabilities\n");
+if (codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS &&
+!(codec->capabilities & AV_CODEC_CAP_FRAME_THREADS))
+ERR("Decoder %s wants allocated progress without supporting"
+"frame threads\n");
 }
 if (priv_data_size_wrong(codec))
 ERR_EXT("Private context of codec %s is impossibly-sized (size 
%d).",

___
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/internal: Update AVCodecInternal.is_copy documentation

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep 24 18:06:28 2021 +0200| [78ec2f3bd70a3f065967b68b0ddc51ba3f552410] | 
committer: Andreas Rheinhardt

avcodec/internal: Update AVCodecInternal.is_copy documentation

Forgotten in 1f4cf92cfbd3accbae582ac63126ed5570ddfd37.

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/internal.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index dc60e4bf08..2111f2b9ae 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -122,10 +122,8 @@ typedef struct EncodeSimpleContext {
 
 typedef struct AVCodecInternal {
 /**
- * Whether the parent AVCodecContext is a copy of the context which had
- * init() called on it.
- * This is used by multithreading - shared tables and picture pointers
- * should be freed from the original context only.
+ * When using frame-threaded decoding, this field is set for the first
+ * worker thread (e.g. to decode extradata just once).
  */
 int is_copy;
 

___
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] swscale/yuv2rgb: fix conversion to X2RGB10

2021-09-26 Thread Manuel Stoeckl
ffmpeg | branch: master | Manuel Stoeckl  | Thu Sep 23 
23:22:29 2021 -0400| [ca594df622abae0c59ef735d63f071db983a35f7] | committer: 
Michael Niedermayer

swscale/yuv2rgb: fix conversion to X2RGB10

This resolves a problem where conversions from YUV to X2RGB10LE
would produce color values a factor 4 too small, because an 8-bit
value was placed in a 10-bit channel.

Signed-off-by: Manuel Stoeckl 
Signed-off-by: Michael Niedermayer 

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

 libswscale/yuv2rgb.c | 2 +-
 tests/ref/fate/filter-pixdesc-x2rgb10le  | 2 +-
 tests/ref/fate/filter-pixfmts-copy   | 2 +-
 tests/ref/fate/filter-pixfmts-crop   | 2 +-
 tests/ref/fate/filter-pixfmts-field  | 2 +-
 tests/ref/fate/filter-pixfmts-fieldorder | 2 +-
 tests/ref/fate/filter-pixfmts-hflip  | 2 +-
 tests/ref/fate/filter-pixfmts-il | 2 +-
 tests/ref/fate/filter-pixfmts-null   | 2 +-
 tests/ref/fate/filter-pixfmts-pad| 2 +-
 tests/ref/fate/filter-pixfmts-scale  | 2 +-
 tests/ref/fate/filter-pixfmts-transpose  | 2 +-
 tests/ref/fate/filter-pixfmts-vflip  | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index cac82f4c6f..c2e8d4894c 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -976,7 +976,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 y_table32   = c->yuvTable;
 yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
 for (i = 0; i < table_plane_size; i++) {
-unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
+unsigned yval = av_clip_uintp2((yb + 0x8000) >> 14, 10);
 y_table32[i]= (yval << rbase) + (needAlpha ? 0 : (255u << abase));
 y_table32[i + table_plane_size] = yval << gbase;
 y_table32[i + 2 * table_plane_size] = yval << bbase;
diff --git a/tests/ref/fate/filter-pixdesc-x2rgb10le 
b/tests/ref/fate/filter-pixdesc-x2rgb10le
index 94c8640a56..6fab74137f 100644
--- a/tests/ref/fate/filter-pixdesc-x2rgb10le
+++ b/tests/ref/fate/filter-pixdesc-x2rgb10le
@@ -1 +1 @@
-pixdesc-x2rgb10le98d697ed4668daf535163d5e08c903bb
+pixdesc-x2rgb10le   b50c6ddaf37214a06251c29798f94d6d
diff --git a/tests/ref/fate/filter-pixfmts-copy 
b/tests/ref/fate/filter-pixfmts-copy
index 1d7657c2af..1941ce37a1 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -80,7 +80,7 @@ rgbab6e1b441c365e03b5ffdf9b7b68d9a0c
 rgba64beae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64leb91e1d77f799eb92241a2d2d28437b15
 uyvy422 3bcf3c80047592f2211fae3260b1b65d
-x2rgb10le   b0a0c8056521beeaa3fea4985ca87176
+x2rgb10le   c1e3ac21be04a16bb157b22784524520
 xyz12be a1ef56bf746d71f59669c28e48fc8450
 xyz12le 831ff03c1ba4ef19374686f16a064d8c
 ya16be  37c07787e544f900c87b853253bfc8dd
diff --git a/tests/ref/fate/filter-pixfmts-crop 
b/tests/ref/fate/filter-pixfmts-crop
index 8fc7614192..1d1c143869 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -77,7 +77,7 @@ rgb89b364a8f112ad9459fec47a51cc03b30
 rgba9488ac85abceaf99a9309eac5a87697e
 rgba64be89910046972ab3c68e2a348302cc8ca9
 rgba64lefea8ebfc869b52adf353778f29eac7a7
-x2rgb10le   5c0789f76a713f343c2ed42a371d441d
+x2rgb10le   f4265aca7a67dbfa9354370098ca6f33
 xyz12be cb4571f9aaa7b59f999ef327276104b7
 xyz12le cd6aae8d26b18bdb4b9d068586276d91
 ya16be  a3d18014454942a96f15a49947c0c55d
diff --git a/tests/ref/fate/filter-pixfmts-field 
b/tests/ref/fate/filter-pixfmts-field
index ce8e53571f..2d8a7bfc54 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -80,7 +80,7 @@ rgbaee616262ca6d67b7ecfba4b36c602ce3
 rgba64be23c8c0edaabe3eaec89ce69633fb0048
 rgba64ledfdba4de4a7cac9abf08852666c341d3
 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e
-x2rgb10le   a7a5dcdfe1d4b6bd71e40b01c735f144
+x2rgb10le   a18bc4ae5274e0a8cca9137ecd50c677
 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437
 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5
 ya16be  40403b5277364777e0671da4d38e01ac
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder 
b/tests/ref/fate/filter-pixfmts-fieldorder
index 90d36add83..3d612c9391 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -71,7 +71,7 @@ rgba1fdf872a087a32cd35b80cc7be399578
 rgba64be5598f44514d122b9a57c5c92c20bbc61
 rgba64leb34e6e30621ae579519a2d91a96a0acf
 uyvy422 75de70e31c435dde878002d3f22b238a
-x2rgb10le   636c90498c64abba1cc0624c5209a61f
+x2rgb10le   cdf6a9e8a8d081aa768c6a

[FFmpeg-cvslog] swscale: add input/output support for X2BGR10LE

2021-09-26 Thread Manuel Stoeckl
ffmpeg | branch: master | Manuel Stoeckl  | Fri Sep 24 
19:09:15 2021 -0400| [32329397e289cc70550f110b72820ef3d219f7e0] | committer: 
Michael Niedermayer

swscale: add input/output support for X2BGR10LE

Signed-off-by: Manuel Stoeckl 
Signed-off-by: Michael Niedermayer 

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

 libswscale/input.c   | 15 +--
 libswscale/output.c  |  9 -
 libswscale/utils.c   |  1 +
 libswscale/yuv2rgb.c |  9 ++---
 tests/ref/fate/filter-pixdesc-x2bgr10le  |  1 +
 tests/ref/fate/filter-pixfmts-copy   |  1 +
 tests/ref/fate/filter-pixfmts-crop   |  1 +
 tests/ref/fate/filter-pixfmts-field  |  1 +
 tests/ref/fate/filter-pixfmts-fieldorder |  1 +
 tests/ref/fate/filter-pixfmts-hflip  |  1 +
 tests/ref/fate/filter-pixfmts-il |  1 +
 tests/ref/fate/filter-pixfmts-null   |  1 +
 tests/ref/fate/filter-pixfmts-pad|  1 +
 tests/ref/fate/filter-pixfmts-scale  |  1 +
 tests/ref/fate/filter-pixfmts-transpose  |  1 +
 tests/ref/fate/filter-pixfmts-vflip  |  1 +
 16 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index b65aaf7c06..477dc3d6b2 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -245,7 +245,8 @@ rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
  origin == AV_PIX_FMT_ARGB ||  \
  origin == AV_PIX_FMT_ABGR)\
 ? AV_RN32A(&src[(i) * 4])  \
-: ((origin == AV_PIX_FMT_X2RGB10LE)\
+: ((origin == AV_PIX_FMT_X2RGB10LE ||  \
+origin == AV_PIX_FMT_X2BGR10LE)\
? AV_RL32(&src[(i) * 4])\
: (isBE(origin) ? AV_RB16(&src[(i) * 2])\
   : AV_RL16(&src[(i) * 2]
@@ -393,6 +394,7 @@ rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0,  0, 0, 
  0xF800, 0x07E0,
 rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0,  0, 0,   0x7C00, 0x03E0,  
 0x001F,  0, 5, 10, RGB2YUV_SHIFT + 7)
 rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0,  0, 0,   0x0F00, 0x00F0,  
 0x000F,  0, 4,  8, RGB2YUV_SHIFT + 4)
 rgb16_32_wrapper(AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF0, 
0xFFC00, 0x3FF, 0, 0, 4, RGB2YUV_SHIFT + 6)
+rgb16_32_wrapper(AV_PIX_FMT_X2BGR10LE, bgr30le, 0, 6, 16, 0, 0x3FF, 0xFFC00, 
0x3FF0, 4, 0, 0, RGB2YUV_SHIFT + 6)
 
 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
  const uint8_t *gsrc, const uint8_t *bsrc, const 
uint8_t *rsrc,
@@ -1344,6 +1346,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_X2RGB10LE:
 c->chrToYV12 = rgb30leToUV_half_c;
 break;
+case AV_PIX_FMT_X2BGR10LE:
+c->chrToYV12 = bgr30leToUV_half_c;
+break;
 }
 } else {
 switch (srcFormat) {
@@ -1428,6 +1433,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_X2RGB10LE:
 c->chrToYV12 = rgb30leToUV_c;
 break;
+case AV_PIX_FMT_X2BGR10LE:
+c->chrToYV12 = bgr30leToUV_c;
+break;
 }
 }
 
@@ -1708,7 +1716,10 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 c->lumToYV12 = y210le_Y_c;
 break;
 case AV_PIX_FMT_X2RGB10LE:
-c->lumToYV12 =rgb30leToY_c;
+c->lumToYV12 = rgb30leToY_c;
+break;
+case AV_PIX_FMT_X2BGR10LE:
+c->lumToYV12 = bgr30leToY_c;
 break;
 }
 if (c->needAlpha) {
diff --git a/libswscale/output.c b/libswscale/output.c
index f1d9a61d53..58b10f85a5 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1603,7 +1603,7 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
 
 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
-} else if (target == AV_PIX_FMT_X2RGB10) {
+} else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) {
 uint32_t *dest = (uint32_t *) _dest;
 const uint32_t *r = (const uint32_t *) _r;
 const uint32_t *g = (const uint32_t *) _g;
@@ -1848,6 +1848,7 @@ YUV2RGBWRAPPER(yuv2rgb,,   8,AV_PIX_FMT_RGB8,  0)
 YUV2RGBWRAPPER(yuv2rgb,,   4,AV_PIX_FMT_RGB4,  0)
 YUV2RGBWRAPPER(yuv2rgb,,   4b,   AV_PIX_FMT_RGB4_BYTE, 0)
 YUV2RGBWRAPPER(yuv2, rgb, x2rgb10, AV_PIX_FMT_X2RGB10, 0)
+YUV2RGBWRAPPER(yuv2, rgb, x2bgr10, AV_PIX_FMT_X2BGR10, 0)
 
 static av_always_inline void yuv2rgb_write_full(SwsContext *c,
 uint8_t *dest, int i, int Y, int A, int U, int V,
@@ -3000,6 +3001,12 @@ av_cold void ff_sws_init_output_funcs(SwsContext 

[FFmpeg-cvslog] lavu/pix_fmt: add pixel format for x2bgr10

2021-09-26 Thread Manuel Stoeckl
ffmpeg | branch: master | Manuel Stoeckl  | Thu Sep 23 
23:22:31 2021 -0400| [0760d9153c39e95e175c434e56916e7d950a4f03] | committer: 
Michael Niedermayer

lavu/pix_fmt: add pixel format for x2bgr10

The new format (given in big/little endian forms) matches the
existing X2RGB10 format, except with B and R channels switched.

AV_PIX_FMT_X2BGR10 data often is created by OpenGL programs
whose buffers use the GL_RGB10 internal format.

Signed-off-by: Manuel Stoeckl 
Signed-off-by: Michael Niedermayer 

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

 doc/APIchanges   |  3 +++
 libavutil/pixdesc.c  | 24 
 libavutil/pixfmt.h   |  3 +++
 libavutil/version.h  |  2 +-
 tests/ref/fate/imgutils  |  2 ++
 tests/ref/fate/sws-pixdesc-query | 11 +++
 6 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5b5c2a6f11..7b267a79ac 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2021-09-21 - xx - lavu 57.7.100 - pixfmt.h
+  Add AV_PIX_FMT_X2BGR10.
+
 2021-09-20 - xx - lavu 57.6.100 - mem.h
   Deprecate av_mallocz_array() as it is identical to av_calloc().
 
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 2346138d04..69cb198646 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -272,6 +272,30 @@ static const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 },
 .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
 },
+[AV_PIX_FMT_X2BGR10LE] = {
+.name = "x2bgr10le",
+.nb_components= 3,
+.log2_chroma_w= 0,
+.log2_chroma_h= 0,
+.comp = {
+{ 0, 4, 0, 0, 10 },   /* R */
+{ 0, 4, 1, 2, 10 },   /* G */
+{ 0, 4, 2, 4, 10 },   /* B */
+},
+.flags = AV_PIX_FMT_FLAG_RGB,
+},
+[AV_PIX_FMT_X2BGR10BE] = {
+.name = "x2bgr10be",
+.nb_components= 3,
+.log2_chroma_w= 0,
+.log2_chroma_h= 0,
+.comp = {
+{ 0, 4, 2, 0, 10 },   /* R */
+{ 0, 4, 1, 2, 10 },   /* G */
+{ 0, 4, 0, 4, 10 },   /* B */
+},
+.flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
+},
 [AV_PIX_FMT_YUV422P] = {
 .name = "yuv422p",
 .nb_components = 3,
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 5814f3f3da..53bdecfcb7 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -350,6 +350,8 @@ enum AVPixelFormat {
 
 AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 
10B(lsb), little-endian, X=unused/undefined
 AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 
10B(lsb), big-endian, X=unused/undefined
+AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 
10R(lsb), little-endian, X=unused/undefined
+AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 
10R(lsb), big-endian, X=unused/undefined
 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you 
want to link with shared libav* because the number of formats might differ 
between versions
 };
 
@@ -440,6 +442,7 @@ enum AVPixelFormat {
 
 #define AV_PIX_FMT_Y210   AV_PIX_FMT_NE(Y210BE,  Y210LE)
 #define AV_PIX_FMT_X2RGB10AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE)
+#define AV_PIX_FMT_X2BGR10AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE)
 
 /**
   * Chromaticity coordinates of the source primaries.
diff --git a/libavutil/version.h b/libavutil/version.h
index a62f73639b..896e348d80 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR   6
+#define LIBAVUTIL_VERSION_MINOR   7
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils
index f510150ea1..495bbd46f0 100644
--- a/tests/ref/fate/imgutils
+++ b/tests/ref/fate/imgutils
@@ -236,3 +236,5 @@ y210be  planes: 1, linesizes: 256   0   0   0, 
plane_sizes: 12288 0
 y210le  planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
 x2rgb10le   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
 x2rgb10be   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
+x2bgr10le   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets: 0 0 0, total_size: 12288
+x2bgr10be   planes: 1, linesizes: 256   0   0   0, plane_sizes: 12288 
0 0 0, plane_offsets:   

[FFmpeg-cvslog] avcodec/utils: ARGO writes 4x4 blocks without regard to the image dimensions

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Sep  3 16:51:07 2021 +0200| [018b611b4ba74a5cecfb8a75a637b49840e7c320] | 
committer: Michael Niedermayer

avcodec/utils: ARGO writes 4x4 blocks without regard to the image dimensions

Fixes: out of array access
Fixes: 
37197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-5877046382297088

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/utils.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 387d285633..b4076d94f2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -298,6 +298,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int 
*width, int *height,
 h_align = 4;
 }
 break;
+case AV_PIX_FMT_BGR0:
+if (s->codec_id == AV_CODEC_ID_ARGO) {
+w_align = 4;
+h_align = 4;
+}
+break;
 default:
 break;
 }

___
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/h274: fix bad left shifts

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Sep 14 20:23:52 2021 +0200| [991b3deea90c6fc01ec575522760f58c650eba11] | 
committer: Michael Niedermayer

avcodec/h274: fix bad left shifts

Fixes: left shift of negative value -3
Fixes: 
37788/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6024714540154880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/h274.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h274.c b/libavcodec/h274.c
index 262106733c..20401ba06b 100644
--- a/libavcodec/h274.c
+++ b/libavcodec/h274.c
@@ -250,8 +250,8 @@ int ff_h274_apply_film_grain(AVFrame *out_frame, const 
AVFrame *in_frame,
 // Adaptation for 4:2:0 chroma subsampling
 for (int i = 0; i < h274.num_intensity_intervals[c]; i++) {
 h274.comp_model_value[c][i][0] >>= 1;
-h274.comp_model_value[c][i][1] <<= 1;
-h274.comp_model_value[c][i][2] <<= 1;
+h274.comp_model_value[c][i][1] *= 2;
+h274.comp_model_value[c][i][2] *= 2;
 }
 }
 

___
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/flicvideo: Check remaining bytes in FLI*COPY

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Sep 14 20:31:39 2021 +0200| [5f835efbca874ad42cb954e6788588f52a57a7a2] | 
committer: Michael Niedermayer

avcodec/flicvideo: Check remaining bytes in FLI*COPY

Fixes: Timeout
Fixes: 
37795/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-4846536543043584

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/flicvideo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index 47ca77f62e..e122fe231f 100644
--- a/libavcodec/flicvideo.c
+++ b/libavcodec/flicvideo.c
@@ -735,6 +735,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
 bytestream2_skip(&g2, chunk_size - 6);
 } else {
 
+if (bytestream2_get_bytes_left(&g2) < 2 * s->avctx->width * 
s->avctx->height )
+return AVERROR_INVALIDDATA;
 for (y_ptr = 0; y_ptr < s->frame->linesize[0] * 
s->avctx->height;
  y_ptr += s->frame->linesize[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/mxpegdec: Check for AVDISCARD_ALL

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Sep 14 20:16:27 2021 +0200| [20afd3a63a75a160f61a98a8dcfe06f527ea19b4] | 
committer: Michael Niedermayer

avcodec/mxpegdec: Check for AVDISCARD_ALL

Fixes: Fixes NULL pointer dereference
Fixes: 
36610/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-6052641783283712
Fixes: 
37907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-4725170850365440
Fixes: 
37904/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-6367889262247936
Fixes: 
38085/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-5175270823297024

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/mxpegdec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c
index 7c97a9340e..16e586c1e9 100644
--- a/libavcodec/mxpegdec.c
+++ b/libavcodec/mxpegdec.c
@@ -193,6 +193,9 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,
 int start_code;
 int ret;
 
+if (avctx->skip_frame == AVDISCARD_ALL)
+return AVERROR_PATCHWELCOME;
+
 buf_ptr = buf;
 buf_end = buf + buf_size;
 jpg->got_picture = 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] avformat/mov: Fix last mfra check

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Sep 15 21:52:00 2021 +0200| [451ceb5131fa67b0b380d4823981e421909c16db] | 
committer: Michael Niedermayer

avformat/mov: Fix last mfra check

Fixes: signed integer overflow: 9223372036854775360 + 536870912 cannot be 
represented in type 'long'
Fixes: 
37940/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6095637855207424

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index bbb45864df..d0b8b2595b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5122,7 +5122,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 // See if the remaining bytes are just an mfra which we can ignore.
 is_complete = offset == stream_size;
-if (!is_complete && (pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+if (!is_complete && (pb->seekable & AVIO_SEEKABLE_NORMAL) && stream_size > 
0 ) {
 int64_t ret;
 int64_t original_pos = avio_tell(pb);
 if (!c->have_read_mfra_size) {
@@ -5133,7 +5133,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if ((ret = avio_seek(pb, original_pos, SEEK_SET)) < 0)
 return ret;
 }
-if (offset + c->mfra_size == stream_size)
+if (offset == stream_size - c->mfra_size)
 is_complete = 1;
 }
 

___
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] tools/target_dec_fuzzer: Adjust threshold for WMV2

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed 
Sep 15 20:48:55 2021 +0200| [8e67cfe15b062362cdc22be2a31167efc55b1e13] | 
committer: Michael Niedermayer

tools/target_dec_fuzzer: Adjust threshold for WMV2

Fixes: Timeout
Fixes: 
37737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-4923012999151616

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 tools/target_dec_fuzzer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 8badbd0b5c..8800231691 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -211,6 +211,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_VP9: maxpixels  /= 4096;  break;
 case AV_CODEC_ID_WAVPACK: maxsamples /= 1024;  break;
 case AV_CODEC_ID_WMV3IMAGE:   maxpixels  /= 8192;  break;
+case AV_CODEC_ID_WMV2:maxpixels  /= 1024;  break;
 case AV_CODEC_ID_WMV3:maxpixels  /= 1024;  break;
 case AV_CODEC_ID_WS_VQA:  maxpixels  /= 16384; break;
 case AV_CODEC_ID_WMALOSSLESS: maxsamples /= 1024;  break;

___
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/apedec: Fix integer overflow in filter_fast_3320()

2021-09-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Sep 17 21:40:59 2021 +0200| [0e45886e6ea272f453cb949e95c3bfd8380974c5] | 
committer: Michael Niedermayer

avcodec/apedec: Fix integer overflow in filter_fast_3320()

Fixes: signed integer overflow: 2145649668 + 3956526 cannot be represented in 
type 'int'
Fixes: 
38351/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4647077926273024

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/apedec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 050523601d..27d0ff3565 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -879,7 +879,7 @@ static av_always_inline int filter_fast_3320(APEPredictor 
*p,
 }
 
 predictionA = p->buf[delayA] * 2U - p->buf[delayA - 1];
-p->lastA[filter] = decoded + ((int32_t)(predictionA  * 
p->coeffsA[filter][0]) >> 9);
+p->lastA[filter] = decoded + (unsigned)((int32_t)(predictionA  * 
p->coeffsA[filter][0]) >> 9);
 
 if ((decoded ^ predictionA) > 0)
 p->coeffsA[filter][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/elbg: Extend filter to include alpha values in the quantization procedure

2021-09-26 Thread Soft Works
ffmpeg | branch: master | Soft Works  | Sun Sep 26 
04:57:25 2021 +| [8983c3d7e4acf9b216599cce218acbea498154c7] | committer: 
Michael Niedermayer

avfilter/elbg: Extend filter to include alpha values in the quantization 
procedure

Usage example:

ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" 
-filter_complex "elbg=pal8=1:use_alpha=1" -frames:v 1 out.png

Signed-off-by: softworkz 
Signed-off-by: Michael Niedermayer 

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

 doc/filters.texi  |  4 
 libavfilter/vf_elbg.c | 25 -
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 94161003c3..a10f5e71d1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11396,6 +11396,10 @@ will try to use a good random seed on a best effort 
basis.
 @item pal8
 Set pal8 output pixel format. This option does not work with codebook
 length greater than 256. Default is disabled.
+
+@item use_alpha
+Include alpha values in the quantization calculation. Allows creating
+palettized output images (e.g. PNG8) with multiple alpha smooth blending.
 @end table
 
 @section entropy
diff --git a/libavfilter/vf_elbg.c b/libavfilter/vf_elbg.c
index 0bebcdbda5..7f40be6092 100644
--- a/libavfilter/vf_elbg.c
+++ b/libavfilter/vf_elbg.c
@@ -46,6 +46,7 @@ typedef struct ELBGFilterContext {
 int codebook_length;
 const AVPixFmtDescriptor *pix_desc;
 uint8_t rgba_map[4];
+int use_alpha;
 int pal8;
 } ELBGFilterContext;
 
@@ -60,6 +61,7 @@ static const AVOption elbg_options[] = {
 { "seed", "set the random seed", OFFSET(lfg_seed), AV_OPT_TYPE_INT64, 
{.i64 = -1}, -1, UINT32_MAX, FLAGS },
 { "s","set the random seed", OFFSET(lfg_seed), AV_OPT_TYPE_INT64, { 
.i64 = -1 }, -1, UINT32_MAX, FLAGS },
 { "pal8", "set the pal8 output", OFFSET(pal8), AV_OPT_TYPE_BOOL, { .i64 = 
0 }, 0, 1, FLAGS },
+{ "use_alpha", "use alpha channel for mapping", OFFSET(use_alpha), 
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
 { NULL }
 };
 
@@ -105,7 +107,7 @@ static int query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-#define NB_COMPONENTS 3
+#define NB_COMPONENTS 4
 
 static int config_input(AVFilterLink *inlink)
 {
@@ -138,6 +140,7 @@ static int config_input(AVFilterLink *inlink)
 #define R 0
 #define G 1
 #define B 2
+#define A 3
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 {
@@ -148,6 +151,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 const uint8_t r_idx  = elbg->rgba_map[R];
 const uint8_t g_idx  = elbg->rgba_map[G];
 const uint8_t b_idx  = elbg->rgba_map[B];
+const uint8_t a_idx  = elbg->rgba_map[A];
 
 /* build the codeword */
 p0 = frame->data[0];
@@ -155,9 +159,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 for (i = 0; i < inlink->h; i++) {
 p = p0;
 for (j = 0; j < inlink->w; j++) {
-elbg->codeword[k++] = p[r_idx];
-elbg->codeword[k++] = p[g_idx];
 elbg->codeword[k++] = p[b_idx];
+elbg->codeword[k++] = p[g_idx];
+elbg->codeword[k++] = p[r_idx];
+elbg->codeword[k++] = elbg->use_alpha ? p[a_idx] : 0xff;
 p += elbg->pix_desc->nb_components;
 }
 p0 += frame->linesize[0];
@@ -188,10 +193,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 p0 = (uint8_t *)out->data[0];
 
 for (i = 0; i < elbg->codebook_length; i++) {
-pal[i] =  0xFFU << 24  |
- (elbg->codebook[i*3  ] << 16) |
- (elbg->codebook[i*3+1] <<  8) |
-  elbg->codebook[i*3+2];
+const int al =  elbg->use_alpha ? elbg->codebook[i*4+3] : 0xff;
+pal[i] =  al<< 24  |
+ (elbg->codebook[i*4+2] << 16) |
+ (elbg->codebook[i*4+1] <<  8) |
+  elbg->codebook[i*4  ];
 }
 
 k = 0;
@@ -214,9 +220,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 p = p0;
 for (j = 0; j < inlink->w; j++) {
 int cb_idx = NB_COMPONENTS * 
elbg->codeword_closest_codebook_idxs[k++];
-p[r_idx] = elbg->codebook[cb_idx];
+p[b_idx] = elbg->codebook[cb_idx];
 p[g_idx] = elbg->codebook[cb_idx+1];
-p[b_idx] = elbg->codebook[cb_idx+2];
+p[r_idx] = elbg->codebook[cb_idx+2];
+p[a_idx] = elbg->use_alpha ? elbg->codebook[cb_idx+3] : 0xFFu;
 p += elbg->pix_desc->nb_components;
 }
 p0 += frame->linesize[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/vf_colorchannelmixer: simplify code a little

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 17:04:23 
2021 +0200| [e4327f97b19360dbc155a72493ad749975113d50] | committer: Paul B Mahol

avfilter/vf_colorchannelmixer: simplify code a little

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

 libavfilter/vf_colorchannelmixer.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/libavfilter/vf_colorchannelmixer.c 
b/libavfilter/vf_colorchannelmixer.c
index 76722523a7..e51f9d2d68 100644
--- a/libavfilter/vf_colorchannelmixer.c
+++ b/libavfilter/vf_colorchannelmixer.c
@@ -145,10 +145,6 @@ static av_always_inline int 
filter_slice_rgba_planar(AVFilterContext *ctx, void
 const uint8_t bin = srcb[j];
 const uint8_t ain = have_alpha ? srca[j] : 0;
 int rout, gout, bout;
-float lin;
-
-if (pl)
-lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 
 rout = s->lut[R][R][rin] +
s->lut[R][G][gin] +
@@ -164,6 +160,7 @@ static av_always_inline int 
filter_slice_rgba_planar(AVFilterContext *ctx, void
(have_alpha == 1 ? s->lut[B][A][ain] : 0);
 
 if (pl) {
+float lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 float frout = rout / sr;
 float fgout = gout / sg;
 float fbout = bout / sb;
@@ -231,10 +228,6 @@ static av_always_inline int 
filter_slice_rgba16_planar(AVFilterContext *ctx, voi
 const uint16_t bin = srcb[j];
 const uint16_t ain = have_alpha ? srca[j] : 0;
 int rout, gout, bout;
-float lin;
-
-if (pl)
-lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 
 rout = s->lut[R][R][rin] +
s->lut[R][G][gin] +
@@ -250,6 +243,7 @@ static av_always_inline int 
filter_slice_rgba16_planar(AVFilterContext *ctx, voi
(have_alpha == 1 ? s->lut[B][A][ain] : 0);
 
 if (pl) {
+float lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 float frout = rout / sr;
 float fgout = gout / sg;
 float fbout = bout / sb;
@@ -418,10 +412,6 @@ static av_always_inline int 
filter_slice_rgba_packed(AVFilterContext *ctx, void
 const uint8_t bin = src[j + boffset];
 const uint8_t ain = src[j + aoffset];
 int rout, gout, bout;
-float lin;
-
-if (pl)
-lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 
 rout = s->lut[R][R][rin] +
s->lut[R][G][gin] +
@@ -437,6 +427,7 @@ static av_always_inline int 
filter_slice_rgba_packed(AVFilterContext *ctx, void
(have_alpha == 1 ? s->lut[B][A][ain] : 0);
 
 if (pl) {
+float lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 float frout = rout / sr;
 float fgout = gout / sg;
 float fbout = bout / sb;
@@ -500,10 +491,6 @@ static av_always_inline int 
filter_slice_rgba16_packed(AVFilterContext *ctx, voi
 const uint16_t bin = src[j + boffset];
 const uint16_t ain = src[j + aoffset];
 int rout, gout, bout;
-float lin;
-
-if (pl)
-lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 
 rout = s->lut[R][R][rin] +
s->lut[R][G][gin] +
@@ -519,6 +506,7 @@ static av_always_inline int 
filter_slice_rgba16_packed(AVFilterContext *ctx, voi
(have_alpha == 1 ? s->lut[B][A][ain] : 0);
 
 if (pl) {
+float lin = FFMAX3(rin, gin, bin) + FFMIN3(rin, gin, bin);
 float frout = rout / sr;
 float fgout = gout / sg;
 float fbout = bout / sb;

___
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_colorlevels: refactor code so all components are processed in same loop

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 13:02:03 
2021 +0200| [4727e30ec3372ea3d758c28338d65f0c67539b02] | committer: Paul B Mahol

avfilter/vf_colorlevels: refactor code so all components are processed in same 
loop

This is also faster.

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

 libavfilter/vf_colorlevels.c | 100 +--
 1 file changed, 59 insertions(+), 41 deletions(-)

diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
index 418a3037d0..9fd49d4536 100644
--- a/libavfilter/vf_colorlevels.c
+++ b/libavfilter/vf_colorlevels.c
@@ -104,56 +104,74 @@ typedef struct ThreadData {
 int omin[4];
 } ThreadData;
 
-#define LOAD_COMMON \
-ColorLevelsContext *s = ctx->priv;  \
-const ThreadData *td = arg; \
-const int process_h = td->h;\
-const int slice_start = (process_h *  jobnr   ) / nb_jobs;  \
-const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;  \
-const uint8_t *srcrow = td->srcrow; \
-uint8_t *dstrow = td->dstrow;   \
-const int step = s->step;
+#define DO_COMMON(type, clip)  
 \
+ColorLevelsContext *s = ctx->priv; 
 \
+const ThreadData *td = arg;
 \
+const int linesize = s->linesize;  
 \
+const int step = s->step;  
 \
+const int process_h = td->h;   
 \
+const int slice_start = (process_h *  jobnr   ) / nb_jobs; 
 \
+const int slice_end   = (process_h * (jobnr+1)) / nb_jobs; 
 \
+const int src_linesize = td->src_linesize / sizeof(type);  
 \
+const int dst_linesize = td->dst_linesize / sizeof(type);  
 \
+const type *srcrow = (const type *)td->srcrow + src_linesize * 
slice_start; \
+type *dstrow = (type *)td->dstrow + dst_linesize * slice_start;
 \
+const uint8_t offset_r = s->rgba_map[R];   
 \
+const uint8_t offset_g = s->rgba_map[G];   
 \
+const uint8_t offset_b = s->rgba_map[B];   
 \
+const uint8_t offset_a = s->rgba_map[A];   
 \
+const int imin_r = td->imin[R];
 \
+const int imin_g = td->imin[G];
 \
+const int imin_b = td->imin[B];
 \
+const int imin_a = td->imin[A];
 \
+const int omin_r = td->omin[R];
 \
+const int omin_g = td->omin[G];
 \
+const int omin_b = td->omin[B];
 \
+const int omin_a = td->omin[A];
 \
+const float coeff_r = td->coeff[R];
 \
+const float coeff_g = td->coeff[G];
 \
+const float coeff_b = td->coeff[B];
 \
+const float coeff_a = td->coeff[A];
 \
+const type *src_r = srcrow + offset_r; 
 \
+const type *src_g = srcrow + offset_g; 
 \
+const type *src_b = srcrow + offset_b; 
 \
+const type *src_a = srcrow + offset_a; 
 \
+type *dst_r = dstrow + offset_r;   
 \
+type *dst_g = dstrow + offset_g;   
 \
+type *dst_b = dstrow + offset_b;   
 \
+type *dst_a = dstrow + offset_a;   
 \
+   
 \
+for (int y = slice_start; y < slice_end; y++) {
 \
+for (int x = 0; x < linesize; x += step) { 
 \
+dst_r[x] = clip((src_r[x] - imin_r) * coeff_r + omin_r);   
 \
+dst_g[x] = clip((src_g[x] - imin_g) * coeff_g + omin_g);   
 \
+dst_b[x] = clip((src_b[x] - imin_b) * coeff_b + omin_b);   
 \
+}  
 \
+

[FFmpeg-cvslog] avfilter/vf_colorchannelmixer: add extended preserve color support

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 18:09:47 
2021 +0200| [53f8a0312303d7d7ba52b28e71a4e6f94356944b] | committer: Paul B Mahol

avfilter/vf_colorchannelmixer: add extended preserve color support

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

 doc/filters.texi   |  23 +-
 libavfilter/vf_colorchannelmixer.c | 155 +
 2 files changed, 94 insertions(+), 84 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b309e8c737..398c6b82fc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8379,8 +8379,27 @@ Default is @code{1} for @var{aa}, and @code{0} for 
@var{ar}, @var{ag} and @var{a
 
 Allowed ranges for options are @code{[-2.0, 2.0]}.
 
-@item pl
-Preserve lightness when changing colors. Allowed range is from @code{[0.0, 
1.0]}.
+@item pc
+Set preserve color mode. The accepted values are:
+@table @samp
+@item none
+Disable color preserving, this is default.
+@item lum
+Preserve luminance.
+@item max
+Preserve max value of RGB triplet.
+@item avg
+Preserve average value of RGB triplet.
+@item sum
+Preserve sum value of RGB triplet.
+@item nrm
+Preserve normalized value of RGB triplet.
+@item pwr
+Preserve power value of RGB triplet.
+@end table
+
+@item pa
+Set the preserve color amount when changing colors. Allowed range is from 
@code{[0.0, 1.0]}.
 Default is @code{0.0}, thus disabled.
 @end table
 
diff --git a/libavfilter/vf_colorchannelmixer.c 
b/libavfilter/vf_colorchannelmixer.c
index e51f9d2d68..f1a193116e 100644
--- a/libavfilter/vf_colorchannelmixer.c
+++ b/libavfilter/vf_colorchannelmixer.c
@@ -27,6 +27,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
+#include "preserve_color.h"
 
 #define R 0
 #define G 1
@@ -43,8 +44,8 @@ typedef struct ColorChannelMixerContext {
 double gr, gg, gb, ga;
 double br, bg, bb, ba;
 double ar, ag, ab, aa;
-double sr, sg, sb;
-double preserve_lightness;
+double preserve_amount;
+int preserve_color;
 
 int *lut[4][4];
 
@@ -75,7 +76,15 @@ static const AVOption colorchannelmixer_options[] = {
 { "ag", "set the green gain for the alpha channel", OFFSET(ag), 
AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
 { "ab", "set the blue gain for the alpha channel",  OFFSET(ab), 
AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
 { "aa", "set the alpha gain for the alpha channel", OFFSET(aa), 
AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
-{ "pl", "preserve lightness",   OFFSET(preserve_lightness), 
AV_OPT_TYPE_DOUBLE, {.dbl=0},  0, 1, FLAGS },
+{ "pc", "set the preserve color mode",  OFFSET(preserve_color), 
AV_OPT_TYPE_INT,{.i64=0},  0, NB_PRESERVE-1, FLAGS, "preserve" },
+{ "none",  "disabled", 0,
AV_OPT_TYPE_CONST,  {.i64=P_NONE}, 0, 0, FLAGS, "preserve" },
+{ "lum",   "luminance",0,
AV_OPT_TYPE_CONST,  {.i64=P_LUM},  0, 0, FLAGS, "preserve" },
+{ "max",   "max",  0,
AV_OPT_TYPE_CONST,  {.i64=P_MAX},  0, 0, FLAGS, "preserve" },
+{ "avg",   "average",  0,
AV_OPT_TYPE_CONST,  {.i64=P_AVG},  0, 0, FLAGS, "preserve" },
+{ "sum",   "sum",  0,
AV_OPT_TYPE_CONST,  {.i64=P_SUM},  0, 0, FLAGS, "preserve" },
+{ "nrm",   "norm", 0,
AV_OPT_TYPE_CONST,  {.i64=P_NRM},  0, 0, FLAGS, "preserve" },
+{ "pwr",   "power",0,
AV_OPT_TYPE_CONST,  {.i64=P_PWR},  0, 0, FLAGS, "preserve" },
+{ "pa", "set the preserve color amount",OFFSET(preserve_amount), 
AV_OPT_TYPE_DOUBLE, {.dbl=0},  0, 1, FLAGS },
 { NULL }
 };
 
@@ -108,24 +117,23 @@ static float lerpf(float v0, float v1, float f)
 return v0 + (v1 - v0) * f;
 }
 
-static void preservel(float *r, float *g, float *b, float lin, float lout)
+static void preservel(float *r, float *g, float *b, float lin, float lout, 
float max)
 {
-*r *= lout / lin;
-*g *= lout / lin;
-*b *= lout / lin;
+if (lout <= 0.f)
+lout = 1.f / (max * 2.f);
+*r *= lin / lout;
+*g *= lin / lout;
+*b *= lin / lout;
 }
 
 static av_always_inline int filter_slice_rgba_planar(AVFilterContext *ctx, 
void *arg, int jobnr, int nb_jobs,
- int have_alpha, int pl)
+ int have_alpha, int pc)
 {
 ColorChannelMixerContext *s = ctx->priv;
 ThreadData *td = arg;
 AVFrame *in = td->in;
 AVFrame *out = td->out;
-const float l = s->preserve_lightness;
-const float sr = s->sr;
-const float sg = s->sg;
-const float sb = s->sb;
+const float pa = s->preserve_amount;
 const int slice_start = (out->height * jobnr) / nb_jobs;
 const int slice

[FFmpeg-cvslog] avfilter/vf_colorlevels: add preserve color option

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 15:39:43 
2021 +0200| [34102f8c07dee33e3dcd954f43dd15fc9925aee4] | committer: Paul B Mahol

avfilter/vf_colorlevels: add preserve color option

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

 doc/filters.texi | 19 ++
 libavfilter/preserve_color.h | 83 
 libavfilter/vf_colorlevels.c | 75 +--
 3 files changed, 166 insertions(+), 11 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index a10f5e71d1..b309e8c737 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8540,6 +8540,25 @@ Adjust red, green, blue and alpha output white point.
 Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
 
 Output levels allows manual selection of a constrained output level range.
+
+@item preserve
+Set preserve color mode. The accepted values are:
+@table @samp
+@item none
+Disable color preserving, this is default.
+@item lum
+Preserve luminance.
+@item max
+Preserve max value of RGB triplet.
+@item avg
+Preserve average value of RGB triplet.
+@item sum
+Preserve sum value of RGB triplet.
+@item nrm
+Preserve normalized value of RGB triplet.
+@item pwr
+Preserve power value of RGB triplet.
+@end table
 @end table
 
 @subsection Examples
diff --git a/libavfilter/preserve_color.h b/libavfilter/preserve_color.h
new file mode 100644
index 00..ac0587ad1e
--- /dev/null
+++ b/libavfilter/preserve_color.h
@@ -0,0 +1,83 @@
+/*
+ * 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
+ */
+
+#ifndef AVFILTER_PRESERVE_COLOR_H
+#define AVFILTER_PRESERVE_COLOR_H
+
+enum {
+P_NONE,
+P_LUM,
+P_MAX,
+P_AVG,
+P_SUM,
+P_NRM,
+P_PWR,
+NB_PRESERVE
+};
+
+static inline float normalize(float r, float g, float b, float max)
+{
+r /= max;
+g /= max;
+b /= max;
+return sqrtf(r * r + g * g + b * b);
+}
+
+static inline float power(float r, float g, float b, float max)
+{
+r /= max;
+g /= max;
+b /= max;
+return cbrtf(r * r * r + g * g * g + b * b * b);
+}
+
+static inline void preserve_color(int preserve_color,
+  float ir, float ig, float ib,
+  float  r, float  g, float  b,
+  float max,
+  float *icolor, float *ocolor)
+{
+switch (preserve_color) {
+case P_LUM:
+*icolor = FFMAX3(ir, ig, ib) + FFMIN3(ir, ig, ib);
+*ocolor = FFMAX3( r,  g,  b) + FFMIN3( r,  g,  b);
+break;
+case P_MAX:
+*icolor = FFMAX3(ir, ig, ib);
+*ocolor = FFMAX3( r,  g,  b);
+break;
+case P_AVG:
+*icolor = (ir + ig + ib + 1.f) / 3.f;
+*ocolor = ( r +  g +  b + 1.f) / 3.f;
+break;
+case P_SUM:
+*icolor = ir + ig + ib;
+*ocolor =  r +  g  + b;
+break;
+case P_NRM:
+*icolor = normalize(ir, ig, ib, max);
+*ocolor = normalize( r,  g,  b, max);
+break;
+case P_PWR:
+*icolor = power(ir, ig, ib, max);
+*ocolor = power( r,  g,  b, max);
+break;
+}
+}
+
+#endif /* AVFILTER_PRESERVE_COLOR_H */
diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
index 9fd49d4536..89021e95d0 100644
--- a/libavfilter/vf_colorlevels.c
+++ b/libavfilter/vf_colorlevels.c
@@ -26,6 +26,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
+#include "preserve_color.h"
 
 #define R 0
 #define G 1
@@ -40,6 +41,7 @@ typedef struct Range {
 typedef struct ColorLevelsContext {
 const AVClass *class;
 Range range[4];
+int preserve_color;
 
 int nb_comp;
 int bpp;
@@ -47,7 +49,7 @@ typedef struct ColorLevelsContext {
 uint8_t rgba_map[4];
 int linesize;
 
-int (*colorlevels_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
+int (*colorlevels_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, 
int nb_jobs);
 } ColorLevelsContext;
 
 #define OFFSET(x) offsetof(ColorLevelsContext, x)
@@ -69,6 +71,14 @@ static const AVOption colorlevels_options[] = {
 { "gomax", "set output green white point", OFFSET(range[G].out_max), 

[FFmpeg-cvslog] avfilter/vf_blend: add softdifference blend mode

2021-09-26 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Sep 26 23:08:14 
2021 +0200| [e2d40cd1d52306035756687257c00bed144928e1] | committer: Paul B Mahol

avfilter/vf_blend: add softdifference blend mode

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

 doc/filters.texi   | 1 +
 libavfilter/blend.h| 1 +
 libavfilter/vf_blend.c | 8 
 3 files changed, 10 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 398c6b82fc..0b7e21f7f8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7559,6 +7559,7 @@ Available values for component modes are:
 @item pinlight
 @item reflect
 @item screen
+@item softdifference
 @item softlight
 @item subtract
 @item vividlight
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index 00db51838d..a9a436a6da 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -59,6 +59,7 @@ enum BlendMode {
 BLEND_HEAT,
 BLEND_FREEZE,
 BLEND_EXTREMITY,
+BLEND_SOFTDIFFERENCE,
 BLEND_NB
 };
 
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 47ec1b5a2d..ff06940a66 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -104,6 +104,7 @@ static const AVOption blend_options[] = {
 { "subtract",   "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SUBTRACT},   0, 0, 
FLAGS, "mode" },
 { "vividlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_VIVIDLIGHT}, 0, 0, 
FLAGS, "mode" },
 { "xor","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_XOR},0, 0, 
FLAGS, "mode" },
+{ "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 
0, 0, FLAGS, "mode" },
 { "c0_expr",  "set color component #0 expression", 
OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 { "c1_expr",  "set color component #1 expression", 
OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 { "c2_expr",  "set color component #2 expression", 
OFFSET(params[2].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
@@ -322,6 +323,7 @@ DEFINE_BLEND8(or, A | B)
 DEFINE_BLEND8(xor,A ^ B)
 DEFINE_BLEND8(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B))
 DEFINE_BLEND8(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * 
(A - 128)))
+DEFINE_BLEND8(softdifference,av_clip_uint8((A > B) ? (B == 255) ? 0 : (A - B) 
* 255 / (255 - B) : (B == 0) ? 0 : (B - A) * 255 / B))
 
 #undef MULTIPLY
 #undef SCREEN
@@ -365,6 +367,7 @@ DEFINE_BLEND16(or, A | B, 16)
 DEFINE_BLEND16(xor,A ^ B, 16)
 DEFINE_BLEND16(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 
32768), B), 16)
 DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B 
+ 2 * (A - 32768)), 16)
+DEFINE_BLEND16(softdifference,av_clip_uint16((A > B) ? (B == 65535) ? 0 : (A - 
B) * 65535 / (65535 - B) : (B == 0) ? 0 : (B - A) * 65535 / B), 16)
 
 #undef MULTIPLY
 #undef SCREEN
@@ -408,6 +411,7 @@ DEFINE_BLEND16(or, A | B, 10)
 DEFINE_BLEND16(xor,A ^ B, 10)
 DEFINE_BLEND16(vividlight, (A < 512) ? BURN(2 * A, B) : DODGE(2 * (A - 512), 
B), 10)
 DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 512) ? B + 2 * A - 1023 : 
B + 2 * (A - 512), 10), 10)
+DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 1023) ? 0 : 
(A - B) * 1023 / (1023 - B) : (B == 0) ? 0 : (B - A) * 1023 / B, 10), 10)
 
 #undef MULTIPLY
 #undef SCREEN
@@ -451,6 +455,7 @@ DEFINE_BLEND16(or, A | B, 12)
 DEFINE_BLEND16(xor,A ^ B, 12)
 DEFINE_BLEND16(vividlight, (A < 2048) ? BURN(2 * A, B) : DODGE(2 * (A - 2048), 
B), 12)
 DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 2048) ? B + 2 * A - 4095 : 
B + 2 * (A - 2048), 12), 12)
+DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (B == 4095) ? 0 : 
(A - B) * 4095 / (4095 - B) : (B == 0) ? 0 : (B - A) * 4095 / B, 12), 12)
 
 #undef MULTIPLY
 #undef SCREEN
@@ -494,6 +499,7 @@ DEFINE_BLEND16(or, A | B, 9)
 DEFINE_BLEND16(xor,A ^ B, 9)
 DEFINE_BLEND16(vividlight, (A < 256) ? BURN(2 * A, B) : DODGE(2 * (A - 256), 
B), 9)
 DEFINE_BLEND16(linearlight,(int)av_clip_uintp2((B < 256) ? B + 2 * A - 511 : B 
+ 2 * (A - 256), 9), 9)
+DEFINE_BLEND16(softdifference,(int)av_clip_uintp2((A > B) ? (A - B) * 511 / 
(511 - B) : (B == 0) ? 0 : (B - A) * 511 / B, 9), 9)
 
 #undef MULTIPLY
 #undef SCREEN
@@ -537,6 +543,7 @@ DEFINE_BLEND32(or, av_int2float(av_float2int(A) | 
av_float2int(B)), 32)
 DEFINE_BLEND32(xor,av_int2float(av_float2int(A) ^ av_float2int(B)), 32)
 DEFINE_BLEND32(vividlight, (A < 0.5) ? BURN(2 * A, B) : DODGE(2 * (A - 0.5), 
B), 32)
 DEFINE_BLEND32(linearlight,(B < 0.5) ? B + 2 * A - 1.0 : B + 2 * (A - 0.5), 32)
+DEFINE_BLEND32(softdifference, (A > B) ? (B == 1.f) ? 0.f : (A - B) / (1.f - 
B) : (B == 0.f) ? 0.f : (B - A) / B, 32)
 
 #define DEFINE_BLEND_EXPR(type, name, div) 
\
 static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize,
  \

[FFmpeg-cvslog] avutil/tests/opt: Set AVClass.version

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 26 12:03:29 2021 +0200| [4e135347a7c2defaa62e27f7d0533d8963f6d539] | 
committer: Andreas Rheinhardt

avutil/tests/opt: Set AVClass.version

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

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

 libavutil/tests/opt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c
index 3134ffd354..e6ea892373 100644
--- a/libavutil/tests/opt.c
+++ b/libavutil/tests/opt.c
@@ -105,6 +105,7 @@ static const AVClass test_class = {
 .class_name = "TestContext",
 .item_name  = test_get_name,
 .option = test_options,
+.version= LIBAVUTIL_VERSION_INT,
 };
 
 static void log_callback_help(void *ptr, int level, const char *fmt, va_list 
vl)

___
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] avutil/opt: Remove outdated version check

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep 26 11:48:33 2021 +0200| [386a4989df09582a4c35e86678243d24c66b9693] | 
committer: Andreas Rheinhardt

avutil/opt: Remove outdated version check

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

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

 libavutil/opt.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index f05283d610..c7001dbcd3 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1831,10 +1831,7 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, 
void *obj, const char *key,
 {
 int ret;
 const AVClass *c = *(AVClass**)obj;
-int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) 
= NULL;
-
-if (c->version > (52 << 16 | 11 << 8))
-callback = c->query_ranges;
+int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) 
= c->query_ranges;
 
 if (!callback)
 callback = av_opt_query_ranges_default;

___
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] avformat/chromaprint: Add deinit function

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 01:52:23 2021 +0200| [dd1975b0bbcfdd7d02808b3deac43f8f4073731d] | 
committer: Andreas Rheinhardt

avformat/chromaprint: Add deinit function

Fixes memleaks in case the trailer is never written.

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index 399de725d3..b7a943e126 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -47,8 +47,10 @@ typedef struct ChromaprintMuxContext {
 #endif
 } ChromaprintMuxContext;
 
-static void cleanup(ChromaprintMuxContext *cpr)
+static void deinit(AVFormatContext *s)
 {
+ChromaprintMuxContext *const cpr = s->priv_data;
+
 if (cpr->ctx) {
 ff_lock_avformat();
 chromaprint_free(cpr->ctx);
@@ -107,7 +109,6 @@ static int write_header(AVFormatContext *s)
 
 return 0;
 fail:
-cleanup(cpr);
 return AVERROR(EINVAL);
 }
 
@@ -156,7 +157,6 @@ fail:
 chromaprint_dealloc(fp);
 if (enc_fp)
 chromaprint_dealloc(enc_fp);
-cleanup(cpr);
 return ret;
 }
 
@@ -187,6 +187,7 @@ const AVOutputFormat ff_chromaprint_muxer = {
 .write_header  = write_header,
 .write_packet  = write_packet,
 .write_trailer = write_trailer,
+.deinit= deinit,
 .flags = AVFMT_NOTIMESTAMPS,
 .priv_class= &chromaprint_class,
 };

___
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] avformat/chromaprint: Improve returned error codes

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 06:57:44 2021 +0200| [aeee5e3967a0024615cea1bb2736ed120c566048] | 
committer: Andreas Rheinhardt

avformat/chromaprint: Improve returned error codes

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/chromaprint.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index b7a943e126..e4882c8e61 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -69,47 +69,45 @@ static int write_header(AVFormatContext *s)
 
 if (!cpr->ctx) {
 av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n");
-return AVERROR(ENOMEM);
+return AVERROR_EXTERNAL;
 }
 
 if (cpr->silence_threshold != -1) {
 #if CPR_VERSION_INT >= AV_VERSION_INT(0, 7, 0)
 if (!chromaprint_set_option(cpr->ctx, "silence_threshold", 
cpr->silence_threshold)) {
 av_log(s, AV_LOG_ERROR, "Failed to set silence threshold. Setting 
silence_threshold requires -algorithm 3 option.\n");
-goto fail;
+return AVERROR_EXTERNAL;
 }
 #else
 av_log(s, AV_LOG_ERROR, "Setting the silence threshold requires 
Chromaprint "
 "version 0.7.0 or later.\n");
-goto fail;
+return AVERROR(ENOSYS);
 #endif
 }
 
 if (s->nb_streams != 1) {
 av_log(s, AV_LOG_ERROR, "Only one stream is supported\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 st = s->streams[0];
 
 if (st->codecpar->channels > 2) {
 av_log(s, AV_LOG_ERROR, "Only up to 2 channels are supported\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 if (st->codecpar->sample_rate < 1000) {
 av_log(s, AV_LOG_ERROR, "Sampling rate must be at least 1000\n");
-goto fail;
+return AVERROR(EINVAL);
 }
 
 if (!chromaprint_start(cpr->ctx, st->codecpar->sample_rate, 
st->codecpar->channels)) {
 av_log(s, AV_LOG_ERROR, "Failed to start chromaprint\n");
-goto fail;
+return AVERROR_EXTERNAL;
 }
 
 return 0;
-fail:
-return AVERROR(EINVAL);
 }
 
 static int write_packet(AVFormatContext *s, AVPacket *pkt)
@@ -124,7 +122,7 @@ static int write_trailer(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 void *fp = NULL;
 char *enc_fp = NULL;
-int size, enc_size, ret = AVERROR(EINVAL);
+int size, enc_size, ret = AVERROR_EXTERNAL;
 
 if (!chromaprint_finish(cpr->ctx)) {
 av_log(s, AV_LOG_ERROR, "Failed to generate fingerprint\n");

___
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] avformat/filmstripenc: Simplify writing reserved elements

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 06:58:41 2021 +0200| [3042e71776a5f09b814c73430c7169e789847bbc] | 
committer: Andreas Rheinhardt

avformat/filmstripenc: Simplify writing reserved elements

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/filmstripenc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c
index 48f483bc90..ebb7294175 100644
--- a/libavformat/filmstripenc.c
+++ b/libavformat/filmstripenc.c
@@ -26,6 +26,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "rawenc.h"
 
 #define RAND_TAG MKBETAG('R','a','n','d')
@@ -43,7 +44,6 @@ static int write_trailer(AVFormatContext *s)
 {
 AVIOContext *pb = s->pb;
 AVStream *st = s->streams[0];
-int i;
 
 avio_wb32(pb, RAND_TAG);
 avio_wb32(pb, st->nb_frames);
@@ -54,8 +54,7 @@ static int write_trailer(AVFormatContext *s)
 avio_wb16(pb, 0);  // leading
 // TODO: should be avg_frame_rate
 avio_wb16(pb, st->time_base.den / st->time_base.num);
-for (i = 0; i < 16; i++)
-avio_w8(pb, 0x00);  // reserved
+ffio_fill(pb, 0x00, 16);  // reserved
 
 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/audio, video: Remove references to avfilter_unref_buffer()

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 07:03:55 2021 +0200| [f7d59ca364c38860089b56826df47db032a80822] | 
committer: Andreas Rheinhardt

avfilter/audio, video: Remove references to avfilter_unref_buffer()

Signed-off-by: Andreas Rheinhardt 

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

 libavfilter/audio.h | 3 +--
 libavfilter/video.h | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavfilter/audio.h b/libavfilter/audio.h
index 6bbe6ee9ef..90709a0ad0 100644
--- a/libavfilter/audio.h
+++ b/libavfilter/audio.h
@@ -37,8 +37,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int 
nb_samples);
  * @param link   the output link to the filter from which the buffer 
will
  *   be requested
  * @param nb_samples the number of samples per channel
- * @return   A reference to the samples. This must be unreferenced 
with
- *   avfilter_unref_buffer when you are finished with it.
+ * @return   on success an AVFrame owned by the caller, NULL on 
error
  */
 AVFrame *ff_get_audio_buffer(AVFilterLink *link, int nb_samples);
 
diff --git a/libavfilter/video.h b/libavfilter/video.h
index 56c58d6766..f448e4ada4 100644
--- a/libavfilter/video.h
+++ b/libavfilter/video.h
@@ -33,8 +33,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, 
int h);
  *  be requested
  * @param w the minimum width of the buffer to allocate
  * @param h the minimum height of the buffer to allocate
- * @return  A reference to the buffer. This must be unreferenced with
- *  avfilter_unref_buffer when you are finished with it.
+ * @return  on success, an AVFrame owned by the caller, NULL on error
  */
 AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int 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] fate/demux: Move caf test to its own file

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 05:35:46 2021 +0200| [e02447e41e2ea91fbaae1c4f65a276b924d6e9e8] | 
committer: Andreas Rheinhardt

fate/demux: Move caf test to its own file

Signed-off-by: Andreas Rheinhardt 

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

 tests/Makefile| 1 +
 tests/fate/caf.mak| 5 +
 tests/fate/demux.mak  | 3 ---
 tests/ref/fate/{caf => caf-demux} | 0
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index e42e66d81b..d5595908b8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -121,6 +121,7 @@ include $(SRC_PATH)/tests/fate/atrac.mak
 include $(SRC_PATH)/tests/fate/audio.mak
 include $(SRC_PATH)/tests/fate/bmp.mak
 include $(SRC_PATH)/tests/fate/build.mak
+include $(SRC_PATH)/tests/fate/caf.mak
 include $(SRC_PATH)/tests/fate/canopus.mak
 include $(SRC_PATH)/tests/fate/cbs.mak
 include $(SRC_PATH)/tests/fate/cdxl.mak
diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak
new file mode 100644
index 00..e921fcc297
--- /dev/null
+++ b/tests/fate/caf.mak
@@ -0,0 +1,5 @@
+FATE_CAF_FFMPEG-$(call ALLYES, CAF_DEMUXER CRC_MUXER) += fate-caf-demux
+fate-caf-demux: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
+
+FATE_SAMPLES_FFMPEG += $(FATE_CAF_FFMPEG-yes)
+fate-caf: $(FATE_CAF_FFMPEG-yes)
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index 6ddbbcbd4d..20aa90427b 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -29,9 +29,6 @@ fate-bcstm: CMD = crc -i 
$(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -c:a copy
 FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm
 fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -c:a copy
 
-FATE_SAMPLES_DEMUX-$(CONFIG_CAF_DEMUXER) += fate-caf
-fate-caf: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
-
 FATE_SAMPLES_DEMUX-$(CONFIG_CDXL_DEMUXER) += fate-cdxl-demux
 fate-cdxl-demux: CMD = framecrc -i $(TARGET_SAMPLES)/cdxl/mirage.cdxl -c:v 
copy -c:a copy
 
diff --git a/tests/ref/fate/caf b/tests/ref/fate/caf-demux
similarity index 100%
rename from tests/ref/fate/caf
rename to tests/ref/fate/caf-demux

___
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] fate/caf: Add remux tests

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 07:46:44 2021 +0200| [3a47e87d554363d9fe2ebf4ca79a5c498c5569c5] | 
committer: Andreas Rheinhardt

fate/caf: Add remux tests

These test both the muxer as well as the demuxer.

Signed-off-by: Andreas Rheinhardt 

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

 tests/fate/caf.mak | 30 +-
 tests/ref/fate/caf-alac-remux  | 27 +++
 tests/ref/fate/caf-amr_nb-remux| 19 +++
 tests/ref/fate/caf-mace6-remux | 20 
 tests/ref/fate/caf-pcm_s24-remux   | 23 +++
 tests/ref/fate/caf-pcm_s24le-remux | 23 +++
 tests/ref/fate/caf-qdm2-remux  | 12 
 7 files changed, 153 insertions(+), 1 deletion(-)

diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak
index e921fcc297..ae2c543358 100644
--- a/tests/fate/caf.mak
+++ b/tests/fate/caf.mak
@@ -1,5 +1,33 @@
 FATE_CAF_FFMPEG-$(call ALLYES, CAF_DEMUXER CRC_MUXER) += fate-caf-demux
 fate-caf-demux: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy
 
+FATE_CAF_REMUX_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-caf-alac-remux
+fate-caf-alac-remux: CMD = transcode m4a 
$(TARGET_SAMPLES)/lossless-audio/inside.m4a caf "-map 0:a -c copy -metadata 
major_brand= " "-c copy -t 0.2" "" "-show_entries format_tags"
+
+FATE_CAF_REMUX-$(CONFIG_AMR_DEMUXER) += fate-caf-amr_nb-remux
+fate-caf-amr_nb-remux: CMD = transcode amr $(TARGET_SAMPLES)/amrnb/4.75k.amr 
caf "-c copy" "-c copy -t 0.2"
+
+FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-qdm2-remux
+fate-caf-qdm2-remux: CMD = transcode mov 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov caf "-c copy" "-c copy 
-t 0.2"
+
+FATE_CAF_REMUX-$(CONFIG_WAV_DEMUXER) += fate-caf-pcm_s24le-remux
+fate-caf-pcm_s24le-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c copy" 
"-c copy -t 0.05"
+
+FATE_CAF_REMUX-$(call ALLYES, WAV_DEMUXER PCM_S24LE_DECODER \
+  PCM_S24BE_ENCODER)\
+  += fate-caf-pcm_s24-remux
+fate-caf-pcm_s24-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c 
pcm_s24be" "-c copy -t 0.05"
+
+FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-mace6-remux
+fate-caf-mace6-remux: CMD = transcode mov 
$(TARGET_SAMPLES)/qtrle/Animation-16Greys.mov caf "-map 0:a -c copy" "-c copy 
-t 0.003"
+
+FATE_CAF_FFMPEG-$(call ALLYES, FILE_PROTOCOL CAF_MUXER CAF_DEMUXER \
+   FRAMECRC_MUXER PIPE_PROTOCOL)   \
+   += $(FATE_CAF_REMUX-yes)
+FATE_CAF_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL CAF_MUXER\
+   CAF_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+  += $(FATE_CAF_REMUX_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_CAF_FFMPEG-yes)
-fate-caf: $(FATE_CAF_FFMPEG-yes)
+FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_CAF_FFMPEG_FFPROBE-yes)
+fate-caf: $(FATE_CAF_FFMPEG-yes) $(FATE_CAF_FFMPEG_FFPROBE-yes)
diff --git a/tests/ref/fate/caf-alac-remux b/tests/ref/fate/caf-alac-remux
new file mode 100644
index 00..97275fd317
--- /dev/null
+++ b/tests/ref/fate/caf-alac-remux
@@ -0,0 +1,27 @@
+9ef40186fb3e24789df03f8c08110486 *tests/data/fate/caf-alac-remux.caf
+1292684 tests/data/fate/caf-alac-remux.caf
+#extradata 0:   36, 0x562b05d8
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: alac
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0,0,   32, 0xa0af0dfe
+0,   4096,   4096,0, 6701, 0xa9ddc14e
+0,   8192,   8192,0, 6639, 0x3ccda8d6
+[FORMAT]
+TAG:track=5/13
+TAG:minor_version=0
+TAG:compatible_brands=M4A mp42isom
+TAG:disc=1
+TAG:title=Inside
+TAG:compilation=1
+TAG:gapless_playback=0
+TAG:genre=Rock
+TAG:Encoding Params=vers
+TAG:iTunNORM= 04DF 04C2 1E64 1AB3 0FB9 0FB9 6480 
6480 0FB9 0B52
+TAG:artist=Maxwell Strait
+TAG:album_artist=Maxwell Strait
+TAG:album=OpenMusic
+[/FORMAT]
diff --git a/tests/ref/fate/caf-amr_nb-remux b/tests/ref/fate/caf-amr_nb-remux
new file mode 100644
index 00..0eed36a5cb
--- /dev/null
+++ b/tests/ref/fate/caf-amr_nb-remux
@@ -0,0 +1,19 @@
+a00bd18f70b66286e67d84f0df034a48 *tests/data/fate/caf-amr_nb-remux.caf
+4145 tests/data/fate/caf-amr_nb-remux.caf
+#extradata 0:   29, 0x6b3407d3
+#tb 0: 1/8000
+#media_type 0: audio
+#codec_id 0: amr_nb
+#sample_rate 0: 8000
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,  0,  0,  160,   13, 0x2bf906f6
+0,160,160,  160,   13, 0x28bd0756
+0,320,320,  160,   13, 0x2b2706f7
+0,480,480,  160,   13, 0

[FFmpeg-cvslog] avformat/cafenc: Fix memleak when trailer is never written

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 04:09:59 2021 +0200| [d94b641b4a3ac3cbb009c8818b0eaf3e15795dca] | 
committer: Andreas Rheinhardt

avformat/cafenc: Fix memleak when trailer is never written

Do this by using the AVStream's priv_data for the buffer holding
the packet size data.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/cafenc.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index b17d2397e9..412b3230e3 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -30,7 +30,6 @@
 
 typedef struct {
 int64_t data;
-uint8_t *pkt_sizes;
 int size_buffer_size;
 int size_entries_used;
 int packets;
@@ -209,25 +208,26 @@ static int caf_write_header(AVFormatContext *s)
 static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 CAFContext *caf = s->priv_data;
+AVStream *const st = s->streams[0];
 
-if (!s->streams[0]->codecpar->block_align) {
-void *pkt_sizes;
+if (!st->codecpar->block_align) {
+uint8_t *pkt_sizes;
 int i, alloc_size = caf->size_entries_used + 5U;
 if (alloc_size < 0)
 return AVERROR(ERANGE);
 
-pkt_sizes = av_fast_realloc(caf->pkt_sizes,
+pkt_sizes = av_fast_realloc(st->priv_data,
 &caf->size_buffer_size,
 alloc_size);
 if (!pkt_sizes)
 return AVERROR(ENOMEM);
-caf->pkt_sizes = pkt_sizes;
+st->priv_data = pkt_sizes;
 for (i = 4; i > 0; i--) {
 unsigned top = pkt->size >> i * 7;
 if (top)
-caf->pkt_sizes[caf->size_entries_used++] = 128 | top;
+pkt_sizes[caf->size_entries_used++] = 128 | top;
 }
-caf->pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
+pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
 caf->packets++;
 }
 avio_write(s->pb, pkt->data, pkt->size);
@@ -260,10 +260,9 @@ static int caf_write_trailer(AVFormatContext *s)
 avio_wb64(pb, caf->packets * packet_size); ///< mNumberValidFrames
 avio_wb32(pb, 0); ///< mPrimingFrames
 avio_wb32(pb, 0); ///< mRemainderFrames
-avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
+avio_write(pb, st->priv_data, caf->size_entries_used);
 }
 }
-av_freep(&caf->pkt_sizes);
 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] avformat/cafenc: Fix potential integer overflow

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 07:21:05 2021 +0200| [42fe438482dd0f1f59d86e27a88a616ad966706b] | 
committer: Andreas Rheinhardt

avformat/cafenc: Fix potential integer overflow

(As long as avio_write() only accepts an int, it makes no sense
to try to support sizes that don't fit into an int.)

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/cafenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 816e978945..622ae14264 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -213,7 +213,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_write(s->pb, pkt->data, pkt->size);
 if (!s->streams[0]->codecpar->block_align) {
 void *pkt_sizes = caf->pkt_sizes;
-int i, alloc_size = caf->size_entries_used + 5;
+int i, alloc_size = caf->size_entries_used + 5U;
 if (alloc_size < 0) {
 caf->pkt_sizes = NULL;
 } else {
@@ -257,7 +257,7 @@ static int caf_write_trailer(AVFormatContext *s)
 }
 avio_seek(pb, file_size, SEEK_SET);
 ffio_wfourcc(pb, "pakt");
-avio_wb64(pb, caf->size_entries_used + 24);
+avio_wb64(pb, caf->size_entries_used + 24U);
 avio_wb64(pb, caf->packets); ///< mNumberPackets
 avio_wb64(pb, caf->packets * packet_size); ///< mNumberValidFrames
 avio_wb32(pb, 0); ///< mPrimingFrames

___
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] avformat/icoenc: Simplify writing bitmask

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 21:52:24 2021 +0200| [7d5e27b473a1ba013a9eb63f57e1e2e445200f6f] | 
committer: Andreas Rheinhardt

avformat/icoenc: Simplify writing bitmask

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index ee793137fd..21966f3921 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -31,6 +31,7 @@
 #include "libavcodec/codec_id.h"
 
 #include "avformat.h"
+#include "avio_internal.h"
 
 typedef struct {
 int offset;
@@ -119,7 +120,6 @@ static int ico_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 IcoImage *image;
 AVIOContext *pb = s->pb;
 AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
-int i;
 
 if (ico->current_image >= ico->nb_images) {
 av_log(s, AV_LOG_ERROR, "ICO already contains %d images\n", 
ico->current_image);
@@ -150,8 +150,8 @@ static int ico_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_wl32(pb, AV_RL32(pkt->data + 22) * 2); // rewrite height as 2 * 
height
 avio_write(pb, pkt->data + 26, pkt->size - 26);
 
-for (i = 0; i < par->height * (par->width + 7) / 8; ++i)
-avio_w8(pb, 0x00); // Write bitmask (opaque)
+// Write bitmask (opaque)
+ffio_fill(pb, 0x00, par->height * (par->width + 7) / 8);
 }
 
 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] avformat/cafenc: Don't segfault upon allocation error

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 02:38:49 2021 +0200| [19a6b51fe61b915b734319b5d917192108df8188] | 
committer: Andreas Rheinhardt

avformat/cafenc: Don't segfault upon allocation error

If an array for the packet sizes could not be successfully reallocated
when writing a packet, the CAF muxer frees said array, but does not
reset the number of valid bytes. As a result, when the trailer is
written later, avio_write tries to read that many bytes from NULL,
which segfaults.

Fix this by not freeing the array in case of error; also, postpone
writing the packet data after having successfully (re)allocated the
array, so that even on allocation error the file can be correctly
finalized.

Also remove an unnecessary resetting of the number of size entries
used at the end.

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

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

 libavformat/cafenc.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 622ae14264..b17d2397e9 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -210,21 +210,18 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 {
 CAFContext *caf = s->priv_data;
 
-avio_write(s->pb, pkt->data, pkt->size);
 if (!s->streams[0]->codecpar->block_align) {
-void *pkt_sizes = caf->pkt_sizes;
+void *pkt_sizes;
 int i, alloc_size = caf->size_entries_used + 5U;
-if (alloc_size < 0) {
-caf->pkt_sizes = NULL;
-} else {
-caf->pkt_sizes = av_fast_realloc(caf->pkt_sizes,
- &caf->size_buffer_size,
- alloc_size);
-}
-if (!caf->pkt_sizes) {
-av_free(pkt_sizes);
+if (alloc_size < 0)
+return AVERROR(ERANGE);
+
+pkt_sizes = av_fast_realloc(caf->pkt_sizes,
+&caf->size_buffer_size,
+alloc_size);
+if (!pkt_sizes)
 return AVERROR(ENOMEM);
-}
+caf->pkt_sizes = pkt_sizes;
 for (i = 4; i > 0; i--) {
 unsigned top = pkt->size >> i * 7;
 if (top)
@@ -233,6 +230,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 caf->pkt_sizes[caf->size_entries_used++] = pkt->size & 127;
 caf->packets++;
 }
+avio_write(s->pb, pkt->data, pkt->size);
 return 0;
 }
 
@@ -263,7 +261,6 @@ static int caf_write_trailer(AVFormatContext *s)
 avio_wb32(pb, 0); ///< mPrimingFrames
 avio_wb32(pb, 0); ///< mRemainderFrames
 avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
-caf->size_buffer_size = 0;
 }
 }
 av_freep(&caf->pkt_sizes);

___
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] avformat/icoenc: Use avcodec_get_name() instead of codec descriptor

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 22:36:23 2021 +0200| [63a5e83de8189372fcf8c543a01f1a0c28860ccb] | 
committer: Andreas Rheinhardt

avformat/icoenc: Use avcodec_get_name() instead of codec descriptor

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/icoenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index 21966f3921..d684f67707 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -27,7 +27,6 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
 
-#include "libavcodec/codec_desc.h"
 #include "libavcodec/codec_id.h"
 
 #include "avformat.h"
@@ -66,8 +65,7 @@ static int ico_check_attributes(AVFormatContext *s, const 
AVCodecParameters *p)
 return AVERROR(EINVAL);
 }
 } else {
-const AVCodecDescriptor *codesc = avcodec_descriptor_get(p->codec_id);
-av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", codesc ? 
codesc->name : "");
+av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", 
avcodec_get_name(p->codec_id));
 return AVERROR(EINVAL);
 }
 

___
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] avformat/movenc: Limit ism_lookahead to a sane value

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 20:36:21 2021 +0200| [1cf3c59b58f4380d5ce166a67331777891d06eef] | 
committer: Andreas Rheinhardt

avformat/movenc: Limit ism_lookahead to a sane value

There can only be a maximum of 255 entries in a tfrf tag, so using
more makes no sense; moreover, several size computations can overflow
in this case. Fix this by limiting it to 255.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index cfb5a5c725..53c8ffadd5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -94,7 +94,7 @@ static const AVOption options[] = {
 { "frag_duration", "Maximum fragment duration", offsetof(MOVMuxContext, 
max_fragment_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
 { "min_frag_duration", "Minimum fragment duration", 
offsetof(MOVMuxContext, min_fragment_duration), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
 { "frag_size", "Maximum fragment size", offsetof(MOVMuxContext, 
max_fragment_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
-{ "ism_lookahead", "Number of lookahead entries for ISM files", 
offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+{ "ism_lookahead", "Number of lookahead entries for ISM files", 
offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 255, 
AV_OPT_FLAG_ENCODING_PARAM},
 { "video_track_timescale", "set timescale of all video tracks", 
offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
 { "brand","Override major brand", offsetof(MOVMuxContext, 
major_brand),   AV_OPT_TYPE_STRING, {.str = NULL}, .flags = 
AV_OPT_FLAG_ENCODING_PARAM },
 { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), 
AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},

___
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] avformat/movenc: Simplify reserving space for tfrf tags

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 21:54:02 2021 +0200| [2c47a9491184d8dc7e3b751c9003af024f018ac8] | 
committer: Andreas Rheinhardt

avformat/movenc: Simplify reserving space for tfrf tags

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/movenc.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 53c8ffadd5..7650ac5ed3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1344,7 +1344,6 @@ static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack 
*track)
 /* also used by all avid codecs (dv, imx, meridien) and their variants */
 static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
 {
-int i;
 int interlaced;
 int cid;
 int display_width = track->par->width;
@@ -1419,8 +1418,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
*track)
 avio_wb32(pb, 6); /* unknown */
 }
 /* padding */
-for (i = 0; i < 10; i++)
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 10 * 8);
 
 return 0;
 }
@@ -1925,10 +1923,7 @@ static int mov_write_dvcc_dvvc_tag(AVFormatContext *s, 
AVIOContext *pb, AVDOVIDe
   dovi->bl_present_flag);
 avio_wb32(pb, (dovi->dv_bl_signal_compatibility_id << 28) | 0);
 
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 4 * 4); /* reserved */
 av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, 
level: %d, "
"rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
dovi->dv_profile > 7 ? "dvvC" : "dvcC",
@@ -2159,9 +2154,7 @@ static int mov_write_video_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContex
 avio_wb32(pb, 0x200); /* Spatial Quality = normal */
 }
 } else {
-avio_wb32(pb, 0); /* Reserved */
-avio_wb32(pb, 0); /* Reserved */
-avio_wb32(pb, 0); /* Reserved */
+ffio_fill(pb, 0, 3 * 4); /* Reserved */
 }
 avio_wb16(pb, track->par->width); /* Video width */
 avio_wb16(pb, track->height); /* Video height */
@@ -3506,9 +3499,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, 
MOVMuxContext *mov)
 
 avio_wb32(pb, 0x0001); /* reserved (preferred rate) 1.0 = normal */
 avio_wb16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
-avio_wb16(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
-avio_wb32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 2 + 2 * 4); /* reserved */
 
 /* Matrix structure */
 write_matrix(pb, 1, 0, 0, 1, 0, 0);
@@ -4668,7 +4659,7 @@ static int mov_write_traf_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 mov_write_tfxd_tag(pb, track);
 
 if (mov->ism_lookahead) {
-int i, size = 16 + 4 + 1 + 16 * mov->ism_lookahead;
+int size = 16 + 4 + 1 + 16 * mov->ism_lookahead;
 
 if (track->nb_frag_info > 0) {
 MOVFragmentInfo *info = &track->frag_info[track->nb_frag_info 
- 1];
@@ -4677,8 +4668,7 @@ static int mov_write_traf_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 }
 avio_wb32(pb, 8 + size);
 ffio_wfourcc(pb, "free");
-for (i = 0; i < size; i++)
-avio_w8(pb, 0);
+ffio_fill(pb, 0, size);
 }
 }
 

___
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] avformat/matroskaenc: Simplify writing qt-compatibility header

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 21:55:43 2021 +0200| [62c8b96a1362622c73f988db05f66a0ebd15211b] | 
committer: Andreas Rheinhardt

avformat/matroskaenc: Simplify writing qt-compatibility header

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/matroskaenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 039f20988a..f17665b0c1 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -785,11 +785,9 @@ static int mkv_write_codecprivate(AVFormatContext *s, 
AVIOContext *pb,
 if (   ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == 
par->codec_id
 && (!par->extradata_size || 
ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(par->extradata + 4)) != 
par->codec_id)
 ) {
-int i;
 avio_wb32(dyn_cp, 0x5a + par->extradata_size);
 avio_wl32(dyn_cp, par->codec_tag);
-for(i = 0; i < 0x5a - 8; i++)
-avio_w8(dyn_cp, 0);
+ffio_fill(dyn_cp, 0, 0x5a - 8);
 }
 avio_write(dyn_cp, par->extradata, par->extradata_size);
 } else {

___
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] avformat/mpegenc: Simplify writing padding/stuffing

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 21:58:33 2021 +0200| [dbc76e4e70a43fbe6dd7c7c899b134e4c26f43f5] | 
committer: Andreas Rheinhardt

avformat/mpegenc: Simplify writing padding/stuffing

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/mpegenc.c | 26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6aed527d50..b1d8bf9c38 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -30,6 +30,7 @@
 #include "libavcodec/put_bits.h"
 
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 #include "mpeg.h"
 
@@ -598,7 +599,6 @@ static void put_padding_packet(AVFormatContext *ctx, 
AVIOContext *pb,
int packet_bytes)
 {
 MpegMuxContext *s = ctx->priv_data;
-int i;
 
 avio_wb32(pb, PADDING_STREAM);
 avio_wb16(pb, packet_bytes - 6);
@@ -608,8 +608,7 @@ static void put_padding_packet(AVFormatContext *ctx, 
AVIOContext *pb,
 } else
 packet_bytes -= 6;
 
-for (i = 0; i < packet_bytes; i++)
-avio_w8(pb, 0xff);
+ffio_fill(pb, 0xff, packet_bytes);
 }
 
 static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len)
@@ -634,7 +633,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 MpegMuxContext *s  = ctx->priv_data;
 StreamInfo *stream = ctx->streams[stream_index]->priv_data;
 uint8_t *buf_ptr;
-int size, payload_size, startcode, id, stuffing_size, i, header_len;
+int size, payload_size, startcode, id, stuffing_size, header_len;
 int packet_size;
 uint8_t buffer[128];
 int zero_trail_bytes = 0;
@@ -685,14 +684,12 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 avio_wb32(ctx->pb, PRIVATE_STREAM_2);
 avio_wb16(ctx->pb, 0x03d4); // length
 avio_w8(ctx->pb, 0x00); // substream ID, 00=PCI
-for (i = 0; i < 979; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, 979);
 
 avio_wb32(ctx->pb, PRIVATE_STREAM_2);
 avio_wb16(ctx->pb, 0x03fa); // length
 avio_w8(ctx->pb, 0x01); // substream ID, 01=DSI
-for (i = 0; i < 1017; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, 1017);
 
 memset(buffer, 0, 128);
 buf_ptr = buffer;
@@ -835,8 +832,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 avio_wb16(ctx->pb, packet_size);
 
 if (!s->is_mpeg2)
-for (i = 0; i < stuffing_size; i++)
-avio_w8(ctx->pb, 0xff);
+ffio_fill(ctx->pb, 0xff, stuffing_size);
 
 if (s->is_mpeg2) {
 avio_w8(ctx->pb, 0x80); /* mpeg2 id */
@@ -891,8 +887,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
  * to prevent accidental generation of start codes. */
 avio_w8(ctx->pb, 0xff);
 
-for (i = 0; i < stuffing_size; i++)
-avio_w8(ctx->pb, 0xff);
+ffio_fill(ctx->pb, 0xff, stuffing_size);
 }
 
 if (startcode == PRIVATE_STREAM_1) {
@@ -925,8 +920,7 @@ static int flush_packet(AVFormatContext *ctx, int 
stream_index,
 if (pad_packet_bytes > 0)
 put_padding_packet(ctx, ctx->pb, pad_packet_bytes);
 
-for (i = 0; i < zero_trail_bytes; i++)
-avio_w8(ctx->pb, 0x00);
+ffio_fill(ctx->pb, 0x00, zero_trail_bytes);
 
 avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
 
@@ -950,10 +944,8 @@ static void put_vcd_padding_sector(AVFormatContext *ctx)
  * So a 0-sector it is... */
 
 MpegMuxContext *s = ctx->priv_data;
-int i;
 
-for (i = 0; i < s->packet_size; i++)
-avio_w8(ctx->pb, 0);
+ffio_fill(ctx->pb, 0, s->packet_size);
 
 s->vcd_padding_bytes_written += s->packet_size;
 

___
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] avformat/asfenc: Simplify writing error correction data

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 22:38:57 2021 +0200| [b98e397252b1950240e04e47e92d17fd8275073a] | 
committer: Andreas Rheinhardt

avformat/asfenc: Simplify writing error correction data

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/asfenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 07588772c6..a0510df7dc 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -838,8 +838,7 @@ static int put_payload_parsing_info(AVFormatContext *s,
 av_assert0(padsize >= 0);
 
 avio_w8(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
-for (int i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++)
-avio_w8(pb, 0x0);
+ffio_fill(pb, 0x0, ASF_PACKET_ERROR_CORRECTION_DATA_SIZE);
 
 if (asf->multi_payloads_present)
 iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT;

___
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] fate/demux: Move Sony OpenMG audio (oma) test into a new file

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 13:52:57 2021 +0200| [fc439f776dc6f4d9e1904cc72c3f3ecab79e6f96] | 
committer: Andreas Rheinhardt

fate/demux: Move Sony OpenMG audio (oma) test into a new file

Signed-off-by: Andreas Rheinhardt 

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

 tests/Makefile   | 1 +
 tests/fate/demux.mak | 3 ---
 tests/fate/oma.mak   | 5 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index d5595908b8..1e0345b163 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -173,6 +173,7 @@ include $(SRC_PATH)/tests/fate/mpeg4.mak
 include $(SRC_PATH)/tests/fate/mpegps.mak
 include $(SRC_PATH)/tests/fate/mpegts.mak
 include $(SRC_PATH)/tests/fate/mxf.mak
+include $(SRC_PATH)/tests/fate/oma.mak
 include $(SRC_PATH)/tests/fate/opus.mak
 include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/pixfmt.mak
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index 20aa90427b..2c508a42aa 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -103,9 +103,6 @@ fate-oggopus-demux: CMD = ffprobe_demux 
$(TARGET_SAMPLES)/ogg/intro-partial.opus
 FATE_SAMPLES_DEMUX-$(CONFIG_OGG_DEMUXER) += fate-oggvp8-demux
 fate-oggvp8-demux: CMD = framecrc -i $(TARGET_SAMPLES)/ogg/videotest.ogv -c:v 
copy
 
-FATE_SAMPLES_DEMUX-$(CONFIG_OMA_DEMUXER) += fate-oma-demux
-fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
-
 FATE_SAMPLES_DEMUX-$(CONFIG_PAF_DEMUXER) += fate-paf-demux
 fate-paf-demux: CMD = framecrc -i $(TARGET_SAMPLES)/paf/hod1-partial.paf -c:v 
copy -c:a copy
 
diff --git a/tests/fate/oma.mak b/tests/fate/oma.mak
new file mode 100644
index 00..977dbd5c32
--- /dev/null
+++ b/tests/fate/oma.mak
@@ -0,0 +1,5 @@
+FATE_OMA_FFMPEG-$(call ALLYES, OMA_DEMUXER CRC_MUXER) += fate-oma-demux
+fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
+
+FATE_SAMPLES_FFMPEG += $(FATE_OMA_FFMPEG-yes)
+fate-oma: $(FATE_OMA_FFMPEG-yes)

___
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] fate/oma: Add remux tests for ATRAC3 and ATRAC3P

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 14:41:23 2021 +0200| [ffe9867bc22aba87fb016e16a4c628e010f404b3] | 
committer: Andreas Rheinhardt

fate/oma: Add remux tests for ATRAC3 and ATRAC3P

They already uncovered an uninitialized-value bug in the ATRAC3 code
in the demuxer; and provide coverage for ID3v2.3.

Signed-off-by: Andreas Rheinhardt 

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

 tests/fate/oma.mak   | 18 +-
 tests/ref/fate/oma-atrac3-remux  | 14 ++
 tests/ref/fate/oma-atrac3p-remux | 18 ++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/tests/fate/oma.mak b/tests/fate/oma.mak
index 977dbd5c32..a088feff21 100644
--- a/tests/fate/oma.mak
+++ b/tests/fate/oma.mak
@@ -1,5 +1,21 @@
 FATE_OMA_FFMPEG-$(call ALLYES, OMA_DEMUXER CRC_MUXER) += fate-oma-demux
 fate-oma-demux: CMD = crc -i $(TARGET_SAMPLES)/oma/01-Untitled-partial.oma 
-c:a copy
 
+# Also tests splitting and joining the date into TYER and TDAT id3v2.3 tags.
+FATE_OMA_REMUX_FFPROBE-yes += fate-oma-atrac3p-remux
+fate-oma-atrac3p-remux: CMD = transcode oma 
$(TARGET_SAMPLES)/atrac3p/at3p_sample1.oma oma "-c copy -metadata 
date=2021-09-23 -metadata time=16:00 -metadata title=noise -metadata 
id3v2_priv.foo=hex\xB3 -metadata_header_padding 500" "-c copy -t 0.2" "" 
"-show_entries format_tags"
+
+FATE_OMA_REMUX-$(CONFIG_WAV_DEMUXER) += fate-oma-atrac3-remux
+fate-oma-atrac3-remux: CMD = transcode wav 
$(TARGET_SAMPLES)/atrac3/mc_sich_at3_132_small.wav oma "-c copy" "-c copy -t 
0.1"
+
+FATE_OMA_FFMPEG-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
+   OMA_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+   += $(FATE_OMA_REMUX-yes)
+FATE_OMA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OMA_MUXER\
+   OMA_DEMUXER FRAMECRC_MUXER \
+   PIPE_PROTOCOL) \
+   += $(FATE_OMA_REMUX_FFPROBE-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_OMA_FFMPEG-yes)
-fate-oma: $(FATE_OMA_FFMPEG-yes)
+FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_OMA_FFMPEG_FFPROBE-yes)
+fate-oma: $(FATE_OMA_FFMPEG-yes) $(FATE_OMA_FFMPEG_FFPROBE-yes)
diff --git a/tests/ref/fate/oma-atrac3-remux b/tests/ref/fate/oma-atrac3-remux
new file mode 100644
index 00..fb402c43c6
--- /dev/null
+++ b/tests/ref/fate/oma-atrac3-remux
@@ -0,0 +1,14 @@
+9f1825375316cb8d6109747def944856 *tests/data/fate/oma-atrac3-remux.oma
+50056 tests/data/fate/oma-atrac3-remux.oma
+#extradata 0:   14, 0x0aa600f2
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: atrac3
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0, 1024,  384, 0xdfded1b5
+0,   1024,   1024, 1024,  384, 0xd8e3badd
+0,   2048,   2048, 1024,  384, 0xa316bdbb
+0,   3072,   3072, 1024,  384, 0xcea0ad2b
+0,   4096,   4096, 1024,  384, 0x88d7a98a
diff --git a/tests/ref/fate/oma-atrac3p-remux b/tests/ref/fate/oma-atrac3p-remux
new file mode 100644
index 00..d909fdaee9
--- /dev/null
+++ b/tests/ref/fate/oma-atrac3p-remux
@@ -0,0 +1,18 @@
+0053481795d07598bf2e7d931dfc4fa3 *tests/data/fate/oma-atrac3p-remux.oma
+671783 tests/data/fate/oma-atrac3p-remux.oma
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: atrac3p
+#sample_rate 0: 44100
+#channel_layout 0: 3
+#channel_layout_name 0: stereo
+0,  0,  0, 2048, 1488, 0x69b7fad9
+0,   2048,   2048, 2048, 1488, 0x3c43fdb8
+0,   4096,   4096, 2048, 1488, 0xdcd2dbcc
+0,   6144,   6144, 2048, 1488, 0x5708e4bd
+0,   8192,   8192, 2048, 1488, 0xdc7bf8a7
+[FORMAT]
+TAG:title=noise
+TAG:time=16:00
+TAG:date=2021-09-23
+[/FORMAT]

___
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] avformat/omaenc: Simplify writing padding

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Wed Sep 22 23:47:58 2021 +0200| [c8e75076f1d5a53a58da9d14574721f9404c99d4] | 
committer: Andreas Rheinhardt

avformat/omaenc: Simplify writing padding

Signed-off-by: Andreas Rheinhardt 

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

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

diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index ec71956fbd..1c4edcac5c 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -29,7 +29,6 @@
 
 static av_cold int oma_write_header(AVFormatContext *s)
 {
-int i;
 AVCodecParameters *par;
 int srate_index;
 int isjointstereo;
@@ -55,8 +54,7 @@ static av_cold int oma_write_header(AVFormatContext *s)
 avio_w8(s->pb, EA3_HEADER_SIZE >> 7);
 avio_w8(s->pb, EA3_HEADER_SIZE & 0x7F);
 avio_wl16(s->pb, 0x);   /* not encrypted */
-for (i = 0; i < 6; i++)
-avio_wl32(s->pb, 0);/* Padding + DRM id */
+ffio_fill(s->pb, 0, 6 * 4); /* Padding + DRM id */
 
 switch (par->codec_tag) {
 case OMA_CODECID_ATRAC3:
@@ -88,8 +86,7 @@ static av_cold int oma_write_header(AVFormatContext *s)
av_fourcc2str(par->codec_tag));
 return AVERROR(EINVAL);
 }
-for (i = 0; i < (EA3_HEADER_SIZE - 36)/4; i++)
-avio_wl32(s->pb, 0);/* Padding */
+ffio_fill(s->pb, 0, EA3_HEADER_SIZE - 36);  /* Padding */
 
 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] avformat/avienc: Simplify writing padding

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 01:10:51 2021 +0200| [5eafbf0b087034771c680f15c6f43608dab5422e] | 
committer: Andreas Rheinhardt

avformat/avienc: Simplify writing padding

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/avienc.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9eb072ce12..3b11841cd3 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -237,7 +237,6 @@ static void write_odml_master(AVFormatContext *s, int 
stream_index)
 AVCodecParameters *par = st->codecpar;
 AVIStream *avist = st->priv_data;
 unsigned char tag[5];
-int j;
 
 /* Starting to lay out AVI OpenDML master index.
 * We want to make it JUNK entry for now, since we'd
@@ -250,10 +249,8 @@ static void write_odml_master(AVFormatContext *s, int 
stream_index)
 avio_wl32(pb, 0);   /* nEntriesInUse (will fill out later on) */
 ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
 /* dwChunkId */
-avio_wl64(pb, 0);   /* dwReserved[3] */
-avio_wl32(pb, 0);   /* Must be 0.*/
-for (j = 0; j < avi->master_index_max_size * 2; j++)
-avio_wl64(pb, 0);
+ffio_fill(pb, 0, 3 * 4 /* dwReserved[3] */
+ + 16LL * avi->master_index_max_size);
 ff_end_tag(pb, avist->indexes.indx_start);
 }
 
@@ -351,10 +348,7 @@ static int avi_write_header(AVFormatContext *s)
 avio_wl32(pb, 0);
 avio_wl32(pb, 0);
 }
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 4 * 4); /* reserved */
 
 /* stream list */
 for (i = 0; i < n; i++) {
@@ -569,8 +563,7 @@ static int avi_write_header(AVFormatContext *s)
 ffio_wfourcc(pb, "odml");
 ffio_wfourcc(pb, "dmlh");
 avio_wl32(pb, 248);
-for (i = 0; i < 248; i += 4)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, 248);
 ff_end_tag(pb, avi->odml_list);
 }
 
@@ -586,8 +579,7 @@ static int avi_write_header(AVFormatContext *s)
 /* some padding for easier tag editing */
 if (padding) {
 list2 = ff_start_tag(pb, "JUNK");
-for (i = padding; i > 0; i -= 4)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, FFALIGN((uint32_t)padding, 4));
 ff_end_tag(pb, list2);
 }
 

___
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] avformat/gxfenc: Simplify writing padding/reserved elements

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 01:11:52 2021 +0200| [9fab059eabf19da13cd80267fba3e9d035c1c08b] | 
committer: Andreas Rheinhardt

avformat/gxfenc: Simplify writing padding/reserved elements

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/gxfenc.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 1a80ecb603..8cc3bd456e 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -25,6 +25,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/timecode.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 #include "gxf.h"
 
@@ -134,9 +135,7 @@ static int gxf_find_lines_index(AVStream *st)
 
 static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
 {
-for (; to_pad > 0; to_pad--) {
-avio_w8(pb, 0);
-}
+ffio_fill(pb, 0, to_pad);
 }
 
 static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
@@ -424,8 +423,7 @@ static int gxf_write_flt_packet(AVFormatContext *s)
 avio_wl32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
 }
 
-for (; i < 1000; i++)
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, (1000 - i) * 4);
 
 return updatePacketSize(pb, pos);
 }
@@ -542,13 +540,7 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, 
AVStream *st)
 static int gxf_write_umf_media_timecode(AVIOContext *pb, int drop)
 {
 avio_wl32(pb, drop); /* drop frame */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
-avio_wl32(pb, 0); /* reserved */
+ffio_fill(pb, 0, 7 * 4); /* reserved */
 return 32;
 }
 
@@ -559,13 +551,7 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, 
GXFStreamContext *sc, AVStrea
 if (st->codecpar->format == AV_PIX_FMT_YUV420P)
 dv_umf_data |= 0x20; /* marks as DVCAM instead of DVPRO */
 avio_wl32(pb, dv_umf_data);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
-avio_wl32(pb, 0);
+ffio_fill(pb, 0, 7 * 4);
 return 32;
 }
 
@@ -585,11 +571,10 @@ static int 
gxf_write_umf_media_description(AVFormatContext *s)
 GXFContext *gxf = s->priv_data;
 AVIOContext *pb = s->pb;
 int64_t pos;
-int i, j;
 
 pos = avio_tell(pb);
 gxf->umf_media_offset = pos - gxf->umf_start_offset;
-for (i = 0; i <= s->nb_streams; ++i) {
+for (unsigned i = 0; i <= s->nb_streams; ++i) {
 GXFStreamContext *sc;
 int64_t startpos, curpos;
 
@@ -609,8 +594,7 @@ static int gxf_write_umf_media_description(AVFormatContext 
*s)
 avio_wl32(pb, gxf->nb_fields); /* mark out */
 avio_write(pb, ES_NAME_PATTERN, strlen(ES_NAME_PATTERN));
 avio_wb16(pb, sc->media_info);
-for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
-avio_w8(pb, 0);
+ffio_fill(pb, 0, 88 - (strlen(ES_NAME_PATTERN) + 2));
 avio_wl32(pb, sc->track_type);
 avio_wl32(pb, sc->sample_rate);
 avio_wl32(pb, sc->sample_size);

___
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] avformat/mxfenc: Simplfy writing padding

2021-09-26 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 23 02:16:41 2021 +0200| [c3222931aba47b313a5b5b9f3796f08433c5f3b9] | 
committer: Andreas Rheinhardt

avformat/mxfenc: Simplfy writing padding

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/mxfenc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index f37606ed89..56facbe4b7 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -965,7 +965,6 @@ static void mxf_write_structural_component(AVFormatContext 
*s, AVStream *st, MXF
 {
 MXFContext *mxf = s->priv_data;
 AVIOContext *pb = s->pb;
-int i;
 
 mxf_write_metadata_key(pb, 0x011100);
 PRINT_KEY(s, "sturctural component key", pb->buf_ptr - 16);
@@ -985,8 +984,7 @@ static void mxf_write_structural_component(AVFormatContext 
*s, AVStream *st, MXF
 // write source package uid, end of the reference
 mxf_write_local_tag(s, 32, 0x1101);
 if (!package->ref) {
-for (i = 0; i < 4; i++)
-avio_wb64(pb, 0);
+ffio_fill(pb, 0, 32);
 } else
 mxf_write_umid(s, package->ref->instance);
 

___
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".