[FFmpeg-devel] (no subject)

2023-07-17 Thread Водянников Александр

From 0fe666c4e3d10a689f4c6854a58eec3e7ff3c922 Mon Sep 17 00:00:00 2001
From: Aleksoid 
Date: Mon, 17 Jul 2023 17:04:43 +1000
Subject: [PATCH] Fixed crash when using hardware acceleration in third party
 projects without using hw_frames_ctx.

---
 libavcodec/decode.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a19cca1a7c..f34f169910 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1802,18 +1802,21 @@ AVBufferRef *ff_hwaccel_frame_priv_alloc(AVCodecContext 
*avctx,
  const AVHWAccel *hwaccel)
 {
 AVBufferRef *ref;
-AVHWFramesContext *frames_ctx = (AVHWFramesContext 
*)avctx->hw_frames_ctx->data;
-uint8_t *data = av_mallocz(hwaccel->frame_priv_data_size);
-if (!data)
-return NULL;
-
-ref = av_buffer_create(data, hwaccel->frame_priv_data_size,
-   hwaccel->free_frame_priv,
-   frames_ctx->device_ctx, 0);
-if (!ref) {
-av_free(data);
-return NULL;
-}
+if (avctx->hw_frames_ctx) {
+AVHWFramesContext *frames_ctx = (AVHWFramesContext 
*)avctx->hw_frames_ctx->data;
+uint8_t *data = av_mallocz(hwaccel->frame_priv_data_size);
+if (!data)
+return NULL;
+
+ref = av_buffer_create(data, hwaccel->frame_priv_data_size,
+   hwaccel->free_frame_priv,
+   frames_ctx->device_ctx, 0);
+if (!ref) {
+av_free(data);
+return NULL;
+}
+} else
+ref = av_buffer_allocz(hwaccel->frame_priv_data_size);
 
 return ref;
 }
-- 
2.41.0.windows.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 2/3] fftools/ffmpeg_enc: Remove always-true checks

2023-07-17 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2023-07-16 16:24:35)
> frame is always != NULL for audio and video here
> (this is checked by an assert and the frame is already dereferenced
> before it reaches this code here).
> Fixes Coverity issue #1538858.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  fftools/ffmpeg_enc.c | 4 
>  1 file changed, 4 deletions(-)

This and the next patch look ok.

Thanks,
-- 
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 2/3] swscale/x86/yuv2yuvX: Add yuv2yuvX avx512

2023-07-17 Thread Alan Kelly
Happy to add the check.

Thanks,
Alan

On Fri, Jul 14, 2023 at 4:59 PM James Almer  wrote:

> On 7/14/2023 11:57 AM, Kieran Kunhya wrote:
> > On Fri, 14 Jul 2023 at 14:03, James Almer  wrote:
> >
> >> On 7/14/2023 9:59 AM, Kieran Kunhya wrote:
>  +#if ARCH_X86_64 && HAVE_AVX512_EXTERNAL
>  +if (EXTERNAL_AVX512(cpu_flags))
>  +c->yuv2planeX = yuv2yuvX_avx512;
> #endif
> 
> >>>
> >>>You want EXTERNAL_AVX512ICL here.
> >>
> >> vpermt2q with zmm registers is avx512f and not any of the extensions, so
> >> that check is fine.
> >>
> >
> > We still support Skylake and we don't want downclocking on that platform.
> > At least that was my understanding of the intention of AVX512 vs
> AVX512ICL.
> > It appears I'm the only one following this convention though.
>
> Ah, no opinion in that regard. I was following the use of the checks in
> the strict technical sense of instruction availability.
> ___
> 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".


[FFmpeg-devel] [PATCH 2/3] swscale/x86/yuv2yuvX: Add yuv2yuvX avx512

2023-07-17 Thread Alan Kelly
---
 Checks for EXTERNAL_AVX512ICL to prevent downclocking on Skylake
 libswscale/x86/swscale.c|  7 +++
 libswscale/x86/yuv2yuvX.asm | 19 ++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 8c67bf4fab..600c7d6c91 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -225,6 +225,9 @@ YUV2YUVX_FUNC(sse3, 32, mmxext)
 #if HAVE_AVX2_EXTERNAL
 YUV2YUVX_FUNC(avx2, 64, sse3)
 #endif
+#if ARCH_X86_64 && HAVE_AVX512_EXTERNAL
+YUV2YUVX_FUNC(avx512, 128, avx2)
+#endif
 
 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
@@ -467,6 +470,10 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
 #if HAVE_AVX2_EXTERNAL
 if (EXTERNAL_AVX2_FAST(cpu_flags))
 c->yuv2planeX = yuv2yuvX_avx2;
+#endif
+#if ARCH_X86_64 && HAVE_AVX512_EXTERNAL
+if (EXTERNAL_AVX512ICL(cpu_flags))
+c->yuv2planeX = yuv2yuvX_avx512;
 #endif
 }
 #if ARCH_X86_32 && !HAVE_ALIGNED_STACK
diff --git a/libswscale/x86/yuv2yuvX.asm b/libswscale/x86/yuv2yuvX.asm
index 369c850674..57bfa09d66 100644
--- a/libswscale/x86/yuv2yuvX.asm
+++ b/libswscale/x86/yuv2yuvX.asm
@@ -22,6 +22,10 @@
 
 %include "libavutil/x86/x86util.asm"
 
+SECTION_RODATA 64
+
+permutation: dq 0, 2, 4, 6, 1, 3, 5, 7
+
 SECTION .text
 
 ;-
@@ -50,6 +54,10 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, 
dstW, dither, offset
 %else
 movq xm3, [ditherq]
 %endif ; avx2
+
+%if cpuflag(avx512)
+mova m15, [permutation]
+%endif
 cmp  offsetd, 0
 jz   .offset
 
@@ -109,7 +117,10 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, 
dstW, dither, offset
 packuswb m6, m6, m1
 %endif
 mov  srcq, [filterq]
-%if cpuflag(avx2)
+%if cpuflag(avx512)
+vpermt2q m3, m15, m3
+vpermt2q m6, m15, m6
+%elif cpuflag(avx2)
 vpermq   m3, m3, 216
 vpermq   m6, m6, 216
 %endif
@@ -131,4 +142,10 @@ YUV2YUVX_FUNC
 %if HAVE_AVX2_EXTERNAL
 INIT_YMM avx2
 YUV2YUVX_FUNC
+%if HAVE_AVX512_EXTERNAL
+%if ARCH_X86_64
+INIT_ZMM avx512
+YUV2YUVX_FUNC
+%endif
+%endif
 %endif
-- 
2.41.0.255.g8b1d071c50-goog

___
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 3/3] swscale/x86/yuv2yuvX: Process tails by jumping back into the main loop.

2023-07-17 Thread Alan Kelly
On Sat, Jul 15, 2023 at 10:40 PM Michael Niedermayer 
wrote:

> On Fri, Jul 14, 2023 at 12:08:46PM +0200, Alan Kelly wrote:
> > ---
> >  libswscale/x86/swscale.c| 11 ---
> >  libswscale/x86/yuv2yuvX.asm | 12 ++--
> >  2 files changed, 14 insertions(+), 9 deletions(-)
>
> seems to segfault with
>
> ./ffmpeg_g -i mm-short.mpg -an -vcodec snow -t 0.2 -bitexact -pix_fmt
> yuv410p -s 199x199 -vstrict -2 -y  snow3914-199-410.avi
>
> Thread 79 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7fffaffef700 (LWP 23533)]
> 0x5658a0f6 in ff_yuv2yuvX_sse3 ()
> (gdb) bt
> #0  0x5658a0f6 in ff_yuv2yuvX_sse3 ()
> #1  0x56585bc6 in chr_planar_vscale ()
> #2  0x565817d1 in scale_internal ()
> #3  0x565827d9 in ff_sws_slice_worker ()
> #4  0x5662b06e in thread_worker ()
> #5  0x775fc6db in start_thread (arg=0x7fffaffef700) at
> pthread_create.c:463
> #6  0x7fffed12861f in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> (gdb) disassemble $rip-32,$rip+32
> Dump of assembler code from 0x5658a0d6 to 0x5658a116:
>0x5658a0d6 :std
>0x5658a0d7 :fldenv 0xf(%rsi)
>0x5658a0da :outsl  %ds:(%rsi),(%dx)
>0x5658a0db :sti
>0x5658a0dc :psraw  $0x4,%xmm7
>0x5658a0e1 :movdqa %xmm7,%xmm4
>0x5658a0e5 :   movdqa %xmm7,%xmm3
>0x5658a0e9 :   movdqa %xmm7,%xmm6
>0x5658a0ed :   movdqa %xmm7,%xmm1
>0x5658a0f1 :   movddup 0x8(%rsi),%xmm0
> => 0x5658a0f6 :   movdqa (%rdx,%rax,2),%xmm2
>0x5658a0fb :   pmulhw %xmm0,%xmm2
>0x5658a0ff :   movdqa
> 0x10(%rdx,%rax,2),%xmm5
>0x5658a105 :   pmulhw %xmm0,%xmm5
>0x5658a109 :   paddw  %xmm2,%xmm3
>0x5658a10d :   paddw  %xmm5,%xmm4
>0x5658a111 :   movdqa
> 0x20(%rdx,%rax,2),%xmm2
> End of assembler dump.
> (gdb) info all-registers
> rax0x12 18
> rbx0x32 50
> rcx0x57915480   93825029723264
> rdx0x57687680   93825027044992
> rsi0x5758   93825026909784
> rdi0x5758   93825026909784
> rbp0x5765b880   0x5765b880
> rsp0x7fffaffee7a8   0x7fffaffee7a8
> r8 0x20 32
> r9 0x32 50
> r100x56589860   93825009227872
> r110x576f9dc0   93825027513792
> r120x5763b280   93825026732672
> r130x5758   93825026909784
> r140x577b5800   93825028282368
> r150x57622640   93825026631232
> rip0x5658a0f6   0x5658a0f6 
> eflags 0x10297  [ CF PF AF SF IF RF ]
> cs 0x33 51
> ss 0x2b 43
> ds 0x0  0
> es 0x0  0
> fs 0x0  0
> gs 0x0  0
> st00(raw 0x)
> st10(raw 0x)
> st20(raw 0x)
> st30(raw 0x)
> st40(raw 0x)
> st50(raw 0x)
> st60(raw 0x)
> st70(raw 0x)
> fctrl  0x   65535
> fstat  0x   65535
> ftag   0x   43690
> fiseg  0x1  1
> fioff  0x0  0
> foseg  0x5646   22086
> fooff  0xa  10
> fop0x7ff2047
> mxcsr  0x1fa8   [ OE PE IM DM ZM OM UM PM ]
>
>
> >
> > diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
> > index 52423a1199..71434f58d3 100644
> > --- a/libswscale/x86/swscale.c
> > +++ b/libswscale/x86/swscale.c
> > @@ -202,17 +202,14 @@ static void yuv2yuvX_ ##opt(const int16_t *filter,
> int filterSize, \
> > const int16_t **src, uint8_t *dest, int
> dstW, \
> > const uint8_t *dither, int offset) \
> >  { \
> > -int remainder = (dstW % step); \
> > -int pixelsProcessed = dstW - remainder; \
> >  if(((uintptr_t)dest) & 15){ \
> >  yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither,
> offset); \
> >  return; \
> >  } \
> > -if(pixelsProcessed > 0) \
> > -ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset,
> pixelsProcessed + offset, dither, offset); \
> > -if(remainder > 0){ \
> > -  yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither,
> offset); \
> > -} \
> > +if (dstW >= step) \
> > +ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset,
> dstW + offset, dither, offset); \
> > +else \
> > +yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither,
> offset); \
> >  return; \
> >  }
> >
> > diff --git a/libswsca

