[FFmpeg-devel] [PATCH v4] libavfilter: add a gblur_vulkan filter

2021-11-15 Thread Wu Jianhua
This commit adds a powerful and customizable gblur Vulkan filter,
which provides a maximum 127x127 kernel size of Gaussian Filter.
The size could be adjusted by requirements on quality or performance.

The following command is on how to apply gblur_vulkan filter:

ffmpeg -init_hw_device vulkan -i input.264 -vf 
hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p output.264

Signed-off-by: Wu Jianhua 
---
 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_gblur_vulkan.c | 524 ++
 4 files changed, 527 insertions(+)
 create mode 100644 libavfilter/vf_gblur_vulkan.c

diff --git a/configure b/configure
index 891824757b..1b47f6512d 100755
--- a/configure
+++ b/configure
@@ -3613,6 +3613,7 @@ frei0r_deps_any="libdl LoadLibrary"
 frei0r_filter_deps="frei0r"
 frei0r_src_filter_deps="frei0r"
 fspp_filter_deps="gpl"
+gblur_vulkan_filter_deps="vulkan libglslang"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e2059766b0..08edc92d8c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -289,6 +289,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER)   += 
vf_freezeframes.o
 OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
 OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o qp_table.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
+OBJS-$(CONFIG_GBLUR_VULKAN_FILTER)   += vf_gblur_vulkan.o vulkan.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
 OBJS-$(CONFIG_GRAPHMONITOR_FILTER)   += f_graphmonitor.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index be94249024..f250020159 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -274,6 +274,7 @@ extern const AVFilter ff_vf_freezeframes;
 extern const AVFilter ff_vf_frei0r;
 extern const AVFilter ff_vf_fspp;
 extern const AVFilter ff_vf_gblur;
+extern const AVFilter ff_vf_gblur_vulkan;
 extern const AVFilter ff_vf_geq;
 extern const AVFilter ff_vf_gradfun;
 extern const AVFilter ff_vf_graphmonitor;
diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c
new file mode 100644
index 00..92f4461dd7
--- /dev/null
+++ b/libavfilter/vf_gblur_vulkan.c
@@ -0,0 +1,524 @@
+/*
+ * copyright (c) 2021 Wu Jianhua 
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/random_seed.h"
+#include "libavutil/opt.h"
+#include "vulkan.h"
+#include "internal.h"
+
+#define CGS 32
+#define GBLUR_MAX_KERNEL_SIZE 127
+
+typedef struct GBlurVulkanContext {
+FFVulkanContext vkctx;
+FFVkQueueFamilyCtx qf;
+FFVkExecContext *exec;
+FFVulkanPipeline *pl_hor;
+FFVulkanPipeline *pl_ver;
+FFVkBuffer params_buf_hor;
+FFVkBuffer params_buf_ver;
+
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo tmp_images[3];
+VkDescriptorImageInfo output_images[3];
+VkDescriptorBufferInfo params_desc_hor;
+VkDescriptorBufferInfo params_desc_ver;
+
+int initialized;
+int size;
+int planes;
+int kernel_size;
+float sigma;
+float sigmaV;
+AVFrame *tmpframe;
+} GBlurVulkanContext;
+
+static const char gblur_horizontal[] = {
+C(0, void gblur(const ivec2 pos, const int index)  
)
+C(0, { 
)
+C(1, vec4 sum = texture(input_image[index], pos) * kernel[0];  
)
+C(0,   
)
+C(1, for(int i = 1; i < kernel.length(); i++) {
)
+C(2, sum += texture(input_image[index], pos + vec2(i, 0.0)) * 
kernel[i];   )
+C(2, sum += texture(input_image[index], pos - vec2(i, 0.0)) * 
kernel[i];   )
+C(1, } 
)
+C(0,   
)
+C(1, imageStore(output_image[index], pos, sum);

Re: [FFmpeg-devel] [PATCH 03/15] lavu/videotoolbox: add 422 and 444 pixel format mappings

2021-11-15 Thread Wang Bin
Ridley Combs  于2021年11月16日周二 上午11:03写道:

>
>
> > On Nov 15, 2021, at 19:35, Wang Bin  wrote:
> >
> >>
> >> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
> >> +{ kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
> >> AV_PIX_FMT_NV20 },
> >> +{ kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
> >> AV_PIX_FMT_NV20 },
> >> +#endif
> >>
> >
> > It's p210, not nv20.
>
> I didn't add a P210 format (since that would've been equivalent to the
> existing NV20), only P410/P216/P416.


P210 != NV20. The lower 6 bits of P210 are zeros and must be shifted away.


> I guess I could add P210 as an alias with appropriate enum values and
> macros?


Not an alias. Add a new one like p010, p410 etc.


> In which case maybe defining the rest of the group (P008 for NV12, P208
> for NV16, P408 for NV24) would be worthwhile.
>
>
Maybe.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] Add support for loongarch.

2021-11-15 Thread 殷时友

> 2021年11月9日 下午3:09,Shiyou Yin  写道:
> 
> [PATCH 1/3] configure: Add support for loongarch.
> [PATCH 2/3] avcodec: [loongarch] optimize get_cabac.
> [PATCH 3/3] avcodec: [loongarch] Optimize decode_significance.
> 

Ping.

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

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


[FFmpeg-devel] [PATCH] x86/intmath: add VEX encoded versions of av_clipf() and av_clipd()

2021-11-15 Thread James Almer
Prevents mixing inlined SSE instructions and AVX instructions when the compiler
generates the latter.

Signed-off-by: James Almer 
---
 libavutil/x86/intmath.h | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index 1520c25ec9..8a6b5ae261 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -134,6 +134,36 @@ static av_always_inline av_const float av_clipf_sse(float 
a, float amin, float a
 
 #endif /* __SSE__ */
 
+#if defined(__AVX__) && !defined(__INTEL_COMPILER)
+
+#undef av_clipd
+#define av_clipd av_clipd_avx
+static av_always_inline av_const double av_clipd_avx(double a, double amin, 
double amax)
+{
+#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
+if (amin > amax) abort();
+#endif
+__asm__ ("vmaxsd %1, %0, %0 \n\t"
+ "vminsd %2, %0, %0 \n\t"
+ : "+"(a) : "xm"(amin), "xm"(amax));
+return a;
+}
+
+#undef av_clipf
+#define av_clipf av_clipf_avx
+static av_always_inline av_const float av_clipf_avx(float a, float amin, float 
amax)
+{
+#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
+if (amin > amax) abort();
+#endif
+__asm__ ("vmaxss %1, %0, %0 \n\t"
+ "vminss %2, %0, %0 \n\t"
+ : "+"(a) : "xm"(amin), "xm"(amax));
+return a;
+}
+
+#endif /* __AVX__ */
+
 #endif /* __GNUC__ */
 
 #endif /* AVUTIL_X86_INTMATH_H */
-- 
2.33.0

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

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


Re: [FFmpeg-devel] [PATCH 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

2021-11-15 Thread Xiang, Haihao


> On Wed, 2021-09-22 at 15:42 +0800, Haihao Xiang wrote:
> > Usually a HW decoder is expected when user specifies a HW acceleration
> > method via -hwaccel option, however the current implementation doesn't
> > take HW acceleration method into account, it is possible to select a SW
> > decoder.
> > 
> > For example:
> > 
> > $> ffmpeg -hwaccel vaapi -i av1.ivf -f null -
> > ...
> > Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))
> > 
> > libdav1d is selected in this case even if vaapi is specified.
> > 
> > After applying this patch, the native av1 decoder (with vaapi support)
> > is selected.
> > ...
> > Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))
> 
> Any comment for this patchset? We may simplify the command line using HW
> acceleration method after applying this patchset.

