[FFmpeg-devel] [PATCH] vaapi: support VAProfileH264High10

2022-12-25 Thread Jean Jogh
see https://github.com/intel/libva/pull/664

Signed-off-by: jianfeng.zheng 
---
 configure  | 13 +
 libavcodec/h264_slice.c|  6 ++
 libavcodec/vaapi_decode.c  | 10 ++
 libavcodec/vaapi_encode_h264.c | 24 ++--
 libavcodec/vaapi_h264.c|  5 +++--
 5 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index f08cdab3d1..ac199d97cb 100755
--- a/configure
+++ b/configure
@@ -2410,6 +2410,7 @@ HAVE_LIST="
 texi2html
 xmllint
 zlib_gzip
+va_profile_h264_high10
 "

 # options emitted with CONFIG_ prefix but not available on the command line
@@ -6958,6 +6959,18 @@ 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"
+
+#
+# Using 'VA_CHECK_VERSION' in source codes make things easy. But
we have to wait
+# until newly added VAProfile being distributed by VAAPI released version.
+#
+# Before or after that, we can use auto-detection to keep version
compatibility.
+# It always works.
+#
+disable va_profile_h264_high10 && enabled h264_vaapi_hwaccel
+test_code cc va/va.h "VAProfile p = VAProfileH264High10" &&
+enable va_profile_h264_high10
+
 fi

 if enabled_all opencl libdrm ; then
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 420758ba0a..b9236281b1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -806,6 +806,12 @@ static enum AVPixelFormat
get_pixel_format(H264Context *h, int force_callback)
 } else if (CHROMA422(h))
 *fmt++ = AV_PIX_FMT_YUV422P10;
 else
+#if CONFIG_H264_VAAPI_HWACCEL
+// Just add as candidate. Whether VAProfileH264High10 usable or
+// not is decided by vaapi_decode_make_config() defined in FFmpeg
+// and vaQueryCodingProfile() defined in libva.
+*fmt++ = AV_PIX_FMT_VAAPI;
+#endif
 *fmt++ = AV_PIX_FMT_YUV420P10;
 break;
 case 12:
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 134f10eca5..03bbbf2c41 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -402,6 +402,9 @@ static const struct {
H264ConstrainedBaseline),
 MAP(H264,H264_MAIN,   H264Main),
 MAP(H264,H264_HIGH,   H264High),
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+MAP(H264,H264_HIGH_10,H264High10  ),
+#endif
 #if VA_CHECK_VERSION(0, 37, 0)
 MAP(HEVC,HEVC_MAIN,   HEVCMain),
 MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
@@ -510,6 +513,13 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 if (exact_match)
 break;
 }
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+//incase 8bit stream being decoded under VAProfileH264High10
+if (avctx->codec_id == AV_CODEC_ID_H264 &&
+(avctx->profile == FF_PROFILE_H264_EXTENDED ||
avctx->profile == FF_PROFILE_H264_BASELINE) &&
+matched_va_profile == VAProfileH264High)
+break;
+#endif
 }
 av_freep(_list);

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index dd17be2190..d26ac5a98f 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -23,6 +23,7 @@

 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"

@@ -290,10 +291,21 @@ static int
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 H264RawPPS*pps = >raw_pps;
 VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
 VAEncPictureParameterBufferH264  *vpic = ctx->codec_picture_params;
+const AVPixFmtDescriptor *desc;
+int bit_depth;

 memset(sps, 0, sizeof(*sps));
 memset(pps, 0, sizeof(*pps));

+desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
+av_assert0(desc);
+if (desc->nb_components == 1 || desc->log2_chroma_w != 1 ||
desc->log2_chroma_h != 1) {
+av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
+"%s is not supported.\n", desc->name);
+return AVERROR(EINVAL);
+}
+bit_depth = desc->comp[0].depth;
+
 sps->nal_unit_header.nal_ref_idc   = 3;
 sps->nal_unit_header.nal_unit_type = H264_NAL_SPS;

@@ -303,11 +315,11 @@ static int
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 avctx->profile == FF_PROFILE_H264_MAIN)
 sps->constraint_set1_flag = 1;

-if (avctx->profile == FF_PROFILE_H264_HIGH)
+if (avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile ==
FF_PROFILE_H264_HIGH_10)
 sps->constraint_set3_flag = ctx->gop_size == 1;

 if 

