[FFmpeg-cvslog] lavf/asfdec: Simplify the check conditions

2019-11-03 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Sat Jun 15 
16:21:56 2019 +0800| [ec3d3fc65d06a9f7bc4d32b12b14a7c75e00484d] | committer: 
Jun Zhao

lavf/asfdec: Simplify the check conditions

Simplify the check conditions

Signed-off-by: Jun Zhao 

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

 libavformat/asfdec_o.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 8e7f044ce9..7891b23445 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1165,7 +1165,7 @@ static int asf_read_replicated_data(AVFormatContext *s, 
ASFPacket *asf_pkt)
 } else
 avio_skip(pb, 4); // reading of media object size is already done
 asf_pkt->dts = avio_rl32(pb); // read presentation time
-if (asf->rep_data_len && (asf->rep_data_len >= 8))
+if (asf->rep_data_len >= 8)
 avio_skip(pb, asf->rep_data_len - 8); // skip replicated data
 
 return 0;

___
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] lavf/mpegtsenc: fix logic check error

2019-11-03 Thread Jun Zhao
ffmpeg | branch: master | Jun Zhao  | Sat Jun 15 
16:19:18 2019 +0800| [8f7a043609554fd5e6917afeaed5d95bca420859] | committer: 
Jun Zhao

lavf/mpegtsenc: fix logic check error

fix the logic check error

fix #6751

Reviewed-by: Andriy Gelman 
Signed-off-by: Jun Zhao 

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

 libavformat/mpegtsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 0678657d09..9f8f1715c9 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1642,7 +1642,7 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 } while (p < buf_end && (state & 0x7e) != 2*35 &&
  (state & 0x7e) >= 2*32);
 
-if ((state & 0x7e) < 2*16 && (state & 0x7e) >= 2*24)
+if ((state & 0x7e) < 2*16 || (state & 0x7e) >= 2*24)
 extradd = 0;
 if ((state & 0x7e) != 2*35) { // AUD NAL
 data = av_malloc(pkt->size + 7 + extradd);

___
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] avformat/ftp: add AVOptions for authentication

2019-11-03 Thread Nicolas Frattaroli
ffmpeg | branch: master | Nicolas Frattaroli  | Sun Oct 27 
00:37:32 2019 +0200| [a8ec0685ac1cfbeb0e87f47b86d4f0b5cf75d745] | committer: 
Marton Balint

avformat/ftp: add AVOptions for authentication

This introduces two new AVOption options for the FTP protocol,
one named ftp-user to supply the username to be used for auth,
one named ftp-password to supply the password to be used for auth.

These are useful for when an API user does not wish to deal with
URL manipulation and percent encoding.

Setting them while also having credentials in the URL will use the
credentials from the URL. The rationale for this is that credentials
embedded in the URL are probably more specific to what the user is
trying to do than anything set by some API user.

Signed-off-by: Nicolas Frattaroli 
Signed-off-by: Marton Balint 

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

 doc/protocols.texi|  8 
 libavformat/ftp.c | 21 -
 libavformat/version.h |  2 +-
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b03432e3e5..0e18a49dda 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -228,6 +228,14 @@ Set timeout in microseconds of socket I/O operations used 
by the underlying low
 operation. By default it is set to -1, which means that the timeout is
 not specified.
 
+@item ftp-user
+Set a user to be used for authenticating to the FTP server. This is overridden 
by the
+user in the FTP URL.
+
+@item ftp-password
+Set a password to be used for authenticating to the FTP server. This is 
overridden by
+the password in the FTP URL, or by @option{ftp-anonymous-password} if no user 
is set.
+
 @item ftp-anonymous-password
 Password used when login as anonymous user. Typically an e-mail address
 should be used.
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 3adc04ee1f..97ad80de0b 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -69,6 +69,8 @@ typedef struct {
 size_t dir_buffer_size;
 size_t dir_buffer_offset;
 int utf8;
+const char *option_user; /**< User to be used if none 
given in the URL */
+const char *option_password; /**< Password to be used if 
none given in the URL */
 } FTPContext;
 
 #define OFFSET(x) offsetof(FTPContext, x)
