Re: [FFmpeg-devel] [PATCH v2] ffmpeg: add option fps_mode

2022-06-10 Thread Gyan Doshi

Pushed as 09c53a04c5892baee88872fbce3df17a00472faa

On 2022-06-10 06:39 pm, Gyan Doshi wrote:

fps_mode sets video sync per output stream. Overrides vsync for matching
streams.

vsync is deprecated.
---
  doc/ffmpeg.texi  | 14 --
  fftools/ffmpeg.c |  9 +
  fftools/ffmpeg.h |  3 +++
  fftools/ffmpeg_mux.c |  2 +-
  fftools/ffmpeg_opt.c | 42 +++---
  5 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 0d7e1a479d..51515c2cb8 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1618,12 +1618,14 @@ it may cause packet loss.
  It is useful for when flow speed of output packets is important, such as live 
streaming.
  @item -re (@emph{input})
  Read input at native frame rate. This is equivalent to setting 
@code{-readrate 1}.
-@item -vsync @var{parameter}
-Video sync method.
-
-For compatibility reasons some of the values can be specified as numbers (shown
-in parentheses in the following table). This is deprecated and will stop 
working
-in the future.
+@item -vsync @var{parameter} (@emph{global})
+@itemx -fps_mode[:@var{stream_specifier}] @var{parameter} 
(@emph{output,per-stream})
+Set video sync method / framerate mode. vsync is applied to all output video 
streams
+but can be overridden for a stream by setting fps_mode. vsync is deprecated 
and will be
+removed in the future.
+
+For compatibility reasons some of the values for vsync can be specified as 
numbers (shown
+in parentheses in the following table).
  
  @table @option

  @item passthrough (0)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a5e1bf3993..09caa3e3c4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3017,11 +3017,12 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
  
  if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))

  enc_ctx->time_base = 