[FFmpeg-devel] [EXTERNAL] [PATCH] vaapi: support VAProfileH264High10

2022-12-25 Thread Jianfeng Zheng
see https://github.com/intel/libva/pull/664

Signed-off-by: jianfeng.zheng 
---
configure  | 13 +
libavcodec/h264_slice.c|  6 ++
libavcodec/vaapi_decode.c  | 10 ++
libavcodec/vaapi_encode_h264.c | 24 ++--
libavcodec/vaapi_h264.c|  5 +++--
5 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index f08cdab3d1..ac199d97cb 100755
--- a/configure
+++ b/configure
@@ -2410,6 +2410,7 @@ HAVE_LIST="
 texi2html
 xmllint
 zlib_gzip
+va_profile_h264_high10
"
 # options emitted with CONFIG_ prefix but not available on the command line
@@ -6958,6 +6959,18 @@ 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"
+
+#
+# Using 'VA_CHECK_VERSION' in source codes make things easy. But we have 
to wait
+# until newly added VAProfile being distributed by VAAPI released version.
+#
+# Before or after that, we can use auto-detection to keep version 
compatibility.
+# It always works.
+#
+disable va_profile_h264_high10 && enabled h264_vaapi_hwaccel
+test_code cc va/va.h "VAProfile p = VAProfileH264High10" &&
+enable va_profile_h264_high10
+
fi
 if enabled_all opencl libdrm ; then
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 420758ba0a..b9236281b1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -806,6 +806,12 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, 
int force_callback)
 } else if (CHROMA422(h))
 *fmt++ = AV_PIX_FMT_YUV422P10;
 else
+#if CONFIG_H264_VAAPI_HWACCEL
+// Just add as candidate. Whether VAProfileH264High10 usable or
+// not is decided by vaapi_decode_make_config() defined in FFmpeg
+// and vaQueryCodingProfile() defined in libva.
+*fmt++ = AV_PIX_FMT_VAAPI;
+#endif
 *fmt++ = AV_PIX_FMT_YUV420P10;
 break;
 case 12:
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 134f10eca5..03bbbf2c41 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -402,6 +402,9 @@ static const struct {
H264ConstrainedBaseline),
 MAP(H264,H264_MAIN,   H264Main),
 MAP(H264,H264_HIGH,   H264High),
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+MAP(H264,H264_HIGH_10,H264High10  ),
+#endif
#if VA_CHECK_VERSION(0, 37, 0)
 MAP(HEVC,HEVC_MAIN,   HEVCMain),
 MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
@@ -510,6 +513,13 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 if (exact_match)
 break;
 }
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+//incase 8bit stream being decoded under VAProfileH264High10
+if (avctx->codec_id == AV_CODEC_ID_H264 &&
+(avctx->profile == FF_PROFILE_H264_EXTENDED || avctx->profile == 
FF_PROFILE_H264_BASELINE) &&
+matched_va_profile == VAProfileH264High)
+break;
+#endif
 }
 av_freep(_list);
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index dd17be2190..d26ac5a98f 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
#include "libavutil/common.h"
+#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
@@ -290,10 +291,21 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 H264RawPPS*pps = >raw_pps;
 VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
 VAEncPictureParameterBufferH264  *vpic = ctx->codec_picture_params;
+const AVPixFmtDescriptor *desc;
+int bit_depth;
 memset(sps, 0, sizeof(*sps));
 memset(pps, 0, sizeof(*pps));
+desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
+av_assert0(desc);
+if (desc->nb_components == 1 || desc->log2_chroma_w != 1 || 
desc->log2_chroma_h != 1) {
+av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
+"%s is not supported.\n", desc->name);
+return AVERROR(EINVAL);
+}
+bit_depth = desc->comp[0].depth;
+
 sps->nal_unit_header.nal_ref_idc   = 3;
 sps->nal_unit_header.nal_unit_type = H264_NAL_SPS;
@@ -303,11 +315,11 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 avctx->profile == FF_PROFILE_H264_MAIN)
 sps->constraint_set1_flag = 1;
-if (avctx->profile == FF_PROFILE_H264_HIGH)
+if (avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile == 
FF_PROFILE_H264_HIGH_10)
 sps->constraint_set3_flag = ctx->gop_size == 1;
 if 

[FFmpeg-devel] [EXTERNAL] [PATCH] vaapi: support VAProfileH264High10