[FFmpeg-devel] [PATCH 3/3] swscale/x86/yuv2yuvX: Process tails by jumping back into the main loop.

2023-07-17 Thread Alan Kelly
---
 libswscale/x86/swscale.c| 11 ---
 libswscale/x86/yuv2yuvX.asm | 24 ++--
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 600c7d6c91..6980002e9e 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -202,17 +202,14 @@ static void yuv2yuvX_ ##opt(const int16_t *filter, int 
filterSize, \
const int16_t **src, uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \
 { \
-int remainder = (dstW % step); \
-int pixelsProcessed = dstW - remainder; \
 if(((uintptr_t)dest) & 15){ \
 yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, offset); \
 return; \
 } \
-if(pixelsProcessed > 0) \
-ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, 
pixelsProcessed + offset, dither, offset); \
-if(remainder > 0){ \
-  yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, offset); \
-} \
+if (dstW >= step) \
+ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + 
offset, dither, offset); \
+else \
+yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, offset); 
\
 return; \
 }
 
diff --git a/libswscale/x86/yuv2yuvX.asm b/libswscale/x86/yuv2yuvX.asm
index 57bfa09d66..03bfd6ad1d 100644
--- a/libswscale/x86/yuv2yuvX.asm
+++ b/libswscale/x86/yuv2yuvX.asm
@@ -54,6 +54,8 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, 
dstW, dither, offset
 %else
 movq xm3, [ditherq]
 %endif ; avx2
+mov  ditherq, dstWq
+sub  dstWq, mmsize * unroll
 
 %if cpuflag(avx512)
 mova m15, [permutation]
@@ -92,13 +94,17 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, 
dstW, dither, offset
 %else
 mova m0, [filterSizeq + 8]
 %endif
-pmulhw   m2, m0, [srcq + offsetq * 2]
-pmulhw   m5, m0, [srcq + offsetq * 2 + mmsize]
+movu m2, [srcq + offsetq * 2]
+movu m5, [srcq + offsetq * 2 + mmsize]
+pmulhw   m2, m0, m2
+pmulhw   m5, m0, m5
 paddwm3, m3, m2
 paddwm4, m4, m5
 %if cpuflag(sse3)
-pmulhw   m2, m0, [srcq + offsetq * 2 + 2 * mmsize]
-pmulhw   m5, m0, [srcq + offsetq * 2 + 3 * mmsize]
+movu m2, [srcq + offsetq * 2 + 2 * mmsize]
+movu m5, [srcq + offsetq * 2 + 3 * mmsize]
+pmulhw   m2, m0, m2
+pmulhw   m5, m0, m5
 paddwm6, m6, m2
 paddwm1, m1, m5
 %endif
@@ -131,8 +137,14 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, 
dstW, dither, offset
 add  offsetq, mmsize * unroll
 mov  filterSizeq, filterq
 cmp  offsetq, dstWq
-jb  .outerloop
-RET
+jb   .outerloop
+
+mov  dstWq, offsetq
+mov  offsetq, ditherq
+sub  offsetq, mmsize * unroll
+cmp  dstWq, ditherq
+jb   .outerloop
+REP_RET
 %endmacro
 
 INIT_MMX mmxext
-- 
2.41.0.255.g8b1d071c50-goog

___
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 v1 6/6] lavc/vaapi_encode: Add VAAPI AV1 encoder

2023-07-17 Thread David Rosca
On Mon, Jul 10, 2023 at 9:40 AM Fei Wang
 wrote:
>
> Signed-off-by: Fei Wang 
> ---
>  Changelog |1 +
>  configure |3 +
>  doc/encoders.texi |   13 +
>  libavcodec/Makefile   |1 +
>  libavcodec/allcodecs.c|1 +
>  libavcodec/vaapi_encode.c |  125 +++-
>  libavcodec/vaapi_encode.h |   12 +
>  libavcodec/vaapi_encode_av1.c | 1228 +
>  8 files changed, 1366 insertions(+), 18 deletions(-)
>  create mode 100644 libavcodec/vaapi_encode_av1.c
>
> diff --git a/Changelog b/Changelog
> index 3876082844..7ae9b85d52 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -25,6 +25,7 @@ version :
>  - Raw VVC bitstream parser, muxer and demuxer
>  - Bitstream filter for editing metadata in VVC streams
>  - Bitstream filter for converting VVC from MP4 to Annex B
> +- VAAPI AV1 encoder
>
>  version 6.0:
>  - Radiance HDR image support
> diff --git a/configure b/configure
> index 0ab0761011..6a1a30aaec 100755
> --- a/configure
> +++ b/configure
> @@ -3323,6 +3323,8 @@ av1_qsv_decoder_select="qsvdec"
>  av1_qsv_encoder_select="qsvenc"
>  av1_qsv_encoder_deps="libvpl"
>  av1_amf_encoder_deps="amf"
> +av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
> +av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
>
>  # parsers
>  aac_parser_select="adts_header mpeg4audio"
> @@ -7106,6 +7108,7 @@ if enabled vaapi; then
>  check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
>  check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
>  check_type "va/va.h va/va_enc_vp9.h"  "VAEncPictureParameterBufferVP9"
> +check_type "va/va.h va/va_enc_av1.h"  "VAEncPictureParameterBufferAV1"
>  fi
>
>  if enabled_all opencl libdrm ; then
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 25d6b7f09e..fb331ebd8e 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -3991,6 +3991,19 @@ Average variable bitrate.
>  Each encoder also has its own specific options:
>  @table @option
>
> +@item av1_vaapi
> +@option{profile} sets the value of @emph{seq_profile}.
> +@option{tier} sets the value of @emph{seq_tier}.
> +@option{level} sets the value of @emph{seq_level_idx}.
> +
> +@table @option
> +@item tiles
> +Set the number of tiles to encode the input video with, as columns x rows.
> +(default is 1x1).
> +@item tile_groups
> +Set tile groups number (default is 1).
> +@end table
> +
>  @item h264_vaapi
>  @option{profile} sets the value of @emph{profile_idc} and the 
> @emph{constraint_set*_flag}s.
>  @option{level} sets the value of @emph{level_idc}.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3cd5997e64..fe1e6aa99d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -259,6 +259,7 @@ OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER)  += mediacodecdec.o
>  OBJS-$(CONFIG_AV1_MEDIACODEC_ENCODER)  += mediacodecenc.o
>  OBJS-$(CONFIG_AV1_NVENC_ENCODER)   += nvenc_av1.o nvenc.o
>  OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
> +OBJS-$(CONFIG_AV1_VAAPI_ENCODER)   += vaapi_encode_av1.o 
> av1_profile_level.o
>  OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
>  OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
>  OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 8775d15a4f..c43c1d7b48 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -844,6 +844,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
>  extern const FFCodec ff_av1_qsv_decoder;
>  extern const FFCodec ff_av1_qsv_encoder;
>  extern const FFCodec ff_av1_amf_encoder;
> +extern const FFCodec ff_av1_vaapi_encoder;
>  extern const FFCodec ff_libopenh264_encoder;
>  extern const FFCodec ff_libopenh264_decoder;
>  extern const FFCodec ff_h264_amf_encoder;
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 2604f12b9e..2907e159fb 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -669,6 +669,15 @@ static int 
> vaapi_encode_set_output_timestamp(AVCodecContext *avctx,
>  {
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>
> +// AV1 packs P frame and next B frame into one pkt, and uses the other
> +// repeat frame header pkt at the display order position of the P frame
> +// to indicate its frame index. Each frame has a corresponding pkt in its
> +// display order position. So don't need to consider delay for AV1 
> timestamp.
> +if (avctx->codec_id == AV_CODEC_ID_AV1) {
> +pkt->dts = pkt->pts - ctx->dts_pts_diff;
> +return 0;
> +}
> +
>  if (ctx->output_delay == 0) {
>  pkt->dts = pkt->pts;
>  } else if (pic->encode_order < ctx->decode_delay) {
> @@ -689,9 +698,10 @@ static int vaapi_encode_output(AVCodecContext *avctx,
>  {
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VACodedBufferSegment *buf_list, *buf;
> -VAStatus vas;
> +AVPacket *pkt_ptr = pkt;
>  

Re: [FFmpeg-devel] [PATCH 3/4] avcodec/msrleenc: Remove useless private class

2023-07-17 Thread Tomas Härdin
sön 2023-07-16 klockan 16:51 +0200 skrev Andreas Rheinhardt:
> A private class for an encoder without options is useless.

Might be useful for explicitly using 8-bit encoding even when palette
size would permit 4-bit MSRLE. But on the other hand if anyone wants to
add 4-bit support then they can also add this stuff back in. So OK.

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


Re: [FFmpeg-devel] [PATCH 1/4] avcodec/msrleenc: Replace stray \r by \n

2023-07-17 Thread Tomas Härdin
sön 2023-07-16 klockan 16:49 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/msrleenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
> index b73aa5e384..e48d11a0f7 100644
> --- a/libavcodec/msrleenc.c
> +++ b/libavcodec/msrleenc.c
> @@ -234,7 +234,8 @@ static int encode(AVCodecContext *avctx, AVPacket
> *pkt,
>  }
>  bytestream_put_be16(&data, 0x0001); // end of bitmap
>  pkt->size = data - pkt->data;
> -    return 0;
> }
> +    return 0;
> +}

Patchset looks OK

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


Re: [FFmpeg-devel] [PATCH v2] avformat/mov: enable identifying TTML subtitle streams as such

2023-07-17 Thread Jan Ekström
On Wed, Jul 12, 2023 at 4:48 PM Jan Ekström  wrote:
>
> From: Jan Ekström 
>
> The contents are full TTML XML documents. TTML writing tests'
> results are updated as the streams are now properly identified
> as TTML ones.
>
> Signed-off-by: Jan Ekström 

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

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


Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg

2023-07-17 Thread Jean-Baptiste Kempf
Please merge.

On Thu, 1 Jun 2023, at 12:29, Jean-Baptiste Kempf wrote:
> Hello,
>
> On Thu, 1 Jun 2023, at 02:02, Steven Liu wrote:
>> Neal Gompa  于2023年5月31日周三 13:47写道:
>>>
>>> On Mon, May 15, 2023 at 10:41 PM Neal Gompa  wrote:
>>> >
>>> > On Mon, May 15, 2023 at 4:32 AM Steven Liu  wrote:
>>> > >
>>> > > Reference file: 
>>> > > https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
>>> > > The Enhanced flv has been supported by OBS, Simple Realtime Server, 
>>> > > mpegts.js.
>>> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
>>> > > The enhanced flv documentation contributors include
>>> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
>>> > > So this should be support by ffmpeg too.
>>> > >
>>> > > v8:
>>> > > Support vp9 codec according to enhanced flv.
>>> > > Support PacketTypeCodedFrames type for hevc in flv.
>>> > > v9:
>>> > > Add dependency codec object files for flvenc in Makefile.
>>> > > Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
>>> > >
>>> > > v10:
>>> > > modify first patch comment like the others before commit.
>>> > > exheader mode should only happened in video stream this patchset.
>>> > >
>>> > > Steven Liu (6):
>>> > >   avformat/flvenc: support mux hevc in enhanced flv
>>> > >   avformat/flvdec: support demux hevc in enhanced flv
>>> > >   avformat/flvenc: support mux av1 in enhanced flv
>>> > >   avformat/flvdec: support demux av1 in enhanced flv
>>> > >   avformat/flvenc: support mux vp9 in enhanced flv
>>> > >   avformat/flvdec: support demux vp9 in enhanced flv
>>> > >
>>> > >  libavformat/Makefile |  2 +-
>>> > >  libavformat/flv.h| 15 +
>>> > >  libavformat/flvdec.c | 73 +++-
>>> > >  libavformat/flvenc.c | 58 +--
>>> > >  4 files changed, 130 insertions(+), 18 deletions(-)
>>> > >
>>> >
>>> > This version works for me. Thanks for this work!
>>> >
>>> > Tested-by: Neal Gompa 
>>> > Reviewed-by: Neal Gompa 
>>> >
>>>
>>> Is this patch set going to get pushed to master anytime soon?
>>
>> Hi Neal,
>>
>> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
>> this patch can be pushed now.
>
> I've just re-asked what is the final status of the spec.
>
> If you cannot wait, use experimental flags.
>
> jb
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> ___
> 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".

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
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/decode: factor out filling frame props

2023-07-17 Thread James Almer

On 7/14/2023 3:20 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/decode.c | 67 -
  1 file changed, 23 insertions(+), 44 deletions(-)


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

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


Re: [FFmpeg-devel] [PATCH v10 0/6] Support enhanced flv in FFmpeg

2023-07-17 Thread Steven Liu
Jean-Baptiste Kempf 于2023年7月17日 周一19:37写道:

> Please merge.

will apply

>
>
> On Thu, 1 Jun 2023, at 12:29, Jean-Baptiste Kempf wrote:
> > Hello,
> >
> > On Thu, 1 Jun 2023, at 02:02, Steven Liu wrote:
> >> Neal Gompa  于2023年5月31日周三 13:47写道:
> >>>
> >>> On Mon, May 15, 2023 at 10:41 PM Neal Gompa 
> wrote:
> >>> >
> >>> > On Mon, May 15, 2023 at 4:32 AM Steven Liu 
> wrote:
> >>> > >
> >>> > > Reference file:
> https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
> >>> > > The Enhanced flv has been supported by OBS, Simple Realtime
> Server, mpegts.js.
> >>> > > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp.
> >>> > > The enhanced flv documentation contributors include
> >>> > > Jean-Baptiste Kempf (FFmpeg, VideoLAN).
> >>> > > So this should be support by ffmpeg too.
> >>> > >
> >>> > > v8:
> >>> > > Support vp9 codec according to enhanced flv.
> >>> > > Support PacketTypeCodedFrames type for hevc in flv.
> >>> > > v9:
> >>> > > Add dependency codec object files for flvenc in Makefile.
> >>> > > Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL.
> >>> > >
> >>> > > v10:
> >>> > > modify first patch comment like the others before commit.
> >>> > > exheader mode should only happened in video stream this
> patchset.
> >>> > >
> >>> > > Steven Liu (6):
> >>> > >   avformat/flvenc: support mux hevc in enhanced flv
> >>> > >   avformat/flvdec: support demux hevc in enhanced flv
> >>> > >   avformat/flvenc: support mux av1 in enhanced flv
> >>> > >   avformat/flvdec: support demux av1 in enhanced flv
> >>> > >   avformat/flvenc: support mux vp9 in enhanced flv
> >>> > >   avformat/flvdec: support demux vp9 in enhanced flv
> >>> > >
> >>> > >  libavformat/Makefile |  2 +-
> >>> > >  libavformat/flv.h| 15 +
> >>> > >  libavformat/flvdec.c | 73
> +++-
> >>> > >  libavformat/flvenc.c | 58 +--
> >>> > >  4 files changed, 130 insertions(+), 18 deletions(-)
> >>> > >
> >>> >
> >>> > This version works for me. Thanks for this work!
> >>> >
> >>> > Tested-by: Neal Gompa 
> >>> > Reviewed-by: Neal Gompa 
> >>> >
> >>>
> >>> Is this patch set going to get pushed to master anytime soon?
> >>
> >> Hi Neal,
> >>
> >> Waiting for j-b check about the Enhanced-FLV status, i cannot sure if
> >> this patch can be pushed now.
> >
> > I've just re-asked what is the final status of the spec.
> >
> > If you cannot wait, use experimental flags.
> >
> > jb
> > --
> > Jean-Baptiste Kempf -  President
> > +33 672 704 734
> > ___
> > 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".
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
>
___
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/evc*: Improve included headers

2023-07-17 Thread Andreas Rheinhardt
In particular, don't include avcodec.h in evc_frame_merge_bsf.c.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/evc_frame_merge_bsf.c | 3 +--
 libavcodec/evc_parse.c   | 1 -
 libavcodec/evc_parse.h   | 1 -
 libavcodec/evc_parser.c  | 2 +-
 libavcodec/evc_ps.c  | 2 +-
 5 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c
index cfdf24c69e..7b8e6b1c9e 100644
--- a/libavcodec/evc_frame_merge_bsf.c
+++ b/libavcodec/evc_frame_merge_bsf.c
@@ -18,13 +18,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "get_bits.h"
-#include "golomb.h"
 #include "bsf.h"
 #include "bsf_internal.h"
-#include "avcodec.h"
 
 #include "evc.h"
 #include "evc_parse.h"
+#include "evc_ps.h"
 
 // Access unit data
 typedef struct AccessUnitBuffer {
diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c
index 447f6195c2..bd3a4416f2 100644
--- a/libavcodec/evc_parse.c
+++ b/libavcodec/evc_parse.c
@@ -17,7 +17,6 @@
  */
 
 #include "golomb.h"
-#include "parser.h"
 #include "evc.h"
 #include "evc_parse.h"
 
diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h
index 55cdd553ea..4712310826 100644
--- a/libavcodec/evc_parse.h
+++ b/libavcodec/evc_parse.h
@@ -28,7 +28,6 @@
 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
-#include "libavutil/rational.h"
 #include "evc.h"
 #include "evc_ps.h"
 
diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c
index 76790d8111..8590ebcdaf 100644
--- a/libavcodec/evc_parser.c
+++ b/libavcodec/evc_parser.c
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "parser.h"
+#include "avcodec.h"
 #include "bytestream.h"
 #include "evc.h"
 #include "evc_parse.h"
diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c
index fc2105b352..04ee6a45e6 100644
--- a/libavcodec/evc_ps.c
+++ b/libavcodec/evc_ps.c
@@ -16,8 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "get_bits.h"
 #include "golomb.h"
-#include "parser.h"
 #include "evc.h"
 #include "evc_ps.h"
 
-- 
2.34.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/vvc_mp4toannexb_bsf: Improve included headers

2023-07-17 Thread Andreas Rheinhardt
A BSF should never include avcodec.h at all.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vvc_mp4toannexb_bsf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/vvc_mp4toannexb_bsf.c b/libavcodec/vvc_mp4toannexb_bsf.c
index 9e606cdc27..25c3726918 100644
--- a/libavcodec/vvc_mp4toannexb_bsf.c
+++ b/libavcodec/vvc_mp4toannexb_bsf.c
@@ -24,14 +24,12 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 
-#include "avcodec.h"
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "bytestream.h"
+#include "defs.h"
 #include "vvc.h"
 
-#include "libavcodec/get_bits.h"
-
 #define MIN_VVCC_LENGTH 23
 
 typedef struct VVCBSFContext {
-- 
2.34.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] lavu/float_dsp: rework RISC-V V scalar product

2023-07-17 Thread Rémi Denis-Courmont
1) Take the reductive sum out of the loop,
   leaving a regular vector addition in the loop.
2) Merge the addition and the multiplication.
3) Unroll.

Before:
scalarproduct_float_rvv_f32: 832.5

After:
scalarproduct_float_rvv_f32: 275.2
---
 libavutil/riscv/float_dsp_rvv.S | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S
index 77961b7387..c80fde2f7e 100644
--- a/libavutil/riscv/float_dsp_rvv.S
+++ b/libavutil/riscv/float_dsp_rvv.S
@@ -166,20 +166,21 @@ endfunc
 
 // a0 = (a0).(a1) [0..a2-1]
 func ff_scalarproduct_float_rvv, zve32f
-vsetivli zero, 1, e32, m1, ta, ma
-vmv.s.x  v8, zero
+vsetvli  t0, zero, e32, m8, ta, ma
+vmv.v.x  v8, zero
+vmv.s.x  v0, zero
 1:
-vsetvli  t0, a2, e32, m1, ta, ma
+vsetvli  t0, a2, e32, m8, tu, ma
 vle32.v  v16, (a0)
 sub  a2, a2, t0
 vle32.v  v24, (a1)
 sh2add   a0, t0, a0
-vfmul.vv v16, v16, v24
+vfmacc.vvv8, v16, v24
 sh2add   a1, t0, a1
-vfredusum.vs v8, v16, v8
 bnez a2, 1b
 
-vfmv.f.s fa0, v8
+vfredusum.vs v0, v8, v0
+vfmv.f.s fa0, v0
 NOHWF   fmv.x.w  a0, fa0
 ret
 endfunc
-- 
2.40.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] lavu/float_dsp: unroll RISC-V V loops