Ping again. 

According to the help string for -hwaccel option, HW accelerated decoding is
used if -hwaccel arg is specified. However in the current code, hwaccel is not
taken into account when choosing a codec for the video stream, (see 
https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffmpeg_opt.c#L792-L805).

For example, libdav1d is selected (if libdav1d is available) when running the
command below because libdav1d has higher priority than the native av1 decoder
in the current FFmpeg. 

$> ffmpeg -hwaccel vaapi -i av1.ivf -f null -

(Note `ffmpeg -hwaccel vaapi -i input.h264 -f null -` works as expected, the
native h264 decoder is selected)

This patch enabled the automatic codec selection for hw accelerated decoding,
-hwaccel option can work as expected after applying this patch. 

Thanks
Haihao


> > ---
> >  fftools/ffmpeg_opt.c | 44 +++-
> >  1 file changed, 43 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> > index 2d9a8a2ea0..914078add9 100644
> > --- a/fftools/ffmpeg_opt.c
> > +++ b/fftools/ffmpeg_opt.c
> > @@ -804,6 +804,48 @@ static const AVCodec *choose_decoder(OptionsContext *o,
> > AVFormatContext *s, AVSt
> >  return avcodec_find_decoder(st->codecpar->codec_id);
> >  }
> >  
> > +static const AVCodec *choose_decoder2(InputStream *ist, OptionsContext *o,
> > AVFormatContext *s, AVStream *st)
> > +{
> > +char *codec_name = NULL;
> > +
> > +MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
> > +if (codec_name) {
> > +const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar-
> > > codec_type, 0);
> > 
> > +st->codecpar->codec_id = codec->id;
> > +if (recast_media && st->codecpar->codec_type != codec->type)
> > +st->codecpar->codec_type = codec->type;
> > +return codec;
> > +} else {
> > +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> > +ist->hwaccel_id == HWACCEL_GENERIC &&
> > +ist->hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
> > +const AVCodec *p;
> > +void *i = 0;
> > +
> > +while ((p = av_codec_iterate())) {
> > +int j;
> > +
> > +if (p->id != st->codecpar->codec_id ||
> > +!av_codec_is_decoder(p) ||
> > +!avcodec_get_hw_config(p, 0))
> > +continue;
> > +
> > +for (j = 0; ;j++) {
> > +const AVCodecHWConfig *config =
> > avcodec_get_hw_config(p,
> > j);
> > +
> > +if (!config)
> > +break;
> > +
> > +if (config->device_type == ist->hwaccel_device_type)
> > +return p;
> > +}
> > +}
> > +}
> > +
> > +return avcodec_find_decoder(st->codecpar->codec_id);
> > +}
> > +}
> > +
> >  /* Add all the streams from the given input file to the global
> >   * list of input streams. */
> >  static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
> > @@ -932,7 +974,7 @@ static void add_input_streams(OptionsContext *o,
> > AVFormatContext *ic)
> >  ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
> >  }
> >  
> > -ist->dec = choose_decoder(o, ic, st);
> > +ist->dec = choose_decoder2(ist, o, ic, st);
> >  ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st-
> > > codecpar->codec_id, ic, st, ist->dec);
> > 
> >  
> >  ist->reinit_filters = -1;
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 03/15] lavu/videotoolbox: add 422 and 444 pixel format mappings

2021-11-15 Thread Wang Bin
>
> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
> +{ kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
> AV_PIX_FMT_NV20 },
> +{ kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
> AV_PIX_FMT_NV20 },
> +#endif
>

It's p210, not nv20.

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

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


Re: [FFmpeg-devel] [PATCH] avformat/http: Add short_seek_size option

2021-11-15 Thread James Almer

On 11/15/2021 6:13 PM, Derek Buitenhuis wrote:

On 11/15/2021 7:53 PM, James Almer wrote:

Don't forget to bump micro before you push.


Yep.


+{ "short_seek_size", "Threshold to favor readahead over seek.", 
OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = -1 }, 1, INT64_MAX, D },


-1 default when the valid range is 1 to INT64_MAX?


D'oh. I had an uncommited change making it 0, and 0 to INT64_MAX.


Make it INT_MAX while at it. The field is an int.



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

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



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

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


Re: [FFmpeg-devel] [PATCH] avformat/http: Add short_seek_size option

2021-11-15 Thread Derek Buitenhuis
On 11/15/2021 7:53 PM, James Almer wrote:
> Don't forget to bump micro before you push.

Yep.

>> +{ "short_seek_size", "Threshold to favor readahead over seek.", 
>> OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = -1 }, 1, INT64_MAX, D },
> 
> -1 default when the valid range is 1 to INT64_MAX?

D'oh. I had an uncommited change making it 0, and 0 to INT64_MAX.

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

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


Re: [FFmpeg-devel] [PATCH] avformat/http: Add short_seek_size option

2021-11-15 Thread James Almer

On 11/15/2021 12:52 PM, Derek Buitenhuis wrote:

In 45bfe8b838275235412777dd430206d9a24eb3ee, short_seek_threshold was removed
from the public AVIO struct. Although this option was private and not intended
to be used by public API users, it was nonetheless, because it provided 
functionality
that could otherwise not be gained via public API.

This was especially important for networked I/O like HTTP, where the internal
size for lavf could be way to small depending on the specifics of a user's
usecase, such as reading interlavd media files from cloud storage.

Add an AVOption to make this functionality accessible to the HTTP client.

Signed-off-by: Derek Buitenhuis 
---
Same as last version but I'm marking it as non-RFC. I think I prefer the 
AVOption approach.

Comments welcome.


Don't forget to bump micro before you push.


---
  libavformat/http.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index 476b9a8456..0dc1ce0f43 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -126,6 +126,7 @@ typedef struct HTTPContext {
  int is_multi_client;
  HandshakeState handshake_step;
  int is_connected_server;
+int short_seek_size;
  } HTTPContext;
  
  #define OFFSET(x) offsetof(HTTPContext, x)

@@ -167,6 +168,7 @@ static const AVOption options[] = {
  { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, 2, D | E },
  { "resource", "The resource requested by a client", OFFSET(resource), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
  { "reply_code", "The http status code to return to a client", 
OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
+{ "short_seek_size", "Threshold to favor readahead over seek.", 
OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = -1 }, 1, INT64_MAX, D },


-1 default when the valid range is 1 to INT64_MAX?


  { NULL }
  };
  
@@ -1842,6 +1844,8 @@ static int http_get_file_handle(URLContext *h)

  static int http_get_short_seek(URLContext *h)
  {
  HTTPContext *s = h->priv_data;
+if (s->short_seek_size >= 1)
+return s->short_seek_size;
  return ffurl_get_short_seek(s->hd);
  }
  



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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] swscale/input: clip rgbf32 values before lrintf

2021-11-15 Thread James Almer

On 11/15/2021 12:29 PM, Michael Niedermayer wrote:

On Sun, Nov 14, 2021 at 10:22:21PM -0800, mindm...@gmail.com wrote:

From: Mark Reid 

if the float pixel * 65535.0f > 2147483647.0f
lrintf may overfow and return negative values, depending on implementation.
nan and +/-inf values may also be implementation defined

clip the value first so lrintf always works.

values < 0.0f, -inf, nan = 0.0f
values > 65535.0f, +inf  = 65535.0f