2022-12-25 Thread Jianfeng Zheng
>From 5a6450e1293efa8ca4678aad3ba59161c89d87a1 Mon Sep 17 00:00:00 2001
From: "jianfeng.zheng" 
Date: Mon, 18 Jul 2022 17:33:15 +0800
Subject: [PATCH] vaapi: support VAProfileH264High10

see https://github.com/intel/libva/pull/664

Signed-off-by: jianfeng.zheng 
---
configure  | 13 +
libavcodec/h264_slice.c|  6 ++
libavcodec/vaapi_decode.c  | 10 ++
libavcodec/vaapi_encode_h264.c | 24 ++--
libavcodec/vaapi_h264.c|  5 +++--
5 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index f08cdab3d1..ac199d97cb 100755
--- a/configure
+++ b/configure
@@ -2410,6 +2410,7 @@ HAVE_LIST="
 texi2html
 xmllint
 zlib_gzip
+va_profile_h264_high10
"
 # options emitted with CONFIG_ prefix but not available on the command line
@@ -6958,6 +6959,18 @@ 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"
+
+#
+# Using 'VA_CHECK_VERSION' in source codes make things easy. But we have 
to wait
+# until newly added VAProfile being distributed by VAAPI released version.
+#
+# Before or after that, we can use auto-detection to keep version 
compatibility.
+# It always works.
+#
+disable va_profile_h264_high10 && enabled h264_vaapi_hwaccel
+test_code cc va/va.h "VAProfile p = VAProfileH264High10" &&
+enable va_profile_h264_high10
+
fi
 if enabled_all opencl libdrm ; then
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 420758ba0a..b9236281b1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -806,6 +806,12 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, 
int force_callback)
 } else if (CHROMA422(h))
 *fmt++ = AV_PIX_FMT_YUV422P10;
 else
+#if CONFIG_H264_VAAPI_HWACCEL
+// Just add as candidate. Whether VAProfileH264High10 usable or
+// not is decided by vaapi_decode_make_config() defined in FFmpeg
+// and vaQueryCodingProfile() defined in libva.
+*fmt++ = AV_PIX_FMT_VAAPI;
+#endif
 *fmt++ = AV_PIX_FMT_YUV420P10;
 break;
 case 12:
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 134f10eca5..03bbbf2c41 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -402,6 +402,9 @@ static const struct {
H264ConstrainedBaseline),
 MAP(H264,H264_MAIN,   H264Main),
 MAP(H264,H264_HIGH,   H264High),
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+MAP(H264,H264_HIGH_10,H264High10  ),
+#endif
#if VA_CHECK_VERSION(0, 37, 0)
 MAP(HEVC,HEVC_MAIN,   HEVCMain),
 MAP(HEVC,HEVC_MAIN_10,HEVCMain10  ),
@@ -510,6 +513,13 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 if (exact_match)
 break;
 }
+#ifdef HAVE_VA_PROFILE_H264_HIGH10
+//incase 8bit stream being decoded under VAProfileH264High10
+if (avctx->codec_id == AV_CODEC_ID_H264 &&
+(avctx->profile == FF_PROFILE_H264_EXTENDED || avctx->profile == 
FF_PROFILE_H264_BASELINE) &&
+matched_va_profile == VAProfileH264High)
+break;
+#endif
 }
 av_freep(_list);
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index dd17be2190..d26ac5a98f 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
#include "libavutil/common.h"
+#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
@@ -290,10 +291,21 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 H264RawPPS*pps = >raw_pps;
 VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
 VAEncPictureParameterBufferH264  *vpic = ctx->codec_picture_params;
+const AVPixFmtDescriptor *desc;
+int bit_depth;
 memset(sps, 0, sizeof(*sps));
 memset(pps, 0, sizeof(*pps));
+desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
+av_assert0(desc);
+if (desc->nb_components == 1 || desc->log2_chroma_w != 1 || 
desc->log2_chroma_h != 1) {
+av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
+"%s is not supported.\n", desc->name);
+return AVERROR(EINVAL);
+}
+bit_depth = desc->comp[0].depth;
+
 sps->nal_unit_header.nal_ref_idc   = 3;
 sps->nal_unit_header.nal_unit_type = H264_NAL_SPS;
@@ -303,11 +315,11 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 avctx->profile == FF_PROFILE_H264_MAIN)
 sps->constraint_set1_flag = 1;
