Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_d3d11va: enable D3D11_RESOURCE_MISC_SHARED for texture

2022-04-20 Thread Wu, Tong1



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Hendrik Leppkes
> Sent: Wednesday, April 20, 2022 2:35 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_d3d11va: enable
> D3D11_RESOURCE_MISC_SHARED for texture
> 
> On Wed, Apr 20, 2022 at 6:11 AM Tong Wu
>  wrote:
> >
> > Add D3D11_RESOURCE_MISC_SHARED flag for texture to make it shareable.
> > This can fix the green frames issue when mapping from d3d11va to opencl.
> > Sample command line: ffmpeg.exe -hwaccel d3d11va
> > -hwaccel_output_format
> > d3d11 -i input.264 -vf
> > "hwmap=derive_device=opencl,format=opencl,hwdownload,format=nv12"
> -c:v
> > libx264 output.mp4
> >
> 
> The flags are configurable, we should not force them for specific cases.
> Specifically, there is also two ways to share a texture, this flag and the
> D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag (which is preferable for
> new code), which would conflict with each other, making it impossible to set
> it.
> 

Thanks for the review. Since the flags should not be set for those specific 
cases
like that, is there any feasible way to enable the share resource between d3d11 
and opencl and make the sample command line work?

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

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


Re: [FFmpeg-devel] [PATCH 1/2] swscale/aarch64: add hscale specializations

2022-04-20 Thread Martin Storsjö

On Sun, 17 Apr 2022, Martin Storsjö wrote:


On Fri, 15 Apr 2022, Swinney, Jonathan wrote:


This patch adds specializations for hscale for filterSize == 4 and 8 and
converts the existing implementation for the X8 version. For the old code, 
now
used for the X8 version, it improves the efficiency of the final summations 
by

reducing 11 instructions to 7.

ff_hscale8to15_8_neon is mostly unchanged from the original except for a 
few

changes.
- The loads for the filter data were consolidated into a single 64 byte ld1
  instruction.


Couldn't you do this optimization on the existing function too?


Sorry, now I realized why this optimization only can be done if you 
operate on a specific known filter width.



- The final summations were improved.
- The inner loop on filterSize was completely removed


I presume that this is the only differing factor which affects whether it's 
worthwhile to keep a separate width=8 function or not. At least from the 
checkasm benchmark numbers, the difference is notable but not huge (on the 
range of 4-10%, while the summation improvements gain even more).


Given a fully optimized function that has an inner loop (which is only taken 
once for the width=8 case), is the separate function without an inner loop 
really necessary?


With the ideal version of the final summation in both functions, the 
separate filtersize=8 function is 11-19% faster than the generic 
multiple-of-8 function (on Cortex A53 and A72 - on A73 the both versions 
are essentially equally fast), so there's probably good reason to go with 
the separate version.


Thus, disregard the review comments above.

// Martin
___
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] swscale: aarch64: Optimize the final summation in the hscale routine

2022-04-20 Thread Martin Storsjö
Before: Cortex A53  A72  A73
hscale_8_to_15_width8_neon: 8273.0   4602.5   4289.5
hscale_8_to_15_width16_neon:   12405.7   6803.0   6359.0
hscale_8_to_15_width32_neon:   21258.7  11491.7  11469.2
hscale_8_to_15_width40_neon:   25652.0  14173.7  12488.2

After:
hscale_8_to_15_width8_neon: 7633.0   3981.5   3350.2
hscale_8_to_15_width16_neon:   11666.7   5951.0   5512.0
hscale_8_to_15_width32_neon:   20900.7  10733.2   9481.7
hscale_8_to_15_width40_neon:   24826.0  13536.2  11502.0

Thus, this gives overall a 8-28% speedup for the smaller filter
sizes, around 3-8% for the smaller filter sizes.

Inspired by a patch by Jonathan Swinney .

Signed-off-by: Martin Storsjö 
---
I'll go ahead and apply this patch within a few days if there's no
opposition, as it should be a fairly uncontroversial change.
---
 libswscale/aarch64/hscale.S | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S
index af55ffe2b7..da34f1cb8d 100644
--- a/libswscale/aarch64/hscale.S
+++ b/libswscale/aarch64/hscale.S
@@ -61,17 +61,9 @@ function ff_hscale_8_to_15_neon, export=1
 smlal   v3.4S, v18.4H, v19.4H   // v3 accumulates 
srcp[filterPos[3] + {0..3}] * filter[{0..3}]
 smlal2  v3.4S, v18.8H, v19.8H   // v3 accumulates 
srcp[filterPos[3] + {4..7}] * filter[{4..7}]
 b.gt2b  // inner loop if 
filterSize not consumed completely
-addpv0.4S, v0.4S, v0.4S // part0 horizontal 
pair adding
-addpv1.4S, v1.4S, v1.4S // part1 horizontal 
pair adding
-addpv2.4S, v2.4S, v2.4S // part2 horizontal 
pair adding
-addpv3.4S, v3.4S, v3.4S // part3 horizontal 
pair adding
-addpv0.4S, v0.4S, v0.4S // part0 horizontal 
pair adding
-addpv1.4S, v1.4S, v1.4S // part1 horizontal 
pair adding
-addpv2.4S, v2.4S, v2.4S // part2 horizontal 
pair adding
-addpv3.4S, v3.4S, v3.4S // part3 horizontal 
pair adding
-zip1v0.4S, v0.4S, v1.4S // part01 = zip values 
from part0 and part1
-zip1v2.4S, v2.4S, v3.4S // part23 = zip values 
from part2 and part3
-mov v0.d[1], v2.d[0]// part0123 = zip 
values from part01 and part23
+addpv0.4S, v0.4S, v1.4S // part01 horizontal 
pair adding
+addpv2.4S, v2.4S, v3.4S // part23 horizontal 
pair adding
+addpv0.4S, v0.4S, v2.4S // part0123 horizontal 
pair adding
 subsw2, w2, #4  // dstW -= 4
 sqshrn  v0.4H, v0.4S, #7// shift and clip the 
2x16-bit final values
 st1 {v0.4H}, [x1], #8   // write to 
destination part0123
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 1/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
###
1. Genaral info
###

The patch provided below contains an integration layer between ffmpeg
framework and EVC codec implementation.
In nutshell, it enables using EVC codec (encoding, decoding)  by the means
of ffmpeg API. 
I'd like to emphasize one more time, that (as mentioned before) it isn't
codec implementation. The provided implementation serves as an integration
layer between ffmpeg framework and the EVC codec.

EVC codec has been published as two separate libraries. 
The first one called XEVE (eXtra-fast Essential Video Encoder) is an
opensource MPEG-5 EVC encoder.
The second one called XEVD (eXtra-fast Essential Video Decoder ) is an
opensource MPEG-5 EVC decoder.
For more information on both libraries please follow the links below:
* https://github.com/mpeg5/xeve 
* https://github.com/mpeg5/xevd 

The patch provided below should be apply to FFmpeg 5.0 release (commit
b655beb025cb54ba19cad89e731990910643f208 release/5.0)

###
2. Building
###

3.1. Download, build and install dependencies