old timings
  195960 decicycles in planar_rgbf32le_to_uv,   1 runs,  0 skips
  186120 decicycles in planar_rgbf32le_to_uv,   2 runs,  0 skips
  188645 decicycles in planar_rgbf32le_to_uv,   4 runs,  0 skips
  183625 decicycles in planar_rgbf32le_to_uv,   8 runs,  0 skips
  181157 decicycles in planar_rgbf32le_to_uv,  16 runs,  0 skips
  177533 decicycles in planar_rgbf32le_to_uv,  32 runs,  0 skips
  175689 decicycles in planar_rgbf32le_to_uv,  64 runs,  0 skips

  232960 decicycles in planar_rgbf32be_to_uv,   1 runs,  0 skips
  221380 decicycles in planar_rgbf32be_to_uv,   2 runs,  0 skips
  216640 decicycles in planar_rgbf32be_to_uv,   4 runs,  0 skips
  213505 decicycles in planar_rgbf32be_to_uv,   8 runs,  0 skips
  211558 decicycles in planar_rgbf32be_to_uv,  16 runs,  0 skips
  210596 decicycles in planar_rgbf32be_to_uv,  32 runs,  0 skips
  210202 decicycles in planar_rgbf32be_to_uv,  64 runs,  0 skips

  161680 decicycles in planar_rgbf32le_to_y,   1 runs,  0 skips
  153540 decicycles in planar_rgbf32le_to_y,   2 runs,  0 skips
  148255 decicycles in planar_rgbf32le_to_y,   4 runs,  0 skips
  140600 decicycles in planar_rgbf32le_to_y,   8 runs,  0 skips
  132935 decicycles in planar_rgbf32le_to_y,  16 runs,  0 skips
  128531 decicycles in planar_rgbf32le_to_y,  32 runs,  0 skips
  140933 decicycles in planar_rgbf32le_to_y,  64 runs,  0 skips

  190980 decicycles in planar_rgbf32be_to_y,   1 runs,  0 skips
  176080 decicycles in planar_rgbf32be_to_y,   2 runs,  0 skips
  167980 decicycles in planar_rgbf32be_to_y,   4 runs,  0 skips
  164685 decicycles in planar_rgbf32be_to_y,   8 runs,  0 skips
  162751 decicycles in planar_rgbf32be_to_y,  16 runs,  0 skips
  162404 decicycles in planar_rgbf32be_to_y,  32 runs,  0 skips
  167849 decicycles in planar_rgbf32be_to_y,  64 runs,  0 skips

new timings
  183320 decicycles in planar_rgbf32le_to_uv,   1 runs,  0 skips
  175700 decicycles in planar_rgbf32le_to_uv,   2 runs,  0 skips
  179570 decicycles in planar_rgbf32le_to_uv,   4 runs,  0 skips
  172932 decicycles in planar_rgbf32le_to_uv,   8 runs,  0 skips
  168707 decicycles in planar_rgbf32le_to_uv,  16 runs,  0 skips
  165224 decicycles in planar_rgbf32le_to_uv,  32 runs,  0 skips
  163423 decicycles in planar_rgbf32le_to_uv,  64 runs,  0 skips

  184940 decicycles in planar_rgbf32be_to_uv,   1 runs,  0 skips
  185150 decicycles in planar_rgbf32be_to_uv,   2 runs,  0 skips
  185790 decicycles in planar_rgbf32be_to_uv,   4 runs,  0 skips
  185472 decicycles in planar_rgbf32be_to_uv,   8 runs,  0 skips
  185277 decicycles in planar_rgbf32be_to_uv,  16 runs,  0 skips
  185813 decicycles in planar_rgbf32be_to_uv,  32 runs,  0 skips
  185332 decicycles in planar_rgbf32be_to_uv,  64 runs,  0 skips

  145400 decicycles in planar_rgbf32le_to_y,   1 runs,  0 skips
  145100 decicycles in planar_rgbf32le_to_y,   2 runs,  0 skips
  143490 decicycles in planar_rgbf32le_to_y,   4 runs,  0 skips
  136687 decicycles in planar_rgbf32le_to_y,   8 runs,  0 skips
  131271 decicycles in planar_rgbf32le_to_y,  16 runs,  0 skips
  128698 decicycles in planar_rgbf32le_to_y,  32 runs,  0 skips
  127170 decicycles in planar_rgbf32le_to_y,  64 runs,  0 skips

  156020 decicycles in planar_rgbf32be_to_y,   1 runs,  0 skips
  146990 decicycles in planar_rgbf32be_to_y,   2 runs,  0 skips
  142020 decicycles in planar_rgbf32be_to_y,   4 runs,  0 skips
  141052 decicycles in planar_rgbf32be_to_y,   8 runs,  0 skips
  138973 decicycles in planar_rgbf32be_to_y,  16 runs,  0 skips
  138027 decicycles in planar_rgbf32be_to_y,  32 runs,  0 skips
  143939 decicycles in planar_rgbf32be_to_y,  64 runs,  0 skips


LGTM

thx


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

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


Re: [FFmpeg-devel] [PATCH v2] lavfi: add a libplacebo filter

2021-11-15 Thread Timo Rothenpieler

On 15.11.2021 19:21, Dennis Mungai wrote:



Hello.

Were you able to build FFmpeg with this filter enabled?
So far, building this package does not generate any pkgconfig file in the
configured prefix, and FFmpeg's ./configure cannot detect it.
I filed the issue on libplacebo's project page, with more details:
https://github.com/haasn/libplacebo/issues/110


Yes, I had no issues with that.
Had to slightly patch the .pc file for static linking for my needs, but 
other than that, it just works:


https://github.com/BtbN/FFmpeg-Builds/blob/master/scripts.d/50-vulkan/60-libplacebo.sh


smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2] lavfi: add a libplacebo filter

2021-11-15 Thread Dennis Mungai
On Fri, 12 Nov 2021 at 13:59, Niklas Haas  wrote:

> From: Niklas Haas 
>
> This filter conceptually maps the libplacebo `pl_renderer` API into
> libavfilter, which is a high-level image rendering API designed to work
> with an RGB pipeline internally. As such, there's no way to avoid e.g.
> chroma interpolation with this filter, although new versions of
> libplacebo support outputting back to subsampled YCbCr after processing
> is done.
>
> That being said, `pl_renderer` supports automatic integration of the
> majority of libplacebo's shaders, ranging from debanding to tone
> mapping, and also supports loading custom mpv-style user shaders, making
> this API a natural candidate for getting a lot of functionality out of
> relatively little code.
>
> In the future, I may approach this problem either by rewriting this
> filter to also support a non-renderer codepath, or by upgrading
> libplacebo's renderer to support a full YCbCr pipeline.
>
> This unfortunately requires a very new version of libplacebo (unreleased
> at time of writing) for timeline semaphore support. But the amount of
> boilerplate needed to hack in backwards compatibility would have been
> very unreasonable.
> ---
>  configure   |   3 +
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_libplacebo.c | 717 
>  4 files changed, 722 insertions(+)
>  create mode 100644 libavfilter/vf_libplacebo.c
>
> diff --git a/configure b/configure
> index eb451d2782..891824757b 100755
> --- a/configure
> +++ b/configure
> @@ -1827,6 +1827,7 @@ EXTERNAL_LIBRARY_LIST="
>  libopenmpt
>  libopenvino
>  libopus
> +libplacebo
>  libpulse
>  librabbitmq
>  librav1e
> @@ -3618,6 +3619,7 @@ interlace_filter_deps="gpl"
>  kerndeint_filter_deps="gpl"
>  ladspa_filter_deps="ladspa libdl"
>  lensfun_filter_deps="liblensfun version3"
> +libplacebo_filter_deps="libplacebo vulkan libglslang"
>  lv2_filter_deps="lv2"
>  mcdeint_filter_deps="avcodec gpl"
>  metadata_filter_deps="avformat"
> @@ -6493,6 +6495,7 @@ enabled libopus   && {
>  require_pkg_config libopus opus opus_multistream.h
> opus_multistream_surround_encoder_create
>  }
>  }
> +enabled libplacebo&& require_pkg_config libplacebo "libplacebo >=
> 4.173.0" libplacebo/vulkan.h pl_vulkan_create
>  enabled libpulse  && require_pkg_config libpulse libpulse
> pulse/pulseaudio.h pa_context_new
>  enabled librabbitmq   && require_pkg_config librabbitmq "librabbitmq
> >= 0.7.1" amqp.h amqp_new_connection
>  enabled librav1e  && require_pkg_config librav1e "rav1e >= 0.4.0"
> rav1e.h rav1e_context_new
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 552bd4e286..e2059766b0 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -323,6 +323,7 @@ OBJS-$(CONFIG_LAGFUN_FILTER) +=
> vf_lagfun.o
>  OBJS-$(CONFIG_LATENCY_FILTER)+= f_latency.o
>  OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o
>  OBJS-$(CONFIG_LENSFUN_FILTER)+= vf_lensfun.o
> +OBJS-$(CONFIG_LIBPLACEBO_FILTER) += vf_libplacebo.o vulkan.o
>  OBJS-$(CONFIG_LIBVMAF_FILTER)+= vf_libvmaf.o framesync.o
>  OBJS-$(CONFIG_LIMITDIFF_FILTER)  += vf_limitdiff.o framesync.o
>  OBJS-$(CONFIG_LIMITER_FILTER)+= vf_limiter.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 667b6fc246..be94249024 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -308,6 +308,7 @@ extern const AVFilter ff_vf_lagfun;
>  extern const AVFilter ff_vf_latency;
>  extern const AVFilter ff_vf_lenscorrection;
>  extern const AVFilter ff_vf_lensfun;
> +extern const AVFilter ff_vf_libplacebo;
>  extern const AVFilter ff_vf_libvmaf;
>  extern const AVFilter ff_vf_limitdiff;
>  extern const AVFilter ff_vf_limiter;
> diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
> new file mode 100644
> index 00..3b48674d1a
> --- /dev/null
> +++ b/libavfilter/vf_libplacebo.c
> @@ -0,0 +1,717 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include 

[FFmpeg-devel] [PATCH] avformat/http: Add short_seek_size option

2021-11-15 Thread Derek Buitenhuis
In 45bfe8b838275235412777dd430206d9a24eb3ee, short_seek_threshold was removed
from the public AVIO struct. Although this option was private and not intended
to be used by public API users, it was nonetheless, because it provided 
functionality
that could otherwise not be gained via public API.

This was especially important for networked I/O like HTTP, where the internal
size for lavf could be way to small depending on the specifics of a user's
usecase, such as reading interlavd media files from cloud storage.

Add an AVOption to make this functionality accessible to the HTTP client.

Signed-off-by: Derek Buitenhuis 
---
Same as last version but I'm marking it as non-RFC. I think I prefer the 
AVOption approach.

Comments welcome.
---
 libavformat/http.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index 476b9a8456..0dc1ce0f43 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -126,6 +126,7 @@ typedef struct HTTPContext {
 int is_multi_client;
 HandshakeState handshake_step;
 int is_connected_server;
+int short_seek_size;
 } HTTPContext;
 
 #define OFFSET(x) offsetof(HTTPContext, x)
@@ -167,6 +168,7 @@ static const AVOption options[] = {
 { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, 2, D | E },
 { "resource", "The resource requested by a client", OFFSET(resource), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
 { "reply_code", "The http status code to return to a client", 
OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E},
+{ "short_seek_size", "Threshold to favor readahead over seek.", 
OFFSET(short_seek_size), AV_OPT_TYPE_INT, { .i64 = -1 }, 1, INT64_MAX, D },
 { NULL }
 };
 
@@ -1842,6 +1844,8 @@ static int http_get_file_handle(URLContext *h)
 static int http_get_short_seek(URLContext *h)
 {
 HTTPContext *s = h->priv_data;
+if (s->short_seek_size >= 1)
+return s->short_seek_size;
 return ffurl_get_short_seek(s->hd);
 }
 
-- 
2.32.0

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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] swscale/input: clip rgbf32 values before lrintf

2021-11-15 Thread Michael Niedermayer
On Sun, Nov 14, 2021 at 10:22:21PM -0800, mindm...@gmail.com wrote:
> From: Mark Reid 
> 
> if the float pixel * 65535.0f > 2147483647.0f
> lrintf may overfow and return negative values, depending on implementation.
> nan and +/-inf values may also be implementation defined
> 
> clip the value first so lrintf always works.
> 
> values < 0.0f, -inf, nan = 0.0f
> values > 65535.0f, +inf  = 65535.0f
> 
> old timings
>  195960 decicycles in planar_rgbf32le_to_uv,   1 runs,  0 skips
>  186120 decicycles in planar_rgbf32le_to_uv,   2 runs,  0 skips
>  188645 decicycles in planar_rgbf32le_to_uv,   4 runs,  0 skips
>  183625 decicycles in planar_rgbf32le_to_uv,   8 runs,  0 skips
>  181157 decicycles in planar_rgbf32le_to_uv,  16 runs,  0 skips
>  177533 decicycles in planar_rgbf32le_to_uv,  32 runs,  0 skips
>  175689 decicycles in planar_rgbf32le_to_uv,  64 runs,  0 skips
> 
>  232960 decicycles in planar_rgbf32be_to_uv,   1 runs,  0 skips
>  221380 decicycles in planar_rgbf32be_to_uv,   2 runs,  0 skips
>  216640 decicycles in planar_rgbf32be_to_uv,   4 runs,  0 skips
>  213505 decicycles in planar_rgbf32be_to_uv,   8 runs,  0 skips
>  211558 decicycles in planar_rgbf32be_to_uv,  16 runs,  0 skips
>  210596 decicycles in planar_rgbf32be_to_uv,  32 runs,  0 skips
>  210202 decicycles in planar_rgbf32be_to_uv,  64 runs,  0 skips
> 
>  161680 decicycles in planar_rgbf32le_to_y,   1 runs,  0 skips
>  153540 decicycles in planar_rgbf32le_to_y,   2 runs,  0 skips
>  148255 decicycles in planar_rgbf32le_to_y,   4 runs,  0 skips
>  140600 decicycles in planar_rgbf32le_to_y,   8 runs,  0 skips
>  132935 decicycles in planar_rgbf32le_to_y,  16 runs,  0 skips
>  128531 decicycles in planar_rgbf32le_to_y,  32 runs,  0 skips
>  140933 decicycles in planar_rgbf32le_to_y,  64 runs,  0 skips
> 
>  190980 decicycles in planar_rgbf32be_to_y,   1 runs,  0 skips
>  176080 decicycles in planar_rgbf32be_to_y,   2 runs,  0 skips
>  167980 decicycles in planar_rgbf32be_to_y,   4 runs,  0 skips
>  164685 decicycles in planar_rgbf32be_to_y,   8 runs,  0 skips
>  162751 decicycles in planar_rgbf32be_to_y,  16 runs,  0 skips
>  162404 decicycles in planar_rgbf32be_to_y,  32 runs,  0 skips
>  167849 decicycles in planar_rgbf32be_to_y,  64 runs,  0 skips
> 
> new timings
>  183320 decicycles in planar_rgbf32le_to_uv,   1 runs,  0 skips
>  175700 decicycles in planar_rgbf32le_to_uv,   2 runs,  0 skips
>  179570 decicycles in planar_rgbf32le_to_uv,   4 runs,  0 skips
>  172932 decicycles in planar_rgbf32le_to_uv,   8 runs,  0 skips
>  168707 decicycles in planar_rgbf32le_to_uv,  16 runs,  0 skips
>  165224 decicycles in planar_rgbf32le_to_uv,  32 runs,  0 skips
>  163423 decicycles in planar_rgbf32le_to_uv,  64 runs,  0 skips
> 
>  184940 decicycles in planar_rgbf32be_to_uv,   1 runs,  0 skips
>  185150 decicycles in planar_rgbf32be_to_uv,   2 runs,  0 skips
>  185790 decicycles in planar_rgbf32be_to_uv,   4 runs,  0 skips
>  185472 decicycles in planar_rgbf32be_to_uv,   8 runs,  0 skips
>  185277 decicycles in planar_rgbf32be_to_uv,  16 runs,  0 skips
>  185813 decicycles in planar_rgbf32be_to_uv,  32 runs,  0 skips
>  185332 decicycles in planar_rgbf32be_to_uv,  64 runs,  0 skips
> 
>  145400 decicycles in planar_rgbf32le_to_y,   1 runs,  0 skips
>  145100 decicycles in planar_rgbf32le_to_y,   2 runs,  0 skips
>  143490 decicycles in planar_rgbf32le_to_y,   4 runs,  0 skips
>  136687 decicycles in planar_rgbf32le_to_y,   8 runs,  0 skips
>  131271 decicycles in planar_rgbf32le_to_y,  16 runs,  0 skips
>  128698 decicycles in planar_rgbf32le_to_y,  32 runs,  0 skips
>  127170 decicycles in planar_rgbf32le_to_y,  64 runs,  0 skips
> 
>  156020 decicycles in planar_rgbf32be_to_y,   1 runs,  0 skips
>  146990 decicycles in planar_rgbf32be_to_y,   2 runs,  0 skips
>  142020 decicycles in planar_rgbf32be_to_y,   4 runs,  0 skips
>  141052 decicycles in planar_rgbf32be_to_y,   8 runs,  0 skips
>  138973 decicycles in planar_rgbf32be_to_y,  16 runs,  0 skips
>  138027 decicycles in planar_rgbf32be_to_y,  32 runs,  0 skips
>  143939 decicycles in planar_rgbf32be_to_y,  64 runs,  0 skips