-if (avctx->profile == 

[FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc_av1: Add max_frame_size support to av1_qsv encoder

2022-12-25 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi   | 5 +
 libavcodec/qsvenc.c | 3 +++
 libavcodec/qsvenc_av1.c | 1 +
 3 files changed, 9 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 543b5e26a9..727f12a59d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3855,6 +3855,11 @@ Depth of look ahead in number frames, available when 
extbrc option is enabled.
 Setting this flag turns on or off LowDelayBRC feautre in qsv plugin, which 
provides
 more accurate bitrate control to minimize the variance of bitstream size frame
 by frame. Value: -1-default 0-off 1-on
+
+@item max_frame_size
+Set the allowed max size in bytes for each frame. If the frame size exceeds
+the limitation, encoder will adjust the QP value to control the frame size.
+Invalid in CQP rate control mode.
 @end table
 
 @section snow
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f5c6a164bb..93f1862a4b 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -538,6 +538,7 @@ static void dump_video_av1_param(AVCodecContext *avctx, 
QSVEncContext *q,
 av_log(avctx, AV_LOG_VERBOSE, "WriteIVFHeaders: %s \n",
print_threestate(av1_bs_param->WriteIVFHeaders));
 av_log(avctx, AV_LOG_VERBOSE, "LowDelayBRC: %s\n", 
print_threestate(co3->LowDelayBRC));
+av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d;\n", co2->MaxFrameSize);
 }
 #endif
 
@@ -1034,6 +1035,8 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 if (q->adaptive_b >= 0)
 q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
+if (q->max_frame_size >= 0)
+q->extco2.MaxFrameSize = q->max_frame_size;
 
 q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
 q->extco2.Header.BufferSz = sizeof(q->extco2);
diff --git a/libavcodec/qsvenc_av1.c b/libavcodec/qsvenc_av1.c
index 1e7801fefe..c697845d7b 100644
--- a/libavcodec/qsvenc_av1.c
+++ b/libavcodec/qsvenc_av1.c
@@ -111,6 +111,7 @@ static const AVOption options[] = {
 QSV_OPTION_ADAPTIVE_B
 QSV_OPTION_EXTBRC
 QSV_OPTION_LOW_DELAY_BRC
+QSV_OPTION_MAX_FRAME_SIZE
 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = 
MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
 { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN 
 }, INT_MIN, INT_MAX, VE, "profile" },
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_PROFILE_AV1_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
-- 
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 1/2] libavcodec/qsvenc_av1: Add low_delay_brc support to av1_qsv encoder

2022-12-25 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi   | 5 +
 libavcodec/qsvenc.c | 4 
 libavcodec/qsvenc_av1.c | 1 +
 3 files changed, 10 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index b8051cda3f..543b5e26a9 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3850,6 +3850,11 @@ Extended bitrate control.
 
 @item @var{look_ahead_depth}
 Depth of look ahead in number frames, available when extbrc option is enabled.
+
+@item @var{low_delay_brc}
+Setting this flag turns on or off LowDelayBRC feautre in qsv plugin, which 
provides
+more accurate bitrate control to minimize the variance of bitstream size frame
+by frame. Value: -1-default 0-off 1-on
 @end table
 
 @section snow
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 514a1e8148..f5c6a164bb 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -537,6 +537,7 @@ static void dump_video_av1_param(AVCodecContext *avctx, 
QSVEncContext *q,
 
 av_log(avctx, AV_LOG_VERBOSE, "WriteIVFHeaders: %s \n",
print_threestate(av1_bs_param->WriteIVFHeaders));
+av_log(avctx, AV_LOG_VERBOSE, "LowDelayBRC: %s\n", 
print_threestate(co3->LowDelayBRC));
 }
 #endif
 
@@ -1090,6 +1091,9 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->extco3.MaxFrameSizeP = q->max_frame_size_p;
 
 q->extco3.ScenarioInfo = q->scenario;
+} else if (avctx->codec_id == AV_CODEC_ID_AV1) {
+if (q->low_delay_brc >= 0)
+q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON 
: MFX_CODINGOPTION_OFF;
 }
 
 if (avctx->codec_id == AV_CODEC_ID_HEVC) {
diff --git a/libavcodec/qsvenc_av1.c b/libavcodec/qsvenc_av1.c
index bb9ad16927..1e7801fefe 100644
--- a/libavcodec/qsvenc_av1.c
+++ b/libavcodec/qsvenc_av1.c
@@ -110,6 +110,7 @@ static const AVOption options[] = {
 QSV_OPTION_ADAPTIVE_I
 QSV_OPTION_ADAPTIVE_B
 QSV_OPTION_EXTBRC
+QSV_OPTION_LOW_DELAY_BRC
 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = 
MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
 { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN 
 }, INT_MIN, INT_MAX, VE, "profile" },
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_PROFILE_AV1_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
-- 
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".


Re: [FFmpeg-devel] [PATCH] avformat/rtpproto: add support for RTP/UDP socket reuse

2022-12-25 Thread zhilizhao(赵志立)


> On Dec 26, 2022, at 07:52, Camille Oudot  
> wrote:
> 
> On Sun, 2022-12-25 at 11:00 +0100, Rémi Denis-Courmont wrote:
> 
> 
>> Again, there is also REUSEPORT, which is what you'd want on Linux in
>> this case, but behaves differently on BSD and doesn't exist at all on
>> Windows (IIRC).
> 
> That option is indeed preferable for security. It works equally good
> for the muxing use case, on Linux, with UDP sockets. I don't see why
> not using it instead, will do it in a new version of the patch.
> 
>> So even for sending, I don't think this patch really works.
> 
> REUSEADDR and thus this patch _are_ working well on Linux, with sockets
> that only send datagrams. It might behave differently on other systems
> though: I've read it is impossible to open two sockets having the same
> proto/src IP/src port/dst IP/dst port on BSD systems, but I don't have
> one handy. I will try it ASAP.
> 
> What is the project's policy on options that are incompatible with some
> systems, or that behave differently?

Just use the same socket file descriptor. Don’t use OS dependent hack to
implement a feature.

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

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

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


Re: [FFmpeg-devel] [PATCH] avformat/rtpproto: add support for RTP/UDP socket reuse

2022-12-25 Thread Camille Oudot
On Sun, 2022-12-25 at 11:00 +0100, Rémi Denis-Courmont wrote:


> Again, there is also REUSEPORT, which is what you'd want on Linux in
> this case, but behaves differently on BSD and doesn't exist at all on
> Windows (IIRC).

That option is indeed preferable for security. It works equally good
for the muxing use case, on Linux, with UDP sockets. I don't see why
not using it instead, will do it in a new version of the patch.

> So even for sending, I don't think this patch really works.

REUSEADDR and thus this patch _are_ working well on Linux, with sockets
that only send datagrams. It might behave differently on other systems
though: I've read it is impossible to open two sockets having the same
proto/src IP/src port/dst IP/dst port on BSD systems, but I don't have
one handy. I will try it ASAP.

What is the project's policy on options that are incompatible with some
systems, or that behave differently?

Regards

-- 
Camille


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

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


[FFmpeg-devel] [PATCH 2/2] avformat/mxfdec: Use 64bit in remainder

2022-12-25 Thread Michael Niedermayer
Fixes: signed integer overflow: 48000 * 223587 cannot be represented in type 
'int'
Fixes: 
54513/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5817594836025344

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

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index e6118e141d..6150c131ec 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3857,8 +3857,8 @@ static int64_t mxf_compute_sample_count(MXFContext *mxf, 
AVStream *st,
 if ((sample_rate.num / sample_rate.den) == 48000) {
 return av_rescale_q(edit_unit, sample_rate, track->edit_rate);
 } else {
-int remainder = (sample_rate.num * time_base.num) %
-(time_base.den * sample_rate.den);
+int64_t remainder = (sample_rate.num * (int64_t)time_base.num) %
+(time_base.den * (int64_t)sample_rate.den);
 if (remainder)
 av_log(mxf->fc, AV_LOG_WARNING,
"seeking detected on stream #%d with time base (%d/%d) and "
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/hdrdec: Check for end of input in decompress()

2022-12-25 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
54386/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-5053598268784640

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

diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c
index 21d3e7f693..998227744b 100644
--- a/libavcodec/hdrdec.c
+++ b/libavcodec/hdrdec.c
@@ -58,6 +58,8 @@ static int decompress(uint8_t *scanline, int w, 
GetByteContext *gb, const uint8_
 int rshift = 0;
 
 while (w > 0) {
+if (bytestream2_get_bytes_left(gb) < 4)
+return AVERROR_INVALIDDATA;
 scanline[0] = bytestream2_get_byte(gb);
 scanline[1] = bytestream2_get_byte(gb);
 scanline[2] = bytestream2_get_byte(gb);
@@ -143,13 +145,17 @@ static int hdr_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 int i;
 
 if (width < MINELEN || width > MAXELEN) {
-decompress(scanline, width, , scanline);
+ret = decompress(scanline, width, , scanline);
+if (ret < 0)
+return ret;
 goto convert;
 }
 
 i = bytestream2_peek_byte();
 if (i != 2) {
-decompress(scanline, width, , scanline);
+ret = decompress(scanline, width, , scanline);
+if (ret < 0)
+return ret;
 goto convert;
 }
 bytestream2_skip(, 1);
@@ -161,7 +167,9 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame 
*p,
 if (scanline[1] != 2 || scanline[2] & 128) {
 scanline[0] = 2;
 scanline[3] = i;
-decompress(scanline + 4, width - 1, , scanline);
+ret = decompress(scanline + 4, width - 1, , scanline);
+if (ret < 0)
+return ret;
 goto convert;
 }
 
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/dts2pts_bsf: Avoid searching for poc == INT_MIN-1

2022-12-25 Thread Michael Niedermayer
On Wed, Dec 07, 2022 at 12:48:07AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 
> 'int'
> Fixes: 
> 53876/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6569754750222336
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dts2pts_bsf.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)

will apply patchset

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

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


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] avcodec/dts2pts_bsf: Avoid poc overflows in cmp_find()

2022-12-25 Thread Michael Niedermayer
Fixes: signed integer overflow: -2147483648 - 5 cannot be represented in type 
'int'
Fixes: 
54242/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-472928339243827

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

diff --git a/libavcodec/dts2pts_bsf.c b/libavcodec/dts2pts_bsf.c
index 48612e59db..60bec91f99 100644
--- a/libavcodec/dts2pts_bsf.c
+++ b/libavcodec/dts2pts_bsf.c
@@ -90,9 +90,11 @@ static int cmp_insert(const void *key, const void *node)
 
 static int cmp_find(const void *key, const void *node)
 {
-int ret = ((const DTS2PTSFrame *)key)->poc - ((const DTS2PTSNode *) 
node)->poc;
+const DTS2PTSFrame * key1 = key;
+const DTS2PTSNode  *node1 = node;
+int ret = (key1->poc > node1->poc) - (key1->poc < node1->poc) ;
 if (!ret)
-ret = ((const DTS2PTSFrame *)key)->gop - ((const DTS2PTSNode *) 
node)->gop;
+ret = key1->gop - node1->gop;
 return ret;
 }
 
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] avformat/segment: add option min_seg_duration

2022-12-25 Thread Gyan Doshi




On 2022-12-21 09:08 pm, Gyan Doshi wrote:

New option can be used to avoid creating very short segments with inputs
whose GOP size is variable or unharmonic with segment_time.

Only effective with segment_time.

Comments?


---
  doc/muxers.texi   |  5 +
  libavformat/segment.c | 12 +++-
  2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 4edbb22b00..ed5341be39 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2369,6 +2369,11 @@ Note that splitting may not be accurate, unless you 
force the
  reference stream key-frames at the given time. See the introductory
  notice and the examples below.
  
+@item min_seg_duration @var{time}

+Set minimum segment duration to @var{time}, the value must be a duration
+specification. This prevents the muxer ending segments at a duration below
+this value. Only effective with @code{segment_time}. Default value is "0".
+
  @item segment_atclocktime @var{1|0}
  If set to "1" split at regular clock time intervals starting from 00:00
  o'clock. The @var{time} value specified in @option{segment_time} is
diff --git a/libavformat/segment.c b/libavformat/segment.c
index c904e20708..c19c2a94ae 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -93,6 +93,7 @@ typedef struct SegmentContext {
  int list_type; ///< set the list type
  AVIOContext *list_pb;  ///< list file put-byte context
  int64_t time;  ///< segment duration
+int64_t min_seg_duration;  ///< minimum segment duration
  int use_strftime;  ///< flag to expand filename with strftime
  int increment_tc;  ///< flag to increment timecode if found
  
@@ -710,6 +711,10 @@ static int seg_init(AVFormatContext *s)

  }
  seg->clocktime_offset = seg->time - (seg->clocktime_offset % 
seg->time);
  }
+if (seg->min_seg_duration > seg->time) {
+av_log(s, AV_LOG_ERROR, "min_seg_duration cannot be greater than 
segment_time\n");
+return AVERROR(EINVAL);
+}
  }
  
  if (seg->list) {

@@ -839,7 +844,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  {
  SegmentContext *seg = s->priv_data;
  AVStream *st = s->streams[pkt->stream_index];
-int64_t end_pts = INT64_MAX, offset;
+int64_t end_pts = INT64_MAX, offset, pkt_pts_avtb;
  int start_frame = INT_MAX;
  int ret;
  struct tm ti;
@@ -890,11 +895,15 @@ calc_times:
  pkt->flags & AV_PKT_FLAG_KEY,
  pkt->stream_index == seg->reference_stream_index ? 
seg->frame_count : -1);
  
+if (pkt->pts != AV_NOPTS_VALUE)

+pkt_pts_avtb = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
+
  if (pkt->stream_index == seg->reference_stream_index &&
  (pkt->flags & AV_PKT_FLAG_KEY || seg->break_non_keyframes) &&
  (seg->segment_frame_count > 0 || seg->write_empty) &&
  (seg->cut_pending || seg->frame_count >= start_frame ||
   (pkt->pts != AV_NOPTS_VALUE &&
+  pkt_pts_avtb - seg->cur_entry.start_pts >= seg->min_seg_duration &&
av_compare_ts(pkt->pts, st->time_base,
  end_pts - seg->time_delta, AV_TIME_BASE_Q) >= 0))) {
  /* sanitize end time in case last packet didn't have a defined 
duration */
@@ -1031,6 +1040,7 @@ static const AVOption options[] = {
  { "segment_clocktime_wrap_duration", "set segment clocktime wrapping 
duration", OFFSET(clocktime_wrap_duration), AV_OPT_TYPE_DURATION, {.i64 = INT64_MAX}, 0, 
INT64_MAX, E},
  { "segment_time",  "set segment duration",   
OFFSET(time),AV_OPT_TYPE_DURATION, {.i64 = 200}, INT64_MIN, INT64_MAX,   E },
  { "segment_time_delta","set approximation value used for the segment 
times", OFFSET(time_delta), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, E },
+{ "min_seg_duration",  "set minimum segment duration",   
OFFSET(min_seg_duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, E },
  { "segment_times", "set segment split time points",  
OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL},  0, 0,   E },
  { "segment_frames","set segment split frame numbers",
OFFSET(frames_str),AV_OPT_TYPE_STRING,{.str = NULL},  0, 0,   E },
  { "segment_wrap",  "set number after which the index wraps", 
OFFSET(segment_idx_wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },


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

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


Re: [FFmpeg-devel] [PATCH] avformat/rtpproto: add support for RTP/UDP socket reuse

2022-12-25 Thread Rémi Denis-Courmont
Le 24 décembre 2022 14:07:26 GMT+01:00, Camille Oudot 
 a écrit :
>Hello,
>
>On Sat, 2022-12-24 at 13:36 +0200, Rémi Denis-Courmont wrote:
>> I don't see why you need an option for this. In parsing the SDP, it
>> should be self-evident if a given socket needs to be reused for RTCP-
>> mux or for SDP BUNDLE.
>
>I indeed disregarded the "receiving RTP streams" part, my bad. I should
>clarify that this patch is only useful for _sending_ bundled RTP
>streams and muxed RTCP sender reports. I am currently using this patch
>successfully in a simulcast streaming WebRTC infrastructure, that could
>not work without it.
>
>Only the AV_OPT_FLAG_ENCODING_PARAM should be set in the option's
>flags, as this is the only case that makes sense and properly works.
>
>Analyzing the corresponding SDP options and opening only one socket and
>demuxing in userspace should be the way to go for reading such streams
>as you pointed it. Again I must clarify that this use case is not
>covered, and will set the option's flags accordingly.
>
>Thanks for your feedback.
>
>-- 
>Camille
>
>
>___
>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".

That is not how REUSEADDR works in general. It's originally meant to allow, 
well, literally reusing the same address/port pair immediately after it's been 
released.

It's not meant to share the same address/port concurrently. That part varies by 
OS, and causes obvious security issues on multi-user systems. Again, there is 
also REUSEPORT, which is what you'd want on Linux in this case, but behaves 
differently on BSD and doesn't exist at all on Windows (IIRC).

So even for sending, I don't think this patch really works.
___
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".