Dependencies:
* eXtra-fast Essential Video Encoder (XEVE) (https://github.com/mpeg5/xeve)
* eXtra-fast Essential Video Decoder (XEVD) (https://github.com/mpeg5/xevd)

---
2.1.1. XEVE
---
git clone g...@github.com:mpeg5/xeve.git 
cd xeve

---
base profile
---
mkdir build_base
cd buid_base
cmake .. -DSET_PROF=BASE
make
make install

---
main profile
---
mkdir build_main
cd buid_base
cmake .. -DSET_PROF=MAIN
make
make install

---
2.1.2. XEVD
---
git clone g...@github.com:mpeg5/xeve.git
cd xeve

---
base profile
---
mkdir build_base
cd buid_base
cmake .. -DSET_PROF=BASE
make
make install

---
main profile
---

mkdir build_main
cd buid_base
cmake .. -DSET_PROF=MAIN
make
make install

---
2.2. Build ffmpeg with libxeve and libxevd
---
It is required ffmpeg to be configfured with --enable-libxeve and --enable-
libxevd

Please find below exaple configuration.

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libdav1d \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libxeve \
--enable-libxevd \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j $(nproc)

make install

###
3. Examples
###

Please find below examples on how to use EVC coded with ffmpeg commandline
tool.

(All samples are available in
https://drive.google.com/drive/folders/1YtCLlSuTAjpLziTKI_QBuQrIOm2ss9LB?usp
=sharing )

#!/bin/bash
#===
#(YUV420P) -> (EVC)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 352x288 -r 30 -i
Test_Video_cif.yuv -c:v libxeve -f rawvideo Test_Video_cif.yuv.evc
ffplay -autoexit Test_Video_cif.yuv.evc

#===
#(YUV420P10LE) -> (EVC)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p10le -s:v 352x288 -r 30 -i
Test_Video_cif_10le.yuv -c:v libxeve -f rawvideo Test_Video_cif_10le.yuv.evc
ffplay -autoexit Test_Video_cif_10le.yuv.evc

#===
#(EVC) -> (YUV420P)
#===
ffmpeg -i Test_Video_cif.yuv.evc -pix_fmt yuv420p Test_Video_cif.evc.yuv
ffplay -autoexit -f rawvideo -pixel_format yuv420p -video_size 352x288
Test_Video_cif.evc.yuv

#===
#(EVC) -> (YUV420Pi10LE)
#===
ffmpeg -i Test_Video_cif_10le.yuv.evc -pix_fmt yuv420p10le
Test_Video_cif_10le.evc.yuv
ffplay -autoexit -f rawvideo -pixel_format yuv420p10le -video_size 352x288
Test_Video_cif_10le.evc.yuv

#===
#(YUV420P) -> (MP4)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 352x288 -r 30 -i
Test_Video_cif.yuv -c:v libxeve -f rawvideo Test_Video_cif.yuv.mp4
ffplay -autoexit Test_Video_cif.yuv.mp4

#===
#(YUV420P10LE) -> (MP4)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p10le -s:v 352x288 -r 30 -i
Test_Video_cif_10le.yuv -c:v libxeve -f rawvideo Test_Video_cif_10le.yuv.mp4
ffplay -autoexit Test_Video_cif_10le.yuv.mp4

#===
#(MP4) -> (

[FFmpeg-devel] [PATCH 2/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
- Added xeve encoder wrapper
- Added xevd dencoder wrapper
- Added documentation for xeve and xevd wrappers
- Added parser for EVC format
- Changes in project configuration file and libavcodec Makefile

Signed-off-by: Dawid Kozinski 
---
 configure |   10 +
 doc/decoders.texi |   23 +
 doc/encoders.texi |  112 
 doc/general_contents.texi |   19 +
 libavcodec/Makefile   |3 +
 libavcodec/allcodecs.c|2 +
 libavcodec/avcodec.h  |3 +
 libavcodec/evc_parser.c   |  514 +
 libavcodec/libxevd.c  |  443 +++
 libavcodec/libxeve.c  | 1139 +
 libavcodec/parsers.c  |1 +
 11 files changed, 2269 insertions(+)
 create mode 100644 libavcodec/evc_parser.c
 create mode 100644 libavcodec/libxevd.c
 create mode 100644 libavcodec/libxeve.c

diff --git a/configure b/configure
index 7a62f0c248..ef3b3cfc1d 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,8 @@ External library support:
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
+  --enable-libxeve enable MPEG-5 Essential Video Coding (EVC) encoding 
via libxeve [no]
+  --enable-libxevd enable MPEG-5 Essential Video Coding (EVC) decoding 
via libxevd [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1880,6 +1882,8 @@ EXTERNAL_LIBRARY_LIST="
 openssl
 pocketsphinx
 vapoursynth
+libxeve
+libxevd
 "
 
 HWACCEL_AUTODETECT_LIBRARY_LIST="
@@ -2453,6 +2457,7 @@ CONFIG_EXTRA="
 h264pred
 h264qpel
 hevcparse
+evcparse
 hpeldsp
 huffman
 huffyuvdsp
@@ -3252,6 +3257,7 @@ mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
 vc1_parser_select="vc1dsp"
+evc_parser_select="evcparse"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
@@ -3377,6 +3383,8 @@ libx264_encoder_select="atsc_a53"
 libx264rgb_encoder_deps="libx264"
 libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
+libxeve_encoder_deps="libxeve"
+libxevd_decoder_deps="libxevd"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
 libxvid_encoder_deps="libxvid"
@@ -6659,6 +6667,8 @@ enabled libx264   && { check_pkg_config libx264 
x264 "stdint.h x264.h" x
  check_cpp_condition libx262 x264.h "X264_MPEG2"
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
+enabled libxeve   && require_pkg_config libxeve "xeve >= 1.0.0" 
"xeve.h" xeve_encode
+enabled libxevd   && require_pkg_config libxevd "xevd >= 1.0.0" 
"xevd.h" xevd_decode
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
diff --git a/doc/decoders.texi b/doc/decoders.texi
index 49ab735dce..9277e20be9 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -126,6 +126,29 @@ Set amount of frame threads to use during decoding. The 
default value is 0 (auto
 
 @end table
 
+@section libxevd
+
+eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper.
+
+This decoder requires the presence of the libxevd headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxevd}.
+
+The xevd project website is at @url{https://github.com/mpeg5/xevd}.
+
+@subsection Options
+
+The following options are supported by the libxevd wrapper.
+The xevd-equivalent options or values are listed in parentheses for easy 
migration.
+
+To get a more accurate and extensive documentation of the libxevd options,
+invoke the command  @code{xevd_app --help} or consult the libxevd 
documentation.
+
+@table @option
+@item threads (@emph{threads})
+Force to use a specific number of threads
+@end table
+
 @c man end VIDEO DECODERS
 
 @chapter Audio Decoders
diff --git a/doc/encoders.texi b/doc/encoders.texi
index e3b61de5a1..870dbc 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2815,6 +2815,118 @@ ffmpeg -i input -c:v libxavs2 -xavs2-params RdoqLevel=0 
output.avs2
 @end example
 @end table
 
+@section libxeve
+
+eXtra-fast Essential Video Encoder (XEVE) MPEG-5 EVC encoder wrapper.
+
+This encoder requires the presence of the libxeve headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxeve}.
+
+@float NOTE
+Many l

[FFmpeg-devel] [PATCH 3/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
- Added muxer for EVC format (MP4, raw)
- Added demuxer for EVC format (MP4)
- Added evc extension to the list of extensions for ff_mov_demuxer

Signed-off-by: Dawid Kozinski 
---
 doc/muxers.texi  |   6 ++
 libavformat/Makefile |   2 +
 libavformat/allformats.c |   2 +
 libavformat/evcdec.c | 127 +++
 libavformat/isom_tags.c  |   2 +
 libavformat/mov.c|   2 +-
 libavformat/movenc.c |  28 +
 libavformat/rawenc.c |  13 
 8 files changed, 181 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/evcdec.c

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 1ea98a69a3..198cb90fe9 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2097,6 +2097,12 @@ DTS Coherent Acoustics (DCA) audio.
 
 Dolby Digital Plus, also known as Enhanced AC-3, audio.
 
+@subsection evc
+
+MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video.
+
+Extensions: evc
+
 @subsection g722
 
 ITU-T G.722 audio.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 84e73e3c63..db461e79b7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -241,6 +241,8 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
+OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d066a7745b..1148024e71 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -145,6 +145,8 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVInputFormat  ff_evc_demuxer;
+extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
 extern const AVOutputFormat ff_ffmetadata_muxer;
diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
new file mode 100644
index 00..21f3f0f0e4
--- /dev/null
+++ b/libavformat/evcdec.c
@@ -0,0 +1,127 @@
+/*
+ * RAW EVC video demuxer
+ *
+ * Copyright (c) 2021 Dawid Kozinski 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-
1301 USA
+ */
+
+#include 
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/internal.h"
+
+#include "rawdec.h"
+#include "avformat.h"
+
+#define EVC_NAL_HEADER_SIZE   2 /* byte */
+
+typedef struct EVCParserContext {
+int got_sps;
+int got_pps;
+int got_idr;
+int got_nonidr;
+} EVCParserContext;
+
+static int get_nalu_type(const uint8_t *bs, int bs_size)
+{
+int nal_unit_type_plus1 = 0;
+XEVD_INFO info;
+int ret;
+
+if(bs_size >= EVC_NAL_HEADER_SIZE) {
+ret = xevd_info((void*)bs, EVC_NAL_HEADER_SIZE, 1, &info);
+if (XEVD_FAILED(ret)) {
+av_log(NULL, AV_LOG_ERROR, "Cannot get bitstream
information\n");
+return -1;
+}
+nal_unit_type_plus1 = info.nalu_type;
+}
+
+return nal_unit_type_plus1 - 1;
+}
+
+static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size)
+{
+uint32_t len = 0;
+XEVD_INFO info;
+int ret;
+
+if(bs_size >= XEVD_NAL_UNIT_LENGTH_BYTE) {
+ret = xevd_info((void *)bs, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info);
+if (XEVD_FAILED(ret)) {
+av_log(NULL, AV_LOG_ERROR, "Cannot get bitstream
information\n");
+return 0;
+}
+len = info.nalu_len;
+if(len == 0) {
+av_log(NULL, AV_LOG_ERROR, "Invalid bitstream size! [%d]\n",
bs_size);
+return 0;
+}
+}
+
+return len;
+}
+
+static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev)
+{
+int nalu_type;
+size_t nalu_size;
+unsigned char *bits = (unsigned char *)p->buf;
+int bytes_to_read = p->buf_size;
+
+while(bytes_to_read > X

Re: [FFmpeg-devel] [PATCH v9 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


These functions are going to be used in libavformat/avisynth.c
and fftools/cmdutils.c remove MAX_PATH limit.
---
libavutil/wchar_filename.h | 51 ++
1 file changed, 51 insertions(+)


I looked through this patchset now, and I think it overall looks 
acceptable - with a couple minor things I'd like touched up and clarified.


However while reviewing this, I noticed a preexisting issue regarding the 
av_fopen_utf8 function. This patchset extends the use of that function 
into fftools, which isn't great given the issue... The use is fairly 
marginal (the preset files) so I guess it can be tolerated, as it's a 
preexisting orthogonal issue.


The other question is whether it's tolerable to use more non-installed 
headers (like libavutil/wchar_filename.h) in fftools. (I'd like to have 
this point confirmed with Anton before landing the patchset.)


A couple comments on the patch below:


diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index 90f08245..e22ffa8a 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -40,6 +40,57 @@ static inline int utf8towchar(const char *filename_utf8, 
wchar_t **filename_w)
MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
return 0;
}
+
+av_warn_unused_result
+static inline int wchartocp(const unsigned int code_page, const wchar_t 
*filename_w,
+char **filename)
+{
+const DWORD flags = code_page == CP_UTF8 ? MB_ERR_INVALID_CHARS : 0;
+const int num_chars = WideCharToMultiByte(code_page, flags, filename_w, -1,
+  NULL, 0, NULL, NULL);


We don't generally use 'const' like this in ffmpeg; we use 'const' where 
it makes a functional difference (i.e. on the type that pointers point 
at), but not for plain scalar values (neither parameters nor local 
variables).




+if (num_chars <= 0) {
+*filename = NULL;
+return 0;
+}
+*filename = av_calloc(num_chars, sizeof(char));
+if (!*filename) {
+errno = ENOMEM;
+return -1;
+}
+WideCharToMultiByte(code_page, flags, filename_w, -1,
+*filename, num_chars, NULL, NULL);
+return 0;
+}
+
+av_warn_unused_result
+static inline int wchartoutf8(const wchar_t *filename_w, char **filename)
+{
+return wchartocp(CP_UTF8, filename_w, filename);
+}
+
+av_warn_unused_result
+static inline int wchartoansi(const wchar_t *filename_w, char **filename)
+{
+return wchartocp(CP_THREAD_ACP, filename_w, filename);
+}


I think this actually would be more correct to use CP_ACP, not 
CP_THREAD_ACP. A bit of googling led me to 
https://github.com/ocaml/ocaml/issues/7854 which indicates that CP_ACP is 
used for ansi file functions, regardless of the current thread specific 
codepage. (But I see that this already is used in libavformat/avisynth.c, 
so it's in one sense a preexisting issue, but I think it'd be more correct 
to use CP_ACP here.)


// Martin

___
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 v9 2/6] libavformat/avisynth.c: Remove MAX_PATH limit

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


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

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 8ba2bdea..f7bea8c3 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -34,6 +34,7 @@
/* Platform-specific directives. */
#ifdef _WIN32
  #include "compat/w32dlfcn.h"
+  #include "libavutil/wchar_filename.h"
  #undef EXTERN_C
  #define AVISYNTH_LIB "avisynth"
#else
@@ -810,8 +811,7 @@ static int avisynth_open_file(AVFormatContext *s)
AVS_Value arg, val;
int ret;
#ifdef _WIN32
-char filename_ansi[MAX_PATH * 4];
-wchar_t filename_wc[MAX_PATH * 4];
+char *filename_ansi = NULL;
#endif

if (ret = avisynth_context_create(s))
@@ -819,10 +819,12 @@ static int avisynth_open_file(AVFormatContext *s)

#ifdef _WIN32
/* Convert UTF-8 to ANSI code page */
-MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc, MAX_PATH * 4);
-WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
-MAX_PATH * 4, NULL, NULL);
+if (utf8toansi(s->url, &filename_ansi)) {
+ret = AVERROR_UNKNOWN;
+goto fail;
+}
arg = avs_new_value_string(filename_ansi);
+av_free(filename_ansi);
#else
arg = avs_new_value_string(s->url);
#endif


This looks ok to me, but as mentioned in the other patch, I think CP_ACP 
actually would be more correct than the current CP_THREAD_ACP 
(https://github.com/ocaml/ocaml/issues/7854), so it could be worthwhile to 
change that at the same time (either just as part of this refactoring, or 
as a totally separate patch for clarity).


// Martin

___
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 v9 3/6] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


---
compat/w32dlfcn.h | 78 ++-
1 file changed, 64 insertions(+), 14 deletions(-)

diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h
index 52a94efa..0f41f50b 100644
--- a/compat/w32dlfcn.h
+++ b/compat/w32dlfcn.h
@@ -25,6 +25,30 @@
#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT
#include "libavutil/wchar_filename.h"
#endif
+
+static inline wchar_t *get_module_filename(const HMODULE module)
+{
+wchar_t *path = NULL, *new_path = NULL;
+DWORD path_size = 0, path_len = 0;
+
+do {
+path_size = path_size ? 2 * path_size : MAX_PATH;
+new_path = av_realloc_array(path, path_size, sizeof *path);
+if (!new_path) {
+av_free(path);
+return NULL;
+}
+path = new_path;
+path_len = GetModuleFileNameW(module, path, path_size);
+} while (path_len && path_size <= 32768 && path_size <= path_len);
+
+if (!path_len) {
+av_free(path);
+return NULL;
+}
+return path;
+}
+
/**
 * Safe function used to open dynamic libs. This attempts to improve program 
security
 * by removing the current directory from the dll search path. Only dll's found 
in the
@@ -34,29 +58,53 @@
 */
static inline HMODULE win32_dlopen(const char *name)
{
+wchar_t *name_w = NULL;
+if (utf8towchar(name, &name_w))
+name_w = NULL;
#if _WIN32_WINNT < 0x0602
// Need to check if KB2533623 is available
if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), 
"SetDefaultDllDirectories")) {
HMODULE module = NULL;
-wchar_t *path = NULL, *name_w = NULL;
-DWORD pathlen;
-if (utf8towchar(name, &name_w))
+wchar_t *path = NULL, *new_path = NULL;
+DWORD pathlen, pathsize, namelen;
+if (!name_w)
goto exit;
-path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
+namelen = wcslen(name_w);
// Try local directory first
-pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
-pathlen = wcsrchr(path, '\\') - path;
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+path = get_module_filename(NULL);
+if (!path)
goto exit;
-path[pathlen] = '\\';
+new_path = wcsrchr(path, '\\');
+if (!new_path)
+goto exit;
+pathlen = new_path - path;
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (module == NULL) {
// Next try System32 directory
-pathlen = GetSystemDirectoryW(path, MAX_PATH);
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
goto exit;
-path[pathlen] = '\\';
+// Buffer is not enough in two cases:
+// 1. system directory + \ + module name
+// 2. system directory even without module name.
+if (pathlen + namelen + 2 > pathsize) {
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
+// Query again to handle case #2.
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
+goto exit;
+}
+path[pathlen] = L'\\';
wcscpy(path + pathlen + 1, name_w);
module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
@@ -73,15 +121,17 @@ exit:
#   define LOAD_LIBRARY_SEARCH_SYSTEM320x0800
#endif
#if HAVE_WINRT
-wchar_t *name_w = NULL;
int ret;
-if (utf8towchar(name, &name_w))
+if (!name_w)
return NULL;
ret = LoadPackagedLibrary(name_w, 0);
av_free(name_w);
return ret;
#else
-return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32);
+/* filename may be be in CP_ACP */
+if (!name_w)
+return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR 
| LOAD_LIBRARY_SEARCH_SYSTEM32);
+return LoadLibraryExW(name_w, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32);
#endif
}
#define dlopen(name, flags) win32_dlopen(name)
--
2.32.0


This looks ok to me.

// Martin

___
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 v9 4/6] fftools/cmdutils.c: Remove MAX_PATH limit and replace fopen with av_fopen_utf8

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


---
fftools/cmdutils.c | 38 +-
1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 5d7cdc3e..a66dbb22 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -37,6 +37,7 @@
#include "libswresample/swresample.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
+#include "libavutil/avutil.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.h"
#include "libavutil/mathematics.h"
@@ -50,6 +51,7 @@
#include "opt_common.h"
#ifdef _WIN32
#include 
+#include "compat/w32dlfcn.h"


This adds a dependency on nonpublic headers - which I think can be 
tolerated as it's only a build-time issue, and fftools are currently built 
as part of the rest of the ffmpeg build anyway.



#endif

AVDictionary *sws_dict;
@@ -812,28 +814,43 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
{
FILE *f = NULL;
int i;
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+char *datadir = NULL;
+#endif
const char *base[3] = { getenv("FFMPEG_DATADIR"),
getenv("HOME"),


Hmm, I guess neither of these are commonly set on Windows - otherwise this 
would suddenly change to interpret generic environment variables as UTF8.



FFMPEG_DATADIR, };

if (is_path) {
av_strlcpy(filename, preset_name, filename_size);
-f = fopen(filename, "r");
+f = av_fopen_utf8(filename, "r");
} else {


As mentioned elsewhere, I realized that av_fopen_utf8 is problematic, but 
that's an orthogonal issue, and the issue is already preexisting, and it's 
used for a fairly marginal feature here, so I guess that can be tolerated 
too (and if the root cause is fixed, this gets taken care of at the same 
time too).


// Martin

___
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 v9 5/6] fftools: Enable long path support on Windows (fixes #8885)

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


---
fftools/Makefile |  5 +
fftools/fftools.manifest | 10 ++
fftools/manifest.rc  |  3 +++
3 files changed, 18 insertions(+)
create mode 100644 fftools/fftools.manifest
create mode 100644 fftools/manifest.rc


I think the change here is fine, but the commit message absolutely needs 
to explain the full situation about what this does, how, etc.


As far as I've understood Windows long path support, it'd be something 
like this:


---8<---

Newer versions of Windows (Windows 10 1607 and newer) can support path 
names longer than MAX_PATH (260 characters). To take advantage of that, an 
application needs to opt in, by including a small manifest as a resource. 
Additionally, the path length limitation is only lifted for file APIs that 
pass paths as wchar_t. Therefore, the preceding patches have refactored a 
few remaining cases to internally open files with wchar_t path name 
functions.


On older versions of Windows, the newly added manifest has no effect.

---8<---

Does that sound like the correct explanation of the situation?

// Martin

___
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 v9 6/6] fftools: Use UTF-8 on Windows

2022-04-20 Thread Martin Storsjö

On Fri, 15 Apr 2022, Nil Admirari wrote:


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

diff --git a/fftools/fftools.manifest b/fftools/fftools.manifest
index 30b7d8fe..d1ac1e4e 100644
--- a/fftools/fftools.manifest
+++ b/fftools/fftools.manifest
@@ -3,8 +3,10 @@

  
  
-http://schemas.microsoft.com/SMI/2016/WindowsSettings";>
+http://schemas.microsoft.com/SMI/2016/WindowsSettings";
+ 
xmlns:ws2019="http://schemas.microsoft.com/SMI/2019/WindowsSettings";>
  true
+  UTF-8

  

--
2.32.0


This needs a similar commit message as what I suggested for the previous 
commit, explaining what it does, when, why, and clarifying that this is a 
noop for older versions.


In particular, it'd be interesting to know why we actually need this; we 
normally should be doing all the conversions between wchar_t and utf8 
everywhere anyway, so the exact codepage used shouldn't really matter 
much? I presume the main noticable benefit is that it improves the path 
name compatibility with avisynth which is stuck on using CP_ACP pathnames?


// Martin

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/openh264: return (DE|EN)CODER_NOT_FOUND if version check fails

2022-04-20 Thread Martin Storsjö

On Fri, 18 Feb 2022, Andreas Schneider wrote:


Signed-off-by: Andreas Schneider 
---
libavcodec/libopenh264dec.c | 2 +-
libavcodec/libopenh264enc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index 7f5e85402a..97d3630df6 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -56,7 +56,7 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
WelsTraceCallback callback_function;

if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+return AVERROR_DECODER_NOT_FOUND;

if (WelsCreateDecoder(&s->decoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create decoder\n");
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 7c0501a2eb..7649e7b025 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -137,7 +137,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
AVCPBProperties *props;

if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+return AVERROR_ENCODER_NOT_FOUND;

if (WelsCreateSVCEncoder(&s->encoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
--
2.35.1


This looks reasonable to me, so I could push this in a little while if 
there's no more comments on it.


But the patch lacks an explanation of _why_ this is done, in addition to 
_what_ it does. I presume that's because the current error code makes some 
decoder/encoder selection logic error out entirely, instead of continuing 
trying some other codec - is that right? That would really be valuable to 
include in the commit message.


// Martin

___
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/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
###
1. Genaral info
###

The patch provided below contains an integration layer between ffmpeg
framework and EVC codec implementation.
In nutshell, it enables using EVC codec (encoding, decoding)  by the means
of ffmpeg API. 
I'd like to emphasize one more time, that (as mentioned before) it isn't
codec implementation. The provided implementation serves as an integration
layer between ffmpeg framework and the EVC codec.

EVC codec has been published as two separate libraries. 
The first one called XEVE (eXtra-fast Essential Video Encoder) is an
opensource MPEG-5 EVC encoder.
The second one called XEVD (eXtra-fast Essential Video Decoder ) is an
opensource MPEG-5 EVC decoder.
For more information on both libraries please follow the links below:
* https://github.com/mpeg5/xeve
* https://github.com/mpeg5/xevd 

The patch provided below should be apply to FFmpeg 5.0 release (commit
b655beb025cb54ba19cad89e731990910643f208 release/5.0)

###
2. Building
###

3.1. Download, build and install dependencies

Dependencies:
* eXtra-fast Essential Video Encoder (XEVE) (https://github.com/mpeg5/xeve)
* eXtra-fast Essential Video Decoder (XEVD) (https://github.com/mpeg5/xevd)

---
2.1.1. XEVE
---
git clone g...@github.com:mpeg5/xeve.git cd xeve

---
base profile
---
mkdir build_base
cd buid_base
cmake .. -DSET_PROF=BASE
make
make install

---
main profile
---
mkdir build_main
cd buid_base
cmake .. -DSET_PROF=MAIN
make
make install

---
2.1.2. XEVD
---
git clone g...@github.com:mpeg5/xeve.git
cd xeve

---
base profile
---
mkdir build_base
cd buid_base
cmake .. -DSET_PROF=BASE
make
make install

---
main profile
---

mkdir build_main
cd buid_base
cmake .. -DSET_PROF=MAIN
make
make install

---
2.2. Build ffmpeg with libxeve and libxevd
---
It is required ffmpeg to be configfured with --enable-libxeve and --enable-
libxevd

Please find below exaple configuration.

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static"
\ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-
L$HOME/ffmpeg_build/lib" \ --extra-libs="-lpthread -lm" \ --
bindir="$HOME/bin" \ --enable-gpl \ --enable-gnutls \ --enable-libaom \ --
enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-
libmp3lame \ --enable-libopus \ --enable-libdav1d \ --enable-libvorbis \ --
enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libxeve \
--enable-libxevd \
--enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j $(nproc)

make install

###
3. Examples
###

Please find below examples on how to use EVC coded with ffmpeg commandline
tool.

(All samples are available in
https://drive.google.com/drive/folders/1YtCLlSuTAjpLziTKI_QBuQrIOm2ss9LB?usp
=sharing )

#!/bin/bash
#===
#(YUV420P) -> (EVC)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 352x288 -r 30 -i
Test_Video_cif.yuv -c:v libxeve -f rawvideo Test_Video_cif.yuv.evc ffplay -
autoexit Test_Video_cif.yuv.evc

#===
#(YUV420P10LE) -> (EVC)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p10le -s:v 352x288 -r 30 -i
Test_Video_cif_10le.yuv -c:v libxeve -f rawvideo
Test_Video_cif_10le.yuv.evc ffplay -autoexit Test_Video_cif_10le.yuv.evc

#===
#(EVC) -> (YUV420P)
#===
ffmpeg -i Test_Video_cif.yuv.evc -pix_fmt yuv420p Test_Video_cif.evc.yuv
ffplay -autoexit -f rawvideo -pixel_format yuv420p -video_size 352x288
Test_Video_cif.evc.yuv

#===
#(EVC) -> (YUV420Pi10LE)
#===
ffmpeg -i Test_Video_cif_10le.yuv.evc -pix_fmt yuv420p10le
Test_Video_cif_10le.evc.yuv ffplay -autoexit -f rawvideo -pixel_format
yuv420p10le -video_size 352x288  Test_Video_cif_10le.evc.yuv

#===
#(YUV420P) -> (MP4)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 352x288 -r 30 -i
Test_Video_cif.yuv -c:v libxeve -f rawvideo Test_Video_cif.yuv.mp4 ffplay -
autoexit Test_Video_cif.yuv.mp4

#===
#(YUV420P10LE) -> (MP4)
#===
ffmpeg -f rawvideo -pix_fmt yuv420p10le -s:v 352x288 -r 30 -i
Test_Video_cif_10le.yuv -c:v libxeve -f rawvideo
Test_Video_cif_10le.yuv.mp4 ffplay -autoexit Test_Video_cif_10le.yuv.mp4

#===
#(MP4

[FFmpeg-devel] [PATCH 2/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
- Added xeve encoder wrapper
- Added xevd dencoder wrapper
- Added documentation for xeve and xevd wrappers
- Added parser for EVC format
- Changes in project configuration file and libavcodec Makefile

Signed-off-by: Dawid Kozinski 
---
 configure |   10 +
 doc/decoders.texi |   23 +
 doc/encoders.texi |  112 
 doc/general_contents.texi |   19 +
 libavcodec/Makefile   |3 +
 libavcodec/allcodecs.c|3 +
 libavcodec/avcodec.h  |3 +
 libavcodec/evc_parser.c   |  514 +
 libavcodec/libxevd.c  |  445 +++
 libavcodec/libxeve.c  | 1141 +
 libavcodec/parsers.c  |1 +
 11 files changed, 2274 insertions(+)
 create mode 100644 libavcodec/evc_parser.c
 create mode 100644 libavcodec/libxevd.c
 create mode 100644 libavcodec/libxeve.c

diff --git a/configure b/configure
index 358a614854..48e0bf79ef 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,8 @@ External library support:
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
+  --enable-libxeve enable MPEG-5 Essential Video Coding (EVC) encoding 
via libxeve [no]
+  --enable-libxevd enable MPEG-5 Essential Video Coding (EVC) decoding 
via libxevd [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1881,6 +1883,8 @@ EXTERNAL_LIBRARY_LIST="
 openssl
 pocketsphinx
 vapoursynth
+libxeve
+libxevd
 "
 
 HWACCEL_AUTODETECT_LIBRARY_LIST="
@@ -2455,6 +2459,7 @@ CONFIG_EXTRA="
 h264pred
 h264qpel
 hevcparse
+evcparse
 hpeldsp
 huffman
 huffyuvdsp
@@ -3252,6 +3257,7 @@ mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+evc_parser_select="evcparse"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
@@ -3376,6 +3382,8 @@ libx264_encoder_select="atsc_a53"
 libx264rgb_encoder_deps="libx264"
 libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
+libxeve_encoder_deps="libxeve"
+libxevd_decoder_deps="libxevd"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
 libxvid_encoder_deps="libxvid"
@@ -6651,6 +6659,8 @@ enabled libx264   && { check_pkg_config libx264 
x264 "stdint.h x264.h" x
  check_cpp_condition libx262 x264.h "X264_MPEG2"
 enabled libx265   && require_pkg_config libx265 x265 x265.h 
x265_api_get &&
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
+enabled libxeve   && require_pkg_config libxeve "xeve >= 1.0.0" 
"xeve.h" xeve_encode
+enabled libxevd   && require_pkg_config libxevd "xevd >= 1.0.0" 
"xevd.h" xevd_decode
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
diff --git a/doc/decoders.texi b/doc/decoders.texi
index de2429abba..1754c517b8 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -126,6 +126,29 @@ Set amount of frame threads to use during decoding. The 
default value is 0 (auto
 
 @end table
 
+@section libxevd
+
+eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper.
+
+This decoder requires the presence of the libxevd headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxevd}.
+
+The xevd project website is at @url{https://github.com/mpeg5/xevd}.
+
+@subsection Options
+
+The following options are supported by the libxevd wrapper.
+The xevd-equivalent options or values are listed in parentheses for easy 
migration.
+
+To get a more accurate and extensive documentation of the libxevd options,
+invoke the command  @code{xevd_app --help} or consult the libxevd 
documentation.
+
+@table @option
+@item threads (@emph{threads})
+Force to use a specific number of threads
+@end table
+
 @section QSV Decoders
 
 The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC,
diff --git a/doc/encoders.texi b/doc/encoders.texi
index aac9f25e55..c4e4bdaa5e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2808,6 +2808,118 @@ ffmpeg -i input -c:v libxavs2 -xavs2-params RdoqLevel=0 
output.avs2
 @end example
 @end table
 
+@section libxeve
+
+eXtra-fast Essential Video Encoder (XEVE) MPEG-5 EVC encoder wrapper.
+
+This encoder requires the presence of the libxeve headers and library
+during configuration. You need to explicitly configure the build with
+@o

[FFmpeg-devel] [PATCH 3/3] Provided support for MPEG-5 EVC (Essential Video Coding) codec

2022-04-20 Thread Dawid Kozinski
- Added muxer for EVC format (MP4, raw)
- Added demuxer for EVC format (MP4)
- Added evc extension to the list of extensions for ff_mov_demuxer

Signed-off-by: Dawid Kozinski 
---
 doc/muxers.texi  |   6 ++
 libavformat/Makefile |   2 +
 libavformat/allformats.c |   2 +
 libavformat/evcdec.c | 127 +++
 libavformat/isom_tags.c  |   2 +
 libavformat/mov.c|   2 +-
 libavformat/movenc.c |  28 +
 libavformat/rawenc.c |  13 
 8 files changed, 181 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/evcdec.c

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 1af603b7f6..585279c0a4 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2114,6 +2114,12 @@ DTS Coherent Acoustics (DCA) audio.
 
 Dolby Digital Plus, also known as Enhanced AC-3, audio.
 
+@subsection evc
+
+MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video.
+
+Extensions: evc
+
 @subsection g722
 
 ITU-T G.722 audio.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index e3233fd7ac..dae53d8b08 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -245,6 +245,8 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
+OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 7c1d0ac38f..90e45572d2 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -147,6 +147,8 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVInputFormat  ff_evc_demuxer;
+extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
 extern const AVOutputFormat ff_ffmetadata_muxer;
diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
new file mode 100644
index 00..21f3f0f0e4
--- /dev/null
+++ b/libavformat/evcdec.c
@@ -0,0 +1,127 @@
+/*
+ * RAW EVC video demuxer
+ *
+ * Copyright (c) 2021 Dawid Kozinski 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-
1301 USA
+ */
+
+#include 
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/internal.h"
+
+#include "rawdec.h"
+#include "avformat.h"
+
+#define EVC_NAL_HEADER_SIZE   2 /* byte */
+
+typedef struct EVCParserContext {
+int got_sps;
+int got_pps;
+int got_idr;
+int got_nonidr;
+} EVCParserContext;
+
+static int get_nalu_type(const uint8_t *bs, int bs_size)
+{
+int nal_unit_type_plus1 = 0;
+XEVD_INFO info;
+int ret;
+
+if(bs_size >= EVC_NAL_HEADER_SIZE) {
+ret = xevd_info((void*)bs, EVC_NAL_HEADER_SIZE, 1, &info);
+if (XEVD_FAILED(ret)) {
+av_log(NULL, AV_LOG_ERROR, "Cannot get bitstream
information\n");
+return -1;
+}
+nal_unit_type_plus1 = info.nalu_type;
+}
+
+return nal_unit_type_plus1 - 1;
+}
+
+static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size)
+{
+uint32_t len = 0;
+XEVD_INFO info;
+int ret;
+
+if(bs_size >= XEVD_NAL_UNIT_LENGTH_BYTE) {
+ret = xevd_info((void *)bs, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info);
+if (XEVD_FAILED(ret)) {
+av_log(NULL, AV_LOG_ERROR, "Cannot get bitstream
information\n");
+return 0;
+}
+len = info.nalu_len;
+if(len == 0) {
+av_log(NULL, AV_LOG_ERROR, "Invalid bitstream size! [%d]\n",
bs_size);
+return 0;
+}
+}
+
+return len;
+}
+
+static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev)
+{
+int nalu_type;
+size_t nalu_size;
+unsigned char *bits = (unsigned char *)p->buf;
+int bytes_to_read = p->buf_size;
+
+while(bytes_to_read > X

[FFmpeg-devel] av_fopen_utf8 and cross-DLL CRT object sharing issue on Windows

2022-04-20 Thread Martin Storsjö

Hi,

I just became aware of the av_fopen_utf8 function - which was introduced 
to fix path name translations on Windows - actually has a notable design 
flaw.



Background:

On Windows, a process can contain more than one C runtime (CRT); the 
system comes with two shared ones (UCRT and msvcrt.dll) and in MSVC 
builds, each DLL/EXE can have one statically linked in instead of linking 
against a shared library CRT (and that's actually the default 
configuration when building with MSVC).


This means that CRT objects (file descriptors from open(), FILE* opened 
with fopen/fdopen) mustn't be shared across DLLs; such an object must be 
opened, accessed and closed within the same DLL.



The issue:

This was fixed for the avpriv_open() function in 
e743e7ae6ee7e535c4394bec6fe6650d2b0dbf65 by duplicating the file_open.c 
source file in all libav* libraries (in MSVC builds, and renaming 
avpriv_open to ff_open), so that each library gets their own copy of 
ff_open (which isn't exported), so that all calls to open/read/write/close 
are done within the same DLL.


When av_fopen_utf8 was added afterwards, in 
85cabf1ca98fcc502fcf5b8d6bfb6d8061c2caef, this issue wasn't taken into 
account - although the issue is somewhat eased by lucky coincidence.


As av_fopen_utf8 is implemented in the same source file, 
libavutil/file_open.c, which gets duplicated in all libraries that use it, 
all uses of the function in other libraries (such as libavformat) actually 
end up using their own copy of it. (This also means that all the libav* 
DLLs export this function.) But for any users of the function outside of 
the ffmpeg libraries, this function (in libavutil, or whichever library it 
ends up imported from) returns a FILE* allocated by libavutil's CRT, which 
then can't be used with the fread/fwrite/fclose/whatever functions in the 
DLL/EXE that called it.


One concrete example of this is that the function is used for the twopass 
log file in fftools/ffmpeg_opt.c. To see the issue in action, build ffmpeg 
with MSVC with this config:


../ffmpeg/configure --enable-shared --toolchain=msvc --prefix=

Then try to do a twopass encoding with it:

ffmpeg -i  -an -c:v ffv1 -pass 1 -f null -

ffmpeg -i  -an -c:v ffv1 -pass 2 -y test-2pass.mkv

The same issue would appear anywhere this function is used from libavutil 
built as a DLL, from a caller built with a different CRT choice (e.g. 
often if mixing mingw/MSVC builds, which otherwise is supported just 
fine). (If built with a shared CRT, i.e. configured with 
--extra-cflags=-MD, it does work though.)



As this is a public function, we can't really do many tricks like we do 
within the libraries. (On the other hand, while it is a public function, 
it doesn't seem to be used much outside of ffmpeg, other than in ffmpeg 
API bindings for other languages.)


I guess the only really robust solution would be to turn av_fopen_utf8 
into a static inline function within the headers, essentially inlineing a 
copy of wchar_filename.h there, so that it expands to a call to the 
callers' _wfopen or similar. But that would end up polluting users' code 
by implicitly including windows.h everywhere, which really isn't nice to 
do either.


Or should we just document this issue, discourage further external use of 
the function, and fold this function into a ffmpeg-internal inline helper 
like libavutil/whcar_filename.h?



// Martin

___
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] Bug report

2022-04-20 Thread Dan Rose
I tried to submit this on the bug tracker, but it never sent a verification 
email so posting here.

The `-protocol_whitelist ALL` option appears to be broken. I expect it to allow 
any protocol as per documentation 
https://ffmpeg.org/ffmpeg-protocols.html#Protocol-Options
> Set a ","-separated list of allowed protocols. "ALL" matches all protocols.

It seems to not match any protocols at all:

$ ffmpeg -v 9 -loglevel 99 -protocol_whitelist ALL -i file://in.mp4 out.mp4L
ffmpeg version N-106633-g25d3f96db7 Copyright (c) 2000-2022 the FFmpeg 
developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.3)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/HEAD-25d3f96 
--enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= 
--host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom 
--enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus 
--enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy 
--enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab 
--enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp 
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid 
--enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r 
--enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb 
--enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq 
--enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox 
--enable-neon
  libavutil  57. 24.101 / 57. 24.101
  libavcodec 59. 26.100 / 59. 26.100
  libavformat59. 22.100 / 59. 22.100
  libavdevice59.  6.100 / 59.  6.100
  libavfilter 8. 33.100 /  8. 33.100
  libswscale  6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc56.  5.100 / 56.  5.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 
'9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) 
with argument '99'.
Reading option '-protocol_whitelist' ... matched as AVOption 
'protocol_whitelist' with argument 'ALL'.
Reading option '-i' ... matched as input url with argument 'file://in.mp4'.
Reading option 'out.mp4L' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url file://in.mp4.
Successfully parsed a group of options.
Opening an input file: file://in.mp4.
[NULL @ 0x13f605000] Opening 'file://in.mp4' for reading
[file @ 0x13f604ae0] Protocol 'file' not on whitelist 'ALL'!
file://in.mp4: Invalid argument


___
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] libavformat/mov.c: Added configuration flag to skip cover art atom while opening mov parser

2022-04-20 Thread Derek Buitenhuis
On 4/20/2022 12:39 PM, Malviya, Janpriya wrote:
> Hello ffmpeg dev team,
> Please look in attached patch.  while integrating FFmpeg we require to add 
> "skip_cover_page" options to skip cover art atom from parsing for M4A / MP4 
> streams. By default values set as 0 ( False ) so it will not impact others.

Why?

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

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


Re: [FFmpeg-devel] [PATCH v2 5/5] avcodec/x86/hevc_mc: add qpel_h64_8_avx512icl

2022-04-20 Thread Xiang, Haihao
On Thu, 2022-04-14 at 11:23 +, Wu Jianhua wrote:
> Ping!
> Wu Jianhua:
> > Henrik Gramner:
> > > Sent: Friday, March 11, 2022 10:51 PM
> > > To: FFmpeg development discussions and patches  > > devel at ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH v2 5/5] avcodec/x86/hevc_mc: add
> > > qpel_h64_8_avx512icl
> > > 
> > > All 5/5 LGTM.
> > > 
> > 
> > Hi there,
> > 
> > Are there any more comments or objections here?  
> > If not, could someone help push this patchset?
> > 
> > Many thanks!
> > Jianhua

Ping, the patchset works well for me. I'll apply this patchset in a few days if
no more comment.

Thanks
Haihao

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: fix timecode with high frame rate content

2022-04-20 Thread Marton Balint




On Mon, 11 Apr 2022, Marton Balint wrote:




On Mon, 11 Apr 2022, Anton Khirnov wrote:


 Quoting Marton Balint (2022-04-10 20:11:59)

 60 fps content have "Number of Frames" set to 30 in the tmcd atom, but
 the
 frame duration / timescale reflects the original video frame rate.

 Therefore we multiply the frame count with the quotient of the rounded
 timecode
 frame rate and the "Number of Frames" per second to get a frame count in
 the original
 (higher) frame rate.

 Note that the frames part in the timecode will be in high frame rate
 which will
 make the timecode different to e.g. MediaInfo which seems to show the 30
 fps
 timecode even for 120 fps content.

 Regression since 428b4aacb1a91a267650de644519882a5f700388.

 Fixes ticket #9710.
 Fixes ticket #9492.


 Sounds like there should be a test for this.


The smallest file I managed to find which is affected by this is
mov/canon_6d/mvi_9114.mov, but that is still 12 MB, therefore probably not
fit for addition to fate-samples.

With our muxer, the issue is not reproducible, so remuxing is not an
option.


Will apply soon.

Regards,
Marton
___
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/rtmpproto: send proper status for response to play command

2022-04-20 Thread Marton Balint




On Thu, 14 Apr 2022, Marton Balint wrote:


This fixes referencing the uninitialized filename variable.

Fixes ticket #9711.


Will apply tomorrow.

Regards,
Marton



Signed-off-by: Marton Balint 
---
libavformat/rtmpproto.c | 19 ++-
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index f97e3c3b8e..f0ef223f05 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -1857,11 +1857,10 @@ static int write_begin(URLContext *s)
}

static int write_status(URLContext *s, RTMPPacket *pkt,
-const char *status, const char *filename)
+const char *status, const char *description, const 
char *details)
{
RTMPContext *rt = s->priv_data;
RTMPPacket spkt = { 0 };
-char statusmsg[128];
uint8_t *pp;
int ret;

@@ -1884,11 +1883,11 @@ static int write_status(URLContext *s, RTMPPacket *pkt,
ff_amf_write_field_name(&pp, "code");
ff_amf_write_string(&pp, status);
ff_amf_write_field_name(&pp, "description");
-snprintf(statusmsg, sizeof(statusmsg),
- "%s is now published", filename);
-ff_amf_write_string(&pp, statusmsg);
-ff_amf_write_field_name(&pp, "details");
-ff_amf_write_string(&pp, filename);
+ff_amf_write_string(&pp, description);
+if (details) {
+ff_amf_write_field_name(&pp, "details");
+ff_amf_write_string(&pp, details);
+}
ff_amf_write_object_end(&pp);

spkt.size = pp - spkt.data;
@@ -1964,20 +1963,22 @@ static int send_invoke_response(URLContext *s, 
RTMPPacket *pkt)
pp = spkt.data;
ff_amf_write_string(&pp, "onFCPublish");
} else if (!strcmp(command, "publish")) {
+char statusmsg[128];
+snprintf(statusmsg, sizeof(statusmsg), "%s is now published", 
filename);
ret = write_begin(s);
if (ret < 0)
return ret;

// Send onStatus(NetStream.Publish.Start)
return write_status(s, pkt, "NetStream.Publish.Start",
-   filename);
+statusmsg, filename);
} else if (!strcmp(command, "play")) {
ret = write_begin(s);
if (ret < 0)
return ret;
rt->state = STATE_SENDING;
return write_status(s, pkt, "NetStream.Play.Start",
-filename);
+"playing stream", NULL);
} else {
if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
 RTMP_PT_INVOKE, 0,
--
2.31.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] avutil/cpu: #define _GNU_SOURCE before including any standard headers

2022-04-20 Thread Marton Balint




On Thu, 14 Apr 2022, Marton Balint wrote:


Otherwise its effect might not work causing CPU_COUNT to not get defined.

Fixes cpu count detection to actually use sched_getaffinity if available.


Will apply tomorrow.

Regards,
Marton



Signed-off-by: Marton Balint 
---
libavutil/cpu.c | 16 +---
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 833c220192..24b99d2554 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -16,6 +16,15 @@
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

+#include "config.h"
+
+#if HAVE_SCHED_GETAFFINITY
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+#include 
+#endif
+
#include 
#include 
#include 
@@ -23,16 +32,9 @@
#include "attributes.h"
#include "cpu.h"
#include "cpu_internal.h"
-#include "config.h"
#include "opt.h"
#include "common.h"

-#if HAVE_SCHED_GETAFFINITY
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-#include 
-#endif
#if HAVE_GETPROCESSAFFINITYMASK || HAVE_WINRT
#include 
#endif
--
2.31.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] avfilter/vf_subtitles: add an option to choose sub stream by language

2022-04-20 Thread Michael Niedermayer
On Tue, Apr 19, 2022 at 02:58:29AM +0200, James Darnley wrote:
> ---
>  doc/filters.texi   |  5 +
>  libavfilter/vf_subtitles.c | 23 ---
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index a161754233..cfbc807f16 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -21160,6 +21160,11 @@ Override default style or script info parameters of 
> the subtitles. It accepts a
>  string containing ASS style format @code{KEY=VALUE} couples separated by ",".
>  @end table
>  
> +@item language
> +Use first stream with the given language, ISO language code. @code{subtitles}
> +filter only. Requires the language metadata to be read from the file.
> +@end table

that @end table looks a bit like its not matched 

thx

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

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier


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] Bug report

2022-04-20 Thread Leo Izen



On 4/20/22 08:56, Dan Rose wrote:

I tried to submit this on the bug tracker, but it never sent a verification 
email so posting here.

The `-protocol_whitelist ALL` option appears to be broken. I expect it to allow 
any protocol as per documentation 
https://ffmpeg.org/ffmpeg-protocols.html#Protocol-Options

Set a ","-separated list of allowed protocols. "ALL" matches all protocols.
The problem here is that ffurl_connect calls av_match_list instead of 
av_match_name. For some reason, av_match_name treats "ALL" as a proper 
wildcard, but av_match_list does not. av_match_name assumes ',' as the 
delimiter, which should work in this context.


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

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


[FFmpeg-devel] [PATCH] avformat/avio: use av_match_name to match protocol lists

2022-04-20 Thread Leo Izen
This swaps av_match_list to av_match_name inside ffurl_connect,
which allows ALL to be treated as a valid value on the whitelist
or blacklist in accordance with the behavior described in the
documentation.
---
 libavformat/avio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4846bbd8c6..d252bec2f3 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -178,12 +178,12 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
 av_assert0(!(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||
(uc->protocol_blacklist && !strcmp(uc->protocol_blacklist, 
e->value)));
 
-if (uc->protocol_whitelist && av_match_list(uc->prot->name, 
uc->protocol_whitelist, ',') <= 0) {
+if (uc->protocol_whitelist && av_match_name(uc->prot->name, 
uc->protocol_whitelist) <= 0) {
 av_log(uc, AV_LOG_ERROR, "Protocol '%s' not on whitelist '%s'!\n", 
uc->prot->name, uc->protocol_whitelist);
 return AVERROR(EINVAL);
 }
 
-if (uc->protocol_blacklist && av_match_list(uc->prot->name, 
uc->protocol_blacklist, ',') > 0) {
+if (uc->protocol_blacklist && av_match_name(uc->prot->name, 
uc->protocol_blacklist) > 0) {
 av_log(uc, AV_LOG_ERROR, "Protocol '%s' on blacklist '%s'!\n", 
uc->prot->name, uc->protocol_blacklist);
 return AVERROR(EINVAL);
 }
-- 
2.36.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] doc/ffplay: put keystrokes to decrease and increase volume on the same line

2022-04-20 Thread Stefano Sabatini
Fix trac issue http://trac.ffmpeg.org/ticket/7832
---
 doc/ffplay.texi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index 0f090128f2..5dd860b846 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -214,8 +214,6 @@ Pause.
 Toggle mute.
 
 @item 9, 0
-Decrease and increase volume respectively.
-
 @item /, *
 Decrease and increase volume respectively.
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 2/2] doc/ffprobe: clarify that the input file is not optional

2022-04-20 Thread Stefano Sabatini
Fix trac issue http://trac.ffmpeg.org/ticket/9562
---
 doc/ffprobe.texi  | 2 +-
 fftools/ffprobe.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index 59a397a225..c61b8979b1 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -12,7 +12,7 @@
 
 @chapter Synopsis
 
-ffprobe [@var{options}] [@file{input_url}]
+ffprobe [@var{options}] @file{input_url}
 
 @chapter Description
 @c man begin DESCRIPTION
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 05c167eeb5..c51c82ff65 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3417,7 +3417,7 @@ end:
 static void show_usage(void)
 {
 av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
-av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] [INPUT_FILE]\n", 
program_name);
+av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] INPUT_FILE\n", 
program_name);
 av_log(NULL, AV_LOG_INFO, "\n");
 }
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Ignore duration of the first packet

2022-04-20 Thread Guangyu Sun
The decoded Data is not returned from the first frame; it must be used
to 'prime' the decode engine. The duration of the first packet should
be ignored also by the container, to make sure the total duration is
trimmed correctly.

This commit fixes #6367.

dd if=/dev/zero of=./silence.raw count=1 bs=500
oggenc --raw silence.raw --output=silence.ogg
oggdec --raw --output silence.oggdec.raw silence.ogg
ffmpeg -codec:a libvorbis -i silence.ogg -f s16le -codec:a pcm_s16le 
silence.libvorbis.ffmpeg.raw
ffmpeg -i silence.ogg -f s16le -codec:a pcm_s16le silence.native.ffmpeg.raw
ls -l *.raw

Signed-off-by: Guangyu Sun 
---
 libavformat/oggparsevorbis.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 289900f7cf..1f922b3c7e 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -479,6 +479,13 @@ static int vorbis_packet(AVFormatContext *s, int idx)
 flags = 0;
 }
 os->pduration = duration;
+/* Data is not returned from the first frame; it must be used to 
'prime'
+ * the decode engine. The duration of the first packet should be 
ignored
+ * also by the container, to make sure the total duration is trimmed
+ * correctly.
+ */
+if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && os->segp == 1)
+os->pduration = 0;
 }
 
 /* final packet handling
-- 
2.30.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] doc/ffplay: put keystrokes to decrease and increase volume on the same line

2022-04-20 Thread Gyan Doshi

Will apply.

On 2022-04-21 03:13 am, Stefano Sabatini wrote:

Fix trac issue http://trac.ffmpeg.org/ticket/7832
---
  doc/ffplay.texi | 2 --
  1 file changed, 2 deletions(-)

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index 0f090128f2..5dd860b846 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -214,8 +214,6 @@ Pause.
  Toggle mute.
  
  @item 9, 0

-Decrease and increase volume respectively.
-
  @item /, *
  Decrease and increase volume respectively.
  


___
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] doc/ffprobe: clarify that the input file is not optional

2022-04-20 Thread Gyan Doshi

Will apply.

On 2022-04-21 03:13 am, Stefano Sabatini wrote:

Fix trac issue http://trac.ffmpeg.org/ticket/9562
---
  doc/ffprobe.texi  | 2 +-
  fftools/ffprobe.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index 59a397a225..c61b8979b1 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -12,7 +12,7 @@
  
  @chapter Synopsis
  
-ffprobe [@var{options}] [@file{input_url}]

+ffprobe [@var{options}] @file{input_url}
  
  @chapter Description

  @c man begin DESCRIPTION
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 05c167eeb5..c51c82ff65 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3417,7 +3417,7 @@ end:
  static void show_usage(void)
  {
  av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
-av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] [INPUT_FILE]\n", 
program_name);
+av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] INPUT_FILE\n", 
program_name);
  av_log(NULL, AV_LOG_INFO, "\n");
  }
  


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