LGTM

thx

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their 

Re: [FFmpeg-devel] [PATCH 05/15] lavc/videotoolbox: escape 0x00000[0-3]s in avcC PSs

2021-11-15 Thread Derek Buitenhuis
On 11/13/2021 9:09 PM, rcombs wrote:
> ---
>  libavcodec/videotoolbox.c | 51 +--
>  1 file changed, 43 insertions(+), 8 deletions(-)

Why reimplement NAL emulation bytes for the Nth time in the codebase?

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

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


Re: [FFmpeg-devel] [PATCH] avformat/dhav: Limit get_duration() iterations

2021-11-15 Thread Derek Buitenhuis
On 11/15/2021 3:04 PM, Michael Niedermayer wrote:
> i dont like it either
> do you have a better idea ?

Why is it seaching like this anyway? This is not even
the only place in dhav.c it does this.

Is the format documented somewhere by chance?

There has to be a better early termination condition than
an arbitrary number of iterations.

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

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


[FFmpeg-devel] [PATCH 3/9] ffmpeg: drop the -deinterlace option

2021-11-15 Thread Anton Khirnov
It is undocumented and has been deprecated since 2013.
---
 fftools/ffmpeg_filter.c | 17 -
 fftools/ffmpeg_opt.c|  3 ---
 2 files changed, 20 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b798459946..886419af32 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -805,23 +805,6 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 return ret;
 }
 
-if (do_deinterlace) {
-AVFilterContext *yadif;
-
-snprintf(name, sizeof(name), "deinterlace_in_%d_%d",
- ist->file_index, ist->st->index);
-if ((ret = avfilter_graph_create_filter(,
-avfilter_get_by_name("yadif"),
-name, "", NULL,
-fg->graph)) < 0)
-return ret;
-
-if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
-return ret;
-
-last_filter = yadif;
-}
-
 snprintf(name, sizeof(name), "trim_in_%d_%d",
  ist->file_index, ist->st->index);
 if (copy_ts) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 8cf932bc6c..c960830ff6 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -153,7 +153,6 @@ int audio_volume  = 256;
 int audio_sync_method = 0;
 int video_sync_method = VSYNC_AUTO;
 float frame_drop_threshold = 0;
-int do_deinterlace= 0;
 int do_benchmark  = 0;
 int do_benchmark_all  = 0;
 int do_hex_dump   = 0;
@@ -3779,8 +3778,6 @@ const OptionDef options[] = {
 { "passlogfile",  OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC 
|
   OPT_OUTPUT,  
  { .off = OFFSET(passlogfiles) },
 "select two pass log file name prefix", "prefix" },
-{ "deinterlace",  OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _deinterlace },
-"this option is deprecated, use the yadif filter instead" },
 { "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _psnr },
 "calculate PSNR of compressed frames" },
 { "vstats",   OPT_VIDEO | OPT_EXPERT , 
  { .func_arg = opt_vstats },
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 8/9] ffmpeg: drop a useless assignment

2021-11-15 Thread Anton Khirnov
bits_per_raw_sample is already set in new_video_stream(), so this code
has no effect.
---
 fftools/ffmpeg.c | 7 ---
 fftools/ffmpeg.h | 1 -
 fftools/ffmpeg_opt.c | 2 +-
 3 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0f2fe192ac..c0ab78608a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3451,13 +3451,6 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 
 ost->st->avg_frame_rate = ost->frame_rate;
 
-if (!dec_ctx ||
-enc_ctx->width   != dec_ctx->width  ||
-enc_ctx->height  != dec_ctx->height ||
-enc_ctx->pix_fmt != dec_ctx->pix_fmt) {
-enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample;
-}
-
 // Field order: autodetection
 if (frame) {
 if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 30225e9ffe..2da7b1b7df 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -625,7 +625,6 @@ extern int print_stats;
 extern int64_t stats_period;
 extern int qp_hist;
 extern int stdin_interaction;
-extern int frame_bits_per_raw_sample;
 extern AVIOContext *progress_avio;
 extern float max_error_rate;
 extern char *videotoolbox_pixfmt;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 54f6279bf5..c16f5e8672 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -166,7 +166,7 @@ int abort_on_flags= 0;
 int print_stats   = -1;
 int qp_hist   = 0;
 int stdin_interaction = 1;
-int frame_bits_per_raw_sample = 0;
+static int frame_bits_per_raw_sample = 0;
 float max_error_rate  = 2.0/3;
 char *filter_nbthreads;
 int filter_complex_nbthreads = 0;
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 7/9] ffmpeg: drop -isync, which did nothing since 2012

2021-11-15 Thread Anton Khirnov
---
 fftools/ffmpeg_opt.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f0f7051392..54f6279bf5 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -178,7 +178,6 @@ int64_t stats_period = 50;
 static int file_overwrite = 0;
 static int no_file_overwrite  = 0;
 static int do_psnr= 0;