2023-07-17 Thread Rémi Denis-Courmont
butterflies_float_c: 1057.0
butterflies_float_rvv_f32: 351.0 (before)
butterflies_float_rvv_f32: 329.5 (after)

vector_dmac_scalar_c: 819.0
vector_dmac_scalar_rvv_f64: 670.5 (before)
vector_dmac_scalar_rvv_f64: 431.0 (after)

vector_dmul_c: 800.2
vector_dmul_rvv_f64: 541.5 (before)
vector_dmul_rvv_f64: 426.0 (after)

vector_dmul_scalar_c: 545.7
vector_dmul_scalar_rvv_f64: 670.7 (before)
vector_dmul_scalar_rvv_f64: 324.7 (after)

vector_fmac_scalar_c: 804.5
vector_fmac_scalar_rvv_f32: 412.7 (before)
vector_fmac_scalar_rvv_f32: 214.5 (after)

vector_fmul_c: 811.2
vector_fmul_rvv_f32: 285.7 (before)
vector_fmul_rvv_f32: 214.2 (after)

vector_fmul_add_c: 1313.0
vector_fmul_add_rvv_f32: 349.0 (before)
vector_fmul_add_rvv_f32: 290.2 (after)

vector_fmul_reverse_c: 815.7
vector_fmul_reverse_rvv_f32: 529.2 (before)
vector_fmul_reverse_rvv_f32: 515.7 (after)

vector_fmul_scalar_c: 546.0
vector_fmul_scalar_rvv_f32: 350.2 (before)
vector_fmul_scalar_rvv_f32: 169.5 (after)
---
 libavutil/riscv/float_dsp_rvv.S | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S
index c80fde2f7e..bcec7074b8 100644
--- a/libavutil/riscv/float_dsp_rvv.S
+++ b/libavutil/riscv/float_dsp_rvv.S
@@ -23,7 +23,7 @@
 // (a0) = (a1) * (a2) [0..a3-1]
 func ff_vector_fmul_rvv, zve32f
 1:
-vsetvli  t0, a3, e32, m1, ta, ma
+vsetvli  t0, a3, e32, m8, ta, ma
 vle32.v  v16, (a1)
 sub  a3, a3, t0
 vle32.v  v24, (a2)
@@ -42,7 +42,7 @@ func ff_vector_fmac_scalar_rvv, zve32f
 NOHWF   fmv.w.x   fa0, a2
 NOHWF   mva2, a3
 1:
-vsetvli   t0, a2, e32, m1, ta, ma
+vsetvli   t0, a2, e32, m8, ta, ma
 slli  t1, t0, 2
 vle32.v   v24, (a1)
 sub   a2, a2, t0
@@ -61,7 +61,7 @@ func ff_vector_fmul_scalar_rvv, zve32f
 NOHWF   fmv.w.x  fa0, a2
 NOHWF   mv   a2, a3
 1:
-vsetvli  t0, a2, e32, m1, ta, ma
+vsetvli  t0, a2, e32, m8, ta, ma
 vle32.v  v16, (a1)
 sub  a2, a2, t0
 vfmul.vf v16, v16, fa0
@@ -82,7 +82,7 @@ func ff_vector_fmul_window_rvv, zve32f
 sh2add t3, t1, a3
 li t1, -4 // byte stride
 1:
-vsetvlit2, a4, e32, m1, ta, ma
+vsetvlit2, a4, e32, m4, ta, ma
 vle32.vv16, (a1)
 slli   t4, t2, 2
 vlse32.v   v20, (a2), t1
@@ -109,7 +109,7 @@ endfunc
 // (a0) = (a1) * (a2) + (a3) [0..a4-1]
 func ff_vector_fmul_add_rvv, zve32f
 1:
-vsetvli   t0, a4, e32, m1, ta, ma
+vsetvli   t0, a4, e32, m8, ta, ma
 vle32.v   v8, (a1)
 sub   a4, a4, t0
 vle32.v   v16, (a2)
@@ -131,7 +131,7 @@ func ff_vector_fmul_reverse_rvv, zve32f
 li   t2, -4 // byte stride
 addi a2, a2, -4
 1:
-vsetvli  t0, a3, e32, m1, ta, ma
+vsetvli  t0, a3, e32, m8, ta, ma
 slli t1, t0, 2
 vle32.v  v16, (a1)
 sub  a3, a3, t0
@@ -149,7 +149,7 @@ endfunc
 // (a0) = (a0) + (a1), (a1) = (a0) - (a1) [0..a2-1]
 func ff_butterflies_float_rvv, zve32f
 1:
-vsetvli  t0, a2, e32, m1, ta, ma
+vsetvli  t0, a2, e32, m8, ta, ma
 vle32.v  v16, (a0)
 sub  a2, a2, t0
 vle32.v  v24, (a1)
@@ -188,7 +188,7 @@ endfunc
 // (a0) = (a1) * (a2) [0..a3-1]
 func ff_vector_dmul_rvv, zve64d
 1:
-vsetvli  t0, a3, e64, m1, ta, ma
+vsetvli  t0, a3, e64, m8, ta, ma
 vle64.v  v16, (a1)
 sub  a3, a3, t0
 vle64.v  v24, (a2)
@@ -207,7 +207,7 @@ func ff_vector_dmac_scalar_rvv, zve64d
 NOHWD   fmv.d.x   fa0, a2
 NOHWD   mva2, a3
 1:
-vsetvli   t0, a2, e64, m1, ta, ma
+vsetvli   t0, a2, e64, m8, ta, ma
 vle64.v   v24, (a1)
 sub   a2, a2, t0
 vle64.v   v16, (a0)
@@ -225,7 +225,7 @@ func ff_vector_dmul_scalar_rvv, zve64d
 NOHWD   fmv.d.x  fa0, a2
 NOHWD   mv   a2, a3
 1:
-vsetvli  t0, a2, e64, m1, ta, ma
+vsetvli  t0, a2, e64, m8, ta, ma
 vle64.v  v16, (a1)
 sub  a2, a2, t0
 vfmul.vf v16, v16, fa0
-- 
2.40.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 4/7] checkasm: use pointers for start/stop functions

2023-07-17 Thread Lynne
Jul 17, 2023, 07:18 by r...@remlab.net:

> Le sunnuntaina 16. heinäkuuta 2023, 23.32.21 EEST Lynne a écrit :
>
>> Introducing additional overhead in the form of a dereference is a point
>> where instability can creep in. Can you guarantee that a context will
>> always remain in L1D cache,
>>
>
> L1D is not involved here. In version 2, the pointers are cached locally.
>
>> as opposed to just reading the raw CPU timing
>> directly where that's supported.
>>
>
> Of course not. Raw CPU timing is subject to noise from interrupts (and 
> whatever those interrupts trigger). And that's not just theoretical. I've 
> experienced it and it sucks. Raw CPU timing is much noisier than Linux perf.
>
> And because it has also been proven vastly insecure, it's been disabled on 
> Arm 
> for a long time, and is being disabled on RISC-V too now.
>
>> > But I still argue that that is, either way, completely negligible compared
>> > to the *existing* overhead. Each loop is making 4 system calls, and each
>> > of those system call requires a direct call (to PLT) and an indirect
>> > branch (from GOT). If you have a problem with the two additional function
>> > calls, then you can't be using Linux perf in the first place.
>>
>> You don't want to ever use linux perf in the first place, it's second class.
>>
>
> No it isn't. The interface is more involved than just reading a CSR; and sure 
> I'd prefer the simple interface that RDCYCLE is all other things being equal. 
> But other things are not equal. Linux perf is in fact *more* accurate by 
> virtue of not *wrongly* counting other things. And it does not threaten the 
> security of the entire system, so it will work inside a rented VM or an 
> unprivileged process.
>

Threaten? This is a development tool first and foremost.
If anyone doesn't want to use rdcycle, they can use linux perf, it still works,
with or without the patch.


>> I don't think it's worth changing the direct inlining we had before. You're
>> not interested in whether or not the same exact code is ran between
>> platforms,
>>
>
> Err, I am definitely interested in doing exactly that. I don't want to have 
> to 
> reconfigure and recompile the entire FFmpeg just to switch between Linux perf 
> and raw cycle counter. A contrario, I *do* want to compare performance 
> between 
> vendors once the hardware is available.
>

That's a weak reason to compromise the accuracy of a development tool.


>> just that the code that's measuring timing is as efficient and
>> low overhead as possible.
>>
>
> Of course not. Low overhead is irrelevant here. The measurement overhead is 
> know and is subtracted. What we need is stable/reproducible overhead, and 
> accurate measurements.
>

Which is what TSC or the equivalent gets you. It's noisy, but that's because
it's better and higher accuracy than having to roundtrip through the kernel.


> And that's assuming the stuff works at all. You can argue that we should use 
> Arm PMU and RISC-V RDCYCLE, and that Linux perf sucks, all you want. PMU 
> access will just throw a SIGILL and end the checkasm process with zero 
> measurements. The rest of the industry wants to use system calls for informed 
> reasons. I don't think you, or even the whole FFmpeg project, can win that 
> argument against OS and CPU vendors.
>