@@ -78,6 +80,8 @@ static const AVOption options[] = {
 {"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
 {"ftp-write-seekable", "control seekability of connection during 
encoding", OFFSET(write_seekable), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
 {"ftp-anonymous-password", "password for anonymous login. E-mail address 
should be used.", OFFSET(anonymous_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, 
D|E },
+{"ftp-user", "user for FTP login. Overridden by whatever is in the URL.", 
OFFSET(option_user), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"ftp-password", "password for FTP login. Overridden by whatever is in the 
URL.", OFFSET(option_password), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
 {NULL}
 };
 
@@ -652,7 +656,7 @@ static int ftp_abort(URLContext *h)
 
 static int ftp_connect(URLContext *h, const char *url)
 {
-char proto[10], path[MAX_URL_SIZE], credencials[MAX_URL_SIZE], 
hostname[MAX_URL_SIZE];
+char proto[10], path[MAX_URL_SIZE], credentials[MAX_URL_SIZE], 
hostname[MAX_URL_SIZE];
 const char *tok_user = NULL, *tok_pass = NULL;
 char *end = NULL, *newpath = NULL;
 int err;
@@ -665,17 +669,24 @@ static int ftp_connect(URLContext *h, const char *url)
 s->features = NULL;
 
 av_url_split(proto, sizeof(proto),
- credencials, sizeof(credencials),
+ credentials, sizeof(credentials),
  hostname, sizeof(hostname),
  >server_control_port,
  path, sizeof(path),
  url);
 
-tok_user = av_strtok(credencials, ":", );
+tok_user = av_strtok(credentials, ":", );
 tok_pass = av_strtok(end, ":", );
 if (!tok_user) {
-tok_user = "anonymous";
-tok_pass = av_x_if_null(s->anonymous_password, "nopassword");
+if (!s->option_user) {
+tok_user = "anonymous";
+tok_pass = av_x_if_null(s->anonymous_password, "nopassword");
+} else {
+tok_user = s->option_user;
+}
+}
+if (!tok_pass) {
+tok_pass = s->option_password;
 }
 s->user = av_strdup(tok_user);
 s->password = av_strdup(tok_pass);
diff --git a/libavformat/version.h b/libavformat/version.h
index dce5a124c7..a978b34350 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  34
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define 

[FFmpeg-cvslog] avformat: Add max_probe_packets option

2019-11-03 Thread Andriy Gelman
ffmpeg | branch: master | Andriy Gelman  | Thu Oct 17 
10:49:20 2019 -0400| [5e3229df4ca86322f334bd098a9335f66ebdd649] | committer: 
Michael Niedermayer

avformat: Add max_probe_packets option

Allows user to set maximum number of buffered packets when
probing a codec. It was a hard-coded parameter before this commit.

Signed-off-by: Michael Niedermayer 

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

 doc/formats.texi| 4 
 libavformat/avformat.h  | 7 +++
 libavformat/internal.h  | 2 --
 libavformat/options_table.h | 1 +
 libavformat/utils.c | 6 +++---
 libavformat/version.h   | 2 +-
 6 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/doc/formats.texi b/doc/formats.texi
index d689fbadfa..fc80ce1d2b 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -27,6 +27,10 @@ stream information. A higher value will enable detecting more
 information in case it is dispersed into the stream, but will increase
 latency. Must be an integer not lesser than 32. It is 500 by default.
 
+@item max_probe_packets @var{integer} (@emph{input})
+Set the maximum number of buffered packets when probing a codec.
+Default is 2500 packets.
+
 @item packetsize @var{integer} (@emph{output})
 Set packet size.
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6eb329f13f..d4d9a3b06e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
  * - decoding: set by user
  */
 int skip_estimate_duration_from_pts;
+
+/**
+ * Maximum number of packets that can be probed
+ * - encoding: unused
+ * - decoding: set by user
+ */
+int max_probe_packets;
 } AVFormatContext;
 
 #if FF_API_FORMAT_GET_SET
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 67c35cc3e1..ec9a29907a 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -33,8 +33,6 @@
 #define PROBE_BUF_MIN 2048
 #define PROBE_BUF_MAX (1 << 20)
 
-#define MAX_PROBE_PACKETS 2500
-
 #ifdef DEBUG
 #define hex_dump_debug(class, buf, size) av_hex_dump_log(class, 
AV_LOG_DEBUG, buf, size)
 #else
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index f2f077b34f..432818f80d 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -111,6 +111,7 @@ static const AVOption avformat_options[] = {
 {"protocol_blacklist", "List of protocols that are not allowed to be used", 
OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, 
CHAR_MAX, D },
 {"max_streams", "maximum number of streams", OFFSET(max_streams), 
AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
 {"skip_estimate_duration_from_pts", "skip duration calculation in 
estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
+{"max_probe_packets", "Maximum number of packets to probe a codec", 
OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D },
 {NULL},
 };
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cfb6d03397..8196442dd1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -363,7 +363,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, 
AVStream *st,
 int i;
 av_log(s, AV_LOG_DEBUG,
"Probe with size=%d, packets=%d detected %s with score=%d\n",
-   pd->buf_size, MAX_PROBE_PACKETS - st->probe_packets,
+   pd->buf_size, s->max_probe_packets - st->probe_packets,
fmt->name, score);
 for (i = 0; fmt_id_type[i].name; i++) {
 if (!strcmp(fmt->name, fmt_id_type[i].name)) {
@@ -1948,7 +1948,7 @@ void ff_read_frame_flush(AVFormatContext *s)
 /* We set the current DTS to an unspecified origin. */
 st->cur_dts = AV_NOPTS_VALUE;
 
-st->probe_packets = MAX_PROBE_PACKETS;
+st->probe_packets = s->max_probe_packets;
 
 for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
 st->pts_buffer[j] = AV_NOPTS_VALUE;
@@ -4570,7 +4570,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 st->start_time = AV_NOPTS_VALUE;
 st->duration   = AV_NOPTS_VALUE;
 st->first_dts = AV_NOPTS_VALUE;
-st->probe_packets = MAX_PROBE_PACKETS;
+st->probe_packets = s->max_probe_packets;
 st->pts_wrap_reference = AV_NOPTS_VALUE;
 st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
 
diff --git a/libavformat/version.h b/libavformat/version.h
index bcd0408d28..dce5a124c7 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  33
+#define LIBAVFORMAT_VERSION_MINOR  34
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT 

[FFmpeg-cvslog] lavc/qsvenc: Fix bitrate_limit to allow AVC encode in limited bitrate

2019-11-03 Thread Linjie Fu
ffmpeg | branch: master | Linjie Fu  | Tue Oct 15 15:56:23 
2019 +0800| [e786e37326d4274c1dfbc37a6478680684c779c9] | committer: Zhong Li

lavc/qsvenc: Fix bitrate_limit to allow AVC encode in limited bitrate

MFXVideoENCODE_Query calls CheckVideoParamQueryLike in MSDK and
will determine whether to set param.mfx.TargetKbps to the allowed
minTargetKbps according to the bitrate_limit in extco2 buffer.

Thus q->param.ExtParam must be set before MFXVideoENCODE_Query in case
minTargetKbps is written to TargetKbps by default.

1080P AVC encoding with option "-bitrate_limit 0 -b:v 100k":
Before patch:
902 kbps
After patch:
156 kbps
Signed-off-by: Linjie Fu 

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

 libavcodec/qsvenc.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index ba85d645ca..dcff778607 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1052,25 +1052,6 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext 
*q)
 if (ret < 0)
 return ret;
 
-ret = MFXVideoENCODE_Query(q->session, >param, >param);
-if (ret == MFX_WRN_PARTIAL_ACCELERATION) {
-av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW 
acceleration\n");
-} else if (ret < 0) {
-return ff_qsv_print_error(avctx, ret,
-  "Error querying encoder params");
-}
-
-ret = MFXVideoENCODE_QueryIOSurf(q->session, >param, >req);
-if (ret < 0)
-return ff_qsv_print_error(avctx, ret,
-  "Error querying (IOSurf) the encoding 
parameters");
-
-if (opaque_alloc) {
-ret = qsv_init_opaque_alloc(avctx, q);
-if (ret < 0)
-return ret;
-}
-
 if (avctx->hwaccel_context) {
 AVQSVContext *qsv = avctx->hwaccel_context;
 int i, j;
@@ -1100,6 +1081,25 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext 
*q)
 q->param.NumExtParam = q->nb_extparam_internal;
 }
 
+ret = MFXVideoENCODE_Query(q->session, >param, >param);
+if (ret == MFX_WRN_PARTIAL_ACCELERATION) {
+av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW 
acceleration\n");
+} else if (ret < 0) {
+return ff_qsv_print_error(avctx, ret,
+  "Error querying encoder params");
+}
+
+ret = MFXVideoENCODE_QueryIOSurf(q->session, >param, >req);
+if (ret < 0)
+return ff_qsv_print_error(avctx, ret,
+  "Error querying (IOSurf) the encoding 
parameters");
+
+if (opaque_alloc) {
+ret = qsv_init_opaque_alloc(avctx, q);
+if (ret < 0)
+return ret;
+}
+
 ret = MFXVideoENCODE_Init(q->session, >param);
 if (ret < 0)
 return ff_qsv_print_error(avctx, ret,

___
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] lavc/qsvenc: enable vp9 encoder

2019-11-03 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Oct 26 22:18:31 
2019 +0800| [33583803e107b6d532def0f9d949364b01b6ad5a] | committer: Zhong Li

lavc/qsvenc: enable vp9 encoder

1. must enable low_power mode since just VDENC can be supported by iHD
driver right now
2. Coding option1 and extra_data are not supported by MSDK
3. IVF header will be inserted in MSDK by default, but it is not needed
for FFmpeg, so disable it.

Signed-off-by: Zhong Li 

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

 Changelog  |  1 +
 configure  |  6 +
 libavcodec/Makefile|  1 +
 libavcodec/allcodecs.c |  1 +
 libavcodec/qsvenc.c| 62 +-
 libavcodec/qsvenc.h|  6 +
 6 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 7c971fce63..558ea8d60c 100644
--- a/Changelog
+++ b/Changelog
@@ -20,6 +20,7 @@ version :
 - maskedmin and maskedmax filters
 - VDPAU VP9 hwaccel
 - median filter
+- QSV-accelerated VP9 encoding
 
 
 version 4.2:
diff --git a/configure b/configure
index 875b77fdf1..211305ff2f 100755
--- a/configure
+++ b/configure
@@ -3090,6 +3090,8 @@ vp9_qsv_decoder_select="qsvdec"
 vp9_rkmpp_decoder_deps="rkmpp"
 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
 vp9_vaapi_encoder_select="vaapi_encode"
+vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9"
+vp9_qsv_encoder_select="qsvenc"
 vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
 wmv3_crystalhd_decoder_select="crystalhd"
 
@@ -6243,6 +6245,10 @@ enabled liblensfun&& require_pkg_config 
liblensfun lensfun lensfun.h lf_
 # can find the libraries and headers through other means.
 enabled libmfx&& { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" 
MFXInit ||
{ require libmfx "mfx/mfxvideo.h" MFXInit 
"-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
+if enabled libmfx; then
+   check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+fi
+
 enabled libmodplug&& require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
 enabled libmp3lame&& require "libmp3lame >= 3.98.3" lame/lame.h 
lame_set_VBR_quality -lmp3lame $libm_extralibs
 enabled libmysofa && { check_pkg_config libmysofa libmysofa mysofa.h 
mysofa_neighborhood_init_withstepdefine ||
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 34c3a22116..2b6fbbca2a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -685,6 +685,7 @@ OBJS-$(CONFIG_VP9_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_VP9_RKMPP_DECODER)   += rkmppdec.o
 OBJS-$(CONFIG_VP9_VAAPI_ENCODER)   += vaapi_encode_vp9.o
+OBJS-$(CONFIG_VP9_QSV_ENCODER) += qsvenc_vp9.o
 OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
 OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 41f680101f..23a778e041 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -784,6 +784,7 @@ extern AVCodec ff_vp9_cuvid_decoder;
 extern AVCodec ff_vp9_mediacodec_decoder;
 extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
+extern AVCodec ff_vp9_qsv_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
 #if CONFIG_OSSFUZZ
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index dcff778607..93d49ba21d 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -637,7 +637,8 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 // The HEVC encoder plugin currently fails with some old libmfx version if 
coding options
 // are provided. Can't find the extract libmfx version which fixed it, 
just enable it from
 // V1.28 in order to keep compatibility security.
-if ((avctx->codec_id != AV_CODEC_ID_HEVC) || 
QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 28)) {
+if (((avctx->codec_id != AV_CODEC_ID_HEVC) || 
QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 28))
+&& (avctx->codec_id != AV_CODEC_ID_VP9)) {
 q->extco.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION;
 q->extco.Header.BufferSz  = sizeof(q->extco);
 
@@ -761,6 +762,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
 
+#if QSV_HAVE_EXT_VP9_PARAM
+if (avctx->codec_id == AV_CODEC_ID_VP9) {
+   q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM;
+   q->extvp9param.Header.BufferSz = sizeof(q->extvp9param);
+   q->extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
+   q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extvp9param;
+}
+#endif
+
 if (!check_enc_param(avctx,q)) {
 av_log(avctx, AV_LOG_ERROR,
"some encoding parameters are not supported by the QSV "
@@ -789,6 +799,53 @@ static