av_buffersink_get_time_base(ost->filter->filter);
-if (   av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != 
VSYNC_PASSTHROUGH
-   && (video_sync_method == VSYNC_CFR || video_sync_method == 
VSYNC_VSCFR ||
-   (video_sync_method == VSYNC_AUTO && !(of->format->flags & 
AVFMT_VARIABLE_FPS{
+if (   av_q2d(enc_ctx->time_base) < 0.001 && ost->vsync_method != 
VSYNC_PASSTHROUGH
+   && (ost->vsync_method == VSYNC_CFR || ost->vsync_method == 
VSYNC_VSCFR ||
+   (ost->vsync_method == VSYNC_AUTO && !(of->format->flags & 
AVFMT_VARIABLE_FPS{
  av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not 
efficiently supporting it.\n"
-   "Please consider specifying a lower 
framerate, a different muxer or -vsync 2\n");
+   "Please consider specifying a lower 
framerate, a different muxer or "
+   "setting vsync/fps_mode to vfr\n");
  }
  
  enc_ctx->width  = av_buffersink_get_w(ost->filter->filter);

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7326193caf..69a368b8d1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -176,6 +176,8 @@ typedef struct OptionsContext {
  intnb_qscale;
  SpecifierOpt *forced_key_frames;
  intnb_forced_key_frames;
+SpecifierOpt *fps_mode;
+intnb_fps_mode;
  SpecifierOpt *force_fps;
  intnb_force_fps;
  SpecifierOpt *frame_aspect_ratios;
@@ -489,6 +491,7 @@ typedef struct OutputStream {
  AVRational max_frame_rate;
  enum VideoSyncMethod vsync_method;
  int is_cfr;
+const char *fps_mode;
  int force_fps;
  int top_field_first;
  int rotate_overridden;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 794d580635..a55fd18f8f 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -96,7 +96,7 @@ void of_write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost,
  return;
  }
  
-if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) ||

+if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method 
== VSYNC_DROP) ||
  (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method 
< 0))
  pkt->pts = pkt->dts = AV_NOPTS_VALUE;
  
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c

index 2c1b3bd0dd..398067da96 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -81,6 +81,7 @@ static const char *const opt_name_codec_tags[]= {"tag", 
"atag",
  static const char *const opt_name_sample_fmts[]   = 
{"sample_fmt", NULL};
  static const char *const opt_name_qscale[]= {"q", 
"qscale", NULL};
  static const char *const opt_name_forced_key_frames[] = 
{"forced_key_frames", NULL};
+static const char *const opt_name_fps_mode[]  = {"fps_mode", 
NULL};
  static const char *const 

Re: [FFmpeg-devel] [PATCH] avcodec/qsvenc: make QSV encoder encode VAAPI and D3D11 frames directly

2022-06-10 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xiang, Haihao
> Sent: Thursday, June 9, 2022 8:48 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Wu, Tong1 ; Chen, Wenbin
> 
> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/qsvenc: make QSV encoder
> encode VAAPI and D3D11 frames directly
> 
> On Wed, 2022-06-08 at 11:13 +, Soft Works wrote:
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> Xiang,
> > > Haihao
> > > Sent: Wednesday, June 8, 2022 10:42 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Wu, Tong1 ; Chen, Wenbin
> 
> > > Subject: Re: [FFmpeg-devel] [PATCH] avcodec/qsvenc: make QSV
> encoder encode
> > > VAAPI and D3D11 frames directly
> > >
> > > On Wed, 2022-06-08 at 05:08 +, Soft Works wrote:
> > > > > -Original Message-
> > > > > From: ffmpeg-devel  On
> Behalf Of Tong
> > > > > Wu
> > > > > Sent: Tuesday, June 7, 2022 11:22 AM
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Cc: Tong Wu ; Wenbin Chen
> 
> > > > > Subject: [FFmpeg-devel] [PATCH] avcodec/qsvenc: make QSV
> encoder encode
> > > > > VAAPI
> > > > > and D3D11 frames directly
> >
> > [..]
> >
> > > > > 2.35.1.windows.2
> > > >
> > > > Hi,
> > > >
> > > > thanks for submitting this patch. Though, I'm afraid, but this
> > > >
> > > > - fundamentally contradicts the logic of ffmpeg's handling of
> hw
> > >
> > > acceleration,
> > > >   hw device and hw frames contexts
> > > > - adds code to an encoder, doing things an encoder is not
> supposed to do-
> > >
> > > qsv
> > > > encoders and decoders have their own context => QSV
> > >
> > > nvdec and nvenc have CUDA but nvenc can also support D3D11va, it
> sounds make
> > > sense for me to support D3D11va/vaapi in qsvenc too as
> d3d11va/vaapi are
> > > used
> > > internally in MediaSDK.
> >
> > Can you please post a command line showing nvenc working with input
> > from a D3D11VA decoder and without using any
> hwmap/hwupload/hwdownload
> > filters?
> >
> 
> According to the code below, nvenc may accept d3d11 frames directly,
> 
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/nvenc.c#L46-
> L72
> 
> so the command below should work
> 
> $> ffmpeg -y -hwaccel_output_format d3d11 -hwaccel d3d11va -i
> input.mp4 -c:v
> hevc_nvenc out.mp4

Right, it does work. Thanks for the command, I had tried like that
before, but in a "wrong" branch.

 
Now I took a bit of a deeper look into it and the ability of NVENC to
encode from plain D3D11 frames. There are quite a few differences
between NVENC and QSVENC.


HW Frames Contexts
--

QSVENV

MSDK cannot work with VAAPI frames, D3D9 frames or D3D11 frames directly.
An application is always required to wrap such frames via mfxSurface and
manage a collection of mfxSurface descriptions.
It's an abstraction that allows coding against the MSDK API independent
from the underlying technology. 
The technical representation of this in ffmpeg is the QSVFramesContext.
When there's an input of plain VAAPI or D3D11 frames (hw frames context),
then it is required to derive a new QSVFramesContext from the input hw
frames context (e.g. via hwmap filter) where the procedure of deriving
means to set up a new QSVFramesContext which does the required wrapping
(or "mapping" as ffmpeg calls it).

I think that the way how this logic is reflected in ffmpeg is thought
out very well and provides a high degree of flexibility.


NVENC

The situation is very different here. Nvidia provides platform independency
not by wrapping platform-specific GPU frame types, but instead uses its own
custom type - CUDA memory/frames. This is what decoders are outputting, filters
are using for input/output and encoders take as input.

What I do not know, is whether it would be possible to map D3D11 frames to
CUDA frames and vice versa. In case, that would be the preferable way IMO
to deal with different hw frame types. 
At least this isn't implemented at this time. The only possible frames
derivation/mapping is from and to Vulkan.

Hence I can't say whether the NVENC implementation to take D3D11 frames
directly has been done out of laziness or whether it was the only possible
way. In case when it wouldn't be possible to map D3D11 frames to CUDA 
frames, and only NVENC encoders would be able to process D3D11 frames,
then it would have been the only option of course.

But in any way, it's not the same as with QSVENC, because NVENC can take
D3D11 frames as input directly without wrapping/mapping first.



There are more differences, but I don't want to drive it too far.

What stands at the bottom line is:

- NVENC can take D3D11 frames context directly
- QSVENC can't - it needs to map it to a QSVFramesContext first


Concluding opinion:

An encoder should not include (duplicated) code for creating a derived frames
context. 
The same goal (= getting those command lines working that Haihao has posted)
could be achieved by auto-inserting a hwmap filter in those cases, which 
would probably take a few lines of code 

[FFmpeg-devel] Trivial codec based on QOI and zstd compresses better than all lossless ffmpeg codecs on my data from screen

2022-06-10 Thread Аскар Сафин
Hi. I use Debian Linux. I always capture my screen. I do this using my
own program, which takes rgb24 frames from X server and saves them
lossless in my own format. At fps 4
(but duplicate frames are dropped). My codec is absolutely trivial
(and lossless), it is based on ideas from QOI (
https://github.com/phoboslab/qoi ) and QOV (
https://github.com/wide-video/qov ).
First I apply something like QOV encoding (with interframe coding) and
then compress every frame using zstd with level 8. Surprisingly such
trivial codec performs very well on my data.
It gives better compress ratio than all lossless ffmpeg codecs I tried
(x264, x265, vp9, av1, ffv1, ffvhuff, flv).

I write this not because I want to brag. I write this because it is
possible that you will be interested in my ideas, that you will
incorporate my ideas into your code.

ffv1 spec reads: "FFV1 is designed to support a wide range of lossless
video applications such as... screen recording..." Unfortunately, ffv1
turned out to be bad compared to my codec
on screen recording data, so it is possible ffv1 could benefit from my ideas.

Now let me show you some data. I have a test video named
"test-video-2022-05-16-17.mkv" in lossless x264 fullhd, which was
captured from my screen. Uncompressed PAM size is
208,268,339,335 bytes (208.2 G). Unfortunately I cannot share it,
because it contains a lot of my personal info. Now let me show you how
different codecs perform on this file. All data
was collected with this premises: pix_fmt is rgb24, everything is
lossless, gop is 32, everything is on aws ec2 c3.4xlarge with 16
cores, everything on Debian sid with sid's version of ffmpeg.

Codec: x264
Command line: ffmpeg -loglevel warning -i /tmp/t.mkv -pix_fmt rgb24
-c:v libx264rgb -preset veryslow -qp 0 -threads 16 -g 32 /tmp/out.mkv
Size: 2506211845 (~ 2.5 G)
Time: 1218.22

Codec: ffv1
Command line: ffmpeg -loglevel warning -i /tmp/t.mkv -c:v ffv1
-pix_fmt rgb24 -level 3 -threads 16 -g 32 -context 1 -slices 4 -coder
-2 /tmp/o.mkv
Size: 9431473324 (~9.4 G)
Time: 1125.15

Codec: my codec (single threaded!)
Command line: ffmpeg -loglevel warning -i /tmp/t.mkv -c:v pam -pix_fmt
rgb24 -f image2pipe pipe: < /dev/null | /tmp/nrdy encode 8 32
Size: 1860479127 (~1.8 G)
Time: 470.88

So, as you can see my codec beats ffv1 and x264 both by compress ratio
and speed. Moreover, my single-threaded codec beats other
multi-threads codecs by time. Are you interested?
If yes, I can share my code. Of course, under some permissive license.
Again: there is no any magic here, just something like QOV + zstd.
Also, I can specially extract some sample
from my videos, which doesn't contain personal info, and perform tests
on this sample and publish sample
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 3/3] avcodec/fmvc: Require key frames to fill a non trivial part of the buffer

2022-06-10 Thread Michael Niedermayer
Keyframes filling only part of the buffer should theoretically be invalid
as they are not really keyframes.

Fixes: Timeout
Fixes: 
47879/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FMVC_fuzzer-6258764937822208

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/fmvc.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index de2bf828f4..36990956e0 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -284,7 +284,7 @@ static int decode_type2(GetByteContext *gb, PutByteContext 
*pb)
 }
 }
 
-return 0;
+return bytestream2_get_bytes_left_p(pb);
 }
 
 static int decode_type1(GetByteContext *gb, PutByteContext *pb)
@@ -391,7 +391,7 @@ static int decode_type1(GetByteContext *gb, PutByteContext 
*pb)
 } while (len && bytestream2_get_bytes_left() > 0);
 }
 
-return 0;
+return bytestream2_get_bytes_left_p(pb);
 }
 
 static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
@@ -414,6 +414,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 if (key_frame) {
 const uint8_t *src;
 unsigned type, size;
+int left;
 uint8_t *dst;
 
 type = bytestream2_get_le16(gb);
@@ -423,14 +424,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 
 bytestream2_init_writer(pb, s->buffer, s->buffer_size);
 if (type == 1) {
-decode_type1(gb, pb);
+left = decode_type1(gb, pb);
 } else if (type == 2){
-decode_type2(gb, pb);
+left = decode_type2(gb, pb);
 } else {
 avpriv_report_missing_feature(avctx, "Compression type %d", type);
 return AVERROR_PATCHWELCOME;
 }
 
+if (left > s->buffer_size*4/5)
+return AVERROR_INVALIDDATA;
+
 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
 return ret;
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/fmvc: buffer size is stride based not 4*width

2022-06-10 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/fmvc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 912ad8fc82..de2bf828f4 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -614,7 +614,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 }
 
 s->bpp  = avctx->bits_per_coded_sample >> 3;
-s->buffer_size  = avctx->width * avctx->height * 4;
+s->buffer_size  = s->stride * avctx->height * 4;
 s->pbuffer_size = avctx->width * avctx->height * 4;
 s->buffer   = av_mallocz(s->buffer_size);
 s->pbuffer  = av_mallocz(s->pbuffer_size);
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage

2022-06-10 Thread Michael Niedermayer
This way more things are checked before allocation

Signed-off-by: Michael Niedermayer 
---
 libavcodec/fmvc.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 4abf6d7048..912ad8fc82 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -401,20 +401,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 GetByteContext *gb = >gb;
 PutByteContext *pb = >pb;
 int ret, y, x;
+int key_frame;
 
 if (avpkt->size < 8)
 return AVERROR_INVALIDDATA;
 
-if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
-return ret;
-
 bytestream2_init(gb, avpkt->data, avpkt->size);
 bytestream2_skip(gb, 2);
 
-frame->key_frame = !!bytestream2_get_le16(gb);
-frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : 
AV_PICTURE_TYPE_P;
+key_frame = !!bytestream2_get_le16(gb);
 
-if (frame->key_frame) {
+if (key_frame) {
 const uint8_t *src;
 unsigned type, size;
 uint8_t *dst;
@@ -434,6 +431,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 return AVERROR_PATCHWELCOME;
 }
 
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+return ret;
+
+frame->key_frame = 1;
+frame->pict_type = AV_PICTURE_TYPE_I;
+
 src = s->buffer;
 dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
 for (y = 0; y < avctx->height; y++) {
@@ -514,6 +517,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 dst = [block_h * s->stride];
 }
 
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+return ret;
+
+frame->key_frame = 0;
+frame->pict_type = AV_PICTURE_TYPE_P;
+
 ssrc = s->buffer;
 ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
 for (y = 0; y < avctx->height; y++) {
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH] avcodec: Fix time reporting for DFPWM streams

2022-06-10 Thread Jack Bruienne


This adds the exact bits per sample for DFPWM to 
av_get_exact_bits_per_sample.
Previously, the DTS and PTS were set to 0 because the codec never 
reported them, but adding this allows libavformat to automatically

set DTS and PTS from the byte position of the stream.

Signed-off-by: Jack Bruienne 
---
 libavcodec/utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index eb7e505a..940f25fe 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -495,6 +495,8 @@ const char *avcodec_profile_name(enum AVCodecID codec_id, int profile)
 int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
 {
 switch (codec_id) {
+case AV_CODEC_ID_DFPWM:
+return 1;
 case AV_CODEC_ID_8SVX_EXP:
 case AV_CODEC_ID_8SVX_FIB:
 case AV_CODEC_ID_ADPCM_ARGO:

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

2022-06-10 Thread Michael Niedermayer
On Thu, Jun 09, 2022 at 10:04:05PM +0300, Nil Admirari wrote:
> ---
>  compat/w32dlfcn.h | 80 +--
>  1 file changed, 64 insertions(+), 16 deletions(-)

breaks build on mingw64
CC  libavcodec/mfenc.o
In file included from /usr/share/mingw-w64/include/dshow.h:40:0,
 from src/libavcodec/mf_utils.h:32,
 from src/libavcodec/mfenc.c:26:
/usr/share/mingw-w64/include/strmif.h:16503:2: warning: #warning COM interfaces 
layout in this header has not been verified. [-Wcpp]
 #warning COM interfaces layout in this header has not been verified.
  ^~~
/usr/share/mingw-w64/include/strmif.h:16504:2: warning: #warning COM interfaces 
with incorrect layout may not work at all. [-Wcpp]
 #warning COM interfaces with incorrect layout may not work at all.
  ^~~
/usr/share/mingw-w64/include/strmif.h:16505:1: note: #pragma message: Interface 
IAMAsyncReaderTimestampScaling has unverified layout.
 __MINGW_BROKEN_INTERFACE(INTERFACE)
 ^~~~
/usr/share/mingw-w64/include/strmif.h:16533:2: warning: #warning COM interfaces 
layout in this header has not been verified. [-Wcpp]
 #warning COM interfaces layout in this header has not been verified.
  ^~~
/usr/share/mingw-w64/include/strmif.h:16534:2: warning: #warning COM interfaces 
with incorrect layout may not work at all. [-Wcpp]
 #warning COM interfaces with incorrect layout may not work at all.
  ^~~
/usr/share/mingw-w64/include/strmif.h:16535:1: note: #pragma message: Interface 
IAMPluginControl has unverified layout.
 __MINGW_BROKEN_INTERFACE(INTERFACE)
 ^~~~
In file included from /usr/share/mingw-w64/include/dshow.h:33:0,
 from src/libavcodec/mf_utils.h:32,
 from src/libavcodec/mfenc.c:26:
src/libavutil/wchar_filename.h: In function ‘add_extended_prefix’:
src/libavutil/wchar_filename.h:211:9: error: 
‘wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW’ undeclared (first use in 
this function)
 wcscpy(temp_w, unc_prefix);
 ^
src/libavutil/wchar_filename.h:211:9: note: each undeclared identifier is 
reported only once for each function it appears in
In file included from src/compat/w32dlfcn.h:25:0,
 from src/libavcodec/mfenc.c:32:
src/libavutil/wchar_filename.h:211:22: warning: left-hand operand of comma 
expression has no effect [-Wunused-value]
 wcscpy(temp_w, unc_prefix);
  ^
src/libavutil/wchar_filename.h:211:15: warning: statement with no effect 
[-Wunused-value]
 wcscpy(temp_w, unc_prefix);
   ^
In file included from /usr/share/mingw-w64/include/dshow.h:33:0,
 from src/libavcodec/mf_utils.h:32,
 from src/libavcodec/mfenc.c:26:
src/libavutil/wchar_filename.h:212:9: error: 
‘wcscat_instead_use_StringCbCatW_or_StringCchCatW’ undeclared (first use in 
this function); did you mean 
‘wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW’?
 wcscat(temp_w, path_w + 2);
 ^
In file included from src/compat/w32dlfcn.h:25:0,
 from src/libavcodec/mfenc.c:32:
src/libavutil/wchar_filename.h:212:22: warning: left-hand operand of comma 
expression has no effect [-Wunused-value]
 wcscat(temp_w, path_w + 2);
  ^
src/libavutil/wchar_filename.h:212:22: warning: statement with no effect 
[-Wunused-value]
 wcscat(temp_w, path_w + 2);
   ~~~^
src/libavutil/wchar_filename.h:220:22: warning: left-hand operand of comma 
expression has no effect [-Wunused-value]
 wcscpy(temp_w, extended_path_prefix);
  ^
src/libavutil/wchar_filename.h:220:15: warning: statement with no effect 
[-Wunused-value]
 wcscpy(temp_w, extended_path_prefix);
   ^
src/libavutil/wchar_filename.h:221:22: warning: left-hand operand of comma 
expression has no effect [-Wunused-value]
 wcscat(temp_w, path_w);
  ^
src/libavutil/wchar_filename.h:221:15: warning: statement with no effect 
[-Wunused-value]
 wcscat(temp_w, path_w);
   ^
src/ffbuild/common.mak:81: recipe for target 'libavcodec/mfenc.o' failed
make: *** [libavcodec/mfenc.o] Error 1

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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] avformat/mov: Only read the primary item for AVIF

2022-06-10 Thread Vignesh Venkatasubramanian
On Fri, Jun 10, 2022 at 10:33 AM Andreas Rheinhardt
 wrote:
>
> Vignesh Venkatasubramanian:
> > Update the still AVIF parser to only read the primary item. With this
> > patch, AVIF still images with exif/icc/alpha channel will no longer
> > fail to parse.
> >
> > For example, this patch enables parsing of files in:
> > https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft
> >
> > Adding two fate tests:
> > 1) demuxing of still image with 1 item - this test will pass regardlesss
> >of this patch.
> > 2) demuxing of still image with 2 items - this test will fail without
> >this patch and will pass with patch applied.
> >
> > Partially fixes trac ticket #7621
> >
> > Signed-off-by: Vignesh Venkatasubramanian 
> > ---
> >  libavformat/isom.h|  1 +
> >  libavformat/mov.c | 41 ++-
> >  tests/fate/mov.mak|  9 
> >  .../fate/mov-avif-demux-still-image-1-item| 11 +
> >  .../mov-avif-demux-still-image-multiple-items | 11 +
> >  5 files changed, 53 insertions(+), 20 deletions(-)
> >  create mode 100644 tests/ref/fate/mov-avif-demux-still-image-1-item
> >  create mode 100644 tests/ref/fate/mov-avif-demux-still-image-multiple-items
> >
> > diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
> > index 2fae054423..842c7f9aa1 100644
> > --- a/tests/fate/mov.mak
> > +++ b/tests/fate/mov.mak
> > @@ -17,6 +17,8 @@ FATE_MOV = fate-mov-3elist \
> > fate-mov-bbi-elst-starts-b \
> > fate-mov-neg-firstpts-discard-frames \
> > fate-mov-stream-shorter-than-movie \
> > +   fate-mov-avif-demux-still-image-1-item \
> > +   fate-mov-avif-demux-still-image-multiple-items \
> >
> >  FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
> > fate-mov-neg-firstpts-discard-vorbis \
> > @@ -138,6 +140,13 @@ FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, TTML SUBRIP, 
> > MP4 MOV, SRT_DEMUXER TTML
> >  fate-mov-mp4-ttml-stpp: CMD = transcode srt 
> > $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt mp4 "-map 0:s -c:s ttml 
> > -time_base:s 1:1000" "-map 0 -c copy" "-of json -show_entries 
> > packet:stream=index,codec_type,codec_tag_string,codec_tag,codec_name,time_base,start_time,duration_ts,duration,nb_frames,nb_read_packets:stream_tags"
> >  fate-mov-mp4-ttml-dfxp: CMD = transcode srt 
> > $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt mp4 "-map 0:s -c:s ttml 
> > -time_base:s 1:1000 -tag:s dfxp -strict unofficial" "-map 0 -c copy" "-of 
> > json -show_entries 
> > packet:stream=index,codec_type,codec_tag_string,codec_tag,codec_name,time_base,start_time,duration_ts,duration,nb_frames,nb_read_packets:stream_tags"
> >
> > +# avif demuxing - still image with 1 item.
> > +fate-mov-avif-demux-still-image-1-item: CMD = framemd5 -i 
> > $(TARGET_SAMPLES)/avif/still_image.avif -c:v copy
> > +
> > +# avif demuxing - still image with multiple items. only the primary item 
> > will be
> > +# parsed.
> > +fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i 
> > $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy
>
> Can we create such files with our muxer? In this case one could use a
> remux test, i.e. a test that creates the file and the demuxes the just
> created file.
>

Unfortunately, the file with exif cannot be created using the ffmpeg's
muxer as of now. So we will have to get that externally (i made that
with MP4Box).

The other still image file however can be creating using our muxer. I
will add another test that does remuxing for the 1-item case in a
separate patch if that's alright (since it's not directly related to
what this patch is doing). I was also going to add some fate tests for
animated AVIF muxing/parsing, so i will include that in the other
patch as well.