Either way, I don't agree with this patch, not accepting it.
___
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] lavu/float_dsp: rework RISC-V V scalar product

2023-07-17 Thread Rémi Denis-Courmont
Le maanantaina 17. heinäkuuta 2023, 20.25.57 EEST Rémi Denis-Courmont a écrit 
:
> 1) Take the reductive sum out of the loop,
>leaving a regular vector addition in the loop.
> 2) Merge the addition and the multiplication.
> 3) Unroll.
> 
> Before:
> scalarproduct_float_rvv_f32: 832.5
> 
> After:
> scalarproduct_float_rvv_f32: 275.2
> ---
>  libavutil/riscv/float_dsp_rvv.S | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/libavutil/riscv/float_dsp_rvv.S
> b/libavutil/riscv/float_dsp_rvv.S index 77961b7387..c80fde2f7e 100644
> --- a/libavutil/riscv/float_dsp_rvv.S
> +++ b/libavutil/riscv/float_dsp_rvv.S
> @@ -166,20 +166,21 @@ endfunc
> 
>  // a0 = (a0).(a1) [0..a2-1]
>  func ff_scalarproduct_float_rvv, zve32f
> -vsetivli zero, 1, e32, m1, ta, ma
> -vmv.s.x  v8, zero
> +vsetvli  t0, zero, e32, m8, ta, ma
> +vmv.v.x  v8, zero
> +vmv.s.x  v0, zero
>  1:
> -vsetvli  t0, a2, e32, m1, ta, ma
> +vsetvli  t0, a2, e32, m8, tu, ma
>  vle32.v  v16, (a0)
>  sub  a2, a2, t0
>  vle32.v  v24, (a1)
>  sh2add   a0, t0, a0
> -vfmul.vv v16, v16, v24
> +vfmacc.vvv8, v16, v24
>  sh2add   a1, t0, a1
> -vfredusum.vs v8, v16, v8
>  bnez a2, 1b
> 
> -vfmv.f.s fa0, v8
> +vfredusum.vs v0, v8, v0

Missing vsetvli; this won't work unless the input vector size is a multiple of 
the hardware vector length.

> +vfmv.f.s fa0, v0
>  NOHWF   fmv.x.w  a0, fa0
>  ret
>  endfunc


-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



___
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 4/7] checkasm: use pointers for start/stop functions

2023-07-17 Thread Rémi Denis-Courmont
Le maanantaina 17. heinäkuuta 2023, 20.48.40 EEST Lynne a écrit :
> >> > But I still argue that that is, either way, completely negligible
> >> > compared
> >> > to the *existing* overhead. Each loop is making 4 system calls, and
> >> > each
> >> > of those system call requires a direct call (to PLT) and an indirect
> >> > branch (from GOT). If you have a problem with the two additional
> >> > function
> >> > calls, then you can't be using Linux perf in the first place.
> >> 
> >> You don't want to ever use linux perf in the first place, it's second
> >> class.> 
> > No it isn't. The interface is more involved than just reading a CSR; and
> > sure I'd prefer the simple interface that RDCYCLE is all other things
> > being equal. But other things are not equal. Linux perf is in fact *more*
> > accurate by virtue of not *wrongly* counting other things. And it does
> > not threaten the security of the entire system, so it will work inside a
> > rented VM or an unprivileged process.
> 
> Threaten?

User-space access to the cycle counter has been deemed a security threat due 
to the Cycle Drift attack, and is disabled as of OpenSBI 1.3.

If FFmpeg does not support Linux perf, FFmpeg will get _no_ performance 
benchmarks on Linux.

> This is a development tool first and foremost.

A development tool is not a justification for leaving a security whole in the 
system. I don't make the rules, and you don't either. OpenSBI and Linux make 
them.

> If anyone doesn't want to use rdcycle, they can use linux perf, it still
> works, with or without the patch.

It does not.

> >> I don't think it's worth changing the direct inlining we had before.
> >> You're
> >> not interested in whether or not the same exact code is ran between
> >> platforms,
> > 
> > Err, I am definitely interested in doing exactly that. I don't want to
> > have to reconfigure and recompile the entire FFmpeg just to switch
> > between Linux perf and raw cycle counter. A contrario, I *do* want to
> > compare performance between vendors once the hardware is available.
> 
> That's a weak reason to compromise the accuracy of a development tool.

This is not compromising any accuracy of any development tool. Again, in a 
scenario where both RDCYCLE and Linux perf work, Linux perf is more accurate 
for reasons that I already outlined in previous messages. And on systems with 
newer OpenSBI and kernel, RDCYCLE does not work at all.

> >> just that the code that's measuring timing is as efficient and
> >> low overhead as possible.
> > 
> > Of course not. Low overhead is irrelevant here. The measurement overhead
> > is know and is subtracted. What we need is stable/reproducible overhead,
> > and accurate measurements.
> 
> Which is what TSC or the equivalent gets you. It's noisy, but that's because
> it's better and higher accuracy than having to roundtrip through the
> kernel.

We _could_ use RDTIME. That's not blocked.

And while that should be "low overhead", but measuring time is also obviously 
way _less_ accurate than measuring cycles (RDCYCLE), which is in turn _less_ 
accurate than measuring cycles only in user mode and only of the current 
process (Linux perf).

> Either way, I don't agree with this patch, not accepting it.

The only vaguely valid reason you've given is that this should cache the 
function pointers locally, which version 2 does.

All you've done is make it abundantly clear that you don't like Linux perf and 
don't care about the rationale for this patch because it doesn't suit your 
personal preferences, especially on IRC:

20:49 <@Lynne> "security"
20:49 <@Lynne> it's a fucking timer
20:49 <@Lynne> "insecure"
20:51 <@Lynne> computers are very good at knowing how much time has passed, to 
   the point of the speed of light being an issue
20:52 <@Lynne> getting rid of this because some script kiddie could 
potentially 
   figure out a bit by calling this a million times while the CPU 
   is busy is paranoid
20:58 <@Lynne> it's a cache issue, so you fix the cache lifetime, not nerf a 
   timer

And it's not a cache issue. Cycle Drift is not a cache issue, it's an 
instruction timing issue.

Since you're giving zero valid reasons, I'm invoking the TC.

-- 
レミ・デニ-クールモン
http://www.remlab.net/



___
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] [PATCHv2] lavu/float_dsp: rework RISC-V V scalar product

2023-07-17 Thread Rémi Denis-Courmont
1) Take the reductive sum out of the loop,
   leaving a regular vector addition in the loop.
2) Merge the addition and the multiplication.
3) Unroll.

Before:
scalarproduct_float_rvv_f32: 832.5

After:
scalarproduct_float_rvv_f32: 275.2
---
 libavutil/riscv/float_dsp_rvv.S | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S
index 77961b7387..605729b1d4 100644
--- a/libavutil/riscv/float_dsp_rvv.S
+++ b/libavutil/riscv/float_dsp_rvv.S
@@ -166,20 +166,22 @@ endfunc
 
 // a0 = (a0).(a1) [0..a2-1]
 func ff_scalarproduct_float_rvv, zve32f
-vsetivli zero, 1, e32, m1, ta, ma
-vmv.s.x  v8, zero
+vsetvli  t0, zero, e32, m8, ta, ma
+vmv.v.x  v8, zero
+vmv.s.x  v0, zero
 1:
-vsetvli  t0, a2, e32, m1, ta, ma
+vsetvli  t0, a2, e32, m8, tu, ma
 vle32.v  v16, (a0)
 sub  a2, a2, t0
 vle32.v  v24, (a1)
 sh2add   a0, t0, a0
-vfmul.vv v16, v16, v24
+vfmacc.vvv8, v16, v24
 sh2add   a1, t0, a1
-vfredusum.vs v8, v16, v8
 bnez a2, 1b
 
-vfmv.f.s fa0, v8
+vsetvli  t0, zero, e32, m8, ta, ma
+vfredusum.vs v0, v8, v0
+vfmv.f.s fa0, v0
 NOHWF   fmv.x.w  a0, fa0
 ret
 endfunc
-- 
2.40.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] lavc/audiodsp: rework RISC-V V scalar product

2023-07-17 Thread Rémi Denis-Courmont
Take vector reduction out of the loop and unroll.

Before:
audiodsp.scalarproduct_int16_c: 12321.0
audiodsp.scalarproduct_int16_rvv_i32: 4175.7

After:
audiodsp.scalarproduct_int16_c: 12320.5
audiodsp.scalarproduct_int16_rvv_i32: 1230.2
---
 libavcodec/riscv/audiodsp_rvv.S | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S
index af1e07bef9..f7eba2114f 100644
--- a/libavcodec/riscv/audiodsp_rvv.S
+++ b/libavcodec/riscv/audiodsp_rvv.S
@@ -21,21 +21,22 @@
 #include "libavutil/riscv/asm.S"
 
 func ff_scalarproduct_int16_rvv, zve32x
-vsetivlizero, 1, e32, m1, ta, ma
-vmv.s.x v8, zero
+vsetvli t0, zero, e32, m8, ta, ma
+vmv.v.x v8, zero
+vmv.s.x v0, zero
 1:
-vsetvli t0, a2, e16, m1, ta, ma
+vsetvli t0, a2, e16, m4, tu, ma
 vle16.v v16, (a0)
 sub a2, a2, t0
 vle16.v v24, (a1)
 sh1add  a0, t0, a0
-vwmul.vvv0, v16, v24
+vwmacc.vv   v8, v16, v24
 sh1add  a1, t0, a1
-vsetvli zero, t0, e32, m2, ta, ma
-vredsum.vs  v8, v0, v8
 bneza2, 1b
 
-vmv.x.s a0, v8
+vsetvli t0, zero, e32, m8, ta, ma
+vredsum.vs  v0, v8, v0
+vmv.x.s a0, v0
 ret
 endfunc
 
-- 
2.40.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 v2 01/14] vvcdec: add thread executor