-static int input_sync;
 static int input_stream_potentially_available = 0;
 static int ignore_unknown_streams = 0;
 static int copy_unknown_streams = 0;
@@ -3858,9 +3857,6 @@ const OptionDef options[] = {
 { "canvas_size", OPT_SUBTITLE | HAS_ARG | OPT_STRING | OPT_SPEC | 
OPT_INPUT, { .off = OFFSET(canvas_sizes) },
 "set canvas size (WxH or abbreviation)", "size" },
 
-/* grab options */
-{ "isync", OPT_BOOL | OPT_EXPERT, { _sync }, "this option is 
deprecated and does nothing", "" },
-
 /* muxer options */
 { "muxdelay",   OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | 
OPT_OUTPUT, { .off = OFFSET(mux_max_delay) },
 "set the maximum demux-decode delay", "seconds" },
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 6/9] ffmpeg: drop -sameq/-samequant options

2021-11-15 Thread Anton Khirnov
They did nothing but return an error since 2012.
---
 fftools/ffmpeg_opt.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f8e6115241..f0f7051392 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -303,15 +303,6 @@ static int opt_stats_period(void *optctx, const char *opt, 
const char *arg)
 return 0;
 }
 
-static int opt_sameq(void *optctx, const char *opt, const char *arg)
-{
-av_log(NULL, AV_LOG_ERROR, "Option '%s' was removed. "
-   "If you are looking for an option to preserve the quality (which is 
not "
-   "what -%s was for), use -qscale 0 or an equivalent quality factor 
option.\n",
-   opt, opt);
-return AVERROR(EINVAL);
-}
-
 static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
 {
 OptionsContext *o = optctx;
@@ -3755,10 +3746,6 @@ const OptionDef options[] = {
 { "vcodec",   OPT_VIDEO | HAS_ARG  | OPT_PERFILE | OPT_INPUT |
   OPT_OUTPUT,  
  { .func_arg = opt_video_codec },
 "force video codec ('copy' to copy stream)", "codec" },
-{ "sameq",OPT_VIDEO | OPT_EXPERT , 
  { .func_arg = opt_sameq },
-"Removed" },
-{ "same_quant",   OPT_VIDEO | OPT_EXPERT , 
  { .func_arg = opt_sameq },
-"Removed" },
 { "timecode", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT,  
  { .func_arg = opt_timecode },
 "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
 { "pass", OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT | OPT_OUTPUT,   
  { .off = OFFSET(pass) },
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 9/9] ffmpeg: drop obsolete rotation API remnants

2021-11-15 Thread Anton Khirnov
No demuxers export the "rotate" metadata tag anymore.
---
 fftools/ffmpeg.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index c0ab78608a..d1904c20d4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3361,11 +3361,6 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 
 set_encoder_id(output_files[ost->file_index], ost);
 
-// Muxers use AV_PKT_DATA_DISPLAYMATRIX to signal rotation. On the other
-// hand, the legacy API makes demuxers set "rotate" metadata entries,
-// which have to be filtered out to prevent leaking them to output files.
-av_dict_set(>st->metadata, "rotate", NULL, 0);
-
 if (ist) {
 dec_ctx = ist->dec_ctx;
 }
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 5/9] ffmpeg: drop the -tvstd option

2021-11-15 Thread Anton Khirnov
It is undocumented and has been deprecated since 2012.
---
 fftools/ffmpeg_opt.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index e381ef8486..f8e6115241 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -312,12 +312,6 @@ static int opt_sameq(void *optctx, const char *opt, const 
char *arg)
 return AVERROR(EINVAL);
 }
 
-static int opt_video_standard(void *optctx, const char *opt, const char *arg)
-{
-av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use 
-standard.\n");
-return opt_default(optctx, "standard", arg);
-}
-
 static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
 {
 OptionsContext *o = optctx;
@@ -3878,8 +3872,6 @@ const OptionDef options[] = {
 "set canvas size (WxH or abbreviation)", "size" },
 
 /* grab options */
-{ "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = 
opt_video_standard },
-"deprecated, use -standard", "standard" },
 { "isync", OPT_BOOL | OPT_EXPERT, { _sync }, "this option is 
deprecated and does nothing", "" },
 
 /* muxer options */
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 4/9] ffmpeg: drop the -vc option

2021-11-15 Thread Anton Khirnov
It is undocumented and has been deprecated since 2012.
---
 fftools/ffmpeg_opt.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index c960830ff6..e381ef8486 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -312,12 +312,6 @@ static int opt_sameq(void *optctx, const char *opt, const 
char *arg)
 return AVERROR(EINVAL);
 }
 
-static int opt_video_channel(void *optctx, const char *opt, const char *arg)
-{
-av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -channel.\n");
-return opt_default(optctx, "channel", arg);
-}
-
 static int opt_video_standard(void *optctx, const char *opt, const char *arg)
 {
 av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use 
-standard.\n");
@@ -3884,8 +3878,6 @@ const OptionDef options[] = {
 "set canvas size (WxH or abbreviation)", "size" },
 
 /* grab options */
-{ "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_channel 
},
-"deprecated, use -channel", "channel" },
 { "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = 
opt_video_standard },
 "deprecated, use -standard", "standard" },
 { "isync", OPT_BOOL | OPT_EXPERT, { _sync }, "this option is 
deprecated and does nothing", "" },
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 2/9] ffmpeg: drop the -intra option

2021-11-15 Thread Anton Khirnov
It is undocumented and has been marked as deprecated since 2012.
---
 fftools/ffmpeg_opt.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 4685cf6435..8cf932bc6c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -176,7 +176,6 @@ int auto_conversion_filters = 1;
 int64_t stats_period = 50;
 
 
-static int intra_only = 0;
 static int file_overwrite = 0;
 static int no_file_overwrite  = 0;
 static int do_psnr= 0;
@@ -1813,8 +1812,6 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
 }
 st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
 
