[FFmpeg-cvslog] lavc/qsvenc: update the selection of bitrate control method

2024-02-28 Thread Haihao Xiang
ffmpeg | branch: master | Haihao Xiang  | Thu Feb  1 
16:35:35 2024 +0800| [d263fce2b209e86a5a1e8f1b6aa33430ecc2c187] | committer: 
Haihao Xiang

lavc/qsvenc: update the selection of bitrate control method

The default method is changed to CQP

Signed-off-by: Haihao Xiang 

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

 Changelog |  1 +
 doc/encoders.texi |  7 --
 libavcodec/qsvenc.c   | 61 +--
 libavcodec/qsvenc_av1.c   |  2 +-
 libavcodec/qsvenc_h264.c  |  2 +-
 libavcodec/qsvenc_hevc.c  |  2 +-
 libavcodec/qsvenc_mpeg2.c |  2 +-
 libavcodec/qsvenc_vp9.c   |  2 +-
 8 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/Changelog b/Changelog
index 610ee61dd6..6e03a49426 100644
--- a/Changelog
+++ b/Changelog
@@ -27,6 +27,7 @@ version :
 - a C11-compliant compiler is now required; note that this requirement
   will be bumped to C17 in the near future, so consider updating your
   build environment if it lacks C17 support
+- Change the default bitrate control method from VBR to CQP for QSV encoders.
 
 version 6.1:
 - libaribcaption decoder
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 9f477d7c53..5f7864770e 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3338,8 +3338,8 @@ quality range is 1 to 51, with 1 being the best quality.
 @end itemize
 
 @item
-Otherwise, a bitrate-based mode is used. For all of those, you should specify 
at
-least the desired average bitrate with the @option{b} option.
+Otherwise when the desired average bitrate is specified with the @option{b}
+option, a bitrate-based mode is used.
 @itemize @minus
 @item
 @var{LA} - VBR with lookahead, when the @option{look_ahead} option is 
specified.
@@ -3360,6 +3360,9 @@ than the average bitrate.
 @option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This
 mode is available for H264 and HEVC on Windows.
 @end itemize
+
+@item
+Otherwise the default ratecontrol method @var{CQP} is used.
 @end itemize
 
 Note that depending on your system, a different mode than the one you specified
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c63b72e384..3a8607fca6 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -597,6 +597,13 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 else if (want_vcm) {
 rc_mode = MFX_RATECONTROL_VCM;
 rc_desc = "video conferencing mode (VCM)";
+
+if (!avctx->bit_rate) {
+av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method 
without "
+   "setting bitrate. Please use the b option to set the 
desired "
+   "bitrate.\n", rc_desc);
+return AVERROR(EINVAL);
+}
 }
 #endif
 else if (want_la) {
@@ -606,32 +613,50 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 if (avctx->global_quality > 0) {
 rc_mode = MFX_RATECONTROL_LA_ICQ;
 rc_desc = "intelligent constant quality with lookahead (LA_ICQ)";
+} else if (!avctx->bit_rate) {
+av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method 
without "
+   "setting bitrate. Please use the b option to set the 
desired "
+   "bitrate.\n", rc_desc);
+return AVERROR(EINVAL);
 }
 }
 else if (avctx->global_quality > 0 && !avctx->rc_max_rate) {
 rc_mode = MFX_RATECONTROL_ICQ;
 rc_desc = "intelligent constant quality (ICQ)";
 }