2023-07-17 Thread Michael Niedermayer
On Sun, Jul 16, 2023 at 02:28:53PM +0800, Nuo Mi wrote:
> On Mon, Jul 10, 2023 at 3:41 PM Nuo Mi  wrote:
> 
> >
> >
> > On Sun, Jul 9, 2023 at 5:52 AM Michael Niedermayer 
> > wrote:
> >
> >> On Fri, Jul 07, 2023 at 10:05:27PM +0800, Nuo Mi wrote:
> >> > The executor design pattern was inroduced by java
> >> > <
> >> https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/Executor.html
> >> >
> >> > it also adapted by python
> >> > 
> >> > Compared to handcrafted thread pool management, it greatly simplifies
> >> the thread code.
> >> > ---
> >> >  libavcodec/Makefile |   1 +
> >> >  libavcodec/executor.c   | 182 
> >> >  libavcodec/executor.h   |  67 +++
> >> >  libavcodec/vvc/Makefile |   4 +
> >> >  4 files changed, 254 insertions(+)
> >> >  create mode 100644 libavcodec/executor.c
> >> >  create mode 100644 libavcodec/executor.h
> >> >  create mode 100644 libavcodec/vvc/Makefile
> >>
> >> This seems to need some fallback if pthreads are unavailable
> >>
> >> src/libavcodec/executor.c: In function ‘executor_worker_task’:
> >> src/libavcodec/executor.c:64:5: error: implicit declaration of function
> >> ‘pthread_mutex_lock’; did you mean ‘ff_mutex_lock’?
> >> [-Werror=implicit-function-declaration]
> >>  pthread_mutex_lock(&e->lock);
> >>  ^~
> >>  ff_mutex_lock
> >> ...
> >> cc1: some warnings being treated as errors
> >> ffmpeg/ffbuild/common.mak:81: recipe for target 'libavcodec/executor.o'
> >> failed
> >> make: *** [libavcodec/executor.o] Error 1
> >> make: *** Waiting for unfinished jobs
> >>
> >> thx
> >>
> >> [...]
> >> --
> >> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >>
> >> Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
> >> ___
> >> 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".
> >>
> > Hi Michael,
> > Thank you for the information. I will fixed it
> >
> 
> Hi Michael,
> FFmpeg application has a dependency on threads
> Once I --disable-pthreads, I can't build ffmpeg for the decoder md5 test.
> Could you share with me how to test the decoder when we disabled threads?

it seems this failure occurred on a ppc cross compile
../configure --target-os=linux --enable-cross-compile --disable-iconv 
--disable-pthreads && make -j32

but its reproduceable on ubuntu x86-64 with a simple
 make distclean ; ./configure   --disable-pthreads && make -j32


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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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] lavu: add AVVideoHint API

2023-07-17 Thread Stefano Sabatini
On date Monday 2023-07-10 12:51:25 +, Carotti, Elias wrote:
> On Mon, 2023-07-10 at 08:13 +, Carotti, Elias wrote:
> > 
> 
> > AVVideoHint is a bad name for something like this.
> > Could you borrow some wording from graphics and call it
> > AVVideoDamagedHint or maybe AVVideoChangedAreaHint or a combination
> > of both?
> > I'd prefer the former, damage is standard language in graphics
> > circles about what has changed since the last frame.
> > 
> > Hi,
> > I have no strong objections on this. Personally I also like the
> > AVVideoDamagedHint name best, my only concern is that it is strictly
> > related to the current use/implementation 
> > (it's true right now that's the only kind of hint) while it may turn
> > out to be a bad naming decision should other forms of hinting for the
> > encoder be added in the future.
> > That said, I am fine with the change too.

AVVideoDamagedHint would be too specific (what if we want to add
"hinting" for different things?).

> > Elias
> > 
> 
> I added a type to the AVVideoRect struct. This should solve the naming
> issue above while preserving the possibility to extend this to
> different hinting types.
> These are the only changes to Anton's version.
> Best
> Elias
> 
>  
> 
> 
> 
> 
> 
> NICE SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle 
> Imprese di Milano Monza Brianza Lodi REA n. 2096882, Capitale Sociale: 
> 10.329,14 EUR i.v., Cod. Fisc. e P.IVA 01133050052, Societa con Socio Unico
> 
> 

> From 8ef4f97410a6b78df048b71d9921a763da6255b3 Mon Sep 17 00:00:00 2001
> From: Elias Carotti 
> Date: Mon, 10 Jul 2023 14:34:53 +0200
> Subject: [PATCH] Add side data type to provide hint to the video encoders
>  about unchanged portions of each frame.
> 
> Signed-off-by: Anton Khirnov 
> ---
>  doc/APIchanges |   3 ++
>  libavutil/Makefile |   2 +
>  libavutil/frame.h  |  10 
>  libavutil/version.h|   2 +-
>  libavutil/video_hint.c |  82 +
>  libavutil/video_hint.h | 117 +
>  6 files changed, 215 insertions(+), 1 deletion(-)
>  create mode 100644 libavutil/video_hint.c
>  create mode 100644 libavutil/video_hint.h
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 27f835cfce..0cda51fdee 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
>  
>  API changes, most recent first:
>  
> +2023-07-xx - xx - lavu 58.15.100 - video_hint.h
> +  Add AVVideoHint API.
> +
>  2023-07-05 - xx - lavu 58.14.100 - random_seed.h
>Add av_random_bytes()
>  
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index bd9c6f9e32..7828c94dc5 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -91,6 +91,7 @@ HEADERS = adler32.h 
> \
>tea.h \
>tx.h  \
>film_grain_params.h   \
> +  video_hint.h
>  
>  ARCH_HEADERS = bswap.h  \
> intmath.h\
> @@ -181,6 +182,7 @@ OBJS = adler32.o  
>   \
> uuid.o   \
> version.o\
> video_enc_params.o   \
> +   video_hint.o \
> film_grain_params.o  \
>  
>  
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index a491315f25..c0c1b23db7 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -214,6 +214,16 @@ enum AVFrameSideDataType {
>   * Ambient viewing environment metadata, as defined by H.274.
>   */
>  AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
> +
> +/**
> + * Provide encoder-specific hinting information about changed/unchanged
> + * portions of a frame.  It can be used to pass information about which
> + * macroblocks can be skipped because they didn't change from the
> + * corresponding ones in the previous frame. This could be useful for
> + * applications which know this information in advance to speed up
> + * encoding.
> + */
> +AV_FRAME_DATA_VIDEO_HINT,
>  };
>  
>  enum AVActiveFormatDescription {
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 24af520e08..9e798b0e3f 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  58
> -#define LIBAVUTIL_VERSION_MINOR  14
> +#define LIBAVUTIL_VERSION_MINOR  15
>  #define LIBAVUTIL_VERSION_MICRO 100
>  
>  #define LIBAVUTIL_VERSION_INT  

Re: [FFmpeg-devel] git email hook

2023-07-17 Thread Michael Niedermayer
On Sun, Jul 16, 2023 at 11:51:23AM +0200, Nicolas George wrote:
> Michael Niedermayer (12023-07-15):
> > COMBINED_REFCHANGE_REVISION_SUBJECT_TEMPLATE = (
> > '%(emailprefix)s%(refname_type)s %(short_refname)s updated: %(oneline)s'
> > )
> 
> Setting this to:
> 
> '%(emailprefix)s %(oneline)s (%(refname_type)s %(short_refname))'

will update the script before next pushing to avradio


> 
> would yield:
> 
> [ffmpeg-radio] avradio/sdrdemux: Some corrections to the FM stereo side 
> channel (branch master)
> 
> instead of:
> 
> [ffmpeg-radio] branch master updated: avradio/sdrdemux: Some corrections to 
> the FM stereo side channel
> 
> and is much closer to what we have now.
> 

> Maybe also get rid of %(emailprefix)s, since the mailing-list will add
> its own.

This might confuse people

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban


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


[FFmpeg-devel] [PATCH] Changelog: Add Enhanced FLV format

2023-07-17 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 Changelog | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Changelog b/Changelog
index 3876082844..db79ae150d 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
 - Raw VVC bitstream parser, muxer and demuxer
 - Bitstream filter for editing metadata in VVC streams
 - Bitstream filter for converting VVC from MP4 to Annex B
+- Enhanced FLV format
 
 version 6.0:
 - Radiance HDR image support
-- 
2.40.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 v2 1/6] avcodec/cbs_av1: Add tx mode enum values

2023-07-17 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavcodec/av1.h | 7 +++
 libavcodec/cbs_av1_syntax_template.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/av1.h b/libavcodec/av1.h
index 384f7cddc7..8704bc41c1 100644
--- a/libavcodec/av1.h
+++ b/libavcodec/av1.h
@@ -175,6 +175,13 @@ enum {
 AV1_RESTORE_SWITCHABLE = 3,
 };
 
+// TX mode (section 6.8.21)
+enum {
+AV1_ONLY_4X4= 0,
+AV1_TX_MODE_LARGEST = 1,
+AV1_TX_MODE_SELECT  = 2,
+};
+
 // Sequence Headers are actually unbounded because one can use
 // an arbitrary number of leading zeroes when encoding via uvlc.
 // The following estimate is based around using the lowest number
diff --git a/libavcodec/cbs_av1_syntax_template.c 
b/libavcodec/cbs_av1_syntax_template.c
index a747e17784..3a5cafbfb7 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1028,9 +1028,9 @@ static int FUNC(read_tx_mode)(CodedBitstreamContext *ctx, 
RWContext *rw,
 int err;
 
 if (priv->coded_lossless)
-infer(tx_mode, 0);
+infer(tx_mode, AV1_ONLY_4X4);
 else
-increment(tx_mode, 1, 2);
+increment(tx_mode, AV1_TX_MODE_LARGEST, AV1_TX_MODE_SELECT);
 
 return 0;
 }
-- 
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 v2 2/6] lavc/av1: Add common code and unit test for level handling

2023-07-17 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavcodec/Makefile|   4 +-
 libavcodec/av1_profile_level.c |  91 
 libavcodec/av1_profile_level.h |  58 +++
 libavcodec/tests/.gitignore|   1 +
 libavcodec/tests/av1_levels.c  | 124 +
 tests/fate/libavcodec.mak  |   5 ++
 6 files changed, 282 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/av1_profile_level.c
 create mode 100644 libavcodec/av1_profile_level.h
 create mode 100644 libavcodec/tests/av1_levels.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1b0226c089..3cd5997e64 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -30,6 +30,7 @@ HEADERS = ac3_parser.h
  \
 OBJS = ac3_parser.o \
adts_parser.o\
allcodecs.o  \
+   av1_profile_level.o  \
avcodec.o\
avdct.o  \
avpacket.o   \
@@ -1308,7 +1309,8 @@ SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan.h 
vulkan_video.h vulkan_decode.
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
v4l2_m2m.h
 SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