> > +
> >  # Resulting remux should have:
> >  # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED
> >  # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | DESCRIPTIONS
> > diff --git a/tests/ref/fate/mov-avif-demux-still-image-1-item 
> > b/tests/ref/fate/mov-avif-demux-still-image-1-item
> > new file mode 100644
> > index 00..93773afd4e
> > --- /dev/null
> > +++ b/tests/ref/fate/mov-avif-demux-still-image-1-item
> > @@ -0,0 +1,11 @@
> > +#format: frame checksums
> > +#version: 2
> > +#hash: MD5
> > +#extradata 0,  13, 
> > b52ae298d37128862ef1918cf916239c
> > +#tb 0: 1/1
> > +#media_type 0: video
> > +#codec_id 0: av1
> > +#dimensions 0: 352x288
> > +#sar 0: 1/1
> > +#stream#, dts,pts, duration, size, hash
> > +0,  0,  0,1,36265, 
> > 235b0c6e389c4084845981e08d60db04
> > diff --git a/tests/ref/fate/mov-avif-demux-still-image-multiple-items 
> > b/tests/ref/fate/mov-avif-demux-still-image-multiple-items
> > new file mode 100644
> > index 00..93773afd4e
> > --- /dev/null
> > +++ b/tests/ref/fate/mov-avif-demux-still-image-multiple-items
> > @@ -0,0 

Re: [FFmpeg-devel] [PATCH] avformat/mov: Only read the primary item for AVIF