-if (intra_only)
-video_enc->gop_size = 0;
 MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st);
 if (intra_matrix) {
 if (!(video_enc->intra_matrix = 
av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) {
@@ -3763,8 +3760,6 @@ const OptionDef options[] = {
 "set pixel format", "format" },
 { "bits_per_raw_sample", OPT_VIDEO | OPT_INT | HAS_ARG,
  { _bits_per_raw_sample },
 "set the number of bits per raw sample", "number" },
-{ "intra",OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _only },
-"deprecated use -g 1" },
 { "vn",   OPT_VIDEO | OPT_BOOL  | OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,{ .off = OFFSET(video_disable) },
 "disable video" },
 { "rc_override",  OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_STRING | 
OPT_SPEC |
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 1/9] ffmpeg: do not copy chroma_sample_location from the input stream

2021-11-15 Thread Anton Khirnov
It will be set from the supplied AVFrame later on.
---
 fftools/ffmpeg.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f755f44bd9..0f2fe192ac 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3368,8 +3368,6 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 
 if (ist) {
 dec_ctx = ist->dec_ctx;
-
-enc_ctx->chroma_sample_location = dec_ctx->chroma_sample_location;
 }
 
 if (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
-- 
2.33.0

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

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


Re: [FFmpeg-devel] [PATCH] avformat/dhav: Limit get_duration() iterations

2021-11-15 Thread Michael Niedermayer
On Sun, Nov 14, 2021 at 07:36:59PM +, Kieran Kunhya wrote:
> > diff --git a/libavformat/dhav.c b/libavformat/dhav.c
> > index b6bb25204c2..6c1cdde32c9 100644
> > --- a/libavformat/dhav.c
> > +++ b/libavformat/dhav.c
> > @@ -234,12 +234,13 @@ static int64_t get_duration(AVFormatContext *s)
> >  int64_t start_pos = avio_tell(s->pb);
> >  int64_t start = 0, end = 0;
> >  struct tm timeinfo;
> > +int max_interations = 10;
> >
> 
> I don't think this should be allowed.

i dont like it either
do you have a better idea ?


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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

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


Re: [FFmpeg-devel] [PATCH 1/6] lavf: improve AV_DISPOSITION_* doxy

2021-11-15 Thread Anton Khirnov
Quoting Tobias Rapp (2021-11-15 15:10:05)
> On 12/11/2021 17:32, Anton Khirnov wrote:
> > Also switch the values definition to the (1 << N) style, which is easier
> > to read.
> > ---
> >   libavformat/avformat.h | 96 +-
> >   1 file changed, 77 insertions(+), 19 deletions(-)
> > 
> > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > index a2af7e9f89..7d8ad08f07 100644
> > --- a/libavformat/avformat.h
> > +++ b/libavformat/avformat.h
> > @@ -803,22 +803,56 @@ typedef struct AVIndexEntry {
> >   int min_distance; /**< Minimum distance between this and the 
> > previous keyframe, used to avoid unneeded searching. */
> >   } AVIndexEntry;
> >   
> > -#define AV_DISPOSITION_DEFAULT   0x0001
> > -#define AV_DISPOSITION_DUB   0x0002
> > -#define AV_DISPOSITION_ORIGINAL  0x0004
> > -#define AV_DISPOSITION_COMMENT   0x0008
> > -#define AV_DISPOSITION_LYRICS0x0010
> > -#define AV_DISPOSITION_KARAOKE   0x0020
> > +/**
> > + * The stream should be chosen by default among other streams of the same 
> > time,
> > + * unless the user has explicitly specified otherwise.
> > + */
> > +#define AV_DISPOSITION_DEFAULT  (1 << 0)
> > +/**
> > + * The stream is not in original language.
> > + *
> > + * @note AV_DISPOSITION_ORIGINAL is the inverse of this disposition. At 
> > most of
> > + *   them should be set in properly tagged streams.
> > + * @note This disposition may apply to any stream type, not just audio.
> > + */
> > +#define AV_DISPOSITION_DUB  (1 << 1)
> 
> "At most of them" -> "At most one of them ..."?

Thank you, fixed locally.
(along with time -> type a few lines above)

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

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


Re: [FFmpeg-devel] [PATCH 1/6] lavf: improve AV_DISPOSITION_* doxy

2021-11-15 Thread Tobias Rapp

On 12/11/2021 17:32, Anton Khirnov wrote:

Also switch the values definition to the (1 << N) style, which is easier
to read.
---
  libavformat/avformat.h | 96 +-
  1 file changed, 77 insertions(+), 19 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a2af7e9f89..7d8ad08f07 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -803,22 +803,56 @@ typedef struct AVIndexEntry {
  int min_distance; /**< Minimum distance between this and the 
previous keyframe, used to avoid unneeded searching. */
  } AVIndexEntry;
  
-#define AV_DISPOSITION_DEFAULT   0x0001

-#define AV_DISPOSITION_DUB   0x0002
-#define AV_DISPOSITION_ORIGINAL  0x0004
-#define AV_DISPOSITION_COMMENT   0x0008
-#define AV_DISPOSITION_LYRICS0x0010
-#define AV_DISPOSITION_KARAOKE   0x0020
+/**
+ * The stream should be chosen by default among other streams of the same time,
+ * unless the user has explicitly specified otherwise.
+ */
+#define AV_DISPOSITION_DEFAULT  (1 << 0)
+/**
+ * The stream is not in original language.
+ *
+ * @note AV_DISPOSITION_ORIGINAL is the inverse of this disposition. At most of
+ *   them should be set in properly tagged streams.
+ * @note This disposition may apply to any stream type, not just audio.
+ */
+#define AV_DISPOSITION_DUB  (1 << 1)


"At most of them" -> "At most one of them ..."?

Regards,
Tobias

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

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


[FFmpeg-devel] [PATCH] libavutil/mips: fix build if sys/auxv.h not present

2021-11-15 Thread Brilliantov Kirill Vladimirovich
---
 configure| 1 +
 libavutil/mips/cpu.c | 6 ++
 2 files changed, 7 insertions(+)

diff --git a/configure b/configure
index 98113c95fd..18c93f2619 100755
--- a/configure
+++ b/configure
@@ -2148,6 +2148,7 @@ HEADERS_LIST="
 valgrind_valgrind_h
 windows_h
 winsock2_h
+sys_auxv_h
 "
 
 INTRINSICS_LIST="
diff --git a/libavutil/mips/cpu.c b/libavutil/mips/cpu.c
index 59619d54de..854eabfc18 100644
--- a/libavutil/mips/cpu.c
+++ b/libavutil/mips/cpu.c
@@ -23,7 +23,9 @@
 #include 
 #include 
 #include 
+#if HAVE_SYS_AUXV_H
 #include 
+#endif
 #include "asmdefs.h"
 #include "libavutil/avstring.h"
 #endif
@@ -34,7 +36,11 @@
 
 static int cpucfg_available(void)
 {
+#if HAVE_SYS_AUXV_H
 return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG;
+#else
+return 0;
+#endif
 }
 
 /* Most toolchains have no CPUCFG support yet */
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 1/2] ffmpeg: Allocate (In|Out)putStream.filter_frame early

2021-11-15 Thread James Almer
Based on a commit by Andreas Rheinhardt.

Signed-off-by: James Almer 
---
 fftools/ffmpeg.c | 7 ---
 fftools/ffmpeg_opt.c | 8 
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d141f34df9..f6ab33a614 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1533,9 +1533,6 @@ static int reap_filters(int flush)
 if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
 init_output_stream_wrapper(ost, NULL, 1);
 
-if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) 
{
-return AVERROR(ENOMEM);
-}
 filtered_frame = ost->filtered_frame;
 
 while (1) {
@@ -2342,8 +2339,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, 
int *got_output,
 
 if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
 return AVERROR(ENOMEM);
-if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
-return AVERROR(ENOMEM);
 decoded_frame = ist->decoded_frame;
 
 update_benchmark(NULL);
@@ -2410,8 +2405,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output, int64_
 
 if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
 return AVERROR(ENOMEM);
-if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc()))
-return AVERROR(ENOMEM);
 decoded_frame = ist->decoded_frame;
 if (ist->dts != AV_NOPTS_VALUE)
 dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ab4c63a362..278cab39bf 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -888,6 +888,10 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 exit_program(1);
 }
 
+ist->filter_frame = av_frame_alloc();
+if (!ist->filter_frame)
+exit_program(1);
+
 ist->pkt = av_packet_alloc();
 if (!ist->pkt)
 exit_program(1);
@@ -1520,6 +1524,10 @@ static OutputStream *new_output_stream(OptionsContext 
*o, AVFormatContext *oc, e
 exit_program(1);
 }
 
+ost->filtered_frame = av_frame_alloc();
+if (!ost->filtered_frame)
+exit_program(1);
+
 ost->pkt = av_packet_alloc();
 if (!ost->pkt)
 exit_program(1);
-- 
2.33.0

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

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


[FFmpeg-devel] [PATCH 2/2] ffmpeg: Allocate InputStream.decoded_frame early

2021-11-15 Thread James Almer
Based on a commit by Andreas Rheinhardt.