-TESTPROGS = avcodec \
+TESTPROGS = av1_levels  \
+avcodec \
 avpacket\
 bitstream_be\
 bitstream_le\
diff --git a/libavcodec/av1_profile_level.c b/libavcodec/av1_profile_level.c
new file mode 100644
index 00..5aacf6ddb0
--- /dev/null
+++ b/libavcodec/av1_profile_level.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2023 Intel Corporation
+ *
+ * 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/common.h"
+#include "av1_profile_level.h"
+
+/** ignore entries which named in spec but no details. Like level 2.2 and 7.0. 
*/
+static const AV1LevelDescriptor av1_levels[] = {
+// Name  MaxVSize   MainMbps   
   MaxTiles
+// |  level_idx | MaxDisplayRate| 
HighMbps | MaxTileCols
+// |  |   MaxPicSize|   | MaxDecodeRate || 
  MainCR|   |
+// |  | |MaxHSize   |   |   | MaxHeaderRate || 
| HighCR|   |
+// |  | ||  |   |   |   |   || 
|  ||   |
+{ "2.0",  0,   147456,  2048, 1152,   4423680, 5529600, 150,   1.5,
 0, 2, 0,   8,  4 },
+{ "2.1",  1,   278784,  2816, 1584,   8363520,10454400, 150,   3.0,
 0, 2, 0,   8,  4 },
+{ "3.0",  4,   665856,  4352, 2448,  19975680,24969600, 150,   6.0,
 0, 2, 0,  16,  6 },
+{ "3.1",  5,  1065024,  5504, 3096,  31950720,39938400, 150,  10.0,
 0, 2, 0,  16,  6 },
+{ "4.0",  8,  2359296,  6144, 3456,  70778880,77856768, 300,  12.0,  
30.0, 4, 4,  32,  8 },
+{ "4.1",  9,  2359296,  6144, 3456,  141557760,  155713536, 300,  20.0,  
50.0, 4, 4,  32,  8 },
+{ "5.0", 12,  8912896,  8192, 4352,  267386880,  273715200, 300,  30.0, 
100.0, 6, 4,  64,  8 },
+{ "5.1", 13,  8912896,  8192, 4352,  534773760,  547430400, 300,  40.0, 
160.0, 8, 4,  64,  8 },
+{ "5.2", 14,  8912896,  8192, 4352, 1069547520, 1094860800, 300,  60.0, 
240.0, 8, 4,  64,  8 },
+{ "5.3", 15,  8912896,  8192, 4352, 1069547520, 1176502272, 300,  60.0, 
240.0, 8, 4,  64,  8 },
+{ "6.0", 16, 35651584, 16384, 8704, 1069547520, 1176502272, 300,  60.0, 
240.0, 8, 4, 128, 16 },
+{ "6.1", 17, 35651584, 16384, 8704, 2139095040, 2189721600, 300, 100.0, 
480.0, 8, 4, 128, 16 },
+{ "6.2", 18, 35651584, 16384, 8704, 4278

[FFmpeg-devel] [PATCH v2 3/6] lavc/vaapi_encode: Init pic at the beginning of API

2023-07-17 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index bfca315a7a..8c9f14df66 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1205,7 +1205,7 @@ fail:
 int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
 {
 VAAPIEncodeContext *ctx = avctx->priv_data;
-VAAPIEncodePicture *pic;
+VAAPIEncodePicture *pic = NULL;
 AVFrame *frame = ctx->frame;
 int err;
 
@@ -1228,8 +1228,6 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 }
 
 if (ctx->has_sync_buffer_func) {
-pic = NULL;
-
 if (av_fifo_can_write(ctx->encode_fifo)) {
 err = vaapi_encode_pick_next(avctx, &pic);
 if (!err) {
@@ -1255,7 +1253,6 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 av_fifo_read(ctx->encode_fifo, &pic, 1);
 ctx->encode_order = pic->encode_order + 1;
 } else {
-pic = NULL;
 err = vaapi_encode_pick_next(avctx, &pic);
 if (err < 0)
 return err;
-- 
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 v2 4/6] lavc/vaapi_encode: Extract set output pkt timestamp function

2023-07-17 Thread Fei Wang
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c | 37 -
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 8c9f14df66..c8545cd8db 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -650,6 +650,27 @@ fail_at_end:
 return err;
 }
 
+static int vaapi_encode_set_output_timestamp(AVCodecContext *avctx,
+ VAAPIEncodePicture *pic,
+ AVPacket *pkt)
+{
+VAAPIEncodeContext *ctx = avctx->priv_data;
+
+if (ctx->output_delay == 0) {
+pkt->dts = pkt->pts;
+} else if (pic->encode_order < ctx->decode_delay) {
+if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff)
+pkt->dts = INT64_MIN;
+else
+pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
+} else {
+pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
+(3 * ctx->output_delay + ctx->async_depth)];
+}
+
+return 0;
+}
+
 static int vaapi_encode_output(AVCodecContext *avctx,
VAAPIEncodePicture *pic, AVPacket *pkt)
 {
@@ -1273,19 +1294,9 @@ int ff_vaapi_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt)
 return err;
 }
 
-if (ctx->output_delay == 0) {
-pkt->dts = pkt->pts;
-} else if (pic->encode_order < ctx->decode_delay) {
-if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff)
-pkt->dts = INT64_MIN;
-else
-pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
-} else {
-pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
-(3 * ctx->output_delay + ctx->async_depth)];
-}
-av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts 
%"PRId64".\n",
-   pkt->pts, pkt->dts);
+vaapi_encode_set_output_timestamp(avctx, pic, pkt);
+av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64", dts %"PRId64", "
+   "size %u bytes.\n", pkt->pts, pkt->dts, pkt->size);
 
 ctx->output_order = pic->encode_order;
 vaapi_encode_clear_old(avctx);
-- 
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 v2 5/6] lavc/vaapi_encode: Separate reference frame into previous/future list

2023-07-17 Thread Fei Wang
To support more reference frames from different directions.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c   | 112 +---
 libavcodec/vaapi_encode.h   |  15 +++--
 libavcodec/vaapi_encode_h264.c  |  94 +--
 libavcodec/vaapi_encode_h265.c  |  76 +-
 libavcodec/vaapi_encode_mpeg2.c |   6 +-
 libavcodec/vaapi_encode_vp8.c   |   6 +-
 libavcodec/vaapi_encode_vp9.c   |  26 
 7 files changed, 208 insertions(+), 127 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index c8545cd8db..2604f12b9e 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -276,21 +276,34 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
-if (pic->nb_refs == 0) {
+if (pic->nb_refs[0] == 0 && pic->nb_refs[1] == 0) {
 av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
 } else {
-av_log(avctx, AV_LOG_DEBUG, "Refers to:");
-for (i = 0; i < pic->nb_refs; i++) {
+av_log(avctx, AV_LOG_DEBUG, "L0 refers to");
+for (i = 0; i < pic->nb_refs[0]; i++) {
 av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
-   pic->refs[i]->display_order, pic->refs[i]->encode_order);
+   pic->refs[0][i]->display_order, 
pic->refs[0][i]->encode_order);
 }
 av_log(avctx, AV_LOG_DEBUG, ".\n");
+
+if (pic->nb_refs[1]) {
+av_log(avctx, AV_LOG_DEBUG, "L1 refers to");
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
+   pic->refs[1][i]->display_order, 
pic->refs[1][i]->encode_order);
+}
+av_log(avctx, AV_LOG_DEBUG, ".\n");
+}
 }
 
 av_assert0(!pic->encode_issued);