2022-06-10 Thread Vignesh Venkatasubramanian
On Thu, Jun 9, 2022 at 12:50 AM Gyan Doshi  wrote:
>
>
>
> On 2022-06-08 10:51 pm, Vignesh Venkatasubramanian wrote:
> > On Thu, Jun 2, 2022 at 1:35 PM James Zern  wrote:
> >> On Wed, Jun 1, 2022 at 1:38 PM Vignesh Venkatasubramanian
> >>  wrote:
> >>> On Wed, Jun 1, 2022 at 10:30 AM James Zern  wrote:
>  On Sun, Apr 24, 2022 at 11:35 AM Vignesh Venkatasubramanian
>   wrote:
> > Update the still AVIF parser to only read the primary item. With this
> > patch, AVIF still images with exif/icc/alpha channel will no longer
> > fail to parse.
> >
> > For example, this patch enables parsing of files in:
> > https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft
> >
>  Can some of the failing files or similar ones be added to fate?
> >>> There are no fate tests for AVIF parsing as of now. I was thinking
> >>> about adding some for the muxing. But i am not sure what can be done
> >>> here for the parsing.
> >>>
> >> Thanks. Are there any for general mov/mp4 parsing that could be
> >> extended? This looks good otherwise.
> >  From what i see, most of the mov tests only seem to be for muxing. I'm
> > not entirely certain about how to add a test for AVIF parsing. If
> > anybody has an idea, i'd be open to adding it.
>
> Basic test would use the framemd5 muxer to compare demuxed packets with
> a reference.
> See fate-ffmpeg-streamloop
>

Thank you i have added a couple of fate tests.

I am not sure how to add the AVIF files to the fate test server. I
have them on Google Drive here:

https://drive.google.com/file/d/1diZoM0Ew7Co3Yh5w5y1J-3IiBYVmUv9J/view?usp=sharing
https://drive.google.com/file/d/1DdrD1mW36evt40a4RkeLYpx-oojmbc3z/view?usp=sharing

These links should be publicly available without any sign in required.
Please let me know if there is another preferred way of sharing test
files and i can share it that way.

Also for the record, these files were created by remuxing an existing
file in the fate suite.

still_image.avif - contains the first frame from
av1-test-vectors/av1-1-b8-02-allintra.ivf
still_image_exif.avif - contains the first frame from
av1-test-vectors/av1-1-b8-02-allintra.ivf with dummy exif data.

> Regards,
> Gyan
> ___
> 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".



-- 
Vignesh
___
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/mov: Only read the primary item for AVIF

2022-06-10 Thread Andreas Rheinhardt
Vignesh Venkatasubramanian:
> Update the still AVIF parser to only read the primary item. With this
> patch, AVIF still images with exif/icc/alpha channel will no longer
> fail to parse.
> 
> For example, this patch enables parsing of files in:
> https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft
> 
> Adding two fate tests:
> 1) demuxing of still image with 1 item - this test will pass regardlesss
>of this patch.
> 2) demuxing of still image with 2 items - this test will fail without
>this patch and will pass with patch applied.
> 
> Partially fixes trac ticket #7621
> 
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  libavformat/isom.h|  1 +
>  libavformat/mov.c | 41 ++-
>  tests/fate/mov.mak|  9 
>  .../fate/mov-avif-demux-still-image-1-item| 11 +
>  .../mov-avif-demux-still-image-multiple-items | 11 +
>  5 files changed, 53 insertions(+), 20 deletions(-)
>  create mode 100644 tests/ref/fate/mov-avif-demux-still-image-1-item
>  create mode 100644 tests/ref/fate/mov-avif-demux-still-image-multiple-items
> 
> diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
> index 2fae054423..842c7f9aa1 100644
> --- a/tests/fate/mov.mak
> +++ b/tests/fate/mov.mak
> @@ -17,6 +17,8 @@ FATE_MOV = fate-mov-3elist \
> fate-mov-bbi-elst-starts-b \
> fate-mov-neg-firstpts-discard-frames \
> fate-mov-stream-shorter-than-movie \
> +   fate-mov-avif-demux-still-image-1-item \
> +   fate-mov-avif-demux-still-image-multiple-items \
>  
>  FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
> fate-mov-neg-firstpts-discard-vorbis \
> @@ -138,6 +140,13 @@ FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, TTML SUBRIP, 
> MP4 MOV, SRT_DEMUXER TTML
>  fate-mov-mp4-ttml-stpp: CMD = transcode srt 
> $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt mp4 "-map 0:s -c:s ttml 
> -time_base:s 1:1000" "-map 0 -c copy" "-of json -show_entries 
> packet:stream=index,codec_type,codec_tag_string,codec_tag,codec_name,time_base,start_time,duration_ts,duration,nb_frames,nb_read_packets:stream_tags"
>  fate-mov-mp4-ttml-dfxp: CMD = transcode srt 
> $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt mp4 "-map 0:s -c:s ttml 
> -time_base:s 1:1000 -tag:s dfxp -strict unofficial" "-map 0 -c copy" "-of 
> json -show_entries 
> packet:stream=index,codec_type,codec_tag_string,codec_tag,codec_name,time_base,start_time,duration_ts,duration,nb_frames,nb_read_packets:stream_tags"
>  
> +# avif demuxing - still image with 1 item.
> +fate-mov-avif-demux-still-image-1-item: CMD = framemd5 -i 
> $(TARGET_SAMPLES)/avif/still_image.avif -c:v copy
> +
> +# avif demuxing - still image with multiple items. only the primary item 
> will be
> +# parsed.
> +fate-mov-avif-demux-still-image-multiple-items: CMD = framemd5 -i 
> $(TARGET_SAMPLES)/avif/still_image_exif.avif -c:v copy

Can we create such files with our muxer? In this case one could use a
remux test, i.e. a test that creates the file and the demuxes the just
created file.

> +
>  # Resulting remux should have:
>  # 1. first audio stream with AV_DISPOSITION_HEARING_IMPAIRED
>  # 2. second audio stream with AV_DISPOSITION_VISUAL_IMPAIRED | DESCRIPTIONS
> diff --git a/tests/ref/fate/mov-avif-demux-still-image-1-item 
> b/tests/ref/fate/mov-avif-demux-still-image-1-item
> new file mode 100644
> index 00..93773afd4e
> --- /dev/null
> +++ b/tests/ref/fate/mov-avif-demux-still-image-1-item
> @@ -0,0 +1,11 @@
> +#format: frame checksums
> +#version: 2
> +#hash: MD5
> +#extradata 0,  13, 
> b52ae298d37128862ef1918cf916239c
> +#tb 0: 1/1
> +#media_type 0: video
> +#codec_id 0: av1
> +#dimensions 0: 352x288
> +#sar 0: 1/1
> +#stream#, dts,pts, duration, size, hash
> +0,  0,  0,1,36265, 
> 235b0c6e389c4084845981e08d60db04
> diff --git a/tests/ref/fate/mov-avif-demux-still-image-multiple-items 
> b/tests/ref/fate/mov-avif-demux-still-image-multiple-items
> new file mode 100644
> index 00..93773afd4e
> --- /dev/null
> +++ b/tests/ref/fate/mov-avif-demux-still-image-multiple-items
> @@ -0,0 +1,11 @@
> +#format: frame checksums
> +#version: 2
> +#hash: MD5
> +#extradata 0,  13, 
> b52ae298d37128862ef1918cf916239c
> +#tb 0: 1/1
> +#media_type 0: video
> +#codec_id 0: av1
> +#dimensions 0: 352x288
> +#sar 0: 1/1
> +#stream#, dts,pts, duration, size, hash
> +0,  0,  0,1,36265, 
> 235b0c6e389c4084845981e08d60db04

___
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/mov: Only read the primary item for AVIF

2022-06-10 Thread Vignesh Venkatasubramanian
Update the still AVIF parser to only read the primary item. With this
patch, AVIF still images with exif/icc/alpha channel will no longer
fail to parse.

For example, this patch enables parsing of files in:
https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft

Adding two fate tests:
1) demuxing of still image with 1 item - this test will pass regardlesss
   of this patch.
2) demuxing of still image with 2 items - this test will fail without
   this patch and will pass with patch applied.

Partially fixes trac ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 libavformat/isom.h|  1 +
 libavformat/mov.c | 41 ++-
 tests/fate/mov.mak|  9 
 .../fate/mov-avif-demux-still-image-1-item| 11 +
 .../mov-avif-demux-still-image-multiple-items | 11 +
 5 files changed, 53 insertions(+), 20 deletions(-)
 create mode 100644 tests/ref/fate/mov-avif-demux-still-image-1-item
 create mode 100644 tests/ref/fate/mov-avif-demux-still-image-multiple-items

diff --git a/libavformat/isom.h b/libavformat/isom.h
index cf36f04d5b..f05c2d9c28 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -317,6 +317,7 @@ typedef struct MOVContext {
 uint32_t mfra_size;
 uint32_t max_stts_delta;
 int is_still_picture_avif;
+int primary_item_id;
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d7be593a86..9310a393fe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7445,6 +7445,13 @@ static int rb_size(AVIOContext *pb, uint64_t* value, int 
size)
 return size;
 }
 
+static int mov_read_pitm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+avio_rb32(pb);  // version & flags.
+c->primary_item_id = avio_rb16(pb);
+return atom.size;
+}
+
 static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 int version, offset_size, length_size, base_offset_size, index_size;
@@ -7501,34 +7508,25 @@ static int mov_read_iloc(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return AVERROR_PATCHWELCOME;
 }
 item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