Signed-off-by: James Almer 
---
 fftools/ffmpeg.c | 11 ++-
 fftools/ffmpeg_opt.c |  4 
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f6ab33a614..05d197b8af 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2332,15 +2332,11 @@ static int send_frame_to_filters(InputStream *ist, 
AVFrame *decoded_frame)
 static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
 int *decode_failed)
 {
-AVFrame *decoded_frame;
+AVFrame *decoded_frame = ist->decoded_frame;
 AVCodecContext *avctx = ist->dec_ctx;
 int ret, err = 0;
 AVRational decoded_frame_tb;
 
-if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
-return AVERROR(ENOMEM);
-decoded_frame = ist->decoded_frame;
-
 update_benchmark(NULL);
 ret = decode(avctx, decoded_frame, got_output, pkt);
 update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index);
@@ -2392,7 +2388,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, 
int *got_output,
 static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, 
int64_t *duration_pts, int eof,
 int *decode_failed)
 {
-AVFrame *decoded_frame;
+AVFrame *decoded_frame = ist->decoded_frame;
 int i, ret = 0, err = 0;
 int64_t best_effort_timestamp;
 int64_t dts = AV_NOPTS_VALUE;
@@ -2403,9 +2399,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output, int64_
 if (!eof && pkt && pkt->size == 0)
 return 0;
 
-if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc()))
-return AVERROR(ENOMEM);
-decoded_frame = ist->decoded_frame;
 if (ist->dts != AV_NOPTS_VALUE)
 dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
 if (pkt) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 278cab39bf..2a95c31107 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -888,6 +888,10 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 exit_program(1);
 }
 
+ist->decoded_frame = av_frame_alloc();
+if (!ist->decoded_frame)
+exit_program(1);
+
 ist->filter_frame = av_frame_alloc();
 if (!ist->filter_frame)
 exit_program(1);
-- 
2.33.0

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

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


Re: [FFmpeg-devel] [PATCH 7/7] libavutil/hwcontext_vulkan: specify the modifier to create VKImage

2021-11-15 Thread Chen, Wenbin
> 9 Nov 2021, 10:18 by wenbin.c...@intel.com:
> 
> > When vulkan image exports to drm, the tilling need to be
> > VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT. Now add code to
> create vulkan
> > image using this format.
> >
> > Now the following command line works:
> >
> > ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -
> hwaccel_output_format \
> > vaapi -i input_1080p.264 -vf "hwmap=derive_device=vulkan,format=vulkan,
> \
> > scale_vulkan=1920:1080,hwmap=derive_device=vaapi,format=vaapi" -c:v
> h264_vaapi output.264
> >
> > Signed-off-by: Wenbin Chen 
> > ---
> >  libavutil/hwcontext_vulkan.c | 76 +-
> --
> >  libavutil/hwcontext_vulkan.h |  5 +++
> >  2 files changed, 75 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
> > index 29ade94b7f..e252c2177e 100644
> > --- a/libavutil/hwcontext_vulkan.c
> > +++ b/libavutil/hwcontext_vulkan.c
> > @@ -1919,6 +1919,7 @@ static void
> try_export_flags(AVHWFramesContext *hwfc,
> >  AVVulkanDeviceContext *dev_hwctx = hwfc->device_ctx->hwctx;
> >  VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
> >  FFVulkanFunctions *vk = >vkfn;
> > +const int has_modifiers = hwctx->tiling ==
> VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
> >  VkExternalImageFormatProperties eprops = {
> >  .sType =
> VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR,
> >  };
> > @@ -1926,9 +1927,18 @@ static void
> try_export_flags(AVHWFramesContext *hwfc,
> >  .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2,
> >  .pNext = ,
> >  };
> > +VkPhysicalDeviceImageDrmFormatModifierInfoEXT phy_dev_mod_info
> = {
> > +.sType =
> VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER
> _INFO_EXT,
> > +.pNext = NULL,
> > +.pQueueFamilyIndices   = p->qfs,
> > +.queueFamilyIndexCount = p->num_qfs,
> > +.sharingMode   = p->num_qfs > 1 ?
> VK_SHARING_MODE_CONCURRENT :
> > +  
> > VK_SHARING_MODE_EXCLUSIVE,
> > +};
> >  VkPhysicalDeviceExternalImageFormatInfo enext = {
> >  .sType =
> VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO,
> >  .handleType = exp,
> > +.pNext = has_modifiers ? _dev_mod_info : NULL,
> >  };
> >  VkPhysicalDeviceImageFormatInfo2 pinfo = {
> >  .sType  =
> VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
> > @@ -1940,11 +1950,15 @@ static void
> try_export_flags(AVHWFramesContext *hwfc,
> >  .flags  = VK_IMAGE_CREATE_ALIAS_BIT,
> >  };
> >
> > -ret = vk->GetPhysicalDeviceImageFormatProperties2(dev_hwctx-
> >phys_dev,
> > -  , );
> > -if (ret == VK_SUCCESS) {
> > -*iexp |= exp;
> > -*comp_handle_types |=
> eprops.externalMemoryProperties.compatibleHandleTypes;
> > +for (int i = 0; i < (has_modifiers ? hwctx->modifier_count : 1); i++) {
> > +if (has_modifiers && hwctx->modifier_count)
> > +phy_dev_mod_info.drmFormatModifier = hwctx->modifiers[i];
> > +ret = vk->GetPhysicalDeviceImageFormatProperties2(dev_hwctx-
> >phys_dev,
> > +, );
> > +if (ret == VK_SUCCESS) {
> > +*iexp |= exp;
> > +*comp_handle_types |=
> eprops.externalMemoryProperties.compatibleHandleTypes;
> > +}
> >  }
> >  }
> >
> > @@ -2007,6 +2021,7 @@ fail:
> >  static void vulkan_frames_uninit(AVHWFramesContext *hwfc)
> >  {
> >  VulkanFramesPriv *fp = hwfc->internal->priv;
> > +AVVulkanFramesContext *hwctx = hwfc->hwctx;
> >
> >  free_exec_ctx(hwfc, >conv_ctx);
> >  free_exec_ctx(hwfc, >upload_ctx);
> > @@ -2021,11 +2036,60 @@ static int
> vulkan_frames_init(AVHWFramesContext *hwfc)
> >  VulkanFramesPriv *fp = hwfc->internal->priv;
> >  AVVulkanDeviceContext *dev_hwctx = hwfc->device_ctx->hwctx;
> >  VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
> > +const int has_modifiers = !!(p->extensions &
> FF_VK_EXT_DRM_MODIFIER_FLAGS);
> >
> >  /* Default pool flags */
> > -hwctx->tiling = hwctx->tiling ? hwctx->tiling : p->use_linear_images ?
> > +hwctx->tiling = hwctx->tiling ? hwctx->tiling : has_modifiers ?
> > +VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT : p-
> >use_linear_images ?
> >  VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
> >
> > +/* get the supported modifier */
> > +if (has_modifiers) {
> > +const VkFormat *fmt = av_vkfmt_from_pixfmt(hwfc->sw_format);
> > +FFVulkanFunctions *vk = >vkfn;
> > +VkDrmFormatModifierPropertiesEXT
> mod_props[MAX_VULKAN_MODIFIERS];
> > +
> > +VkDrmFormatModifierPropertiesListEXT mod_props_list = {
> > +.sType =
> VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT,
> > +.pNext = NULL,
> > +.drmFormatModifierCount = 0,
> > +.pDrmFormatModifierProperties = NULL,
> > +};
> > +