-for (i = 0; i < pic->nb_refs; i++) {
-av_assert0(pic->refs[i]);
-av_assert0(pic->refs[i]->encode_issued);
+for (i = 0; i < pic->nb_refs[0]; i++) {
+av_assert0(pic->refs[0][i]);
+av_assert0(pic->refs[0][i]->encode_issued);
+}
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_assert0(pic->refs[1][i]);
+av_assert0(pic->refs[1][i]->encode_issued);
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
@@ -832,8 +845,12 @@ static void vaapi_encode_add_ref(AVCodecContext *avctx,
 
 if (is_ref) {
 av_assert0(pic != target);
-av_assert0(pic->nb_refs < MAX_PICTURE_REFERENCES);
-pic->refs[pic->nb_refs++] = target;
+av_assert0(pic->nb_refs[0] < MAX_PICTURE_REFERENCES &&
+   pic->nb_refs[1] < MAX_PICTURE_REFERENCES);
+if (target->display_order < pic->display_order)
+pic->refs[0][pic->nb_refs[0]++] = target;
+else
+pic->refs[1][pic->nb_refs[1]++] = target;
 ++refs;
 }
 
@@ -862,10 +879,16 @@ static void vaapi_encode_remove_refs(AVCodecContext 
*avctx,
 if (pic->ref_removed[level])
 return;
 
-for (i = 0; i < pic->nb_refs; i++) {
-av_assert0(pic->refs[i]);
---pic->refs[i]->ref_count[level];
-av_assert0(pic->refs[i]->ref_count[level] >= 0);
+for (i = 0; i < pic->nb_refs[0]; i++) {
+av_assert0(pic->refs[0][i]);
+--pic->refs[0][i]->ref_count[level];
+av_assert0(pic->refs[0][i]->ref_count[level] >= 0);
+}
+
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_assert0(pic->refs[1][i]);
+--pic->refs[1][i]->ref_count[level];
+av_assert0(pic->refs[1][i]->ref_count[level] >= 0);
 }
 
 for (i = 0; i < pic->nb_dpb_pics; i++) {
@@ -910,7 +933,7 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 vaapi_encode_add_ref(avctx, pic, end,   1, 1, 0);
 vaapi_encode_add_ref(avctx, pic, prev,  0, 0, 1);
 
-for (ref = end->refs[1]; ref; ref = ref->refs[1])
+for (ref = end->refs[1][0]; ref; ref = ref->refs[1][0])
 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
 }
 *last = prev;
@@ -933,7 +956,7 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 vaapi_encode_add_ref(avctx, pic, end,   1, 1, 0);
 vaapi_encode_add_ref(avctx, pic, prev,  0, 0, 1);
 
-for (ref = end->refs[1]; ref; ref = ref->refs[1])
+for (ref = end->refs[1][0]; ref; ref = ref->refs[1][0])
 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
 
 if (i > 1)
@@ -947,11 +970,44 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 }
 }
 
+static void vaapi_encode_add_next_prev(AVCodecContext *avctx,
+   VAAPIEncodePicture *pic)
+{
+VAAPIEncodeContext *ctx = avctx->priv_data;
+int i;

[FFmpeg-devel] [PATCH v2 6/6] lavc/vaapi_encode: Add VAAPI AV1 encoder

2023-07-17 Thread Fei Wang
Signed-off-by: Fei Wang 
---
update
1. set color_range in sequence header.

 Changelog |1 +
 configure |3 +
 doc/encoders.texi |   13 +
 libavcodec/Makefile   |1 +
 libavcodec/allcodecs.c|1 +
 libavcodec/vaapi_encode.c |  125 +++-
 libavcodec/vaapi_encode.h |   12 +
 libavcodec/vaapi_encode_av1.c | 1229 +
 8 files changed, 1367 insertions(+), 18 deletions(-)
 create mode 100644 libavcodec/vaapi_encode_av1.c

diff --git a/Changelog b/Changelog
index 3876082844..7ae9b85d52 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
 - Raw VVC bitstream parser, muxer and demuxer
 - Bitstream filter for editing metadata in VVC streams
 - Bitstream filter for converting VVC from MP4 to Annex B
+- VAAPI AV1 encoder
 
 version 6.0:
 - Radiance HDR image support
diff --git a/configure b/configure
index b018abf139..fbc729b5c6 100755
--- a/configure
+++ b/configure
@@ -3323,6 +3323,8 @@ av1_qsv_decoder_select="qsvdec"
 av1_qsv_encoder_select="qsvenc"
 av1_qsv_encoder_deps="libvpl"
 av1_amf_encoder_deps="amf"
+av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
+av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
 
 # parsers
 aac_parser_select="adts_header mpeg4audio"
@@ -7104,6 +7106,7 @@ if enabled vaapi; then
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
 check_type "va/va.h va/va_enc_vp9.h"  "VAEncPictureParameterBufferVP9"
+check_type "va/va.h va/va_enc_av1.h"  "VAEncPictureParameterBufferAV1"
 fi
 
 if enabled_all opencl libdrm ; then
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 25d6b7f09e..fb331ebd8e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3991,6 +3991,19 @@ Average variable bitrate.
 Each encoder also has its own specific options:
 @table @option
 
+@item av1_vaapi
+@option{profile} sets the value of @emph{seq_profile}.
+@option{tier} sets the value of @emph{seq_tier}.
+@option{level} sets the value of @emph{seq_level_idx}.
+
+@table @option
+@item tiles
+Set the number of tiles to encode the input video with, as columns x rows.
+(default is 1x1).
+@item tile_groups
+Set tile groups number (default is 1).
+@end table
+
 @item h264_vaapi
 @option{profile} sets the value of @emph{profile_idc} and the 
@emph{constraint_set*_flag}s.
 @option{level} sets the value of @emph{level_idc}.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd5997e64..fe1e6aa99d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -259,6 +259,7 @@ OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_AV1_MEDIACODEC_ENCODER)  += mediacodecenc.o
 OBJS-$(CONFIG_AV1_NVENC_ENCODER)   += nvenc_av1.o nvenc.o
 OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
+OBJS-$(CONFIG_AV1_VAAPI_ENCODER)   += vaapi_encode_av1.o 
av1_profile_level.o
 OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
 OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
 OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8775d15a4f..c43c1d7b48 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -844,6 +844,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
 extern const FFCodec ff_h264_amf_encoder;
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 2604f12b9e..2907e159fb 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -669,6 +669,15 @@ static int 
vaapi_encode_set_output_timestamp(AVCodecContext *avctx,
 {
 VAAPIEncodeContext *ctx = avctx->priv_data;
 
+// AV1 packs P frame and next B frame into one pkt, and uses the other
+// repeat frame header pkt at the display order position of the P frame
+// to indicate its frame index. Each frame has a corresponding pkt in its
+// display order position. So don't need to consider delay for AV1 
timestamp.
+if (avctx->codec_id == AV_CODEC_ID_AV1) {
+pkt->dts = pkt->pts - ctx->dts_pts_diff;
+return 0;
+}
+
 if (ctx->output_delay == 0) {
 pkt->dts = pkt->pts;
 } else if (pic->encode_order < ctx->decode_delay) {
@@ -689,9 +698,10 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 {
 VAAPIEncodeContext *ctx = avctx->priv_data;
 VACodedBufferSegment *buf_list, *buf;
-VAStatus vas;
+AVPacket *pkt_ptr = pkt;
 int total_size = 0;
 uint8_t *ptr;
+VAStatus vas;
 int err;
 
 err = vaapi_encode_wait(avctx, pic);
@@ -711,11 +721,52 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 for (buf = buf_list; buf; buf = buf->next)
   

Re: [FFmpeg-devel] [PATCH v1 6/6] lavc/vaapi_encode: Add VAAPI AV1 encoder

2023-07-17 Thread Wang, Fei W
On Mon, 2023-07-17 at 13:12 +0200, David Rosca wrote:
> On Mon, Jul 10, 2023 at 9:40 AM Fei Wang
>  wrote:
> > Signed-off-by: Fei Wang 
> > ---
> >  Changelog |1 +
> >  configure |3 +
> >  doc/encoders.texi |   13 +
> >  libavcodec/Makefile   |1 +
> >  libavcodec/allcodecs.c|1 +
> >  libavcodec/vaapi_encode.c |  125 +++-
> >  libavcodec/vaapi_encode.h |   12 +
> >  libavcodec/vaapi_encode_av1.c | 1228
> > +
> >  8 files changed, 1366 insertions(+), 18 deletions(-)
> >  create mode 100644 libavcodec/vaapi_encode_av1.c
> > 
> > diff --git a/Changelog b/Changelog
> > index 3876082844..7ae9b85d52 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -25,6 +25,7 @@ version :
> >  - Raw VVC bitstream parser, muxer and demuxer
> >  - Bitstream filter for editing metadata in VVC streams
> >  - Bitstream filter for converting VVC from MP4 to Annex B
> > +- VAAPI AV1 encoder
> > 
> >  version 6.0:
> >  - Radiance HDR image support
> > diff --git a/configure b/configure
> > index 0ab0761011..6a1a30aaec 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3323,6 +3323,8 @@ av1_qsv_decoder_select="qsvdec"
> >  av1_qsv_encoder_select="qsvenc"
> >  av1_qsv_encoder_deps="libvpl"
> >  av1_amf_encoder_deps="amf"
> > +av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
> > +av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
> > 
> >  # parsers
> >  aac_parser_select="adts_header mpeg4audio"
> > @@ -7106,6 +7108,7 @@ if enabled vaapi; then
> >  check_type "va/va.h va/va_enc_jpeg.h"
> > "VAEncPictureParameterBufferJPEG"
> >  check_type "va/va.h
> > va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
> >  check_type "va/va.h
> > va/va_enc_vp9.h"  "VAEncPictureParameterBufferVP9"
> > +check_type "va/va.h
> > va/va_enc_av1.h"  "VAEncPictureParameterBufferAV1"
> >  fi
> > 
> >  if enabled_all opencl libdrm ; then
> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index 25d6b7f09e..fb331ebd8e 100644
> > --- a/doc/encoders.texi
> > +++ b/doc/encoders.texi
> > @@ -3991,6 +3991,19 @@ Average variable bitrate.
> >  Each encoder also has its own specific options:
> >  @table @option
> > 
> > +@item av1_vaapi
> > +@option{profile} sets the value of @emph{seq_profile}.
> > +@option{tier} sets the value of @emph{seq_tier}.
> > +@option{level} sets the value of @emph{seq_level_idx}.
> > +
> > +@table @option
> > +@item tiles
> > +Set the number of tiles to encode the input video with, as columns
> > x rows.
> > +(default is 1x1).
> > +@item tile_groups
> > +Set tile groups number (default is 1).
> > +@end table
> > +
> >  @item h264_vaapi
> >  @option{profile} sets the value of @emph{profile_idc} and the
> > @emph{constraint_set*_flag}s.
> >  @option{level} sets the value of @emph{level_idc}.
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 3cd5997e64..fe1e6aa99d 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -259,6 +259,7 @@ OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER)  +=
> > mediacodecdec.o
> >  OBJS-$(CONFIG_AV1_MEDIACODEC_ENCODER)  += mediacodecenc.o
> >  OBJS-$(CONFIG_AV1_NVENC_ENCODER)   += nvenc_av1.o nvenc.o
> >  OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
> > +OBJS-$(CONFIG_AV1_VAAPI_ENCODER)   += vaapi_encode_av1.o
> > av1_profile_level.o
> >  OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
> >  OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
> >  OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
> > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> > index 8775d15a4f..c43c1d7b48 100644
> > --- a/libavcodec/allcodecs.c
> > +++ b/libavcodec/allcodecs.c
> > @@ -844,6 +844,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
> >  extern const FFCodec ff_av1_qsv_decoder;
> >  extern const FFCodec ff_av1_qsv_encoder;
> >  extern const FFCodec ff_av1_amf_encoder;
> > +extern const FFCodec ff_av1_vaapi_encoder;
> >  extern const FFCodec ff_libopenh264_encoder;
> >  extern const FFCodec ff_libopenh264_decoder;
> >  extern const FFCodec ff_h264_amf_encoder;
> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index 2604f12b9e..2907e159fb 100644
> > --- a/libavcodec/vaapi_encode.c
> > +++ b/libavcodec/vaapi_encode.c
> > @@ -669,6 +669,15 @@ static int
> > vaapi_encode_set_output_timestamp(AVCodecContext *avctx,
> >  {
> >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > 
> > +// AV1 packs P frame and next B frame into one pkt, and uses
> > the other
> > +// repeat frame header pkt at the display order position of
> > the P frame
> > +// to indicate its frame index. Each frame has a corresponding
> > pkt in its
> > +// display order position. So don't need to consider delay for
> > AV1 timestamp.
> > +if (avctx->codec_id == AV_CODEC_ID_AV1) {
> > +pkt->dts = pkt->pts - ctx->dts_pts_diff;
> > +return 0;
> > +}
> > +
> >  if (ctx->output_delay == 0) {