-if (item_count > 1) {
-// For still AVIF images, we only support one item. Second item will
-// generally be found for AVIF images with alpha channel. We don't
-// support them as of now.
-av_log(c->fc, AV_LOG_ERROR, "iloc: item_count > 1 not supported.\n");
-return AVERROR_PATCHWELCOME;
-}
 
 // Populate the necessary fields used by mov_build_index.
-sc->stsc_count = item_count;
-sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
+sc->stsc_count = 1;
+sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data));
 if (!sc->stsc_data)
 return AVERROR(ENOMEM);
 sc->stsc_data[0].first = 1;
 sc->stsc_data[0].count = 1;
 sc->stsc_data[0].id = 1;
-sc->chunk_count = item_count;
-sc->chunk_offsets =
-av_malloc_array(item_count, sizeof(*sc->chunk_offsets));
+sc->chunk_count = 1;
+sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets));
 if (!sc->chunk_offsets)
 return AVERROR(ENOMEM);
-sc->sample_count = item_count;
-sc->sample_sizes =
-av_malloc_array(item_count, sizeof(*sc->sample_sizes));
+sc->sample_count = 1;
+sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));
 if (!sc->sample_sizes)
 return AVERROR(ENOMEM);
-sc->stts_count = item_count;
-sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data));
+sc->stts_count = 1;
+sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));
 if (!sc->stts_data)
 return AVERROR(ENOMEM);
 sc->stts_data[0].count = 1;
@@ -7536,7 +7534,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 sc->stts_data[0].duration = 0;
 
 for (int i = 0; i < item_count; i++) {
-(version < 2) ? avio_rb16(pb) : avio_rb32(pb);  // item_id;
+int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
 if (version > 0)
 avio_rb16(pb);  // construction_method.
 avio_rb16(pb);  // data_reference_index.
@@ -7552,8 +7550,10 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (rb_size(pb, _offset, offset_size) < 0 ||
 rb_size(pb, _length, length_size) < 0)
 return AVERROR_INVALIDDATA;
-sc->sample_sizes[0] = extent_length;
-sc->chunk_offsets[0] = base_offset + extent_offset;
+if (item_id == c->primary_item_id) {
+sc->sample_sizes[0] = extent_length;
+sc->chunk_offsets[0] = base_offset + extent_offset;
+}
 }
 }
 
@@ -7670,6 +7670,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('S','A','3','D'), 

Re: [FFmpeg-devel] [PATCH 05/41] avcodec/videodsp: Make ff_emulated_edge_mc_16 static