-else if (avctx->rc_max_rate == avctx->bit_rate) {
-rc_mode = MFX_RATECONTROL_CBR;
-rc_desc = "constant bitrate (CBR)";
-}
+else if (avctx->bit_rate) {
+if (avctx->rc_max_rate == avctx->bit_rate) {
+rc_mode = MFX_RATECONTROL_CBR;
+rc_desc = "constant bitrate (CBR)";
+}
 #if QSV_HAVE_AVBR
-else if (!avctx->rc_max_rate &&
- (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC) &&
- q->avbr_accuracy &&
- q->avbr_convergence) {
-rc_mode = MFX_RATECONTROL_AVBR;
-rc_desc = "average variable bitrate (AVBR)";
-}
+else if (!avctx->rc_max_rate &&
+ (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC) &&
+ q->avbr_accuracy &&
+ q->avbr_convergence) {
+rc_mode = MFX_RATECONTROL_AVBR;
+rc_desc = "average variable bitrate (AVBR)";
+}
 #endif
-else if (avctx->global_quality > 0) {
-rc_mode = MFX_RATECONTROL_QVBR;
-rc_desc = "constant quality with VBR algorithm (QVBR)";
-}
-else {
-rc_mode = MFX_RATECONTROL_VBR;
-rc_desc = "variable bitrate (VBR)";
+else if (avctx->global_quality > 0) {
+rc_mode = MFX_RATECONTROL_QVBR;
+rc_desc = "constant quality with VBR algorithm (QV

[FFmpeg-cvslog] avcodec/av1dec: Move message of OBU info back to the beginning

2024-02-28 Thread Fei Wang
ffmpeg | branch: master | Fei Wang  | Thu Dec 28 09:24:02 
2023 +0800| [3f7e50f53939cfd3153a21f7342c9e65364984dd] | committer: Haihao Xiang

avcodec/av1dec: Move message of OBU info back to the beginning

So that can show OBU info even it doesn't have decomposed content. And
add OBU content status into the message.

Signed-off-by: Fei Wang 

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

 libavcodec/av1dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 7debc4deda..d4bfa3c69c 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -1200,11 +1200,12 @@ static int av1_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 AV1RawOBU *obu = unit->content;
 const AV1RawOBUHeader *header;
 
+av_log(avctx, AV_LOG_DEBUG, "OBU idx:%d, type:%d, content 
available:%d.\n", i, unit->type, !!obu);
+
 if (!obu)
 continue;
 
 header = &obu->header;
-av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, 
unit->type);
 
 switch (unit->type) {
 case AV1_OBU_SEQUENCE_HEADER:

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

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


[FFmpeg-cvslog] avcodec/av1dec: Return error for unsupported tile list OBU

2024-02-28 Thread Fei Wang
ffmpeg | branch: master | Fei Wang  | Thu Dec 28 09:24:03 
2023 +0800| [57fbe929f368e65ff0bfaa3c1df5b1aa3b8b88db] | committer: Haihao Xiang

avcodec/av1dec: Return error for unsupported tile list OBU

Otherwise decoding maybe successful but output result is incorrect.

Signed-off-by: Fei Wang 

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

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

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index d4bfa3c69c..820fa79f48 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -1202,6 +1202,12 @@ static int av1_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 av_log(avctx, AV_LOG_DEBUG, "OBU idx:%d, type:%d, content 
available:%d.\n", i, unit->type, !!obu);
 
+if (unit->type == AV1_OBU_TILE_LIST) {
+av_log(avctx, AV_LOG_ERROR, "Large scale tile decoding is 
unsupported.\n");
+ret = AVERROR_PATCHWELCOME;
+goto end;
+}
+
 if (!obu)
 continue;
 

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

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


[FFmpeg-cvslog] avdevice: deprecate sdl outdev

2024-02-28 Thread J . Dekker
ffmpeg | branch: master | J. Dekker  | Tue Feb 13 08:34:26 
2024 +0100| [2b17a74df5fbbc87cdf7a0a784e2e088ab4afd3c] | committer: J. Dekker

avdevice: deprecate sdl outdev

Signed-off-by: J. Dekker 

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

 doc/outdevs.texi|  8 +++-
 libavdevice/sdl2.c  | 10 ++
 libavdevice/version_major.h |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index 941429a8c8..9ee857528e 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -408,7 +408,13 @@ ffmpeg  -i INPUT -f pulse "stream name"
 
 @section sdl
 
-SDL (Simple DirectMedia Layer) output device.
+SDL (Simple DirectMedia Layer) output device. Deprecated and will be removed.
+
+For monitoring purposes in FFmpeg, pipes and a video player such as ffplay can 
be used:
+
+@example
+ffmpeg -i INPUT -f nut -c:v rawvideo - | ffplay -
+@end example
 
 "sdl2" can be used as alias for "sdl".
 
diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c
index 342a253dc0..ec3c3d19b5 100644
--- a/libavdevice/sdl2.c
+++ b/libavdevice/sdl2.c
@@ -51,6 +51,7 @@ typedef struct {
 SDL_Rect texture_rect;
 
 int inited;
+int warned;
 } SDLContext;
 
 static const struct sdl_texture_format_entry {
@@ -165,6 +166,15 @@ static int sdl2_write_header(AVFormatContext *s)
 int i, ret = 0;
 int flags  = 0;
 
+if (!sdl->warned) {
+av_log(sdl, AV_LOG_WARNING,
+"The sdl output device is deprecated due to being fundamentally 
incompatible with libavformat API. "
+"For monitoring purposes in ffmpeg you can output to a file or use 
pipes and a video player.\n"
+"Example: ffmpeg -i INPUT -f nut -c:v rawvideo - | ffplay -\n"
+);
+sdl->warned = 1;
+}
+
 if (!sdl->window_title)
 sdl->window_title = av_strdup(s->url);
 
diff --git a/libavdevice/version_major.h b/libavdevice/version_major.h
index da5854ed4c..6e04e0939d 100644
--- a/libavdevice/version_major.h
+++ b/libavdevice/version_major.h
@@ -37,5 +37,7 @@
 #define FF_API_BKTR_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
 // reminder to remove the opengl device on next major bump
 #define FF_API_OPENGL_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
+// reminder to remove the sdl2 device on next major bump
+#define FF_API_SDL2_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
 
 #endif /* AVDEVICE_VERSION_MAJOR_H */

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

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


[FFmpeg-cvslog] avdevice: deprecate opengl outdev

2024-02-28 Thread J . Dekker
ffmpeg | branch: master | J. Dekker  | Tue Feb 13 08:34:25 
2024 +0100| [e4c0cdf8df96047ee195cc594a2a93443e2aa25d] | committer: J. Dekker

avdevice: deprecate opengl outdev

Signed-off-by: J. Dekker 

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

 doc/outdevs.texi|  2 +-
 libavdevice/opengl_enc.c| 11 +++
 libavdevice/version_major.h |  2 ++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index f0484bbf8f..941429a8c8 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -302,7 +302,7 @@ ffmpeg -re -i INPUT -c:v rawvideo -pix_fmt bgra -f fbdev 
/dev/fb0
 See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1).
 
 @section opengl
-OpenGL output device.
+OpenGL output device. Deprecated and will be removed.
 
 To enable this output device you need to configure FFmpeg with 
@code{--enable-opengl}.
 
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index b2ac6eb16a..69de6fad03 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -224,6 +224,8 @@ typedef struct OpenGLContext {
 int picture_height;///< Rendered height
 int window_width;
 int window_height;
+
+int warned;
 } OpenGLContext;
 
 static const struct OpenGLFormatDesc {
@@ -1060,6 +1062,15 @@ static av_cold int opengl_write_header(AVFormatContext 
*h)
 AVStream *st;
 int ret;
 
+if (!opengl->warned) {
+av_log(opengl, AV_LOG_WARNING,
+"The opengl output device is deprecated due to being fundamentally 
incompatible with libavformat API. "
+"For monitoring purposes in ffmpeg you can output to a file or use 
pipes and a video player.\n"
+"Example: ffmpeg -i INPUT -f nut -c:v rawvideo - | ffplay -\n"
+);
+opengl->warned = 1;
+}
+
 if (h->nb_streams != 1 ||
 par->codec_type != AVMEDIA_TYPE_VIDEO ||
 (par->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME && par->codec_id != 
AV_CODEC_ID_RAWVIDEO)) {
diff --git a/libavdevice/version_major.h b/libavdevice/version_major.h
index 9f7b79b2ee..da5854ed4c 100644
--- a/libavdevice/version_major.h
+++ b/libavdevice/version_major.h
@@ -35,5 +35,7 @@
 
 // reminder to remove the bktr device on next major bump
 #define FF_API_BKTR_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
+// reminder to remove the opengl device on next major bump
+#define FF_API_OPENGL_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62)
 
 #endif /* AVDEVICE_VERSION_MAJOR_H */

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

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


[FFmpeg-cvslog] avcodec/aarch64/hevc: add luma deblock NEON

2024-02-28 Thread J . Dekker
ffmpeg | branch: master | J. Dekker  | Tue Feb 13 01:09:28 
2024 +0100| [570052cd2a38200ae6aca52e817517513812ec56] | committer: J. Dekker

avcodec/aarch64/hevc: add luma deblock NEON

Benched using single-threaded full decode on an Ampere Altra.

Bpp Before  After  Speedup
8   73,3s   65,2s  1.124x
10  114,2s  104,0s 1.098x
12  125,8s  115,7s 1.087x

Signed-off-by: J. Dekker 

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

 libavcodec/aarch64/hevcdsp_deblock_neon.S | 417 ++
 libavcodec/aarch64/hevcdsp_init_aarch64.c |  18 ++
 2 files changed, 435 insertions(+)

diff --git a/libavcodec/aarch64/hevcdsp_deblock_neon.S 
b/libavcodec/aarch64/hevcdsp_deblock_neon.S
index 8227f65649..581056a91e 100644
--- a/libavcodec/aarch64/hevcdsp_deblock_neon.S
+++ b/libavcodec/aarch64/hevcdsp_deblock_neon.S
@@ -181,3 +181,420 @@ hevc_h_loop_filter_chroma 12
 hevc_v_loop_filter_chroma 8
 hevc_v_loop_filter_chroma 10
 hevc_v_loop_filter_chroma 12
+
+.macro hevc_loop_filter_luma_body bitdepth
+function hevc_loop_filter_luma_body_\bitdepth\()_neon, export=0
+.if \bitdepth > 8
+lsl w2, w2, #(\bitdepth - 8) // beta <<= BIT_DEPTH - 8
+.else
+uxtlv0.8h, v0.8b
+uxtlv1.8h, v1.8b
+uxtlv2.8h, v2.8b
+uxtlv3.8h, v3.8b
+uxtlv4.8h, v4.8b
+uxtlv5.8h, v5.8b
+uxtlv6.8h, v6.8b
+uxtlv7.8h, v7.8b
+.endif
+ldr w7, [x3] // tc[0]
+ldr w8, [x3, #4] // tc[1]
+dup v18.4h, w7
+dup v19.4h, w8
+trn1v18.2d, v18.2d, v19.2d
+.if \bitdepth > 8
+shl v18.8h, v18.8h, #(\bitdepth - 8)
+.endif
+dup v27.8h, w2 // beta
+// tc25
+shl v19.8h, v18.8h, #2 // * 4
+add v19.8h, v19.8h, v18.8h // (tc * 5)
+srshr   v19.8h, v19.8h, #1 // (tc * 5 + 1) >> 1
+sshrv17.8h, v27.8h, #2 // beta2
+
+// beta_2 check
+// dp0  = abs(P2  - 2 * P1  + P0)
+add v22.8h, v3.8h, v1.8h
+shl v23.8h, v2.8h, #1
+sabdv30.8h, v22.8h, v23.8h
+// dq0  = abs(Q2  - 2 * Q1  + Q0)
+add v21.8h, v6.8h, v4.8h
+shl v26.8h, v5.8h, #1
+sabdv31.8h, v21.8h, v26.8h
+// d0   = dp0 + dq0
+add v20.8h, v30.8h, v31.8h
+shl v25.8h, v20.8h, #1
+// (d0 << 1) < beta_2
+cmgtv23.8h, v17.8h, v25.8h
+
+// beta check
+// d0 + d3 < beta
+mov x9, #0x
+dup v24.2d, x9
+and v25.16b, v24.16b, v20.16b
+addpv25.8h, v25.8h, v25.8h // 1+0 0+1 1+0 0+1
+addpv25.4h, v25.4h, v25.4h // 1+0+0+1 1+0+0+1
+cmgtv25.4h, v27.4h, v25.4h // lower/upper mask in h[0/1]
+mov w9, v25.s[0]
+cmp w9, #0
+sxtlv26.4s, v25.4h
+sxtlv16.2d, v26.2s // full skip mask
+b.eq3f // skip both blocks
+
+// TODO: we can check the full skip mask with the weak/strong mask to
+// potentially skip weak or strong calculation entirely if we only 
have one
+
+// beta_3 check
+// abs(P3  -  P0) + abs(Q3  -  Q0) < beta_3
+sshrv17.8h, v17.8h, #1 // beta_3
+sabdv20.8h, v0.8h, v3.8h
+sabav20.8h, v7.8h, v4.8h
+cmgtv21.8h, v17.8h, v20.8h
+
+and v23.16b, v23.16b, v21.16b
+
+// tc25 check
+// abs(P0  -  Q0) < tc25
+sabdv20.8h, v3.8h, v4.8h
+cmgtv21.8h, v19.8h, v20.8h
+
+and v23.16b, v23.16b, v21.16b
+
+// Generate low/high line max from lines 0/3/4/7
+// mask out lines 2/3/5/6
+not v20.16b, v24.16b // 0x
+orr v23.16b, v23.16b, v20.16b
+
+// generate weak/strong mask
+uminp   v23.8h, v23.8h, v23.8h // extend to singles
+sxtlv23.4s, v23.4h
+uminp   v26.4s, v23.4s, v23.4s // check lines
+// extract to gpr
+ext v25.16b, v26.16b, v26.16b, #2
+zip1v17.4s, v26.4s, v26.4s
+mov w12, v25.s[0]
+mov w11, #0x
+mov w13, #0x
+//   -> strong strong
+//   -> strong weak
+//   -> weak   strong
+//   -> weak   weak
+cmp w12, w13
+b.hi0f // only strong/strong, skip weak nd_p/nd_q calc
+