2022-06-10 Thread Andreas Rheinhardt
Ronald S. Bultje:
> Hi,
> 
> On Thu, Jun 9, 2022 at 7:56 PM Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
> 
>> Only ff_emulated_edge_mc_8() is used outside of lavc/videodsp.c.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/videodsp.c  | 4 
>>  libavcodec/videodsp.h  | 1 -
>>  libavcodec/videodsp_template.c | 1 +
>>  3 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
>> index 2198d46c15..02af046b81 100644
>> --- a/libavcodec/videodsp.c
>> +++ b/libavcodec/videodsp.c
>> @@ -25,11 +25,15 @@
>>  #include "videodsp.h"
>>
>>  #define BIT_DEPTH 8
>> +#define STATIC
>>  #include "videodsp_template.c"
>> +#undef STATIC
>>  #undef BIT_DEPTH
>>
>>  #define BIT_DEPTH 16
>> +#define STATIC static
>>  #include "videodsp_template.c"
>> +#undef STATIC
>>  #undef BIT_DEPTH
>>
>>  static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
>>
> [..]
> 
>> diff --git a/libavcodec/videodsp_template.c
>> b/libavcodec/videodsp_template.c
>> index 55123a5844..8bc3290248 100644
>> --- a/libavcodec/videodsp_template.c
>> +++ b/libavcodec/videodsp_template.c
>> @@ -20,6 +20,7 @@
>>   */
>>
>>  #include "bit_depth_template.c"
>> +STATIC
>>  void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
>> ptrdiff_t buf_linesize,
>> ptrdiff_t src_linesize,
>> --
>> 2.34.1
>>
> 
> This splits the "staticness" over two places (i.e. to understand what
> STATIC means and/or why it exists, you have to look at two places), and
> also doesn't explain why we need "variable staticness" (i.e. one being
> static, but not the other one).
> 
> Maybe you could use the following:
> 
> #if BIT_DEPTH != 8 // we make a call to the 8-bit version in
> $fill_me_in_here$
> static
> #endif
> void FUNC(ff_..
> 
> That way the meaning of STATIC is not obfuscated (I know, STATIC should be
> obvious, but it's still an indirection) and the reasoning is included also.
> 
> Ronald
> 

I'll change it if you prefer it that way.

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

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


Re: [FFmpeg-devel] [PATCH 05/41] avcodec/videodsp: Make ff_emulated_edge_mc_16 static

2022-06-10 Thread Ronald S. Bultje
Hi,

On Thu, Jun 9, 2022 at 7:56 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Only ff_emulated_edge_mc_8() is used outside of lavc/videodsp.c.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/videodsp.c  | 4 
>  libavcodec/videodsp.h  | 1 -
>  libavcodec/videodsp_template.c | 1 +
>  3 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
> index 2198d46c15..02af046b81 100644
> --- a/libavcodec/videodsp.c
> +++ b/libavcodec/videodsp.c
> @@ -25,11 +25,15 @@
>  #include "videodsp.h"
>
>  #define BIT_DEPTH 8
> +#define STATIC
>  #include "videodsp_template.c"
> +#undef STATIC
>  #undef BIT_DEPTH
>
>  #define BIT_DEPTH 16
> +#define STATIC static
>  #include "videodsp_template.c"
> +#undef STATIC
>  #undef BIT_DEPTH
>
>  static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
>
[..]

> diff --git a/libavcodec/videodsp_template.c
> b/libavcodec/videodsp_template.c
> index 55123a5844..8bc3290248 100644
> --- a/libavcodec/videodsp_template.c
> +++ b/libavcodec/videodsp_template.c
> @@ -20,6 +20,7 @@
>   */
>
>  #include "bit_depth_template.c"
> +STATIC
>  void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
> ptrdiff_t buf_linesize,
> ptrdiff_t src_linesize,
> --
> 2.34.1
>

This splits the "staticness" over two places (i.e. to understand what
STATIC means and/or why it exists, you have to look at two places), and
also doesn't explain why we need "variable staticness" (i.e. one being
static, but not the other one).

Maybe you could use the following:

#if BIT_DEPTH != 8 // we make a call to the 8-bit version in
$fill_me_in_here$
static
#endif
void FUNC(ff_..

That way the meaning of STATIC is not obfuscated (I know, STATIC should be
obvious, but it's still an indirection) and the reasoning is included also.

Ronald
___
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] swscale: add NV16 input/output

2022-06-10 Thread Matthieu Bouron
On Thu, Jun 2, 2022 at 9:13 PM Michael Niedermayer 
wrote:

> On Wed, Jun 01, 2022 at 10:33:37PM +0200, Matthieu Bouron wrote:
> > ---
> >  libswscale/input.c   | 1 +
> >  libswscale/utils.c   | 1 +
> >  libswscale/version.h | 2 +-
> >  tests/ref/fate/filter-pixdesc-nv16   | 1 +
> >  tests/ref/fate/filter-pixfmts-copy   | 1 +
> >  tests/ref/fate/filter-pixfmts-crop   | 1 +
> >  tests/ref/fate/filter-pixfmts-field  | 1 +
> >  tests/ref/fate/filter-pixfmts-fieldorder | 1 +
> >  tests/ref/fate/filter-pixfmts-hflip  | 1 +
> >  tests/ref/fate/filter-pixfmts-il | 1 +
> >  tests/ref/fate/filter-pixfmts-null   | 1 +
> >  tests/ref/fate/filter-pixfmts-pad| 1 +
> >  tests/ref/fate/filter-pixfmts-scale  | 1 +
> >  tests/ref/fate/filter-pixfmts-vflip  | 1 +
> >  14 files changed, 14 insertions(+), 1 deletion(-)
> >  create mode 100644 tests/ref/fate/filter-pixdesc-nv16
>
>
Sorry for the late reply


> has this been tested ? (various scaled and non scaled) variants ?
>

I only tested the non scaled variant using the command line doing multiple
round trips to/from nv16.
Is there a particular test procedure to validate every variants ?

[...]
___
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] avcodec/avs2: add AVS2 related definitions

2022-06-10 Thread Zhao Zhili
Replace magic numbers by enum values.

Signed-off-by: Zhao Zhili 
---
 libavcodec/avs2.h| 41 
 libavcodec/avs2_parser.c |  6 +-
 2 files changed, 42 insertions(+), 5 deletions(-)
 create mode 100644 libavcodec/avs2.h

diff --git a/libavcodec/avs2.h b/libavcodec/avs2.h
new file mode 100644
index 00..7b66f51998
--- /dev/null
+++ b/libavcodec/avs2.h
@@ -0,0 +1,41 @@
+/*
+ * AVS2 related definitions
+ *
+ * Copyright (C) 2022 Zhao Zhili, 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AVS2_H
+#define AVCODEC_AVS2_H
+
+#define AVS2_SLICE_MAX_START_CODE0x01AF
+
+enum {
+AVS2_SEQ_START_CODE = 0xB0,
+AVS2_SEQ_END_CODE   = 0xB1,
+AVS2_USER_DATA_START_CODE   = 0xB2,
+AVS2_INTRA_PIC_START_CODE   = 0xB3,
+// reserved = 0xB4,
+AVS2_EXTENSION_START_CODE   = 0xB5,
+AVS2_INTER_PIC_START_CODE   = 0xB6,
+};
+
+#define AVS2_ISPIC(x)  ((x) == AVS2_INTRA_PIC_START_CODE || (x) == 
AVS2_INTER_PIC_START_CODE)
+#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || (x) == AVS2_SEQ_END_CODE 
|| (x) == AVS2_USER_DATA_START_CODE || AVS2_ISPIC(x))
+
+#endif
diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index b7d5d7774e..3755dbd78c 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -19,13 +19,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "avs2.h"
 #include "parser.h"
 
-#define AVS2_SLICE_MAX_START_CODE 0x01AF
-
-#define AVS2_ISPIC(x)  ((x) == 0xB3 || (x) == 0xB6)
-#define AVS2_ISUNIT(x) ((x) == 0xB0 || (x) == 0xB1 || (x) == 0xB2 || 
AVS2_ISPIC(x))
-
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
 {
 int pic_found  = pc->frame_start_found;
-- 
2.35.3

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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/avs2_parser: split data into frames

2022-06-10 Thread Zhao Zhili
From: Zhao Zhili 

Before the patch, the parser split data into units, not frames.

Signed-off-by: Zhao Zhili 
---
 libavcodec/avs2.h| 2 +-
 libavcodec/avs2_parser.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avs2.h b/libavcodec/avs2.h
index 7b66f51998..f342ba52a0 100644
--- a/libavcodec/avs2.h
+++ b/libavcodec/avs2.h
@@ -36,6 +36,6 @@ enum {
 };
 
 #define AVS2_ISPIC(x)  ((x) == AVS2_INTRA_PIC_START_CODE || (x) == 
AVS2_INTER_PIC_START_CODE)
-#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || (x) == AVS2_SEQ_END_CODE 
|| (x) == AVS2_USER_DATA_START_CODE || AVS2_ISPIC(x))
+#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || AVS2_ISPIC(x))
 
 #endif
diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 3755dbd78c..71cf442903 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -31,7 +31,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 if (!pic_found) {
 for (; cur < buf_size; ++cur) {
 state = (state << 8) | buf[cur];
-if (AVS2_ISUNIT(buf[cur])){
+if ((state & 0xFF00) == 0x100 && AVS2_ISPIC(buf[cur])) {
 cur++;
 pic_found = 1;
 break;
@@ -44,7 +44,7 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 for (; cur < buf_size; cur++) {
 state = (state << 8) | buf[cur];
-if ((state & 0xFF00) == 0x100 && state > 
AVS2_SLICE_MAX_START_CODE) {
+if ((state & 0xFF00) == 0x100 && AVS2_ISUNIT(buf[cur])) {
 pc->frame_start_found = 0;
 pc->state = -1;
 return cur - 3;
-- 
2.35.3

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

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


[FFmpeg-devel] [PATCH 3/3] avcodec/avs2_parser: parse more info

2022-06-10 Thread Zhao Zhili
Including video resolution, framerate and picture type, etc.

Signed-off-by: Zhao Zhili 
---
 libavcodec/avs2.h|  27 ++
 libavcodec/avs2_parser.c | 103 +++
 2 files changed, 130 insertions(+)

diff --git a/libavcodec/avs2.h b/libavcodec/avs2.h
index f342ba52a0..e961c7d517 100644
--- a/libavcodec/avs2.h
+++ b/libavcodec/avs2.h
@@ -23,6 +23,8 @@
 #ifndef AVCODEC_AVS2_H
 #define AVCODEC_AVS2_H
 
+#include "libavutil/rational.h"
+
 #define AVS2_SLICE_MAX_START_CODE0x01AF
 
 enum {
@@ -38,4 +40,29 @@ enum {
 #define AVS2_ISPIC(x)  ((x) == AVS2_INTRA_PIC_START_CODE || (x) == 
AVS2_INTER_PIC_START_CODE)
 #define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || AVS2_ISPIC(x))
 
+enum AVS2Profile {
+AVS2_PROFILE_MAIN_PIC   = 0x12,
+AVS2_PROFILE_MAIN   = 0x20,
+AVS2_PROFILE_MAIN10 = 0x22,
+};
+
+static const AVRational ff_avs2_frame_rate_tab[16] = {
+{ 0, 0   }, // forbid
+{ 24000, 1001},
+{ 24   , 1   },
+{ 25   , 1   },
+{ 3, 1001},
+{ 30   , 1   },
+{ 50   , 1   },
+{ 6, 1001},
+{ 60   , 1   },
+{ 100  , 1   },
+{ 120  , 1   },
+{ 200  , 1   },
+{ 240  , 1   },
+{ 300  , 1   },
+{ 0, 0   }, // reserved
+{ 0, 0   }  // reserved
+};
+
 #endif
diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 71cf442903..0638a35030 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -19,7 +19,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avutil.h"
 #include "avs2.h"
+#include "get_bits.h"
 #include "parser.h"
 
 static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int 
buf_size)
@@ -58,6 +60,105 @@ static int avs2_find_frame_end(ParseContext *pc, const 
uint8_t *buf, int buf_siz
 return END_NOT_FOUND;
 }
 
+static void parse_avs2_seq_header(AVCodecParserContext *s, const uint8_t *buf,
+ int buf_size, AVCodecContext *avctx)
+{
+GetBitContext gb;
+int profile, level;
+int width, height;
+int chroma, sample_precision, encoding_precision = 1;
+// sample_precision and encoding_precision is 3 bits
+static uint8_t precision[8] = { 0, 8, 10 };
+int aspect_ratio;
+int frame_rate_code;
+int low_delay;
+
+if (buf_size < 15)
+return;
+
+init_get_bits8(, buf, buf_size);
+
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+
+profile = get_bits(, 8);
+level = get_bits(, 8);
+
+// progressive_sequence u(1)
+// field_coded_sequence u(1)
+skip_bits(, 2);
+
+width = get_bits(, 14);
+height = get_bits(, 14);
+
+chroma = get_bits(, 2);
+sample_precision = get_bits(, 3);
+if (profile == AVS2_PROFILE_MAIN10)
+encoding_precision = get_bits(, 3);
+
+aspect_ratio = get_bits(, 4);
+frame_rate_code = get_bits(, 4);
+
+// bit_rate_lower   u(18)
+// marker_bit   f(1)
+// bit_rate_upper   u(12)
+skip_bits(, 31);
+
+low_delay = get_bits(, 1);
+
+s->width = width;
+s->height = height;
+s->coded_width = FFALIGN(width, 8);
+s->coded_height = FFALIGN(height, 8);
+avctx->framerate.num = avctx->time_base.den =
+ff_avs2_frame_rate_tab[frame_rate_code].num;
+avctx->framerate.den = avctx->time_base.num =
+ff_avs2_frame_rate_tab[frame_rate_code].den;
+avctx->has_b_frames = FFMAX(avctx->has_b_frames, !low_delay);
+
+av_log(avctx, AV_LOG_DEBUG,
+   "AVS2 parse seq HDR: profile %x, level %x, "
+   "width %d, height %d, "
+   "chroma %d, sample_precision %d bits, encoding_precision %d bits, "
+   "framerate %d/%d, low_delay %d\n",
+   profile, level,
+   width, height,
+   chroma, precision[sample_precision], precision[encoding_precision],
+   avctx->framerate.num, avctx->framerate.den, low_delay);
+}
+
+static void parse_avs2_units(AVCodecParserContext *s, const uint8_t *buf,
+ int buf_size, AVCodecContext *avctx)
+{
+if (buf_size < 5)
+return;
+
+if (!(buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1))
+return;
+
+switch (buf[3]) {
+case AVS2_SEQ_START_CODE:
+parse_avs2_seq_header(s, buf + 4, buf_size - 4, avctx);
+return;
+case AVS2_INTRA_PIC_START_CODE:
+s->key_frame = 1;
+s->pict_type = AV_PICTURE_TYPE_I;
+return;
+case AVS2_INTER_PIC_START_CODE:
+s->key_frame = 0;
+if (buf_size > 9) {
+int pic_code_type = buf[8] & 0x3;
+if (pic_code_type == 1)
+s->pict_type = AV_PICTURE_TYPE_P;
+else if (pic_code_type == 3)
+s->pict_type = AV_PICTURE_TYPE_S;
+else
+s->pict_type = AV_PICTURE_TYPE_B;
+}
+return;
+}
+}
+
 static int avs2_parse(AVCodecParserContext *s, 

[FFmpeg-devel] [PATCH v2] ffmpeg: add option fps_mode

2022-06-10 Thread Gyan Doshi
fps_mode sets video sync per output stream. Overrides vsync for matching
streams.

vsync is deprecated.
---
 doc/ffmpeg.texi  | 14 --
 fftools/ffmpeg.c |  9 +
 fftools/ffmpeg.h |  3 +++
 fftools/ffmpeg_mux.c |  2 +-
 fftools/ffmpeg_opt.c | 42 +++---
 5 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 0d7e1a479d..51515c2cb8 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1618,12 +1618,14 @@ it may cause packet loss.
 It is useful for when flow speed of output packets is important, such as live 
streaming.
 @item -re (@emph{input})
 Read input at native frame rate. This is equivalent to setting @code{-readrate 
1}.
-@item -vsync @var{parameter}
-Video sync method.
-
-For compatibility reasons some of the values can be specified as numbers (shown
-in parentheses in the following table). This is deprecated and will stop 
working
-in the future.
+@item -vsync @var{parameter} (@emph{global})
+@itemx -fps_mode[:@var{stream_specifier}] @var{parameter} 
(@emph{output,per-stream})
+Set video sync method / framerate mode. vsync is applied to all output video 
streams
+but can be overridden for a stream by setting fps_mode. vsync is deprecated 
and will be
+removed in the future.
+
+For compatibility reasons some of the values for vsync can be specified as 
numbers (shown
+in parentheses in the following table).
 
 @table @option
 @item passthrough (0)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a5e1bf3993..09caa3e3c4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3017,11 +3017,12 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 
 if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
 enc_ctx->time_base = 
av_buffersink_get_time_base(ost->filter->filter);
-if (   av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != 
VSYNC_PASSTHROUGH
-   && (video_sync_method == VSYNC_CFR || video_sync_method == 
VSYNC_VSCFR ||
-   (video_sync_method == VSYNC_AUTO && !(of->format->flags & 
AVFMT_VARIABLE_FPS{
+if (   av_q2d(enc_ctx->time_base) < 0.001 && ost->vsync_method != 
VSYNC_PASSTHROUGH
+   && (ost->vsync_method == VSYNC_CFR || ost->vsync_method == 
VSYNC_VSCFR ||
+   (ost->vsync_method == VSYNC_AUTO && !(of->format->flags & 
AVFMT_VARIABLE_FPS{
 av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not 
efficiently supporting it.\n"
-   "Please consider specifying a lower 
framerate, a different muxer or -vsync 2\n");
+   "Please consider specifying a lower 
framerate, a different muxer or "
+   "setting vsync/fps_mode to vfr\n");
 }
 
 enc_ctx->width  = av_buffersink_get_w(ost->filter->filter);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7326193caf..69a368b8d1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -176,6 +176,8 @@ typedef struct OptionsContext {
 intnb_qscale;
 SpecifierOpt *forced_key_frames;
 intnb_forced_key_frames;
+SpecifierOpt *fps_mode;
+intnb_fps_mode;
 SpecifierOpt *force_fps;
 intnb_force_fps;
 SpecifierOpt *frame_aspect_ratios;
@@ -489,6 +491,7 @@ typedef struct OutputStream {
 AVRational max_frame_rate;
 enum VideoSyncMethod vsync_method;
 int is_cfr;
+const char *fps_mode;
 int force_fps;
 int top_field_first;
 int rotate_overridden;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 794d580635..a55fd18f8f 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -96,7 +96,7 @@ void of_write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost,
 return;
 }
 
-if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method 
== VSYNC_DROP) ||
+if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method 
== VSYNC_DROP) ||
 (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 
0))
 pkt->pts = pkt->dts = AV_NOPTS_VALUE;
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 2c1b3bd0dd..398067da96 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -81,6 +81,7 @@ static const char *const opt_name_codec_tags[]
= {"tag", "atag",
 static const char *const opt_name_sample_fmts[]   = {"sample_fmt", 
NULL};
 static const char *const opt_name_qscale[]= {"q", 
"qscale", NULL};
 static const char *const opt_name_forced_key_frames[] = 
{"forced_key_frames", NULL};
+static const char *const opt_name_fps_mode[]  = {"fps_mode", 
NULL};
 static const char *const opt_name_force_fps[] = {"force_fps", 
NULL};
 static const char *const opt_name_frame_aspect_ratios[]   = {"aspect", 
NULL};
 static const 

[FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way

2022-06-10 Thread Fei Wang
From: Xu Guangxin 

For range extension, the luma/chroma offset is larger than 8 bits, we
need fill the 16 bits version.

Signed-off-by: Xu Guangxin 
Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
update:
1. Add some warning log.

 libavcodec/vaapi_hevc.c | 55 +
 1 file changed, 39 insertions(+), 16 deletions(-)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 9083331c45..d82975979a 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -322,11 +322,20 @@ fail:
 return ret;
 }
 
-static void fill_pred_weight_table(const HEVCContext *h,
+static void fill_pred_weight_table(AVCodecContext *avctx,
+   const HEVCContext *h,
const SliceHeader *sh,
VASliceParameterBufferHEVC *slice_param)
 {
 int i;
+#if VA_CHECK_VERSION(1, 2, 0)
+int is_rext = avctx->profile >= FF_PROFILE_HEVC_REXT;
+#else
+int is_rext = 0;
+if (avctx->profile >= FF_PROFILE_HEVC_REXT)
+av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI 
1.2.0 "
+   "or above, which can support REXT related setting 
correctly.\n");
+#endif
 
 memset(slice_param->delta_luma_weight_l0,   0, 
sizeof(slice_param->delta_luma_weight_l0));
 memset(slice_param->delta_luma_weight_l1,   0, 
sizeof(slice_param->delta_luma_weight_l1));
@@ -353,21 +362,25 @@ static void fill_pred_weight_table(const HEVCContext *h,
 
 for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
 slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 << 
sh->luma_log2_weight_denom);
-slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
 slice_param->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] 
- (1 << sh->chroma_log2_weight_denom);
 slice_param->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] 
- (1 << sh->chroma_log2_weight_denom);
-slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
-slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+if (!is_rext) {
+slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
+slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+}
 }
 
 if (sh->slice_type == HEVC_SLICE_B) {
 for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
 slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 
<< sh->luma_log2_weight_denom);
-slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
 slice_param->delta_chroma_weight_l1[i][0] = 
sh->chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
 slice_param->delta_chroma_weight_l1[i][1] = 
sh->chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
-slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
-slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+if (!is_rext) {
+slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
+slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
+slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+}
 }
 }
 }
@@ -462,7 +475,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, 
rpl->ref[i]);
 }
 
-fill_pred_weight_table(h, sh, last_slice_param);
+fill_pred_weight_table(avctx, h, sh, last_slice_param);
 
 #if VA_CHECK_VERSION(1, 2, 0)
 if (avctx->profile == FF_PROFILE_HEVC_REXT) {
@@ -471,15 +484,25 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 .cu_chroma_qp_offset_enabled_flag = 
sh->cu_chroma_qp_offset_enabled_flag,
 },
 };
+for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
+pic->last_slice_param.rext.luma_offset_l0[i] = 
sh->luma_offset_l0[i];
+pic->last_slice_param.rext.ChromaOffsetL0[i][0] = 
sh->chroma_offset_l0[i][0];
+pic->last_slice_param.rext.ChromaOffsetL0[i][1] = 
sh->chroma_offset_l0[i][1];
+}
+
+for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
+pic->last_slice_param.rext.luma_offset_l0[i] = 
sh->luma_offset_l0[i];
+pic->last_slice_param.rext.ChromaOffsetL0[i][0] = 
sh->chroma_offset_l0[i][0];
+pic->last_slice_param.rext.ChromaOffsetL0[i][1] = 
sh->chroma_offset_l0[i][1];
+}
 
-memcpy(pic->last_slice_param.rext.luma_offset_l0, 
pic->last_slice_param.base.luma_offset_l0,
-
sizeof(pic->last_slice_param.base.luma_offset_l0));
-memcpy(pic->last_slice_param.rext.luma_offset_l1, 
pic->last_slice_param.base.luma_offset_l1,
-  

Re: [FFmpeg-devel] [PATCH v1] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way

2022-06-10 Thread Wang, Fei W
> -Original Message-
> From: Xiang, Haihao 
> Sent: Friday, June 10, 2022 11:49 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Wang, Fei W ; Xu, Guangxin
> ; linjie.justin...@gmail.com
> Subject: Re: [FFmpeg-devel] [PATCH v1] lavc/vaapi_hevc: fill rext luma/chroma
> offset in the right way
> 
> On Wed, 2022-06-01 at 22:58 +0800, Fei Wang wrote:
> > From: Xu Guangxin 
> >
> > For range extension, the luma/chroma offset is larger than 8 bits, we
> > need fill the 16 bits version.
> >
> > Signed-off-by: Xu Guangxin 
> > Signed-off-by: Linjie Fu 
> > Signed-off-by: Fei Wang 
> > ---
> >  libavcodec/vaapi_hevc.c | 53
> > -
> >  1 file changed, 37 insertions(+), 16 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index
> > 9083331c45..59beb86650 100644
> > --- a/libavcodec/vaapi_hevc.c
> > +++ b/libavcodec/vaapi_hevc.c
> > @@ -322,10 +322,17 @@ fail:
> >  return ret;
> >  }
> >
> > -static void fill_pred_weight_table(const HEVCContext *h,
> > +static void fill_pred_weight_table(const AVCodecContext *avctx,
> > +   const HEVCContext *h,
> > const SliceHeader *sh,
> > VASliceParameterBufferHEVC
> > *slice_param)  {
> > +#if VA_CHECK_VERSION(1, 2, 0)
> > +int is_rext = avctx->profile >= FF_PROFILE_HEVC_REXT; #else
> > +int is_rext = 0;
> 
> It will uses the wrong luma/offset for REXT stream when vaapi < 1.2 , right ? 
> I
> think it would be better to add some warning text to remind user.

Thanks, fixed in v2.

Fei

> 
> Thanks
> Haihao
> 
> 
> > +#endif
> > +
> >  int i;
> >
> >  memset(slice_param->delta_luma_weight_l0,   0, sizeof(slice_param-
> > >delta_luma_weight_l0));
> > @@ -353,21 +360,25 @@ static void fill_pred_weight_table(const
> > HEVCContext *h,
> >
> >  for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> >  slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i]
> > - (1 <<
> > sh->luma_log2_weight_denom);
> > -slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
> >  slice_param->delta_chroma_weight_l0[i][0] = sh-
> > >chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom);
> >  slice_param->delta_chroma_weight_l0[i][1] = sh-
> > >chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom);
> > -slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
> > -slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
> > +if (!is_rext) {
> > +slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
> > +slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
> > +slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
> > +}
> >  }
> >
> >  if (sh->slice_type == HEVC_SLICE_B) {
> >  for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
> >  slice_param->delta_luma_weight_l1[i] =
> > sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom);
> > -slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
> >  slice_param->delta_chroma_weight_l1[i][0] = sh-
> > >chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
> >  slice_param->delta_chroma_weight_l1[i][1] = sh-
> > >chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
> > -slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
> > -slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
> > +if (!is_rext) {
> > +slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
> > +slice_param->ChromaOffsetL1[i][0] = sh-
> > >chroma_offset_l1[i][0];
> > +slice_param->ChromaOffsetL1[i][1] = sh-
> > >chroma_offset_l1[i][1];
> > +}
> >  }
> >  }
> >  }
> > @@ -462,7 +473,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext
> *avctx,
> >  last_slice_param->RefPicList[list_idx][i] =
> > get_ref_pic_index(h,
> > rpl->ref[i]);
> >  }
> >
> > -fill_pred_weight_table(h, sh, last_slice_param);
> > +fill_pred_weight_table(avctx, h, sh, last_slice_param);
> >
> >  #if VA_CHECK_VERSION(1, 2, 0)
> >  if (avctx->profile == FF_PROFILE_HEVC_REXT) { @@ -471,15 +482,25
> > @@ static int vaapi_hevc_decode_slice(AVCodecContext
> > *avctx,
> >  .cu_chroma_qp_offset_enabled_flag = sh-
> > >cu_chroma_qp_offset_enabled_flag,
> >  },
> >  };
> > +for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> > +pic->last_slice_param.rext.luma_offset_l0[i] = sh-
> > >luma_offset_l0[i];
> > +pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh-
> > >chroma_offset_l0[i][0];
> > +pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh-
> > >chroma_offset_l0[i][1];
> > +}
> > +
> > +for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> > +   

Re: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c: Remove MAX_PATH limit

2022-06-10 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Nil
> Admirari
> Sent: Thursday, June 9, 2022 9:04 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v13 2/4] libavformat/avisynth.c:
> Remove MAX_PATH limit
> 
> ---
>  libavformat/avisynth.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
> index 8ba2bde..f7bea8c 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, _ansi)) {
> +ret = AVERROR_UNKNOWN;
> +goto fail;
> +}

Why not use the AviSynth mechanism that allows to supply a UTF-8 string?

https://github.com/AviSynth/AviSynthPlus/blob/c377916aa4146d2f4386852d91dc177d49103c16/avs_core/core/parser/script.cpp#L477-L481

Best,
sw
___
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] ffmpeg: add option fps_mode

2022-06-10 Thread Gyan Doshi




On 2022-06-10 02:54 pm, Anton Khirnov wrote:

It seems pointless to have two options that do the same thing. If this
option is added, -vsync should be deprecated.


Will do.

Regards,
Gyan
___
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] avfilter: add virtualbass filter

2022-06-10 Thread Paul B Mahol
Hi,

Patch attached.
From 68b1edf19c441a59fd53c0286eee841244cf5f11 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Mon, 30 May 2022 11:36:22 +0200
Subject: [PATCH] avfilter: add virtualbass filter

Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  20 
 libavfilter/Makefile |   1 +
 libavfilter/af_virtualbass.c | 183 +++
 libavfilter/allfilters.c |   1 +
 4 files changed, 205 insertions(+)
 create mode 100644 libavfilter/af_virtualbass.c

diff --git a/doc/filters.texi b/doc/filters.texi
index d65e83d4d0..5abab5de18 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6927,6 +6927,26 @@ Depth of modulation as a percentage. Range is 0.0 - 1.0.
 Default value is 0.5.
 @end table
 
+@section virtualbass
+
+Apply audio Virtual Bass filter.
+
+This filter accepts stereo input and produce stereo with LFE (2.1) channels output.
+The newly produced LFE channel have enhanced virtual bass originally obtained from both stereo channels.
+This filter outputs front left and front right channels unchanged as available in stereo input.
+
+The filter accepts the following options:
+
+@table @option
+@item cutoff
+Set the virtual bass cutoff frequency. Default value is 250 Hz.
+Allowed range is from 100 to 500 Hz.
+
+@item strength
+Set the virtual bass strength. Allowed range is from 0.5 to 3.
+Default value is 3.
+@end table
+
 @section volume
 
 Adjust the input audio volume.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e0e4d0de2c..7ba1c8a861 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -164,6 +164,7 @@ OBJS-$(CONFIG_SURROUND_FILTER)   += af_surround.o
 OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o
 OBJS-$(CONFIG_TREMOLO_FILTER)+= af_tremolo.o
 OBJS-$(CONFIG_VIBRATO_FILTER)+= af_vibrato.o generate_wave_table.o
+OBJS-$(CONFIG_VIRTUALBASS_FILTER)+= af_virtualbass.o
 OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o
 OBJS-$(CONFIG_VOLUMEDETECT_FILTER)   += af_volumedetect.o
 
diff --git a/libavfilter/af_virtualbass.c b/libavfilter/af_virtualbass.c
new file mode 100644
index 00..950159096b
--- /dev/null
+++ b/libavfilter/af_virtualbass.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2022 Paul B Mahol
+ *
+ * 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/channel_layout.h"
+#include "libavutil/opt.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+
+#include 
+
+typedef struct AudioVirtualBassContext {
+const AVClass *class;
+
+double cutoff;
+double strength;
+
+double a[3], m[3], cf[2];
+} AudioVirtualBassContext;
+
+#define OFFSET(x) offsetof(AudioVirtualBassContext, x)
+#define TFLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM
+#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption virtualbass_options[] = {
+{ "cutoff",   "set virtual bass cutoff",   OFFSET(cutoff),   AV_OPT_TYPE_DOUBLE, {.dbl=250},100,500, FLAGS },
+{ "strength", "set virtual bass strength", OFFSET(strength), AV_OPT_TYPE_DOUBLE, {.dbl=3},  0.5,  3, TFLAGS },
+{NULL}
+};
+
+AVFILTER_DEFINE_CLASS(virtualbass);
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterChannelLayouts *in_layout = NULL, *out_layout = NULL;
+AVFilterFormats *formats = NULL;
+int ret;
+
+if ((ret = ff_add_format (, AV_SAMPLE_FMT_DBLP )) < 0 ||
+(ret = ff_set_common_formats (ctx,  formats)) < 0 ||
+(ret = ff_add_channel_layout (_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) < 0 ||
+(ret = ff_channel_layouts_ref(in_layout, >inputs[0]->outcfg.channel_layouts)) < 0 ||
+(ret = ff_add_channel_layout (_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_2POINT1)) < 0 ||
+(ret = ff_channel_layouts_ref(out_layout, >outputs[0]->incfg.channel_layouts)) < 0)
+return ret;
+
+return ff_set_common_all_samplerates(ctx);
+}
+
+static int config_input(AVFilterLink *inlink)
+{
+AVFilterContext *ctx = inlink->dst;
+AudioVirtualBassContext *s = ctx->priv;
+const double Q = 0.707;
+double 

Re: [FFmpeg-devel] [PATCH] ffmpeg: add option fps_mode

2022-06-10 Thread Anton Khirnov
It seems pointless to have two options that do the same thing. If this
option is added, -vsync should be deprecated.

-- 
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/8] libavcodec/jpeg2000_parser: Speed up long skips

2022-06-10 Thread Tomas Härdin
Pushed all except patch 8/8 because I'm working on something better

/Tomas

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

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