[FFmpeg-cvslog] lavc/qsvenc: specify codec name when print profile

2021-12-23 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Dec 21 23:18:06 
2021 +0800| [0598b38e9316391c76da24cc0f8c11d5e0292ae7] | committer: Haihao Xiang

lavc/qsvenc: specify codec name when print profile

It is more clear and easily to detect the issues similar to commit
3857ecbe70e81cb6ad7a7f155c311e8522b93b3e

Signed-off-by: Zhong Li 
Signed-off-by: Haihao Xiang 

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

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

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 92a8b49fe3..be5a541409 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -47,41 +47,41 @@ struct profile_names {
 };
 
 static const struct profile_names avc_profiles[] = {
-{ MFX_PROFILE_AVC_BASELINE, "baseline"  },
-{ MFX_PROFILE_AVC_MAIN, "main"  },
-{ MFX_PROFILE_AVC_EXTENDED, "extended"  },
-{ MFX_PROFILE_AVC_HIGH, "high"  },
+{ MFX_PROFILE_AVC_BASELINE, "avc baseline"  },
+{ MFX_PROFILE_AVC_MAIN, "avc main"  },
+{ MFX_PROFILE_AVC_EXTENDED, "avc extended"  },
+{ MFX_PROFILE_AVC_HIGH, "avc high"  },
 #if QSV_VERSION_ATLEAST(1, 15)
-{ MFX_PROFILE_AVC_HIGH_422, "high 422"  },
+{ MFX_PROFILE_AVC_HIGH_422, "avc high 422"  },
 #endif
 #if QSV_VERSION_ATLEAST(1, 4)
-{ MFX_PROFILE_AVC_CONSTRAINED_BASELINE, "constrained baseline"  },
-{ MFX_PROFILE_AVC_CONSTRAINED_HIGH, "constrained high"  },
-{ MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "progressive high"  },
+{ MFX_PROFILE_AVC_CONSTRAINED_BASELINE, "avc constrained baseline"  },
+{ MFX_PROFILE_AVC_CONSTRAINED_HIGH, "avc constrained high"  },
+{ MFX_PROFILE_AVC_PROGRESSIVE_HIGH, "avc progressive high"  },
 #endif
 };
 
 static const struct profile_names mpeg2_profiles[] = {
-{ MFX_PROFILE_MPEG2_SIMPLE, "simple"},
-{ MFX_PROFILE_MPEG2_MAIN,   "main"  },
-{ MFX_PROFILE_MPEG2_HIGH,   "high"  },
+{ MFX_PROFILE_MPEG2_SIMPLE, "mpeg2 simple"
},
+{ MFX_PROFILE_MPEG2_MAIN,   "mpeg2 main"  
},
+{ MFX_PROFILE_MPEG2_HIGH,   "mpeg2 high"  
},
 };
 
 static const struct profile_names hevc_profiles[] = {
 #if QSV_VERSION_ATLEAST(1, 8)
-{ MFX_PROFILE_HEVC_MAIN,"main"  },
-{ MFX_PROFILE_HEVC_MAIN10,  "main10"},
-{ MFX_PROFILE_HEVC_MAINSP,  "mainsp"},
-{ MFX_PROFILE_HEVC_REXT,"rext"  },
+{ MFX_PROFILE_HEVC_MAIN,"hevc main"  },
+{ MFX_PROFILE_HEVC_MAIN10,  "hevc main10"},
+{ MFX_PROFILE_HEVC_MAINSP,  "hevc mainsp"},
+{ MFX_PROFILE_HEVC_REXT,"hevc rext"  },
 #endif
 };
 
 static const struct profile_names vp9_profiles[] = {
 #if QSV_VERSION_ATLEAST(1, 19)
-{ MFX_PROFILE_VP9_0,"0" },
-{ MFX_PROFILE_VP9_1,"1" },
-{ MFX_PROFILE_VP9_2,"2" },
-{ MFX_PROFILE_VP9_3,"3" },
+{ MFX_PROFILE_VP9_0,"vp9 0" },
+{ MFX_PROFILE_VP9_1,"vp9 1" },
+{ MFX_PROFILE_VP9_2,"vp9 2" },
+{ MFX_PROFILE_VP9_3,"vp9 3" },
 #endif
 };
 

___
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 lookahead for hevc encoding

2021-12-23 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Dec 21 23:22:25 
2021 +0800| [7e4747ec504586658bf12a38c304659fa8d84a6a] | committer: Haihao Xiang

lavc/qsvenc: enable lookahead for hevc encoding

Update version based on the patch:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211009015949.1510-1-haihao.xi...@intel.com/

Signed-off-by: Daniel Socek 
Signed-off-by: Haihao Xiang 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 10 ++
 libavcodec/qsvenc_hevc.c |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index be5a541409..db6d397068 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -210,6 +210,11 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 av_log(avctx, AV_LOG_VERBOSE,
"BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; 
TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n",
info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, 
info->MaxKbps, info->BRCParamMultiplier);
+#if QSV_HAVE_LA
+if (info->RateControlMethod == MFX_RATECONTROL_VBR && q->extbrc && 
q->look_ahead_depth > 0 ) {
+av_log(avctx, AV_LOG_VERBOSE, "LookAheadDepth: 
%"PRIu16"\n",co2->LookAheadDepth);
+}
+#endif
 } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
 av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: 
%"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
@@ -742,6 +747,11 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 switch (q->param.mfx.RateControlMethod) {
 case MFX_RATECONTROL_CBR:
 case MFX_RATECONTROL_VBR:
+#if QSV_HAVE_LA
+if (q->extbrc) {
+q->extco2.LookAheadDepth = q->look_ahead_depth;
+}
+#endif
 #if QSV_HAVE_VCM
 case MFX_RATECONTROL_VCM:
 #endif
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index b7b2f5633e..5847ea21f7 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -235,6 +235,9 @@ static const AVOption options[] = {
 { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in 
an internal session",
 OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VE 
},
 
+#if QSV_HAVE_LA
+{ "look_ahead_depth", "Depth of look ahead in number frames, available 
when extbrc option is enabled", OFFSET(qsv.look_ahead_depth), AV_OPT_TYPE_INT, 
{ .i64 = 0 }, 0, 100, VE },
+#endif
 { "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_HEVC_MAIN
}, INT_MIN, INT_MAX, VE, "profile" },

___
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] MAINTAINERS: Add Haihao Xiang for qsv

2021-12-20 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Jun  8 22:11:34 
2021 +0800| [c47896536ce7fe480242c61ba5ca404648db6c00] | committer: Zhong Li

MAINTAINERS: Add Haihao Xiang for qsv

Signed-off-by: Zhong Li 

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

 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index dcac46003e..39ce91b755 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -226,7 +226,7 @@ Codecs:
   ptx.c Ivo van Poorten
   qcelp*Reynaldo H. Verdejo Pinochet
   qdm2.c, qdm2data.hRoberto Togni
-  qsv*  Mark Thompson, Zhong Li
+  qsv*  Mark Thompson, Zhong Li, Haihao Xiang
   qtrle.c   Mike Melanson
   ra144.c, ra144.h, ra288.c, ra288.hRoberto Togni
   resample2.c   Michael Niedermayer

___
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] mailmap: add entry for myself

2020-06-17 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Jun 17 22:11:34 
2020 +0800| [157feea0416b41d309820e6595c27428ad04502c] | committer: Zhong Li

mailmap: add entry for myself

Signed-off-by: Zhong Li 

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

 .mailmap | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index d1925bfab0..f14770d800 100644
--- a/.mailmap
+++ b/.mailmap
@@ -15,7 +15,8 @@
  
  
  
- 
+ 
+ 
  
 rcombs  
  

___
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/mpeg12dec: always submit the first field to hwaccel

2020-01-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Oct 23 15:43:30 
2017 +0800| [12c4d00c10cb73f1976c8de5b23b1405803bd454] | committer: Timo 
Rothenpieler

avcodec/mpeg12dec: always submit the first field to hwaccel

Though this patch to fix ticket #6668, I belive it
is unnecessary to set SLICE_FLAG_ALLOW_FIELD flag to other
hwaccels(dxva, vdpau, etc). Please also refer the orginal comment
of 9cb150c9ab520eba5636bbcf925db6a70e67f3e5

Should also fix ticket #8442.

Signed-off-by: Zhong Li 
Signed-off-by: Timo Rothenpieler 

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

 libavcodec/mpeg12dec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 775579f9f0..17f9495a1d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1669,8 +1669,7 @@ static int mpeg_field_start(MpegEncContext *s, const 
uint8_t *buf, int buf_size)
 return AVERROR_INVALIDDATA;
 }
 
-if (s->avctx->hwaccel &&
-(s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
+if (s->avctx->hwaccel) {
 if ((ret = s->avctx->hwaccel->end_frame(s->avctx)) < 0) {
 av_log(avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode first field\n");

___
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/qsvdec: fix the error retrun code in ff_qsv_get_continuous_buffer()

2019-12-29 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Dec 28 22:22:07 
2019 +0800| [9fff5c40a781098480210f96daba88aba287f316] | committer: Zhong Li

lavc/qsvdec: fix the error retrun code in ff_qsv_get_continuous_buffer()

Signed-off-by: Zhong Li 

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

 libavcodec/qsvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 0d34021b42..baaf1f205f 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -74,7 +74,7 @@ static int ff_qsv_get_continuous_buffer(AVCodecContext 
*avctx, AVFrame *frame, A
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
-return AVERROR(ENOMEM);
+return AVERROR(EINVAL);
 }
 
 frame->linesize[1] = frame->linesize[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] lavc/qsvdec: disable gpu copy when not supported

2019-12-29 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Dec 28 22:28:45 
2019 +0800| [779951f7b2fb39f2321c41dc5971b26f8a9e89c9] | committer: Zhong Li

lavc/qsvdec: disable gpu copy when not supported

Signed-off-by: Zhong Li 

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

 libavcodec/qsvdec.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index baaf1f205f..fc25dc73e5 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -99,9 +99,11 @@ static int qsv_init_session(AVCodecContext *avctx, 
QSVContext *q, mfxSession ses
 int ret;
 
 if (q->gpu_copy == MFX_GPUCOPY_ON &&
-!(q->iopattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY))
+!(q->iopattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY)) {
 av_log(avctx, AV_LOG_WARNING, "GPU-accelerated memory copy "
-"only works in MFX_IOPATTERN_OUT_SYSTEM_MEMORY.\n");
+"only works in system memory mode.\n");
+q->gpu_copy = MFX_GPUCOPY_OFF;
+}
 if (session) {
 q->session = session;
 } else if (hw_frames_ref) {

___
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/qsv: remove the unused funtion ff_qsv_profile_to_mfx()

2019-12-29 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Dec 28 22:58:02 
2019 +0800| [755ad01dd1dffc6209a9f71641e1c4169bb7691a] | committer: Zhong Li

lavc/qsv: remove the unused funtion ff_qsv_profile_to_mfx()

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 52 ---
 libavcodec/qsv_internal.h |  1 -
 2 files changed, 53 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index b00e427435..db98c75073 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -72,58 +72,6 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 return AVERROR(ENOSYS);
 }
 
-
-static const struct {
-enum AVCodecID codec_id;
-int codec_profile;
-int mfx_profile;
-} qsv_profile_map[] = {
-#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, MFX_PROFILE_ ## v }
-MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2_SIMPLE ),
-MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2_MAIN   ),
-MAP(MPEG2VIDEO,  MPEG2_HIGH,  MPEG2_HIGH   ),
-
-MAP(H264,H264_BASELINE,   AVC_BASELINE ),
-MAP(H264,H264_CONSTRAINED_BASELINE, AVC_BASELINE),
-#if QSV_VERSION_ATLEAST(1, 3)
-MAP(H264,H264_EXTENDED,   AVC_EXTENDED ),
-#endif
-MAP(H264,H264_MAIN,   AVC_MAIN ),
-MAP(H264,H264_HIGH,   AVC_HIGH ),
-MAP(H264,H264_HIGH_422,   AVC_HIGH_422 ),
-
-#if QSV_VERSION_ATLEAST(1, 8)
-MAP(HEVC,HEVC_MAIN,   HEVC_MAIN),
-MAP(HEVC,HEVC_MAIN_10,HEVC_MAIN10  ),
-MAP(HEVC,HEVC_MAIN_STILL_PICTURE,HEVC_MAINSP ),
-#endif
-#if QSV_VERSION_ATLEAST(1, 16)
-MAP(HEVC,HEVC_REXT,   HEVC_REXT),
-#endif
-
-MAP(VC1, VC1_SIMPLE,  VC1_SIMPLE   ),
-MAP(VC1, VC1_MAIN,VC1_MAIN ),
-MAP(VC1, VC1_COMPLEX, VC1_ADVANCED ),
-MAP(VC1, VC1_ADVANCED,VC1_ADVANCED ),
-#undef MAP
-};
-
-int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile)
-{
-int i;
-if (profile == FF_PROFILE_UNKNOWN)
-return MFX_PROFILE_UNKNOWN;
-
-for (i = 0; i < FF_ARRAY_ELEMS(qsv_profile_map); i++) {
-if (qsv_profile_map[i].codec_id != codec_id)
-continue;
-if (qsv_profile_map[i].codec_profile == profile)
-return qsv_profile_map[i].mfx_profile;
-}
-
-return MFX_PROFILE_UNKNOWN;
-}
-
 int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level)
 {
 if (level == FF_LEVEL_UNKNOWN)
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 37559270e5..6489836a67 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -116,7 +116,6 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
  const char *warning_string);
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
-int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 
 enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc);

___
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/midivid: check return value of init_get_bits8()

2019-12-23 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Dec 23 14:14:09 
2019 +| [5dc527f9cad2912069dcc9dc6c05bcf9bf05eb87] | committer: Paul B Mahol

lavc/midivid: check return value of init_get_bits8()

Fix CID 1456088

Signed-off-by: Zhong Li 

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

 libavcodec/midivid.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c
index 38465c5fbc..bb5105bd57 100644
--- a/libavcodec/midivid.c
+++ b/libavcodec/midivid.c
@@ -63,7 +63,7 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext 
*avctx, AVFrame *frame)
 if (intra_flag) {
 nb_blocks = (avctx->width / 2) * (avctx->height / 2);
 } else {
-int skip_linesize;
+int ret, skip_linesize;
 
 nb_blocks = bytestream2_get_le32(gb);
 skip_linesize = avctx->width >> 1;
@@ -73,7 +73,9 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext 
*avctx, AVFrame *frame)
 if (bytestream2_get_bytes_left(gb) < mask_size)
 return AVERROR_INVALIDDATA;
 
-init_get_bits8(, mask_start, mask_size);
+ret = init_get_bits8(, mask_start, mask_size);
+if (ret < 0)
+return ret;
 bytestream2_skip(gb, mask_size);
 skip = s->skip;
 

___
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/x265: set preferred_transfer_characteristics for HLG

2019-12-12 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Dec  4 14:24:09 
2019 +| [a87b5d5e8c9424b5cadd46abba98dae8edd454df] | committer: Zhong Li

lavc/x265: set preferred_transfer_characteristics for HLG

"HEVC HDR UHDTV Bitstreams using HLG10 shall also contain the
alternative_transfer_characteristics SEI message. The
alternative_transfer_characteristics SEI message shall be inserted on
the HEVC DVB_RAP, and preferred_transfer_characteristics shall be set
equal to "18", indicating Recommendation ITU-R BT. 2100 [45] HLG
system."

Signed-off-by: Zhong Li 

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

 libavcodec/libx265.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 4e7507728f..963c28fb1d 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -159,6 +159,10 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 // x265 validates the parameters internally
 ctx->params->vui.colorPrimaries  = avctx->color_primaries;
 ctx->params->vui.transferCharacteristics = avctx->color_trc;
+#if X265_BUILD >= 159
+if (avctx->color_trc == AVCOL_TRC_ARIB_STD_B67)
+ctx->params->preferredTransferCharacteristics = 
ctx->params->vui.transferCharacteristics;
+#endif
 ctx->params->vui.matrixCoeffs= avctx->colorspace;
 }
 

___
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] doc/encoder: add the missing qsv encoders

2019-11-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Nov 27 07:04:23 
2019 +| [1b831bc72975d621b8821849d05357e6afafc229] | committer: Zhong Li

doc/encoder: add the missing qsv encoders

Reviewed-by: Gyan Doshi 
Signed-off-by: Zhong Li 

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

 doc/encoders.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6b02c7798d..4ee518a124 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2776,7 +2776,7 @@ recommended value) and do not set a size constraint.
 
 @section QSV encoders
 
-The family of Intel QuickSync Video encoders (MPEG-2, H.264 and HEVC)
+The family of Intel QuickSync Video encoders (MPEG-2, H.264, HEVC, JPEG/MJPEG 
and VP9)
 
 The ratecontrol method is selected as follows:
 

___
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/rav1e: log and doc updated for const quantizer mode

2019-11-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Nov 12 09:09:20 
2019 +| [846e26b8c93a313d9f0c1f7d4a2965b357482abf] | committer: Zhong Li

lavc/rav1e: log and doc updated for const quantizer mode

Signed-off-by: Zhong Li 

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

 doc/encoders.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6cf3a74093..6b02c7798d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1395,7 +1395,7 @@ Sets the maximum quantizer to use when using bitrate mode.
 Sets the minimum quantizer to use when using bitrate mode.
 
 @item qp
-Uses quantizer mode to encode at the given quantizer.
+Uses quantizer mode to encode at the given quantizer (0-255).
 
 @item speed
 Selects the speed preset (0-10) to encode with.

___
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] tools/probetest: replace the deprecated API

2019-11-04 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Nov  2 23:47:00 
2019 +0800| [f52e15df0f6a91428220d7a0852f0d020c2e75a2] | committer: Zhong Li

tools/probetest: replace the deprecated API

Signed-off-by: Zhong Li 

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

 tools/probetest.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/probetest.c b/tools/probetest.c
index 2c6c1de246..cfa309cabd 100644
--- a/tools/probetest.c
+++ b/tools/probetest.c
@@ -38,9 +38,10 @@ static const char *single_format;
 static void probe(AVProbeData *pd, int type, int p, int size)
 {
 int i = 0;
-AVInputFormat *fmt = NULL;
+const AVInputFormat *fmt = NULL;
+void *fmt_opaque = NULL;
 
-while ((fmt = av_iformat_next(fmt))) {
+while ((fmt = av_demuxer_iterate(_opaque))) {
 if (fmt->flags & AVFMT_NOFILE)
 continue;
 if (fmt->read_probe &&
@@ -66,8 +67,9 @@ static void print_times(void)
 {
 int i = 0;
 AVInputFormat *fmt = NULL;
+void *fmt_opaque = NULL;
 
-while ((fmt = av_iformat_next(fmt))) {
+while ((fmt = av_demuxer_iterate(_opaque))) {
 if (fmt->flags & AVFMT_NOFILE)
 continue;
 if (time_array[i] > 100) {

___
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] tools/enum_options: replace the deprecated API

2019-11-04 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sat Nov  2 23:47:01 
2019 +0800| [8ff432eb447ec0eca9954829aa58b611eafd835d] | committer: Zhong Li

tools/enum_options: replace the deprecated API

Signed-off-by: Zhong Li 

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

 tools/enum_options.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/enum_options.c b/tools/enum_options.c
index 77e1f9f799..28631d1a6b 100644
--- a/tools/enum_options.c
+++ b/tools/enum_options.c
@@ -88,20 +88,22 @@ static void show_opts(const AVClass *class)
 
 static void show_format_opts(void)
 {
-AVInputFormat *iformat = NULL;
-AVOutputFormat *oformat = NULL;
+const AVInputFormat *iformat = NULL;
+const AVOutputFormat *oformat = NULL;
+void *iformat_opaque = NULL;
+void *oformat_opaque = NULL;
 
 printf("@section Generic format AVOptions\n");
 show_opts(avformat_get_class());
 
 printf("@section Format-specific AVOptions\n");
-while ((iformat = av_iformat_next(iformat))) {
+while ((iformat = av_demuxer_iterate(_opaque))) {
 if (!iformat->priv_class)
 continue;
 printf("@subsection %s AVOptions\n", iformat->priv_class->class_name);
 show_opts(iformat->priv_class);
 }
-while ((oformat = av_oformat_next(oformat))) {
+while ((oformat = av_muxer_iterate(_opaque))) {
 if (!oformat->priv_class)
 continue;
 printf("@subsection %s AVOptions\n", oformat->priv_class->class_name);

___
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_interna

[FFmpeg-cvslog] lavc/qsv: remove vaapi device free function

2019-10-08 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Oct  8 12:55:01 
2019 +0800| [949a1b3e2f75338e17e446e97105e06ad6b4012a] | committer: Zhong Li

lavc/qsv: remove vaapi device free function

It is not needed since av_buffer_unref() will call it internally

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index a43f0d5c5a..81fa4a82ef 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -835,10 +835,6 @@ int ff_qsv_close_internal_session(QSVSession *qs)
 qs->session = NULL;
 }
 #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
-if (qs->va_device_ctx) {
-qs->va_device_ctx->free(qs->va_device_ctx);
-}
-
 av_buffer_unref(>va_device_ref);
 #endif
 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] lavfi/normalize: remove the unused pointer

2019-10-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sun Sep 29 16:05:51 
2019 +0800| [8df91de9aa263df77bd3f59a65355a1ccca83f0c] | committer: Zhong Li

lavfi/normalize: remove the unused pointer

Signed-off-by: Zhong Li 

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

 libavfilter/vf_normalize.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/vf_normalize.c b/libavfilter/vf_normalize.c
index c955aeb7d2..4a96088ee5 100644
--- a/libavfilter/vf_normalize.c
+++ b/libavfilter/vf_normalize.c
@@ -147,14 +147,12 @@ static void normalize(NormalizeContext *s, AVFrame *in, 
AVFrame *out)
 min[c].in = max[c].in = in->data[0][s->co[c]];
 for (y = 0; y < in->height; y++) {
 uint8_t *inp = in->data[0] + y * in->linesize[0];
-uint8_t *outp = out->data[0] + y * out->linesize[0];
 for (x = 0; x < in->width; x++) {
 for (c = 0; c < 3; c++) {
 min[c].in = FFMIN(min[c].in, inp[s->co[c]]);
 max[c].in = FFMAX(max[c].in, inp[s->co[c]]);
 }
 inp += s->step;
-outp += s->step;
 }
 }
 

___
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/qsv: fix a memory leak in ff_qsv_set_display_handle()

2019-10-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sun Sep 29 16:01:06 
2019 +0800| [6f0dd6b4ab6536ef0506c121263de15a0be64d5d] | committer: Zhong Li

lavc/qsv: fix a memory leak in ff_qsv_set_display_handle()

Reported-by: Linjie Fu 
Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 994c9ebcb0..a43f0d5c5a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -838,6 +838,8 @@ int ff_qsv_close_internal_session(QSVSession *qs)
 if (qs->va_device_ctx) {
 qs->va_device_ctx->free(qs->va_device_ctx);
 }
+
+av_buffer_unref(>va_device_ref);
 #endif
 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] lavu/qsv: remove redundant version query

2019-09-27 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Sep 20 04:45:25 
2019 +0800| [0686651aab1de86cf25ec3c611fe82f9f5d7099c] | committer: Zhong Li

lavu/qsv: remove redundant version query

Signed-off-by: Zhong Li 

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

 libavutil/hwcontext_qsv.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 0329a81ec3..b1b67400de 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1180,11 +1180,6 @@ static int 
qsv_device_derive_from_child(AVHWDeviceContext *ctx,
 goto fail;
 }
 
-ret = MFXQueryVersion(hwctx->session,);
-if (ret == MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_VERBOSE, "MFX compile/runtime API: %d.%d/%d.%d\n",
-   MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
-}
 return 0;
 
 fail:

___
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/qsv: Fix MSDK initialization failure in system memory mode

2019-09-25 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Sep 20 04:45:26 
2019 +0800| [74007dd86a87289a075926704fae5bd8ef313bb5] | committer: Zhong Li

lavc/qsv: Fix MSDK initialization failure in system memory mode

MSDK does not create internal acceleration device on Linux,
So MFXVideoCORE_SetHandle() is necessary.
It has been added for ff_qsv_init_session_device().
But missed for ff_qsv_init_internal_session() due to commit
1f26a23 overwrited commit db89f45

Fix #7030

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 62 ---
 libavcodec/qsv_internal.h | 28 -
 libavcodec/qsvdec.c   | 29 +++---
 libavcodec/qsvdec.h   |  2 +-
 libavcodec/qsvenc.c   | 17 ++---
 libavcodec/qsvenc.h   |  2 +-
 6 files changed, 109 insertions(+), 31 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 65ad070e1f..c4aef70b1e 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -348,7 +348,41 @@ load_plugin_fail:
 
 }
 
-int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
+//This code is only required for Linux since a display handle is required.
+//For Windows the session is complete and ready to use.
+
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)
+{
+AVDictionary *child_device_opts = NULL;
+AVVAAPIDeviceContext *hwctx;
+int ret;
+
+av_dict_set(_device_opts, "kernel_driver", "i915", 0);
+av_dict_set(_device_opts, "driver","iHD",  0);
+
+ret = av_hwdevice_ctx_create(>va_device_ref, AV_HWDEVICE_TYPE_VAAPI, 
NULL, child_device_opts, 0);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Failed to create a VAAPI device.\n");
+return ret;
+} else {
+qs->va_device_ctx = (AVHWDeviceContext*)qs->va_device_ref->data;
+hwctx = qs->va_device_ctx->hwctx;
+
+ret = MFXVideoCORE_SetHandle(qs->session,
+(mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)hwctx->display);
+if (ret < 0) {
+return ff_qsv_print_error(avctx, ret, "Error during set display 
handle\n");
+}
+}
+
+av_dict_free(_device_opts);
+
+return 0;
+}
+#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
+
+int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
  const char *load_plugins)
 {
 mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
@@ -357,18 +391,24 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, 
mfxSession *session,
 const char *desc;
 int ret;
 
-ret = MFXInit(impl, , session);
+ret = MFXInit(impl, , >session);
 if (ret < 0)
 return ff_qsv_print_error(avctx, ret,
   "Error initializing an internal MFX 
session");
 
-ret = qsv_load_plugins(*session, load_plugins, avctx);
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+ret = ff_qsv_set_display_handle(avctx, qs);
+if (ret < 0)
+return ret;
+#endif
+
+ret = qsv_load_plugins(qs->session, load_plugins, avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error loading plugins\n");
 return ret;
 }
 
-MFXQueryIMPL(*session, );
+MFXQueryIMPL(qs->session, );
 
 switch (MFX_IMPL_BASETYPE(impl)) {
 case MFX_IMPL_SOFTWARE:
@@ -758,3 +798,17 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx, 
mfxSession *psession,
 *psession = session;
 return 0;
 }
+
+int ff_qsv_close_internal_session(QSVSession *qs)
+{
+if (qs->session) {
+MFXClose(qs->session);
+qs->session = NULL;
+}
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+if (qs->va_device_ctx) {
+qs->va_device_ctx->free(qs->va_device_ctx);
+}
+#endif
+return 0;
+}
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index c50e9c792c..62885134b1 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -21,6 +21,22 @@
 #ifndef AVCODEC_QSV_INTERNAL_H
 #define AVCODEC_QSV_INTERNAL_H
 
+#if CONFIG_VAAPI
+#define AVCODEC_QSV_LINUX_SESSION_HANDLE
+#endif //CONFIG_VAAPI
+
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+#include 
+#include 
+#if HAVE_UNISTD_H
+#include 
+#endif
+#include 
+#include 
+#include 
+#include "libavutil/hwcontext_vaapi.h"
+#endif
+
 #include 
 
 #include "libavutil/frame.h"
@@ -64,6 +80,14 @@ typedef struct QSVFrame {
 struct QSVFrame *next;
 } QSVFrame;
 
+typedef struct QSVSession {
+mfxSession session;
+#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
+AVBufferRef *va_device_ref;
+AVHWDeviceContext *va_device_ctx;
+#endif
+} QSVSession;
+
 typedef struct QSVFramesContext {
 AVBufferRef *hw_frame

[FFmpeg-cvslog] lavc/qsv: add memory type message

2019-09-25 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Sep 20 04:45:27 
2019 +0800| [525de9567903e32b6ee2dc594bd55c26581029dd] | committer: Zhong Li

lavc/qsv: add memory type message

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 29 +
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c   |  2 ++
 3 files changed, 34 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index c4aef70b1e..994c9ebcb0 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -137,6 +137,35 @@ int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level)
 }
 }
 
+static const struct {
+int mfx_iopattern;
+const char *desc;
+} qsv_iopatterns[] = {
+{MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface"
 },
+{MFX_IOPATTERN_IN_SYSTEM_MEMORY,"input is system memory surface"   
 },
+{MFX_IOPATTERN_IN_OPAQUE_MEMORY,"input is opaque memory surface"   
 },
+{MFX_IOPATTERN_OUT_VIDEO_MEMORY,"output is video memory surface"   
 },
+{MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"  
 },
+{MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"  
 },
+};
+
+int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
+   const char *extra_string)
+{
+const char *desc = NULL;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
+if (qsv_iopatterns[i].mfx_iopattern == mfx_iopattern) {
+desc = qsv_iopatterns[i].desc;
+}
+}
+if (!desc)
+desc = "unknown iopattern";
+
+av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
+return 0;
+}
+
 static const struct {
 mfxStatus   mfxerr;
 int averr;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 62885134b1..8b44a9b6f4 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -101,6 +101,9 @@ typedef struct QSVFramesContext {
 int  nb_mids;
 } QSVFramesContext;
 
+int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
+   const char *extra_string);
+
 /**
  * Convert a libmfx error code into an ffmpeg error code.
  */
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 2fce478d63..9299596e33 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -193,6 +193,8 @@ static int qsv_decode_preinit(AVCodecContext *avctx, 
QSVContext *q, enum AVPixel
 iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
 q->iopattern = iopattern;
 
+ff_qsv_print_iopattern(avctx, q->iopattern, "Decoder");
+
 ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx, 
avctx->hw_device_ctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n");

___
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] lavfi/qsvvpp: disable pass through mode if format changed

2019-08-20 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Aug 15 10:33:57 
2019 +0800| [74e6800381a2c82fff0aef6457414b3cefc1157c] | committer: Zhong Li

lavfi/qsvvpp: disable pass through mode if format changed

Partly fix tiket#8065

Signed-off-by: Zhong Li 

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

 libavfilter/vf_vpp_qsv.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index f18513359a..858587411d 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -312,7 +312,9 @@ static int config_output(AVFilterLink *outlink)
 } else
 in_format = inlink->format;
 
-param.out_sw_format  = (vpp->out_format == AV_PIX_FMT_NONE) ? in_format : 
vpp->out_format;
+if (vpp->out_format == AV_PIX_FMT_NONE)
+vpp->out_format = in_format;
+param.out_sw_format  = vpp->out_format;
 
 if (vpp->use_crop) {
 crop.in_idx = 0;
@@ -454,7 +456,7 @@ static int config_output(AVFilterLink *outlink)
 
 if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
 vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
-inlink->w != outlink->w || inlink->h != outlink->h)
+inlink->w != outlink->w || inlink->h != outlink->h || in_format != 
vpp->out_format)
 return ff_qsvvpp_create(ctx, >qsv, );
 else {
 av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n");

___
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/qsvdec: Add VP9 decoder support

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:12 
2019 +0800| [655ff4708bfe160447b07d0cbae6b710666f0139] | committer: Zhong Li

lavc/qsvdec: Add VP9 decoder support

VP9 decoder is support on Intel kabyLake+ platforms with MSDK Version 1.19+

Signed-off-by: Zhong Li 

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

 Changelog |  1 +
 configure |  1 +
 libavcodec/allcodecs.c|  1 +
 libavcodec/qsv.c  |  5 +
 libavcodec/qsvdec_other.c | 46 +++---
 5 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index e9a15d812b..c1f1237770 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 - Intel QSV-accelerated MJPEG decoding
+- Intel QSV-accelerated VP9 decoding
 
 version 4.2:
 - tpad filter
diff --git a/configure b/configure
index 78a4b00df6..c5b71883fd 100755
--- a/configure
+++ b/configure
@@ -3082,6 +3082,7 @@ vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp9_cuvid_decoder_deps="cuvid"
 vp9_mediacodec_decoder_deps="mediacodec"
+vp9_qsv_decoder_select="qsvdec"
 vp9_rkmpp_decoder_deps="rkmpp"
 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
 vp9_vaapi_encoder_select="vaapi_encode"
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index cfc1d4778d..22985325e0 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -780,6 +780,7 @@ extern AVCodec ff_vp8_v4l2m2m_encoder;
 extern AVCodec ff_vp8_vaapi_encoder;
 extern AVCodec ff_vp9_cuvid_decoder;
 extern AVCodec ff_vp9_mediacodec_decoder;
+extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of 
binaries created
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 533804ac4d..65ad070e1f 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -60,6 +60,11 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 #endif
 case AV_CODEC_ID_MJPEG:
 return MFX_CODEC_JPEG;
+#if QSV_VERSION_ATLEAST(1, 19)
+case AV_CODEC_ID_VP9:
+return MFX_CODEC_VP9;
+#endif
+
 default:
 break;
 }
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index ca5b285044..b044c11540 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -1,5 +1,5 @@
 /*
- * Intel MediaSDK QSV based MPEG-2, VC-1, VP8 and MJPEG decoders
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8, MJPEG and VP9 decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -60,8 +60,8 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
 {
 QSVOtherContext *s = avctx->priv_data;
 
-#if CONFIG_VP8_QSV_DECODER
-if (avctx->codec_id == AV_CODEC_ID_VP8)
+#if CONFIG_VP8_QSV_DECODER || CONFIG_VP9_QSV_DECODER
+if (avctx->codec_id == AV_CODEC_ID_VP8 || avctx->codec_id == 
AV_CODEC_ID_VP9)
 av_freep(>qsv.load_plugins);
 #endif
 
@@ -90,6 +90,17 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
 }
 #endif
 
+#if CONFIG_VP9_QSV_DECODER
+if (avctx->codec_id == AV_CODEC_ID_VP9) {
+static const char *uid_vp9dec_hw = "a922394d8d87452f878c51f2fc9b4131";
+
+av_freep(>qsv.load_plugins);
+s->qsv.load_plugins = av_strdup(uid_vp9dec_hw);
+if (!s->qsv.load_plugins)
+return AVERROR(ENOMEM);
+}
+#endif
+
 s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
 s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
 if (!s->packet_fifo) {
@@ -282,3 +293,32 @@ AVCodec ff_mjpeg_qsv_decoder = {
 AV_PIX_FMT_NONE },
 };
 #endif
+
+#if CONFIG_VP9_QSV_DECODER
+static const AVClass vp9_qsv_class = {
+.class_name = "vp9_qsv",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vp9_qsv_decoder = {
+.name   = "vp9_qsv",
+.long_name  = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video 
acceleration)"),
+.priv_data_size = sizeof(QSVOtherContext),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_VP9,
+.init   = qsv_decode_init,
+.decode = qsv_decode_frame,
+.flush  = qsv_decode_flush,
+.close  = qsv_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+.priv_class = _qsv_class,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+AV_PIX_FMT_P010,
+AV_PIX_FMT_Q

[FFmpeg-cvslog] lavc/qsvdec: Add mjpeg decoder support

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:11 
2019 +0800| [7555cfd29b7150a9c59f8a757ae0e5804a369644] | committer: Zhong Li

lavc/qsvdec: Add mjpeg decoder support

Signed-off-by: Zhong Li 

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

 Changelog |  3 +++
 configure |  1 +
 libavcodec/Makefile   |  1 +
 libavcodec/allcodecs.c|  1 +
 libavcodec/qsvdec_other.c | 28 +++-
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 389ca6c4db..e9a15d812b 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,9 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version :
+- Intel QSV-accelerated MJPEG decoding
+
 version 4.2:
 - tpad filter
 - AV1 decoding support through libdav1d
diff --git a/configure b/configure
index 5bd02498ee..78a4b00df6 100755
--- a/configure
+++ b/configure
@@ -3042,6 +3042,7 @@ hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 mjpeg_cuvid_decoder_deps="cuvid"
+mjpeg_qsv_decoder_select="qsvdec"
 mjpeg_qsv_encoder_deps="libmfx"
 mjpeg_qsv_encoder_select="qsvenc"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..e49188357b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -425,6 +425,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)   += metasound.o 
metasound_data.o \
 OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o
 OBJS-$(CONFIG_MIMIC_DECODER)   += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)   += mjpegdec.o
+OBJS-$(CONFIG_MJPEG_QSV_DECODER)   += qsvdec_other.o
 OBJS-$(CONFIG_MJPEG_ENCODER)   += mjpegenc.o mjpegenc_common.o \
   mjpegenc_huffman.o
 OBJS-$(CONFIG_MJPEGB_DECODER)  += mjpegbdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39ce5..cfc1d4778d 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -763,6 +763,7 @@ extern AVCodec ff_hevc_videotoolbox_encoder;
 extern AVCodec ff_libkvazaar_encoder;
 extern AVCodec ff_mjpeg_cuvid_decoder;
 extern AVCodec ff_mjpeg_qsv_encoder;
+extern AVCodec ff_mjpeg_qsv_decoder;
 extern AVCodec ff_mjpeg_vaapi_encoder;
 extern AVCodec ff_mpeg1_cuvid_decoder;
 extern AVCodec ff_mpeg2_cuvid_decoder;
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index a6f1b88ca0..ca5b285044 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -1,5 +1,5 @@
 /*
- * Intel MediaSDK QSV based MPEG-2, VC-1 and VP8 decoders
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8 and MJPEG decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -256,3 +256,29 @@ AVCodec ff_vp8_qsv_decoder = {
 .wrapper_name   = "qsv",
 };
 #endif
+
+#if CONFIG_MJPEG_QSV_DECODER
+static const AVClass mjpeg_qsv_class = {
+.class_name = "mjpeg_qsv",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_mjpeg_qsv_decoder = {
+.name   = "mjpeg_qsv",
+.long_name  = NULL_IF_CONFIG_SMALL("MJPEG video (Intel Quick Sync 
Video acceleration)"),
+.priv_data_size = sizeof(QSVOtherContext),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_MJPEG,
+.init   = qsv_decode_init,
+.decode = qsv_decode_frame,
+.flush  = qsv_decode_flush,
+.close  = qsv_decode_close,
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+.priv_class = _qsv_class,
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+AV_PIX_FMT_QSV,
+AV_PIX_FMT_NONE },
+};
+#endif

___
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/qsvdec: remove orignal parser code since not needed now

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:10 
2019 +0800| [0dfcfc5096d76e30a4ef688fc5b2402cf81f3190] | committer: Zhong Li

lavc/qsvdec: remove orignal parser code since not needed now

Signed-off-by: Zhong Li 

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

 configure   | 10 +-
 libavcodec/qsvdec.c | 28 +---
 libavcodec/qsvdec.h |  3 ---
 3 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/configure b/configure
index c09c842809..5bd02498ee 100755
--- a/configure
+++ b/configure
@@ -3018,7 +3018,7 @@ h264_mediacodec_decoder_select="h264_mp4toannexb_bsf 
h264_parser"
 h264_mmal_decoder_deps="mmal"
 h264_nvenc_encoder_deps="nvenc"
 h264_omx_encoder_deps="omx"
-h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec"
+h264_qsv_decoder_select="h264_mp4toannexb_bsf qsvdec"
 h264_qsv_encoder_select="qsvenc"
 h264_rkmpp_decoder_deps="rkmpp"
 h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
@@ -3032,7 +3032,7 @@ hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
 hevc_mediacodec_decoder_deps="mediacodec"
 hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
 hevc_nvenc_encoder_deps="nvenc"
-hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
+hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec"
 hevc_qsv_encoder_select="hevcparse qsvenc"
 hevc_rkmpp_decoder_deps="rkmpp"
 hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
@@ -3052,7 +3052,7 @@ mpeg2_crystalhd_decoder_select="crystalhd"
 mpeg2_cuvid_decoder_deps="cuvid"
 mpeg2_mmal_decoder_deps="mmal"
 mpeg2_mediacodec_decoder_deps="mediacodec"
-mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
+mpeg2_qsv_decoder_select="qsvdec"
 mpeg2_qsv_encoder_select="qsvenc"
 mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode"
 mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m"
@@ -3069,11 +3069,11 @@ nvenc_hevc_encoder_select="hevc_nvenc_encoder"
 vc1_crystalhd_decoder_select="crystalhd"
 vc1_cuvid_decoder_deps="cuvid"
 vc1_mmal_decoder_deps="mmal"
-vc1_qsv_decoder_select="qsvdec vc1_parser"
+vc1_qsv_decoder_select="qsvdec"
 vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m"
 vp8_cuvid_decoder_deps="cuvid"
 vp8_mediacodec_decoder_deps="mediacodec"
-vp8_qsv_decoder_select="qsvdec vp8_parser"
+vp8_qsv_decoder_select="qsvdec"
 vp8_rkmpp_decoder_deps="rkmpp"
 vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
 vp8_vaapi_encoder_select="vaapi_encode"
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 7e48c833ab..eef4fe7138 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -529,9 +529,6 @@ int ff_qsv_decode_close(QSVContext *q)
 av_fifo_free(q->async_fifo);
 q->async_fifo = NULL;
 
-av_parser_close(q->parser);
-avcodec_free_context(>avctx_internal);
-
 if (q->internal_session)
 MFXClose(q->internal_session);
 
@@ -544,36 +541,13 @@ int ff_qsv_decode_close(QSVContext *q)
 int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
 AVFrame *frame, int *got_frame, AVPacket *pkt)
 {
-uint8_t *dummy_data;
-int dummy_size;
 int ret;
 mfxVideoParam param = { 0 };
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NV12;
 
-if (!q->avctx_internal) {
-q->avctx_internal = avcodec_alloc_context3(NULL);
-if (!q->avctx_internal)
-return AVERROR(ENOMEM);
-
-q->avctx_internal->codec_id = avctx->codec_id;
-
-q->parser = av_parser_init(avctx->codec_id);
-if (!q->parser)
-return AVERROR(ENOMEM);
-
-q->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-}
-
 if (!pkt->size)
 return qsv_decode(avctx, q, frame, got_frame, pkt);
 
-/* we assume the packets are already split properly and want
- * just the codec parameters here */
-av_parser_parse2(q->parser, q->avctx_internal,
- _data, _size,
- pkt->data, pkt->size, pkt->pts, pkt->dts,
- pkt->pos);
-
 /* TODO: flush delayed frames on reinit */
 
 // sw_pix_fmt, coded_width/height should be set for ff_get_format(),
@@ -622,7 +596,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 return qsv_decode(avctx, q, frame, got_frame, pkt);
 
 reinit_fail:
-q->orig_pix_fmt = q->parser->format = avctx->pix_fmt = AV_PIX_FMT_NONE;
+q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
 return ret;
 }
 
diff --git a/libavcodec

[FFmpeg-cvslog] lavfi/scale_qsv: change alignment to be 16 bytes

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Jul 30 22:54:08 
2019 +0800| [d252d1c2e987960be54488f962098af8bcdc4f60] | committer: Zhong Li

lavfi/scale_qsv: change alignment to be 16 bytes

32 bytes alignment is not needed and increases the failure possibilty of
SFC (low power scaling mode)

Signed-off-by: Zhong Li 

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

 libavfilter/vf_scale_qsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 499534e30d..3cc05b64f3 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -201,8 +201,8 @@ static int init_out_pool(AVFilterContext *ctx,
 out_frames_hwctx = out_frames_ctx->hwctx;
 
 out_frames_ctx->format= AV_PIX_FMT_QSV;
-out_frames_ctx->width = FFALIGN(out_width,  32);
-out_frames_ctx->height= FFALIGN(out_height, 32);
+out_frames_ctx->width = FFALIGN(out_width,  16);
+out_frames_ctx->height= FFALIGN(out_height, 16);
 out_frames_ctx->sw_format = out_format;
 out_frames_ctx->initial_pool_size = 4;
 

___
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/qsvdec: add function ff_qsv_map_picstruct()

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:07 
2019 +0800| [f115a2b7635d9e47b1299661ddaa6ac2386e9db1] | committer: Zhong Li

lavc/qsvdec: add function ff_qsv_map_picstruct()

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 18 ++
 libavcodec/qsv_internal.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 986d4f6022..437ef7ca75 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -245,6 +245,24 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, 
QSVFrame *frame)
 return AVERROR_BUG;
 }
 
+enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct)
+{
+enum AVFieldOrder field = AV_FIELD_UNKNOWN;
+switch (mfx_pic_struct & 0xF) {
+case MFX_PICSTRUCT_PROGRESSIVE:
+field = AV_FIELD_PROGRESSIVE;
+break;
+case MFX_PICSTRUCT_FIELD_TFF:
+field = AV_FIELD_TT;
+break;
+case MFX_PICSTRUCT_FIELD_BFF:
+field = AV_FIELD_BB;
+break;
+}
+
+return field;
+}
+
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 {
 enum AVPictureType type;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index b63a7d6a31..f701ceec8d 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -95,6 +95,8 @@ int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
+enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct);
+
 int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
  const char *load_plugins);
 

___
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/qsvdec: Replace current parser with MFXVideoDECODE_DecodeHeader()

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:09 
2019 +0800| [00d0a4aa9eda8553113e51556123c46648a5f31b] | committer: Zhong Li

lavc/qsvdec: Replace current parser with MFXVideoDECODE_DecodeHeader()

Using MSDK parser can improve qsv decoder pass rate in some cases (E.g:
sps declares a wrong level_idc, smaller than it should be).
And it is necessary for adding new qsv decoders such as MJPEG and VP9
since current parser can't provide enough information.
Actually using MFXVideoDECODE_DecodeHeader() was disscussed at
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/175734.html and merged as 
commit 1acb19d,
but was overwritten when merged libav patches (commit: 1f26a23) without any 
explain.

Split decode header from decode_init, and call it for everyframe to
detect format/resoultion change. It can fix some regression issues such
as hevc 10bits decoding.

Signed-off-by: Zhong Li 
Signed-off-by: Dmitry Rogozhkin 

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

 libavcodec/qsvdec.c   | 184 --
 libavcodec/qsvdec.h   |   2 +
 libavcodec/qsvdec_h2645.c |   1 +
 libavcodec/qsvdec_other.c |   1 +
 4 files changed, 100 insertions(+), 88 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 46aa2d6814..7e48c833ab 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -147,19 +147,21 @@ static int check_dec_param(AVCodecContext *avctx, 
QSVContext *q, mfxVideoParam *
 return 1;
 }
 
-static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
+static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum 
AVPixelFormat pix_fmt, mfxVideoParam *param)
 {
-const AVPixFmtDescriptor *desc;
 mfxSession session = NULL;
 int iopattern = 0;
-mfxVideoParam param = { 0 };
-int frame_width  = avctx->coded_width;
-int frame_height = avctx->coded_height;
 int ret;
+enum AVPixelFormat pix_fmts[3] = {
+AV_PIX_FMT_QSV, /* opaque format in case of video memory output */
+pix_fmt,/* system memory format obtained from bitstream parser 
*/
+AV_PIX_FMT_NONE };
 
-desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
-if (!desc)
-return AVERROR_BUG;
+ret = ff_get_format(avctx, pix_fmts);
+if (ret < 0) {
+q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
+return ret;
+}
 
 if (!q->async_fifo) {
 q->async_fifo = av_fifo_alloc(q->async_depth * qsv_fifo_item_size());
@@ -197,54 +199,72 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 return ret;
 }
 
-ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
-if (ret < 0)
-return ret;
+param->IOPattern   = q->iopattern;
+param->AsyncDepth  = q->async_depth;
+param->ExtParam= q->ext_buffers;
+param->NumExtParam = q->nb_ext_buffers;
 
-param.mfx.CodecId  = ret;
-param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, 
avctx->profile);
-param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id, 
avctx->level);
-
-param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
-param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
-param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
-param.mfx.FrameInfo.FourCC = q->fourcc;
-param.mfx.FrameInfo.Width  = frame_width;
-param.mfx.FrameInfo.Height = frame_height;
-param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
-
-switch (avctx->field_order) {
-case AV_FIELD_PROGRESSIVE:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
-break;
-case AV_FIELD_TT:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
-break;
-case AV_FIELD_BB:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
-break;
-default:
-param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
-break;
-}
+return 0;
+ }
 
-param.IOPattern   = q->iopattern;
-param.AsyncDepth  = q->async_depth;
-param.ExtParam= q->ext_buffers;
-param.NumExtParam = q->nb_ext_buffers;
+static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxVideoParam 
*param)
+{
+int ret;
 
-if (!check_dec_param(avctx, q, )) {
-//Just give a warning instead of an error since it is still decodable 
possibly.
-av_log(avctx, AV_LOG_WARNING,
-   "Current input bitstream is not supported by QSV decoder.\n");
-}
+avctx->width= param->mfx.FrameInfo.CropW;
+avctx->height   = param->mfx.FrameInfo.CropH;
+avctx->coded_width  = param->mfx.FrameInfo.Width;
+avctx->coded_height = param->mfx.FrameInfo.Height;
+avctx->level= param->mfx.CodecLevel;
+

[FFmpeg-cvslog] lavc/qsv: make function qsv_map_fourcc() can be called externally

2019-08-19 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Aug 13 14:11:08 
2019 +0800| [f3dfd34f27ae11279baa9e2e2525e990b7c858f4] | committer: Zhong Li

lavc/qsv: make function qsv_map_fourcc() can be called externally

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 4 ++--
 libavcodec/qsv_internal.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 437ef7ca75..533804ac4d 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -207,7 +207,7 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
 return ret;
 }
 
-static enum AVPixelFormat qsv_map_fourcc(uint32_t fourcc)
+enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 {
 switch (fourcc) {
 case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
@@ -518,7 +518,7 @@ static mfxStatus qsv_frame_alloc(mfxHDL pthis, 
mfxFrameAllocRequest *req,
 frames_hwctx = frames_ctx->hwctx;
 
 frames_ctx->format= AV_PIX_FMT_QSV;
-frames_ctx->sw_format = qsv_map_fourcc(i->FourCC);
+frames_ctx->sw_format = ff_qsv_map_fourcc(i->FourCC);
 frames_ctx->width = i->Width;
 frames_ctx->height= i->Height;
 frames_ctx->initial_pool_size = req->NumFrameSuggested;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index f701ceec8d..c50e9c792c 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -92,6 +92,8 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 
+enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc);
+
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 

___
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] fate: add a case for ticket #3229

2019-08-12 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Aug 12 14:13:33 
2019 +0800| [8cd96e13eea858108667000d47281b8811042d1b] | committer: Zhong Li

fate: add a case for ticket #3229

Reviewed-by: Michael Niedermayer 
Reviewed-by: Thilo Borgmann 
Signed-off-by: Zhong Li 

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

 tests/fate/video.mak| 3 +++
 tests/ref/fate/mjpeg-ticket3229 | 8 
 2 files changed, 11 insertions(+)

diff --git a/tests/fate/video.mak b/tests/fate/video.mak
index be1458c8bb..d2d43e518d 100644
--- a/tests/fate/video.mak
+++ b/tests/fate/video.mak
@@ -232,6 +232,9 @@ fate-mimic: CMD = framecrc -idct simple -i 
$(TARGET_SAMPLES)/mimic/mimic2-womanl
 FATE_VIDEO-$(call DEMDEC, MOV, MJPEGB) += fate-mjpegb
 fate-mjpegb: CMD = framecrc -idct simple -fflags +bitexact -i 
$(TARGET_SAMPLES)/mjpegb/mjpegb_part.mov -an
 
+FATE_VIDEO-$(call DEMDEC, AVI, MJPEG) += fate-mjpeg-ticket3229
+fate-mjpeg-ticket3229: CMD = framecrc -idct simple -fflags +bitexact -i 
$(TARGET_SAMPLES)/mjpeg/mjpeg_field_order.avi -an
+
 FATE_VIDEO-$(call DEMDEC, MVI, MOTIONPIXELS) += fate-motionpixels
 fate-motionpixels: CMD = framecrc -i 
$(TARGET_SAMPLES)/motion-pixels/INTRO-partial.MVI -an -pix_fmt rgb24 -frames:v 
111
 
diff --git a/tests/ref/fate/mjpeg-ticket3229 b/tests/ref/fate/mjpeg-ticket3229
new file mode 100644
index 00..fc5a8dd7ff
--- /dev/null
+++ b/tests/ref/fate/mjpeg-ticket3229
@@ -0,0 +1,8 @@
+#tb 0: 1/30
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 468x312
+#sar 0: 0/1
+0,  0,  0,1,   292032, 0x3af3a5f7
+0,  6,  6,1,   292032, 0xe97fb504
+0,  8,  8,1,   292032, 0xd448db04

___
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: fix the incorrent map from bits to bytes

2019-06-30 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Jun 28 13:18:43 
2019 +0800| [4dc3d93880315f66ce917ae327c67a85262f285e] | committer: Zhong Li

lavc/qsvenc: fix the incorrent map from bits to bytes

Reported-by:Maggie Sun 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 2 +-
 libavcodec/version.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 8dbad713d0..9bf8574e30 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -577,7 +577,7 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 
 //libmfx BRC parameters are 16 bits thus maybe overflow, then 
BRCParamMultiplier is needed
 buffer_size_in_kilobytes   = avctx->rc_buffer_size / 8000;
-initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 1000;
+initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 8000;
 target_bitrate_kbps= avctx->bit_rate / 1000;
 max_bitrate_kbps   = avctx->rc_max_rate / 1000;
 brc_param_multiplier   = (FFMAX(FFMAX3(target_bitrate_kbps, 
max_bitrate_kbps, buffer_size_in_kilobytes),
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 2709163700..3583499f19 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  53
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

___
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/mjpegdec: make code aligned

2019-06-30 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Jun 27 16:58:24 
2019 +0800| [e51cc7ed856aa3d5e14c50a46d8156c79d483367] | committer: Zhong Li

lavc/mjpegdec: make code aligned

Reviewed-by: Michael Niedermayer 
Signed-off-by: Zhong Li 

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

 libavcodec/mjpegdec.c | 450 +-
 1 file changed, 225 insertions(+), 225 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1030861e85..a65bc8df15 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -453,268 +453,268 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 avpriv_request_sample(s->avctx, "progressively coded interlaced 
picture");
 return AVERROR_INVALIDDATA;
 }
-} else{
+} else {
 if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && 
(nb_components==3 || nb_components==4))
 s->rgb = 1;
 else if (!s->lossless)
 s->rgb = 0;
-/* XXX: not complete test ! */
-pix_fmt_id = ((unsigned)s->h_count[0] << 28) | (s->v_count[0] << 24) |
- (s->h_count[1] << 20) | (s->v_count[1] << 16) |
- (s->h_count[2] << 12) | (s->v_count[2] <<  8) |
- (s->h_count[3] <<  4) |  s->v_count[3];
-av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
-/* NOTE we do not allocate pictures large enough for the possible
- * padding of h/v_count being 4 */
-if (!(pix_fmt_id & 0xD0D0D0D0))
-pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
-if (!(pix_fmt_id & 0x0D0D0D0D))
-pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
-
-for (i = 0; i < 8; i++) {
-int j = 6 + (i&1) - (i&6);
-int is = (pix_fmt_id >> (4*i)) & 0xF;
-int js = (pix_fmt_id >> (4*j)) & 0xF;
-
-if (is == 1 && js != 2 && (i < 2 || i > 5))
-js = (pix_fmt_id >> ( 8 + 4*(i&1))) & 0xF;
-if (is == 1 && js != 2 && (i < 2 || i > 5))
-js = (pix_fmt_id >> (16 + 4*(i&1))) & 0xF;
-
-if (is == 1 && js == 2) {
-if (i & 1) s->upscale_h[j/2] = 1;
-else   s->upscale_v[j/2] = 1;
-}
-}
-
-switch (pix_fmt_id) {
-case 0x1100:
-if (s->rgb)
-s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
-else {
-if (   s->adobe_transform == 0
-|| s->component_id[0] == 'R' - 1 && s->component_id[1] == 'G' 
- 1 && s->component_id[2] == 'B' - 1) {
-s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : 
AV_PIX_FMT_GBRP16;
-} else {
-if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
-else  s->avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
-s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
+/* XXX: not complete test ! */
+pix_fmt_id = ((unsigned)s->h_count[0] << 28) | (s->v_count[0] << 24) |
+ (s->h_count[1] << 20) | (s->v_count[1] << 16) |
+ (s->h_count[2] << 12) | (s->v_count[2] <<  8) |
+ (s->h_count[3] <<  4) |  s->v_count[3];
+av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
+/* NOTE we do not allocate pictures large enough for the possible
+ * padding of h/v_count being 4 */
+if (!(pix_fmt_id & 0xD0D0D0D0))
+pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
+if (!(pix_fmt_id & 0x0D0D0D0D))
+pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
+
+for (i = 0; i < 8; i++) {
+int j = 6 + (i&1) - (i&6);
+int is = (pix_fmt_id >> (4*i)) & 0xF;
+int js = (pix_fmt_id >> (4*j)) & 0xF;
+
+if (is == 1 && js != 2 && (i < 2 || i > 5))
+js = (pix_fmt_id >> ( 8 + 4*(i&1))) & 0xF;
+if (is == 1 && js != 2 && (i < 2 || i > 5))
+js = (pix_fmt_id >> (16 + 4*(i&1))) & 0xF;
+
+if (is == 1 && js == 2) {
+if (i & 1) s->upscale_h[j/2] = 1;
+else   s->upscale_v[j/2] = 1;
 }
 }
-av_assert0(s->nb_components == 3);
-break;
-case 0x:
-if (s->rgb)
-s-

[FFmpeg-cvslog] lavc/mjpegdec: replace number with marker name

2019-06-30 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Jun 27 16:58:23 
2019 +0800| [a6c648f2b4fdace0eeea66a7b556bc814023b598] | committer: Zhong Li

lavc/mjpegdec: replace number with marker name

Make it easier to read.

Signed-off-by: Zhong Li 

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

 libavcodec/mjpegdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 20eeb960bb..1030861e85 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2115,7 +2115,7 @@ static int find_marker(const uint8_t **pbuf_ptr, const 
uint8_t *buf_end)
 while (buf_end - buf_ptr > 1) {
 v  = *buf_ptr++;
 v2 = *buf_ptr;
-if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
+if ((v == 0xff) && (v2 >= SOF0) && (v2 <= COM) && buf_ptr < buf_end) {
 val = *buf_ptr++;
 goto found;
 }
@@ -2180,7 +2180,7 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s,
 src--;
 }
 
-if (x < 0xd0 || x > 0xd7) {
+if (x < RST0 || x > RST7) {
 copy_data_segment(1);
 if (x)
 break;
@@ -2319,7 +2319,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
 
 /* process markers */
-if (start_code >= 0xd0 && start_code <= 0xd7) {
+if (start_code >= RST0 && start_code <= RST7) {
 av_log(avctx, AV_LOG_DEBUG,
"restart marker: %d\n", start_code & 0x0f);
 /* APP fields */

___
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/qsv_scale: add scaling modes support

2019-06-24 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Jun 18 15:52:29 
2019 +0800| [dd662bbdd26e09957b3e67d3cde07b9468931e15] | committer: Zhong Li

lavf/qsv_scale: add scaling modes support

low_power mode will use a fixed HW engine (SFC), thus can offload EU usage.
high quality mode will take EU usage (AVS sampler).

Performance and EU usage (Render usage) comparsion on Intel(R) Xeon(R) CPU 
E3-1225 v5 @ 3.30GHz:

High quality mode : ffmpeg -hwaccel qsv -c:v h264_qsv -i 
bbb_sunflower_1080p_30fps_normal_2000frames.h264 \
-vf scale_qsv=w=1280:h=736:mode=hq -f null -
fps=389
RENDER usage: 28.10 (provided by MSDK metrics_monitor)

Low Power mode: ffmpeg -hwaccel qsv -c:v h264_qsv -i 
~/bbb_sunflower_1080p_30fps_normal_2000frames.h264 \
-vf scale_qsv=w=1280:h=736:mode=low_power -f null -
fps=343
RENDER usage: 0.00

Low power mode (SFC) may be disabled if not supported by
MSDK/Driver/HW, and replaced by AVS mode interanlly.

Signed-off-by: Zhong Li 

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

 libavfilter/vf_scale_qsv.c | 40 +++-
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index db7715fc1b..499534e30d 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -69,6 +69,8 @@ enum var_name {
 VARS_NB
 };
 
+#define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
+
 typedef struct QSVScaleContext {
 const AVClass *class;
 
@@ -88,7 +90,14 @@ typedef struct QSVScaleContext {
 int nb_surface_ptrs_out;
 
 mfxExtOpaqueSurfaceAlloc opaque_alloc;
-mfxExtBuffer*ext_buffers[1];
+
+#if QSV_HAVE_SCALING_CONFIG
+mfxExtVPPScaling scale_conf;
+#endif
+int  mode;
+
+mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
+int  num_ext_buf;
 
 int shift_width, shift_height;
 
@@ -285,6 +294,8 @@ static int init_out_session(AVFilterContext *ctx)
 mfxStatus err;
 int i;
 
+s->num_ext_buf = 0;
+
 /* extract the properties of the "master" session given to us */
 err = MFXQueryIMPL(device_hwctx->session, );
 if (err == MFX_ERR_NONE)
@@ -357,10 +368,7 @@ static int init_out_session(AVFilterContext *ctx)
 s->opaque_alloc.Header.BufferId = 
MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
 
-s->ext_buffers[0] = (mfxExtBuffer*)>opaque_alloc;
-
-par.ExtParam= s->ext_buffers;
-par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
+s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)>opaque_alloc;
 
 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | 
MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
 } else {
@@ -396,6 +404,18 @@ static int init_out_session(AVFilterContext *ctx)
 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | 
MFX_IOPATTERN_OUT_VIDEO_MEMORY;
 }
 
+#if QSV_HAVE_SCALING_CONFIG
+memset(>scale_conf, 0, sizeof(mfxExtVPPScaling));
+s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
+s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
+s->scale_conf.ScalingMode = s->mode;
+s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)>scale_conf;
+av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %"PRIu16"\n", s->mode);
+#endif
+
+par.ExtParam= s->ext_buffers;
+par.NumExtParam = s->num_ext_buf;
+
 par.AsyncDepth = 1;// TODO async
 
 par.vpp.In  = in_frames_hwctx->surfaces[0].Info;
@@ -595,6 +615,16 @@ static const AVOption options[] = {
 { "h",  "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, 
{ .str = "ih"   }, .flags = FLAGS },
 { "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, 
{ .str = "same" }, .flags = FLAGS },
 
+#if QSV_HAVE_SCALING_CONFIG
+{ "mode",  "set scaling mode",OFFSET(mode),AV_OPT_TYPE_INT,
{ .i64 = MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, 
MFX_SCALING_MODE_QUALITY, FLAGS, "mode"},
+{ "low_power", "low power mode",0, AV_OPT_TYPE_CONST,  
{ .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "mode"},
+{ "hq","high quality mode", 0, AV_OPT_TYPE_CONST,  
{ .i64 = MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX, FLAGS, "mode"},
+#else
+{ "mode",  "(not supported)", OFFSET(mode),AV_OPT_TYPE_INT,
{ .i64 = 0}, 0, INT_MAX, FLAGS, "mode"},
+{ "low_power", "",  0, AV_OPT_TYPE_CONST,  
{ .i64 = 1}, 0,   0, FLAGS, "mode"},
+   

[FFmpeg-cvslog] lavf/qsv_vpp: add frame format option

2019-06-13 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri May 31 08:44:47 
2019 +0800| [4208b428c4730f86438ec777642c6e455845b670] | committer: Zhong Li

lavf/qsv_vpp: add frame format option

1. Currently output format is hard-coded as NV12, thus means
   CSC is always done for not NV12 input such as P010.
   Follow original input format as default output.
2. Add an option to specify output format.

Signed-off-by: Zhong Li 

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

 libavfilter/vf_vpp_qsv.c | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index dd05e8baff..915cf748c4 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -57,6 +57,10 @@ typedef struct VPPContext{
 
 int out_width;
 int out_height;
+/**
+ * Output sw format. AV_PIX_FMT_NONE for no conversion.
+ */
+enum AVPixelFormat out_format;
 
 AVRational framerate;   /* target framerate */
 int use_frc;/* use framerate conversion */
@@ -79,6 +83,7 @@ typedef struct VPPContext{
 
 char *cx, *cy, *cw, *ch;
 char *ow, *oh;
+char *output_format_str;
 } VPPContext;
 
 static const AVOption options[] = {
@@ -104,6 +109,8 @@ static const AVOption options[] = {
 { "width",  "Output video width",  OFFSET(ow), AV_OPT_TYPE_STRING, { 
.str="cw" }, 0, 255, .flags = FLAGS },
 { "h",  "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { 
.str="w*ch/cw" }, 0, 255, .flags = FLAGS },
 { "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { 
.str="w*ch/cw" }, 0, 255, .flags = FLAGS },
+{ "format", "Output pixel format", OFFSET(output_format_str), 
AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
+
 { NULL }
 };
 
@@ -207,6 +214,23 @@ release:
 return ret;
 }
 
+static av_cold int vpp_init(AVFilterContext *ctx)
+{
+VPPContext  *vpp  = ctx->priv;
+
+if (!strcmp(vpp->output_format_str, "same")) {
+vpp->out_format = AV_PIX_FMT_NONE;
+} else {
+vpp->out_format = av_get_pix_fmt(vpp->output_format_str);
+if (vpp->out_format == AV_PIX_FMT_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Unrecognized output pixel format: 
%s\n", vpp->output_format_str);
+return AVERROR(EINVAL);
+}
+}
+
+return 0;
+}
+
 static int config_input(AVFilterLink *inlink)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -251,6 +275,7 @@ static int config_output(AVFilterLink *outlink)
 QSVVPPCrop  crop  = { 0 };
 mfxExtBuffer*ext_buf[ENH_FILTERS_COUNT];
 AVFilterLink*inlink = ctx->inputs[0];
+enum AVPixelFormat in_format;
 
 outlink->w  = vpp->out_width;
 outlink->h  = vpp->out_height;
@@ -258,10 +283,19 @@ static int config_output(AVFilterLink *outlink)
 outlink->time_base  = av_inv_q(vpp->framerate);
 
 param.filter_frame  = NULL;
-param.out_sw_format = AV_PIX_FMT_NV12;
 param.num_ext_buf   = 0;
 param.ext_buf   = ext_buf;
 
+if (inlink->format == AV_PIX_FMT_QSV) {
+ if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data)
+ return AVERROR(EINVAL);
+ else
+ in_format = 
((AVHWFramesContext*)inlink->hw_frames_ctx->data)->sw_format;
+} else
+in_format = inlink->format;
+
+param.out_sw_format  = (vpp->out_format == AV_PIX_FMT_NONE) ? in_format : 
vpp->out_format;
+
 if (vpp->use_crop) {
 crop.in_idx = 0;
 crop.x = vpp->crop_x;
@@ -422,6 +456,7 @@ AVFilter ff_vf_vpp_qsv = {
 .description   = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."),
 .priv_size = sizeof(VPPContext),
 .query_formats = query_formats,
+.init  = vpp_init,
 .uninit= vpp_uninit,
 .inputs= vpp_inputs,
 .outputs   = vpp_outputs,

___
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/qsvvpp: add P010 output format support

2019-06-10 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri May 31 08:44:48 
2019 +0800| [e62f625163f8cde794ebe02bc228735b4e65c772] | committer: Zhong Li

lavf/qsvvpp: add P010 output format support

Signed-off-by: Zhong Li 

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

 libavfilter/qsvvpp.c | 1 +
 libavfilter/vf_vpp_qsv.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index b5ef74efa4..8d5ff2eb65 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -153,6 +153,7 @@ static int map_frame_to_surface(AVFrame *frame, 
mfxFrameSurface1 *surface)
 {
 switch (frame->format) {
 case AV_PIX_FMT_NV12:
+case AV_PIX_FMT_P010:
 surface->Data.Y  = frame->data[0];
 surface->Data.UV = frame->data[1];
 break;
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 41a9f38962..dd05e8baff 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -367,6 +367,7 @@ static int query_formats(AVFilterContext *ctx)
 };
 static const enum AVPixelFormat out_pix_fmts[] = {
 AV_PIX_FMT_NV12,
+AV_PIX_FMT_P010,
 AV_PIX_FMT_QSV,
 AV_PIX_FMT_NONE
 };

___
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/qsvvpp: add extra_hw_frames support

2019-06-10 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Jun  5 16:56:27 
2019 +0800| [ef56c28b2596eea233860d8c90f054e76da44758] | committer: Zhong Li

lavf/qsvvpp: add extra_hw_frames support

extra_hw_frames is needed for some cases.
(eg: qsv decoding + qsv vpp + qsv look_ahead encoding, transcoding
 failed if no extra_hw_frames supported:
 ffmpeg -hwaccel qsv -c:v h264_qsv -i 
bbb_sunflower_1080p_30fps_normal_2000frames.mp4 \
-vf vpp_qsv=w=1280:h=720:extra_hw_frames=100 -v verbose  -c:v h264_qsv \
-look_ahead 1 -look_ahead_depth 100 out1.mp4
)

Signed-off-by: Zhong Li 

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

 libavfilter/qsvvpp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 5cd1d5d345..b5ef74efa4 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -460,6 +460,8 @@ static int init_vpp_session(AVFilterContext *avctx, 
QSVVPPContext *s)
 out_frames_ctx->height= FFALIGN(outlink->h, 32);
 out_frames_ctx->sw_format = s->out_sw_format;
 out_frames_ctx->initial_pool_size = 64;
+if (avctx->extra_hw_frames > 0)
+out_frames_ctx->initial_pool_size += avctx->extra_hw_frames;
 out_frames_hwctx->frame_type  = s->out_mem_mode;
 
 ret = av_hwframe_ctx_init(out_frames_ref);

___
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/qsv: use av_cold for init/uninit

2019-06-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri May 31 08:44:49 
2019 +0800| [165eabf19bf21d235e1b5254314ba2ba5c627454] | committer: Zhong Li

lavf/qsv: use av_cold for init/uninit

Signed-off-by: Zhong Li 

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

 libavfilter/vf_deinterlace_qsv.c | 2 +-
 libavfilter/vf_overlay_qsv.c | 2 +-
 libavfilter/vf_scale_qsv.c   | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index bee10c220f..80217c8419 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -83,7 +83,7 @@ typedef struct QSVDeintContext {
 int mode;
 } QSVDeintContext;
 
-static void qsvdeint_uninit(AVFilterContext *ctx)
+static av_cold void qsvdeint_uninit(AVFilterContext *ctx)
 {
 QSVDeintContext *s = ctx->priv;
 QSVFrame *cur;
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 9aabb594ba..2a4dc5cb58 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -345,7 +345,7 @@ static int overlay_qsv_init(AVFilterContext *ctx)
 return 0;
 }
 
-static void overlay_qsv_uninit(AVFilterContext *ctx)
+static av_cold void overlay_qsv_uninit(AVFilterContext *ctx)
 {
 QSVOverlayContext *vpp = ctx->priv;
 
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 7d593b2b21..db7715fc1b 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -109,7 +109,7 @@ typedef struct QSVScaleContext {
 char *format_str;
 } QSVScaleContext;
 
-static int qsvscale_init(AVFilterContext *ctx)
+static av_cold int qsvscale_init(AVFilterContext *ctx)
 {
 QSVScaleContext *s = ctx->priv;
 
@@ -126,7 +126,7 @@ static int qsvscale_init(AVFilterContext *ctx)
 return 0;
 }
 
-static void qsvscale_uninit(AVFilterContext *ctx)
+static av_cold void qsvscale_uninit(AVFilterContext *ctx)
 {
 QSVScaleContext *s = ctx->priv;
 

___
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/qsv: extactly map profile

2019-05-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sun Apr 28 20:27:48 
2019 +0800| [5b318ce68df6cb4939b0be68e22853621e1e3aab] | committer: Zhong Li

lavc/qsv: extactly map profile

Currently profile mapping is hard-coded, and not flexible to do extactly
map (E.g: libmfx treats H264 constrained baseline to be baseline profile).

vaapi profile mapping funtion provides a better soultion than current
qsv mapping.

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c | 52 
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 4d3fbafe04..986d4f6022 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -67,19 +67,55 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 return AVERROR(ENOSYS);
 }
 
+
+static const struct {
+enum AVCodecID codec_id;
+int codec_profile;
+int mfx_profile;
+} qsv_profile_map[] = {
+#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, MFX_PROFILE_ ## v }
+MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2_SIMPLE ),
+MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2_MAIN   ),
+MAP(MPEG2VIDEO,  MPEG2_HIGH,  MPEG2_HIGH   ),
+
+MAP(H264,H264_BASELINE,   AVC_BASELINE ),
+MAP(H264,H264_CONSTRAINED_BASELINE, AVC_BASELINE),
+#if QSV_VERSION_ATLEAST(1, 3)
+MAP(H264,H264_EXTENDED,   AVC_EXTENDED ),
+#endif
+MAP(H264,H264_MAIN,   AVC_MAIN ),
+MAP(H264,H264_HIGH,   AVC_HIGH ),
+MAP(H264,H264_HIGH_422,   AVC_HIGH_422 ),
+
+#if QSV_VERSION_ATLEAST(1, 8)
+MAP(HEVC,HEVC_MAIN,   HEVC_MAIN),
+MAP(HEVC,HEVC_MAIN_10,HEVC_MAIN10  ),
+MAP(HEVC,HEVC_MAIN_STILL_PICTURE,HEVC_MAINSP ),
+#endif
+#if QSV_VERSION_ATLEAST(1, 16)
+MAP(HEVC,HEVC_REXT,   HEVC_REXT),
+#endif
+
+MAP(VC1, VC1_SIMPLE,  VC1_SIMPLE   ),
+MAP(VC1, VC1_MAIN,VC1_MAIN ),
+MAP(VC1, VC1_COMPLEX, VC1_ADVANCED ),
+MAP(VC1, VC1_ADVANCED,VC1_ADVANCED ),
+#undef MAP
+};
+
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile)
 {
+int i;
 if (profile == FF_PROFILE_UNKNOWN)
 return MFX_PROFILE_UNKNOWN;
-switch (codec_id) {
-case AV_CODEC_ID_H264:
-case AV_CODEC_ID_HEVC:
-return profile;
-case AV_CODEC_ID_VC1:
-return 4 * profile + 1;
-case AV_CODEC_ID_MPEG2VIDEO:
-return 0x10 * profile;
+
+for (i = 0; i < FF_ARRAY_ELEMS(qsv_profile_map); i++) {
+if (qsv_profile_map[i].codec_id != codec_id)
+continue;
+if (qsv_profile_map[i].codec_profile == profile)
+return qsv_profile_map[i].mfx_profile;
 }
+
 return MFX_PROFILE_UNKNOWN;
 }
 

___
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/qsvdec: fix hevc level incorrectly map

2019-05-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sun Apr 28 17:15:55 
2019 +0800| [94ab39ec78c536703f77821fc039fee649105aab] | committer: Zhong Li

lavc/qsvdec: fix hevc level incorrectly map

libmfx hevc level defination is same as h264, not level_idc of SPEC.

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c  | 13 +
 libavcodec/qsv_internal.h |  1 +
 libavcodec/qsvdec.c   |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index bb0d79588c..4d3fbafe04 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -83,6 +83,19 @@ int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int 
profile)
 return MFX_PROFILE_UNKNOWN;
 }
 
+int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level)
+{
+if (level == FF_LEVEL_UNKNOWN)
+return MFX_LEVEL_UNKNOWN;
+
+switch (codec_id) {
+case AV_CODEC_ID_HEVC:
+return level / 3;
+default:
+return level;
+}
+}
+
 static const struct {
 mfxStatus   mfxerr;
 int averr;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 57d861d2be..b63a7d6a31 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -90,6 +90,7 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
+int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 2a8a032111..46aa2d6814 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -203,7 +203,7 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 
 param.mfx.CodecId  = ret;
 param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, 
avctx->profile);
-param.mfx.CodecLevel   = avctx->level == FF_LEVEL_UNKNOWN ? 
MFX_LEVEL_UNKNOWN : avctx->level;
+param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id, 
avctx->level);
 
 param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
 param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;

___
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/qsvdec: add query function and provide error message

2019-05-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Apr 25 18:51:10 
2019 +0800| [48627aaf646270a8c98337ee208574543e499bfd] | committer: Zhong Li

lavc/qsvdec: add query function and provide error message

It is helpful to know why some clips decoding failed.
Ticket#7330 is a good example, with this patch it is easily to
know bitstream codec level is out of support range.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvdec.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 4a0be811fb..2a8a032111 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -120,6 +120,33 @@ static inline unsigned int qsv_fifo_size(const 
AVFifoBuffer* fifo)
 return av_fifo_size(fifo) / qsv_fifo_item_size();
 }
 
+static int check_dec_param(AVCodecContext *avctx, QSVContext *q, mfxVideoParam 
*param_in)
+{
+mfxVideoParam param_out = { .mfx.CodecId = param_in->mfx.CodecId };
+mfxStatus ret;
+
+#define CHECK_MATCH(x) \
+do { \
+  if (param_out.mfx.x != param_in->mfx.x) {   \
+  av_log(avctx, AV_LOG_WARNING, "Required "#x" %d is unsupported\n", \
+  param_in->mfx.x); \
+  } \
+} while (0)
+
+ret = MFXVideoDECODE_Query(q->session, param_in, _out);
+
+if (ret < 0) {
+CHECK_MATCH(CodecId);
+CHECK_MATCH(CodecProfile);
+CHECK_MATCH(CodecLevel);
+CHECK_MATCH(FrameInfo.Width);
+CHECK_MATCH(FrameInfo.Height);
+#undef CHECK_MATCH
+return 0;
+}
+return 1;
+}
+
 static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
 {
 const AVPixFmtDescriptor *desc;
@@ -206,6 +233,12 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 param.ExtParam= q->ext_buffers;
 param.NumExtParam = q->nb_ext_buffers;
 
+if (!check_dec_param(avctx, q, )) {
+//Just give a warning instead of an error since it is still decodable 
possibly.
+av_log(avctx, AV_LOG_WARNING,
+   "Current input bitstream is not supported by QSV decoder.\n");
+}
+
 ret = MFXVideoDECODE_Init(q->session, );
 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: no need to include h264.h for jpeg encoder

2019-04-03 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Apr  1 12:18:57 
2019 +0800| [6f9d7c556d5f466c604fe76723950b834c5d1af4] | committer: Zhong Li

lavc/qsvenc: no need to include h264.h for jpeg encoder

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc_jpeg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index 1e7785a826..1619a335c7 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -29,7 +29,6 @@
 
 #include "avcodec.h"
 #include "internal.h"
-#include "h264.h"
 #include "qsv.h"
 #include "qsv_internal.h"
 #include "qsvenc.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] lavc/qsvenc: enable hevc gpb option

2019-04-03 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Jan 11 15:09:07 
2019 +0800| [1125277bc64ebef1a7a6bee7349c7a8fab7fdcc7] | committer: Zhong Li

lavc/qsvenc: enable hevc gpb option

GPB is the default type, just contains forward references but the
slice_type is B slice with higher encoding efficiency than regular P
slice, but lower performance.

Add an option to allow user to set regular P slice.

Fix ticket#6870

Test data on Intel Kabylake (i7-7567U CPU @ 3.50GHz):
1. ffmpeg -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 
-vsync passthrough
-vframes 1000  -c:v hevc_qsv -gpb 0 -bf 0 -q 25 test_gpb_off_bf0_kbl.mp4

transcoding fps: 85
encoded file size of test_gpb_off_bf0_kbl.mp4: 21960100 (bytes)

2. ffmpeg -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 
-vsync passthrough
-vframes 1000  -c:v hevc_qsv -gpb 1 -bf 0 -q 25 test_gpb_on_bf0_kbl.mp4

transcoding fps: 79
encoded file size oftest_gpb_on_bf0_kbl.mp4:  21211449 (bytes)

In this case, enable gpb can bring about 7% performance drop but 3.4% encoding 
efficiency improvment.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 9 +
 libavcodec/qsvenc.h  | 3 +++
 libavcodec/qsvenc_hevc.c | 2 ++
 3 files changed, 14 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 55f1223f02..a03ab69590 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -267,6 +267,11 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #endif
 #endif
 
+#if QSV_HAVE_GPB
+if (avctx->codec_id == AV_CODEC_ID_HEVC)
+av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB));
+#endif
+
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 av_log(avctx, AV_LOG_VERBOSE, "Entropy coding: %s; 
MaxDecFrameBuffering: %"PRIu16"\n",
co->CAVLC == MFX_CODINGOPTION_ON ? "CAVLC" : "CABAC", 
co->MaxDecFrameBuffering);
@@ -748,6 +753,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #if QSV_HAVE_CO3
 q->extco3.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION3;
 q->extco3.Header.BufferSz  = sizeof(q->extco3);
+#if QSV_HAVE_GPB
+if (avctx->codec_id == AV_CODEC_ID_HEVC)
+q->extco3.GPB  = q->gpb ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
+#endif
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco3;
 #endif
 }
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index f6d53d44cd..f2f4d38503 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -47,6 +47,8 @@
 #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
 #define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)
 
+#define QSV_HAVE_GPBQSV_VERSION_ATLEAST(1, 18)
+
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
 #define QSV_HAVE_ICQQSV_VERSION_ATLEAST(1, 8)
@@ -173,6 +175,7 @@ typedef struct QSVEncContext {
 
 int repeat_pps;
 int low_power;
+int gpb;
 
 int a53_cc;
 
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 4c2592355e..da64b4c21b 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -241,6 +241,8 @@ static const AVOption options[] = {
 { "main10",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10  
}, INT_MIN, INT_MAX, VE, "profile" },
 { "mainsp",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP  
}, INT_MIN, INT_MAX, VE, "profile" },
 
+{ "gpb", "1: GPB (generalized P/B frame); 0: regular P frame", 
OFFSET(qsv.gpb), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE},
+
 { NULL },
 };
 

___
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 hevc coding options configuration

2019-04-03 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 27 14:33:36 
2019 +0800| [c745bedd18afea19e3eb75da3d094d542b02a88b] | committer: Zhong Li

lavc/qsvenc: enable hevc coding options configuration

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e76c580b4a..55f1223f02 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -629,9 +629,10 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 #endif
 }
 
-// the HEVC encoder plugin currently fails if coding options
-// are provided
-if (avctx->codec_id != AV_CODEC_ID_HEVC) {
+// 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)) {
 q->extco.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION;
 q->extco.Header.BufferSz  = sizeof(q->extco);
 

___
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: get vps extradata from MSDK

2019-04-01 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 27 02:56:24 
2019 +0800| [d071a1117daff0a84bafe9b437164fdef97af98f] | committer: Zhong Li

lavc/qsvenc: get vps extradata from MSDK

Signed-off-by: Zhong Li 
Reviewed-by: Mark Thompson 

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

 libavcodec/qsvenc.c  | 66 +++-
 libavcodec/qsvenc.h  |  3 +++
 libavcodec/qsvenc_hevc.c | 10 +---
 3 files changed, 58 insertions(+), 21 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 4c03133817..e76c580b4a 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -810,22 +810,37 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, 
QSVEncContext *q)
 };
 #endif
 
-mfxExtBuffer *ext_buffers[] = {
-(mfxExtBuffer*),
-(mfxExtBuffer*),
+#if QSV_HAVE_CO_VPS
+uint8_t vps_buf[128];
+mfxExtCodingOptionVPS extradata_vps = {
+.Header.BufferId = MFX_EXTBUFF_CODING_OPTION_VPS,
+.Header.BufferSz = sizeof(extradata_vps),
+.VPSBuffer   = vps_buf,
+.VPSBufSize  = sizeof(vps_buf),
+};
+#endif
+
+mfxExtBuffer *ext_buffers[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + 
QSV_HAVE_CO_VPS];
+
+int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO;
+int ret, ext_buf_num = 0, extradata_offset = 0;
+
+ext_buffers[ext_buf_num++] = (mfxExtBuffer*)
+ext_buffers[ext_buf_num++] = (mfxExtBuffer*)
 #if QSV_HAVE_CO2
-(mfxExtBuffer*),
+ext_buffers[ext_buf_num++] = (mfxExtBuffer*)
 #endif
 #if QSV_HAVE_CO3
-(mfxExtBuffer*),
+ext_buffers[ext_buf_num++] = (mfxExtBuffer*)
+#endif
+#if QSV_HAVE_CO_VPS
+q->hevc_vps = ((avctx->codec_id == AV_CODEC_ID_HEVC) && 
QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 17));
+if (q->hevc_vps)
+ext_buffers[ext_buf_num++] = (mfxExtBuffer*)_vps;
 #endif
-};
-
-int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO;
-int ret;
 
 q->param.ExtParam= ext_buffers;
-q->param.NumExtParam = FF_ARRAY_ELEMS(ext_buffers);
+q->param.NumExtParam = ext_buf_num;
 
 ret = MFXVideoENCODE_GetVideoParam(q->session, >param);
 if (ret < 0)
@@ -834,20 +849,37 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, 
QSVEncContext *q)
 
 q->packet_size = q->param.mfx.BufferSizeInKB * 
q->param.mfx.BRCParamMultiplier * 1000;
 
-if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)) {
+if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)
+#if QSV_HAVE_CO_VPS
+|| (q->hevc_vps && !extradata_vps.VPSBufSize)
+#endif
+) {
 av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n");
 return AVERROR_UNKNOWN;
 }
 
-avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * 
extradata.PPSBufSize +
- AV_INPUT_BUFFER_PADDING_SIZE);
+avctx->extradata_size = extradata.SPSBufSize + need_pps * 
extradata.PPSBufSize;
+#if QSV_HAVE_CO_VPS
+avctx->extradata_size += q->hevc_vps * extradata_vps.VPSBufSize;
+#endif
+
+avctx->extradata = av_malloc(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!avctx->extradata)
 return AVERROR(ENOMEM);
 
-memcpy(avctx->extradata,sps_buf, 
extradata.SPSBufSize);
-if (need_pps)
-memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, 
extradata.PPSBufSize);
-avctx->extradata_size = extradata.SPSBufSize + need_pps * 
extradata.PPSBufSize;
+#if QSV_HAVE_CO_VPS
+if (q->hevc_vps) {
+memcpy(avctx->extradata, vps_buf, extradata_vps.VPSBufSize);
+extradata_offset += extradata_vps.VPSBufSize;
+}
+#endif
+
+memcpy(avctx->extradata + extradata_offset, sps_buf, extradata.SPSBufSize);
+extradata_offset += extradata.SPSBufSize;
+if (need_pps) {
+memcpy(avctx->extradata + extradata_offset, pps_buf, 
extradata.PPSBufSize);
+extradata_offset += extradata.PPSBufSize;
+}
 memset(avctx->extradata + avctx->extradata_size, 0, 
AV_INPUT_BUFFER_PADDING_SIZE);
 
 cpb_props = ff_add_cpb_side_data(avctx);
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 70e0b048ee..f6d53d44cd 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -36,6 +36,7 @@
 
 #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6)
 #define QSV_HAVE_CO3 QSV_VERSION_ATLEAST(1, 11)
+#define QSV_HAVE_CO_VPS  QSV_VERSION_ATLEAST(1, 17)
 
 #define QSV_HAVE_TRELLIS QSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_MAX_SLICE_SIZE QSV_VERSION_ATLEAST(1, 9)
@@ -134,6 +135,8 @@ typedef struct QSVEncContext {
 
 mfxVersion  ver;
 
+int hevc_vps;
+
 // options set by the caller
 int async_depth;
 int idr_interval;
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc

[FFmpeg-cvslog] lavc/qsvenc: fix hevc vps extradata issues

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Mar 26 06:10:21 
2019 +0800| [9dece050ef01c70df1ac74a04da3548b3c0d79a9] | committer: Zhong Li

lavc/qsvenc: fix hevc vps extradata issues

cbs trace qsv vps header failed due to some reasons:
1. vps_temporal_id_nesting_flag is not set but spec required it must to
   be 1 when vps_max_sub_layers_minus1 is equal to 0.
2. vps_num_hrd_parameters is not set and written.
3. other issues in ff_hevc_encode_nal_vps() (fixed in pervious commit_id: 
520226b683).

Reproduce: ffmpeg -hwaccel qsv -v verbose -c:v h264_qsv -i 
bbb_sunflower_1080p_30fps_normal.mp4 -vframes 1
-c:v hevc_qsv  -bsf:v trace_headers -f null -

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc_hevc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index d2e5432f99..39aa8843c2 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -107,6 +107,7 @@ static int generate_fake_vps(QSVEncContext *q, 
AVCodecContext *avctx)
 /* generate the VPS */
 vps.vps_max_layers = 1;
 vps.vps_max_sub_layers = sps.max_sub_layers;
+vps.vps_temporal_id_nesting_flag = sps.temporal_id_nesting_flag;
 memcpy(, , sizeof(vps.ptl));
 vps.vps_sub_layer_ordering_info_present_flag = 1;
 for (i = 0; i < HEVC_MAX_SUB_LAYERS; i++) {
@@ -121,6 +122,7 @@ static int generate_fake_vps(QSVEncContext *q, 
AVCodecContext *avctx)
 vps.vps_time_scale  = sps.vui.vui_time_scale;
 vps.vps_poc_proportional_to_timing_flag = 
sps.vui.vui_poc_proportional_to_timing_flag;
 vps.vps_num_ticks_poc_diff_one  = 
sps.vui.vui_num_ticks_poc_diff_one_minus1 + 1;
+vps.vps_num_hrd_parameters  = 0;
 
 /* generate the encoded RBSP form of the VPS */
 ret = ff_hevc_encode_nal_vps(, sps.vps_id, vps_rbsp_buf, 
sizeof(vps_rbsp_buf));
@@ -138,8 +140,7 @@ static int generate_fake_vps(QSVEncContext *q, 
AVCodecContext *avctx)
 bytestream2_put_byte(, 1); // header
 
 while (bytestream2_get_bytes_left()) {
-uint32_t b = bytestream2_peek_be24();
-if (b <= 3) {
+if (bytestream2_get_bytes_left() >= 3 && 
bytestream2_peek_be24() <= 3) {
 bytestream2_put_be24(, 3);
 bytestream2_skip(, 2);
 } else

___
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/hevc_ps_enc: fix vps nal issues

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Mar 26 06:08:37 
2019 +0800| [520226b6835f649c2804698ebcf4e4e16acab514] | committer: Zhong Li

lavc/hevc_ps_enc: fix vps nal issues

1. write vps_num_hrd_parameters element
2. flush left bits

Signed-off-by: Zhong Li 

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

 libavcodec/hevc_ps_enc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_ps_enc.c b/libavcodec/hevc_ps_enc.c
index 4c71cf41ca..78a73a5c0a 100644
--- a/libavcodec/hevc_ps_enc.c
+++ b/libavcodec/hevc_ps_enc.c
@@ -67,7 +67,7 @@ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
uint8_t *buf, int buf_size)
 {
 PutBitContext pb;
-int i;
+int i, data_size;
 
 init_put_bits(, buf, buf_size);
 put_bits(,  4, id);
@@ -103,6 +103,7 @@ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
 if (vps->vps_poc_proportional_to_timing_flag)
 set_ue_golomb(, vps->vps_num_ticks_poc_diff_one - 1);
 
+set_ue_golomb(, vps->vps_num_hrd_parameters);
 if (vps->vps_num_hrd_parameters) {
 avpriv_report_missing_feature(NULL, "Writing HRD parameters");
 return AVERROR_PATCHWELCOME;
@@ -114,5 +115,8 @@ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
 put_bits(, 1, 1);// stop bit
 avpriv_align_put_bits();
 
-return put_bits_count() / 8;
+data_size = put_bits_count() / 8;
+flush_put_bits();
+
+return data_size;
 }

___
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: make the queried libmfx version easily reused

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Mar 26 07:40:54 
2019 +0800| [b47446cc39d9dbdd314b391d256447bc697de848] | committer: Zhong Li

lavc/qsvenc: make the queried libmfx version easily reused

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 17 -
 libavcodec/qsvenc.h |  2 ++
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 5aa020d47b..9091772687 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -468,13 +468,6 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier;
 int buffer_size_in_kilobytes, initial_delay_in_kilobytes;
 int ret;
-mfxVersion ver;
-
-ret = MFXQueryVersion(q->session,);
-if (ret != MFX_ERR_NONE) {
-av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n");
-return AVERROR_UNKNOWN;
-}
 
 ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
 if (ret < 0)
@@ -530,7 +523,7 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 // If the minor version is greater than or equal to 19,
 // then can use the same alignment settings as H.264 for HEVC
 q->width_align = (avctx->codec_id != AV_CODEC_ID_HEVC ||
-  QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 19)) ? 16 : 32;
+  QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 19)) ? 16 : 32;
 q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align);
 
 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
@@ -729,7 +722,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 #if QSV_HAVE_MF
-if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
+if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 25)) {
 q->extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM;
 q->extmfp.Header.BufferSz = sizeof(q->extmfp);
 
@@ -985,6 +978,12 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext 
*q)
 if (ret < 0)
 return ret;
 
+ret = MFXQueryVersion(q->session,>ver);
+if (ret < 0) {
+return ff_qsv_print_error(avctx, ret,
+  "Error querying mfx version");
+}
+
 // in the mfxInfoMFX struct, JPEG is different from other codecs
 switch (avctx->codec_id) {
 case AV_CODEC_ID_MJPEG:
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 00afbd80aa..fcd01f4a61 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -131,6 +131,8 @@ typedef struct QSVEncContext {
 
 QSVFramesContext frames_ctx;
 
+mfxVersion  ver;
+
 // options set by the caller
 int async_depth;
 int idr_interval;

___
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: use the common option "trellis" of AVCodecContext

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 27 19:33:37 
2019 +0800| [b9a066ae23cbf488faf332cbfd101a3af5b77611] | committer: Zhong Li

lavc/qsvenc: use the common option "trellis" of AVCodecContext

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c   | 5 -
 libavcodec/qsvenc_h264.c  | 2 +-
 libavcodec/qsvenc_hevc.c  | 2 +-
 libavcodec/qsvenc_mpeg2.c | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 9091772687..a6641f68fc 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -683,7 +683,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 #if QSV_HAVE_TRELLIS
-q->extco2.Trellis = q->trellis;
+if (avctx->trellis >= 0)
+q->extco2.Trellis = (avctx->trellis == 0) ? MFX_TRELLIS_OFF : 
(MFX_TRELLIS_I | MFX_TRELLIS_P | MFX_TRELLIS_B);
+else
+q->extco2.Trellis = MFX_TRELLIS_UNKNOWN;
 #endif
 
 #if QSV_VERSION_ATLEAST(1, 8)
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index f458137848..4fea69fb2c 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -181,7 +181,7 @@ static const AVCodecDefault qsv_enc_defaults[] = {
 #if FF_API_CODER_TYPE
 { "coder", "-1"},
 #endif
-
+{ "trellis",   "-1"},
 { "flags", "+cgop" },
 #if FF_API_PRIVATE_OPT
 { "b_strategy", "-1"   },
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 1c615b4e81..d2e5432f99 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -254,7 +254,7 @@ static const AVCodecDefault qsv_enc_defaults[] = {
 // same as the x264 default
 { "g", "248"   },
 { "bf","8" },
-
+{ "trellis",   "-1"},
 { "flags", "+cgop" },
 #if FF_API_PRIVATE_OPT
 { "b_strategy", "-1"   },
diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index a7427d8109..e4ade56d62 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -87,7 +87,7 @@ static const AVCodecDefault qsv_enc_defaults[] = {
 // same as the x264 default
 { "g", "250"   },
 { "bf","3" },
-
+{ "trellis",   "-1"},
 { "flags", "+cgop" },
 #if FF_API_PRIVATE_OPT
 { "b_strategy", "-1"   },

___
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] qsv: fix the dangerous macro definitions

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 27 18:18:15 
2019 +0800| [4131b0619c22cc0da29e95ea16b2970e2e3a566e] | committer: Zhong Li

qsv: fix the dangerous macro definitions

Signed-off-by: Zhong Li 
Reviewed-by: Carl Eugen Hoyos 

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

 libavcodec/qsv_internal.h | 4 ++--
 libavfilter/qsvvpp.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 394c558883..57d861d2be 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -39,8 +39,8 @@
  MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
 
 #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
-(MFX_VERSION.Major > (MAJOR)) ||   \
-(MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))
+((MFX_VERSION.Major > (MAJOR)) ||   \
+(MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
 
 typedef struct QSVMid {
 AVBufferRef *hw_frames_ref;
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index ff02b64c41..c2bcce7548 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -36,8 +36,8 @@
  MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
 
 #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
-(MFX_VERSION.Major > (MAJOR)) ||   \
-(MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR))
+((MFX_VERSION.Major > (MAJOR)) ||   \
+(MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
 
 typedef struct QSVVPPContext QSVVPPContext;
 

___
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] configure: include pkgconfig path as vaapi header search

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 20 14:51:12 
2019 +0800| [81ae387a265de856b63dc953c4195904360b7e98] | committer: Zhong Li

configure: include pkgconfig path as vaapi header search

Currectly just standard header path can be found,
check_type/struct will fail if vaapi is installed somewhere else.

Move them followed "check_pkg_config"

Reviewed-by: Mark Thompson 
Reviewed-by: Timo Rothenpieler 
Signed-off-by: Zhong Li 

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

 configure | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index c94f516224..f6123f53e5 100755
--- a/configure
+++ b/configure
@@ -6022,14 +6022,6 @@ check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
 check_type "windows.h d3d11.h" "ID3D11VideoContext"
 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
 
-check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
-check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
-check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
-check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
-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 "vdpau/vdpau.h" "VdpPictureInfoHEVC"
 
 if enabled cuda_sdk; then
@@ -6461,6 +6453,14 @@ if enabled vaapi; then
 fi
 
 check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
+
+check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
+check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
+check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
+check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
+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"
 fi
 
 if enabled_all opencl libdrm ; then

___
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_h264: remove the privite option trellis

2019-03-28 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Mar 27 19:39:41 
2019 +0800| [391f884675f319b95f5a72a410178516e11c557d] | committer: Zhong Li

lavc/qsvenc_h264: remove the privite option trellis

There are many problems of current qsv trellis option:
1. Duplicated with AVCodecContext definition
2. MFX_TRELLIS_XXX is introduced by MSDK API 1.17
   Currently Without MSDK API checking thus may cause compilation issue.
3. user is inclined to enable trellis when set "-trellis 1", but
   actually it is to disable since MFX_TRELLIS_OFF is equal to 1.
4. It is too complex for user to enable trellis for every frame(I/P/B).

Just simply remove the private option, and switch to the AVCodecContext
definition. Compatibility should not a big problem (except can't exact map)
since the option name is same as AVCodecContext.

Signed-off-by: Zhong Li 
Reviewed-by: Carl Eugen Hoyos 
Reviewed-by: Moritz Barsnick 

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

 libavcodec/qsvenc.h  | 1 -
 libavcodec/qsvenc_h264.c | 6 --
 libavcodec/version.h | 2 +-
 3 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index fcd01f4a61..eed6f2c2c2 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -153,7 +153,6 @@ typedef struct QSVEncContext {
 
 int single_sei_nal_unit;
 int max_dec_frame_buffering;
-int trellis;
 
 int bitrate_limit;
 int mbbrc;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 4fea69fb2c..2bf3419d27 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -132,12 +132,6 @@ static const AVOption options[] = {
 { "int_ref_qp_delta",   "QP difference for the refresh MBs",   
  OFFSET(qsv.int_ref_qp_delta),AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, 
INT16_MIN,  INT16_MAX, VE },
 { "recovery_point_sei", "Insert recovery point SEI messages",  
  OFFSET(qsv.recovery_point_sei),  AV_OPT_TYPE_INT, { .i64 = -1 },  
 -1,  1, VE },
 
-{ "trellis", "Trellis quantization",   
  OFFSET(qsv.trellis), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, 0, 
UINT_MAX, VE, "trellis" },
-{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TRELLIS_OFF }, 
.flags = VE, "trellis" },
-{ "I",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TRELLIS_I },   
.flags = VE, "trellis" },
-{ "P",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TRELLIS_P },   
.flags = VE, "trellis" },
-{ "B",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TRELLIS_B },   
.flags = VE, "trellis" },
-
 { "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" },
 { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 348b4d0300..e73390e21f 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  47
-#define LIBAVCODEC_VERSION_MICRO 105
+#define LIBAVCODEC_VERSION_MICRO 106
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

___
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] lavu/qsv: allow surface size larger than requirement

2019-03-18 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Mar  8 14:41:22 
2019 +0800| [15d016be30bd24cdba514c7c888e9da0286b5647] | committer: Zhong Li

lavu/qsv: allow surface size larger than requirement

Just like commit 6829a079444e10818a847e153121fb458cc5c0a8,
surface size larger than requirement should not be treated as error.

Signed-off-by: Zhong Li 

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

 libavutil/hwcontext_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 814ce215ce..b6d8bfe2bf 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -389,7 +389,7 @@ static mfxStatus frame_alloc(mfxHDL pthis, 
mfxFrameAllocRequest *req,
 !(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
 !(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
 return MFX_ERR_UNSUPPORTED;
-if (i->Width  != i1->Width || i->Height != i1->Height ||
+if (i->Width  > i1->Width || i->Height > i1->Height ||
 i->FourCC != i1->FourCC || i->ChromaFormat != i1->ChromaFormat) {
 av_log(ctx, AV_LOG_ERROR, "Mismatching surface properties in an "
"allocation request: %dx%d %d %d vs %dx%d %d %d\n",

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


[FFmpeg-cvslog] lavc/qsvenc_jpeg: add async_depth support

2019-02-20 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 11 17:26:12 
2018 +0800| [4c5e77e0bf14aa3cb838e788dbaf88441c82e5d2] | committer: Luca Barbato

lavc/qsvenc_jpeg: add async_depth support

Currently qsv (m)jpeg encoding is broken.
Regression introducing by the commit(id: c1bcd3): fix async support,
which requires the minimum async_depth to be 1, instead previous zero.
But the default async_depth of qsv (m)jpeg encoding is still initialized
(mostly) as zero.

This patch also abviously improves qsv (m)jpeg encoding performance
due to the default async_depth is changed to 4.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavcodec/qsvenc_jpeg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index e11b74dc9f..7465bb917f 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -64,6 +64,7 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(QSVMJPEGEncContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+{ "async_depth", "Maximum processing parallelism", 
OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, 
INT_MAX, VE },
 { NULL },
 };
 

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


[FFmpeg-cvslog] lavc/qsvenc_jpeg: set a default quality

2019-02-20 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 11 17:26:13 
2018 +0800| [1ff6cb2ca6652e7d2a929afd33d8ed6268c45568] | committer: Luca Barbato

lavc/qsvenc_jpeg: set a default quality

Keep alignment with vaapi mjpeg encoder.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

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

diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index 7465bb917f..bbfd00975a 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -75,6 +75,11 @@ static const AVClass class = {
 .version= LIBAVUTIL_VERSION_INT,
 };
 
+static const AVCodecDefault qsv_enc_defaults[] = {
+{ "global_quality",  "80" },
+{ NULL },
+};
+
 AVCodec ff_mjpeg_qsv_encoder = {
 .name   = "mjpeg_qsv",
 .long_name  = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video 
acceleration)"),
@@ -89,5 +94,6 @@ AVCodec ff_mjpeg_qsv_encoder = {
 AV_PIX_FMT_QSV,
 AV_PIX_FMT_NONE },
 .priv_class = ,
+.defaults   = qsv_enc_defaults,
 .wrapper_name   = "qsv",
 };

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


[FFmpeg-cvslog] lavc/qsvenc: enable QVBR mode

2019-01-25 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Jan 23 19:16:17 
2019 +0800| [74cf2dc3ac405c5e55b7ecd4d17b40e26d59eb84] | committer: Zhong Li

lavc/qsvenc: enable QVBR mode

QVBR mode is to use the variable bitrate control algorithm
with constant quality.
mfxExtCodingOption3 should be supported to enable QVBR mode.

It is neccesary to specify a max_rate for QVBR, else it may be ICQ mode.
Example usage: ffmpeg -hwaccel qsv -c:v h264_qsv -i input.mp4 -c:v
h264_qsv -global_quality 25 -maxrate 2M test_qvbr.mp4 -v verbose

Clip QVBR quality range to be [0, 51] as Mark's commments.
It is similar to qp range of CQP but possibly should be updated when VP8/VP9
encoding can be supported.

Reviewed-by: Mark Thompson 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 39 +--
 libavcodec/qsvenc.h |  7 +--
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index ba9bcf16d7..5aa020d47b 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -136,6 +136,9 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #if QSV_HAVE_CO2
 mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
 #endif
+#if QSV_HAVE_CO3
+mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
+#endif
 
 av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
print_profile(info->CodecProfile), info->CodecLevel);
@@ -190,7 +193,12 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
info->ICQQuality, co2->LookAheadDepth);
 }
 #endif
-
+#if QSV_HAVE_QVBR
+else if (info->RateControlMethod == MFX_RATECONTROL_QVBR) {
+av_log(avctx, AV_LOG_VERBOSE, "QVBRQuality: %"PRIu16"\n",
+   co3->QVBRQuality);
+}
+#endif
 av_log(avctx, AV_LOG_VERBOSE, "NumSlice: %"PRIu16"; NumRefFrame: 
%"PRIu16"\n",
info->NumSlice, info->NumRefFrame);
 av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n",
@@ -330,7 +338,7 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 }
 #endif
 #if QSV_HAVE_ICQ
-else if (avctx->global_quality > 0) {
+else if (avctx->global_quality > 0 && !avctx->rc_max_rate) {
 rc_mode = MFX_RATECONTROL_ICQ;
 rc_desc = "intelligent constant quality (ICQ)";
 }
@@ -345,6 +353,12 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 rc_desc = "average variable bitrate (AVBR)";
 }
 #endif
+#if QSV_HAVE_QVBR
+else if (avctx->global_quality > 0) {
+rc_mode = MFX_RATECONTROL_QVBR;
+rc_desc = "constant quality with VBR algorithm (QVBR)";
+}
+#endif
 else {
 rc_mode = MFX_RATECONTROL_VBR;
 rc_desc = "variable bitrate (VBR)";
@@ -568,11 +582,18 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 #if QSV_HAVE_VCM
 case MFX_RATECONTROL_VCM:
 #endif
+#if QSV_HAVE_QVBR
+case MFX_RATECONTROL_QVBR:
+#endif
 q->param.mfx.BufferSizeInKB   = buffer_size_in_kilobytes / 
brc_param_multiplier;
 q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / 
brc_param_multiplier;
 q->param.mfx.TargetKbps   = target_bitrate_kbps / 
brc_param_multiplier;
 q->param.mfx.MaxKbps  = max_bitrate_kbps / 
brc_param_multiplier;
 q->param.mfx.BRCParamMultiplier = brc_param_multiplier;
+#if QSV_HAVE_QVBR
+if (q->param.mfx.RateControlMethod == MFX_RATECONTROL_QVBR)
+q->extco3.QVBRQuality = av_clip(avctx->global_quality, 0, 51);
+#endif
 break;
 case MFX_RATECONTROL_CQP:
 quant = avctx->global_quality / FF_QP2LAMBDA;
@@ -718,6 +739,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 #endif
 }
+#if QSV_HAVE_CO3
+q->extco3.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION3;
+q->extco3.Header.BufferSz  = sizeof(q->extco3);
+q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco3;
+#endif
 }
 
 if (!check_enc_param(avctx,q)) {
@@ -772,6 +798,12 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, 
QSVEncContext *q)
 .Header.BufferSz = sizeof(co2),
 };
 #endif
+#if QSV_HAVE_CO3
+mfxExtCodingOption3 co3 = {
+.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3,
+.Header.BufferSz = sizeof(co3),
+};
+#endif
 
 mfxExtBuffer *ext_buffers[] = {
 (mfxExtBuffer*),
@@ -779,6 +811,9 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, 
QSVEncContext *q)
 #if QSV_HAVE_CO2
 (mfxExtBuffer*),
 #endif
+#if QSV_HAVE_CO3
+(mfxExtBuffer*),
+#endif
 };
 
 int ne

[FFmpeg-cvslog] lavf/vaapi_deinterlace: return error if mode unsupported

2019-01-25 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Jan 14 15:29:54 
2019 +0800| [260f1960e7e2e2bff56957a216130623f8109d8f] | committer: Zhong Li

lavf/vaapi_deinterlace: return error if mode unsupported

Reviewed-by: Mark Thompson 
Signed-off-by: Fuwei Tang 
Signed-off-by: Zhong Li 

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

 libavfilter/vf_deinterlace_vaapi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_deinterlace_vaapi.c 
b/libavfilter/vf_deinterlace_vaapi.c
index 97aee6588f..f67a1c8e79 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -113,6 +113,7 @@ static int deint_vaapi_build_filter_params(AVFilterContext 
*avctx)
 av_log(avctx, AV_LOG_ERROR, "Deinterlacing mode %d (%s) is "
"not supported.\n", ctx->mode,
deint_vaapi_mode_name(ctx->mode));
+return AVERROR(EINVAL);
 }
 }
 

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


[FFmpeg-cvslog] lavc/qsvenc: set BRCParamMultiplier to aviod BRC overflow

2019-01-21 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Jan 14 15:12:15 
2019 +0800| [87c165c2379a69a6261c439299cabbe4b77c4b3c] | committer: Zhong Li

lavc/qsvenc: set BRCParamMultiplier to aviod BRC overflow

Fix ticket #7663

Reviewed-by: Carl Eugen Hoyos 
Reviewed-by: Hendrik Leppkes 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 41 +++--
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e3b5a72dd4..ba9bcf16d7 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -158,8 +158,8 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #endif
 ) {
 av_log(avctx, AV_LOG_VERBOSE,
-   "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; 
TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n",
-   info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, 
info->MaxKbps);
+   "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; 
TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n",
+   info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, 
info->MaxKbps, info->BRCParamMultiplier);
 } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
 av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: 
%"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
@@ -167,8 +167,8 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #if QSV_HAVE_AVBR
 else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
 av_log(avctx, AV_LOG_VERBOSE,
-   "TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: 
%"PRIu16"\n",
-   info->TargetKbps, info->Accuracy, info->Convergence);
+   "TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: 
%"PRIu16"; BRCParamMultiplier: %"PRIu16"\n",
+   info->TargetKbps, info->Accuracy, info->Convergence, 
info->BRCParamMultiplier);
 }
 #endif
 #if QSV_HAVE_LA
@@ -178,8 +178,8 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #endif
  ) {
 av_log(avctx, AV_LOG_VERBOSE,
-   "TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"\n",
-   info->TargetKbps, co2->LookAheadDepth);
+   "TargetKbps: %"PRIu16"; LookAheadDepth: %"PRIu16"; 
BRCParamMultiplier: %"PRIu16"\n",
+   info->TargetKbps, co2->LookAheadDepth, 
info->BRCParamMultiplier);
 }
 #endif
 #if QSV_HAVE_ICQ
@@ -451,6 +451,8 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
avctx->sw_pix_fmt : avctx->pix_fmt;
 const AVPixFmtDescriptor *desc;
 float quant;
+int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier;
+int buffer_size_in_kilobytes, initial_delay_in_kilobytes;
 int ret;
 mfxVersion ver;
 
@@ -552,16 +554,25 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 if (ret < 0)
 return ret;
 
+//libmfx BRC parameters are 16 bits thus maybe overflow, then 
BRCParamMultiplier is needed
+buffer_size_in_kilobytes   = avctx->rc_buffer_size / 8000;
+initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 1000;
+target_bitrate_kbps= avctx->bit_rate / 1000;
+max_bitrate_kbps   = avctx->rc_max_rate / 1000;
+brc_param_multiplier   = (FFMAX(FFMAX3(target_bitrate_kbps, 
max_bitrate_kbps, buffer_size_in_kilobytes),
+  initial_delay_in_kilobytes) + 0x1) / 
0x1;
+
 switch (q->param.mfx.RateControlMethod) {
 case MFX_RATECONTROL_CBR:
 case MFX_RATECONTROL_VBR:
 #if QSV_HAVE_VCM
 case MFX_RATECONTROL_VCM:
 #endif
-q->param.mfx.BufferSizeInKB   = avctx->rc_buffer_size / 8000;
-q->param.mfx.InitialDelayInKB = avctx->rc_initial_buffer_occupancy / 
1000;
-q->param.mfx.TargetKbps   = avctx->bit_rate / 1000;
-q->param.mfx.MaxKbps  = avctx->rc_max_rate / 1000;
+q->param.mfx.BufferSizeInKB   = buffer_size_in_kilobytes / 
brc_param_multiplier;
+q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / 
brc_param_multiplier;
+q->param.mfx.TargetKbps   = target_bitrate_kbps / 
brc_param_multiplier;
+q->param.mfx.MaxKbps  = max_bitrate_kbps / 
brc_param_multiplier;
+q-&g

[FFmpeg-cvslog] lavc/qsvenc: set pict_type to be I for IDR frames.

2019-01-10 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Dec 12 15:44:18 
2018 +0800| [0aaaca25e044a4b87fb8f899f3a920b79163e811] | committer: Zhong Li

lavc/qsvenc: set pict_type to be I for IDR frames.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 5b6c68e307..e3b5a72dd4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1341,11 +1341,10 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext 
*q,
 new_pkt.pts  = av_rescale_q(bs->TimeStamp,   (AVRational){1, 
9}, avctx->time_base);
 new_pkt.size = bs->DataLength;
 
-if (bs->FrameType & MFX_FRAMETYPE_IDR ||
-bs->FrameType & MFX_FRAMETYPE_xIDR)
+if (bs->FrameType & MFX_FRAMETYPE_IDR || bs->FrameType & 
MFX_FRAMETYPE_xIDR) {
 new_pkt.flags |= AV_PKT_FLAG_KEY;
-
-if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & 
MFX_FRAMETYPE_xI)
+pict_type = AV_PICTURE_TYPE_I;
+} else if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & 
MFX_FRAMETYPE_xI)
 pict_type = AV_PICTURE_TYPE_I;
 else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & 
MFX_FRAMETYPE_xP)
 pict_type = AV_PICTURE_TYPE_P;

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


[FFmpeg-cvslog] lavc/qsv_hevc: correct QSV HEVC default plugin on Windows

2018-12-17 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Dec 12 15:03:21 
2018 +0800| [978c935f2f659edf028b9219c7397efdcf4a1260] | committer: Zhong Li

lavc/qsv_hevc: correct QSV HEVC default plugin on Windows

1. Old logic meaned: everywhere, except Windows, ffmpeg has to use HW
acceleration, but on Windows ffmpeg has to use (unavailable) software
HEVC by default
2. Software HEVC is available only if you provide corresponding
software MediaSDK library, which isn't provided with ffmpeg. More
information could be found in
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/samples/readme-encode_linux.pdf
3. HW HEVC decoding/encoding are available on Windows in the driver by default

Note: Default case should be the most common case but this change still has 
potential risk
on windows if HW path is not supported(or doesn't work as expection).
(See the historical disscution: 
https://lists.libav.org/pipermail/libav-devel/2016-November/080419.html).
In such case, two options suggested:
1. Use the option "-load_plugin hevc_sw" to switch SW path manually.
2. Or report bug to Intel windows driver if your GPU can support HEVC HW codec.
  (HEVC decoding is supported since Braswell, and encoding supported since 
Skylake)

Patch started by Landgraph. Add similar change for hevc decoder and bump a new 
version.

Reviewed-by: Mark Thompson 
Reviewed-by: Maxym Dmytrychenko 
Signed-off-by: Landgraph 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvdec_h2645.c | 8 +---
 libavcodec/qsvenc_hevc.c  | 8 +---
 libavcodec/version.h  | 2 +-
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index b8a78aa81b..9b49f5506e 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -178,12 +178,6 @@ static void qsv_decode_flush(AVCodecContext *avctx)
 ff_qsv_decode_flush(avctx, >qsv);
 }
 
-#if defined(_WIN32)
-#define LOAD_PLUGIN_DEFAULT LOAD_PLUGIN_HEVC_SW
-#else
-#define LOAD_PLUGIN_DEFAULT LOAD_PLUGIN_HEVC_HW
-#endif
-
 #define OFFSET(x) offsetof(QSVH2645Context, x)
 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
@@ -191,7 +185,7 @@ static void qsv_decode_flush(AVCodecContext *avctx)
 static const AVOption hevc_options[] = {
 { "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 
ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
 
-{ "load_plugin", "A user plugin to load in an internal session", 
OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_DEFAULT }, 
LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" },
+{ "load_plugin", "A user plugin to load in an internal session", 
OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, 
LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" },
 { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE },
0, 0, VD, "load_plugin" },
 { "hevc_sw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_SW }, 
0, 0, VD, "load_plugin" },
 { "hevc_hw",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_HEVC_HW }, 
0, 0, VD, "load_plugin" },
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 4339b316a3..1c615b4e81 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -217,12 +217,6 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
 return ff_qsv_enc_close(avctx, >qsv);
 }
 
-#if defined(_WIN32)
-#define LOAD_PLUGIN_DEFAULT LOAD_PLUGIN_HEVC_SW
-#else
-#define LOAD_PLUGIN_DEFAULT LOAD_PLUGIN_HEVC_HW
-#endif
-
 #define OFFSET(x) offsetof(QSVHEVCEncContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -230,7 +224,7 @@ static const AVOption options[] = {
 
 { "idr_interval", "Distance (in I-frames) between IDR frames", 
OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, VE, 
"idr_interval" },
 { "begin_only", "Output an IDR-frame only at the beginning of the stream", 
0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "idr_interval" },
-{ "load_plugin", "A user plugin to load in an internal session", 
OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_DEFAULT }, 
LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VE, "load_plugin" },
+{ "load_plugin", "A user plugin to load in an internal session", 
OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, 
LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VE, "load_plugin" },
 { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE },
0, 0, VE

[FFmpeg-cvslog] lavc/qsvenc: make hevc alignment same as h264 for 1.19+ version

2018-12-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 25 18:44:37 
2018 +0800| [33df1afe39fa401e5421ff3489e25b022b74f8ed] | committer: Zhong Li

lavc/qsvenc: make hevc alignment same as h264 for 1.19+ version

It is to clean up to the code and To-Do list.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a9e44be981..331f49faac 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -446,6 +446,12 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 int ret;
 mfxVersion ver;
 
+ret = MFXQueryVersion(q->session,);
+if (ret != MFX_ERR_NONE) {
+av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n");
+return AVERROR_UNKNOWN;
+}
+
 ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
 if (ret < 0)
 return AVERROR_BUG;
@@ -494,10 +500,10 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
 q->param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
 
-// TODO:  detect version of MFX--if the minor version is greater than
-// or equal to 19, then can use the same alignment settings as H.264
-// for HEVC
-q->width_align = avctx->codec_id == AV_CODEC_ID_HEVC ? 32 : 16;
+// If the minor version is greater than or equal to 19,
+// then can use the same alignment settings as H.264 for HEVC
+q->width_align = (avctx->codec_id != AV_CODEC_ID_HEVC ||
+  QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 19)) ? 16 : 32;
 q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, q->width_align);
 
 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
@@ -677,8 +683,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 #if QSV_HAVE_MF
-ret = MFXQueryVersion(q->session,);
-if (ret >= MFX_ERR_NONE && QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 
25)) {
+if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
 q->extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM;
 q->extmfp.Header.BufferSz = sizeof(q->extmfp);
 

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


[FFmpeg-cvslog] lavc/qsvenc: dump log for frame rate

2018-12-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Nov  5 16:02:57 
2018 +0800| [c4a4cfa7628b0b958b7406012d7cfe1e11f1ca10] | committer: Zhong Li

lavc/qsvenc: dump log for frame rate

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 331f49faac..48bfec70c4 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -263,6 +263,10 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
print_threestate(co->NalHrdConformance), 
print_threestate(co->SingleSeiNalUnit),
print_threestate(co->VuiVclHrdParameters), 
print_threestate(co->VuiNalHrdParameters));
 }
+
+av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: 
%"PRIu32" \n",
+   info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN);
+
 }
 
 static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)

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


[FFmpeg-cvslog] lavc/qsvenc: add an option to set h264 pps for every frame

2018-12-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 25 19:14:16 
2018 +0800| [c9f0cff5efd8096caf8a6fa37b0640abddcde8e8] | committer: Zhong Li

lavc/qsvenc: add an option to set h264 pps for every frame

RepeatPPS is enabled by default in mfx. It is not necessary mostly and
wasting encoding bits.
Add an option to control it and disable it by default.

Reviewed-by: Mark Thompson 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 1 +
 libavcodec/qsvenc.h  | 2 ++
 libavcodec/qsvenc_h264.c | 2 ++
 libavcodec/version.h | 2 +-
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 48bfec70c4..53ba7cad15 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -654,6 +654,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 #if QSV_VERSION_ATLEAST(1, 8)
 q->extco2.LookAheadDS = q->look_ahead_downsampling;
+q->extco2.RepeatPPS   = q->repeat_pps ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 
 #if FF_API_PRIVATE_OPT
 FF_DISABLE_DEPRECATION_WARNINGS
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index fbdc19900d..4316a101ca 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -162,6 +162,8 @@ typedef struct QSVEncContext {
 int int_ref_qp_delta;
 int recovery_point_sei;
 
+int repeat_pps;
+
 int a53_cc;
 
 #if QSV_HAVE_MF
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 07c9d64e6b..8e61826eef 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -154,6 +154,8 @@ static const AVOption options[] = {
 { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO }, 
INT_MIN, INT_MAX, VE, "mfmode" },
 #endif
 
+{ "repeat_pps", "repeat pps for every frame", OFFSET(qsv.repeat_pps), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+
 { NULL },
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f758093582..372a6f45b4 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  41
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

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


[FFmpeg-cvslog] lavc/qsvenc: remove redundant code

2018-12-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 25 18:23:00 
2018 +0800| [34cba655576761a25f7fbd64f8406f19185f69fb] | committer: Zhong Li

lavc/qsvenc: remove redundant code

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 7f4592f878..a9e44be981 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -444,6 +444,7 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 const AVPixFmtDescriptor *desc;
 float quant;
 int ret;
+mfxVersion ver;
 
 ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
 if (ret < 0)
@@ -611,8 +612,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco;
 
-#if QSV_HAVE_CO2
 if (avctx->codec_id == AV_CODEC_ID_H264) {
+#if QSV_HAVE_CO2
 q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
 q->extco2.Header.BufferSz = sizeof(q->extco2);
 
@@ -641,11 +642,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 q->extco2.Trellis = q->trellis;
 #endif
 
-#if QSV_HAVE_LA_DS
+#if QSV_VERSION_ATLEAST(1, 8)
 q->extco2.LookAheadDS = q->look_ahead_downsampling;
-#endif
 
-#if QSV_HAVE_BREF_TYPE
 #if FF_API_PRIVATE_OPT
 FF_DISABLE_DEPRECATION_WARNINGS
 if (avctx->b_frame_strategy >= 0)
@@ -675,11 +674,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 #endif
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco2;
-}
 #endif
+
 #if QSV_HAVE_MF
-if (avctx->codec_id == AV_CODEC_ID_H264) {
-mfxVersionver;
 ret = MFXQueryVersion(q->session,);
 if (ret >= MFX_ERR_NONE && QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 
25)) {
 q->extmfp.Header.BufferId = MFX_EXTBUFF_MULTI_FRAME_PARAM;
@@ -689,8 +686,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx,AV_LOG_VERBOSE,"MFMode:%d\n", q->extmfp.MFMode);
 q->extparam_internal[q->nb_extparam_internal++] = 
(mfxExtBuffer *)>extmfp;
 }
-}
 #endif
+}
 }
 
 if (!check_enc_param(avctx,q)) {

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


[FFmpeg-cvslog] lavc/qsvenc: add forced_idr option

2018-11-30 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Nov 29 16:29:00 
2018 +0800| [ac0bcd6b619479d56612b3938e8f00f5b88c0f10] | committer: Zhong Li

lavc/qsvenc: add forced_idr option

This option can be used to repect original input I/IDR frame type.

Reviewed-by: Mark Thompson 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c | 7 +++
 libavcodec/qsvenc.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 948751daf4..3946c1d837 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1192,6 +1192,13 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 if (qsv_frame) {
 surf = _frame->surface;
 enc_ctrl = _frame->enc_ctrl;
+memset(enc_ctrl, 0, sizeof(mfxEncodeCtrl));
+
+if (frame->pict_type == AV_PICTURE_TYPE_I) {
+enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
+if (q->forced_idr)
+enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
+}
 }
 
 ret = av_new_packet(_pkt, q->packet_size);
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 055b4a60fa..fbdc19900d 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -87,6 +87,7 @@
 { "adaptive_i", "Adaptive I-frame placement", 
OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "adaptive_b", "Adaptive B-frame placement", 
OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "b_strategy", "Strategy to choose between I/P/B-frames", 
OFFSET(qsv.b_strategy),AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
+{ "forced_idr", "Forcing I frames as IDR frames", 
OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,  1, VE 
}, \
 
 typedef int SetEncodeCtrlCB (AVCodecContext *avctx,
  const AVFrame *frame, mfxEncodeCtrl* enc_ctrl);
@@ -168,6 +169,7 @@ typedef struct QSVEncContext {
 #endif
 char *load_plugins;
 SetEncodeCtrlCB *set_encode_ctrl_cb;
+int forced_idr;
 } QSVEncContext;
 
 int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);

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


[FFmpeg-cvslog] lavc/qsvenc: enable ICQ and ICQ_LA on Linux

2018-11-30 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Nov 29 16:28:59 
2018 +0800| [518b963d2c99ad03570b3224f76a1224c62e66e9] | committer: Zhong Li

lavc/qsvenc: enable ICQ and ICQ_LA on Linux

ICQ/ICQ_LA are enabled with MSDK V1.28

Reviewed-by: Mark Thompson 
Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 50cc4267e7..055b4a60fa 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -53,7 +53,7 @@
 #define QSV_HAVE_MF 0
 #else
 #define QSV_HAVE_AVBR   0
-#define QSV_HAVE_ICQ0
+#define QSV_HAVE_ICQQSV_VERSION_ATLEAST(1, 28)
 #define QSV_HAVE_VCM0
 #define QSV_HAVE_QVBR   0
 #define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25)

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


[FFmpeg-cvslog] lavc/qsv_overlay: suppress code scan complain

2018-11-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu May 24 16:34:32 
2018 +0800| [d96ae9d5ea1f47a437fc0663b0cc26ff5d4d5d31] | committer: Zhong Li

lavc/qsv_overlay: suppress code scan complain

Suppress the complain "variables 'pix_fmt' is used but maybe
uninitialized".

Signed-off-by: Zhong Li 

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

 libavfilter/vf_overlay_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 20871786ee..9aabb594ba 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -160,7 +160,7 @@ release:
 
 static int have_alpha_planar(AVFilterLink *link)
 {
-enum AVPixelFormat pix_fmt;
+enum AVPixelFormat pix_fmt = link->format;
 const AVPixFmtDescriptor *desc;
 AVHWFramesContext *fctx;
 

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


[FFmpeg-cvslog] lavc/qsvenc_jpeg: add async_depth support

2018-10-23 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 11 17:26:12 
2018 +0800| [0e3d7d845d9b4596c0dac1f6e99c493af07308ae] | committer: Zhong Li

lavc/qsvenc_jpeg: add async_depth support

Currently qsv (m)jpeg encoding is broken.
Regression introducing by the commit(id: c1bcd3): fix async support,
which requires the minimum async_depth to be 1, instead previous zero.
But the default async_depth of qsv (m)jpeg encoding is still initialized
(mostly) as zero.

This patch also abviously improves qsv (m)jpeg encoding performance
due to the default async_depth is changed to 4.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavcodec/qsvenc_jpeg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index c18fe91940..01c1012504 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -64,6 +64,7 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(QSVMJPEGEncContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+{ "async_depth", "Maximum processing parallelism", 
OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, 
INT_MAX, VE },
 { NULL },
 };
 

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


[FFmpeg-cvslog] lavc/qsvenc_jpeg: set a default quality

2018-10-23 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Oct 11 17:26:13 
2018 +0800| [92c25963e8b68c47055b813334eaf76599936a90] | committer: Zhong Li

lavc/qsvenc_jpeg: set a default quality

Keep alignment with vaapi mjpeg encoder.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

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

diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index 01c1012504..1e7785a826 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -75,6 +75,11 @@ static const AVClass class = {
 .version= LIBAVUTIL_VERSION_INT,
 };
 
+static const AVCodecDefault qsv_enc_defaults[] = {
+{ "global_quality",  "80" },
+{ NULL },
+};
+
 AVCodec ff_mjpeg_qsv_encoder = {
 .name   = "mjpeg_qsv",
 .long_name  = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video 
acceleration)"),
@@ -89,5 +94,6 @@ AVCodec ff_mjpeg_qsv_encoder = {
 AV_PIX_FMT_QSV,
 AV_PIX_FMT_NONE },
 .priv_class = ,
+.defaults   = qsv_enc_defaults,
 .wrapper_name   = "qsv",
 };

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


[FFmpeg-cvslog] lavu/hwcontext_qsv: Add support for AV_PIX_FMT_BGRA.

2018-10-10 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon May 21 17:58:52 
2018 +0800| [a5e1cb9e96bca091ed7103d8be72a99e7dc31582] | committer: Zhong Li

lavu/hwcontext_qsv: Add support for AV_PIX_FMT_BGRA.

RGB32(AV_PIX_FMT_BGRA on intel platforms) format may be used as overlay with 
alpha blending.
So add AV_PIX_FMT_BGRA format support.

One example of alpha blending overlay: ffmpeg -hwaccel qsv -c:v h264_qsv -i 
BA1_Sony_D.jsv
-filter_complex 
'movie=lena-rgba.png,hwupload=extra_hw_frames=16[a];[0:v][a]overlay_qsv=x=10:y=10'
-c:v h264_qsv -y out.mp4

Rename RGB32 to be BGRA to make it clearer as Mark Thompson's suggestion.

V2: Add P010 format support else will introduce HEVC 10bit encoding regression.
Thanks for LinJie's discovery.

Signed-off-by: Zhong Li 
Verified-by: Fu, Linjie 

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

 libavfilter/qsvvpp.c  |  2 +-
 libavutil/hwcontext_qsv.c | 44 ++--
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 7ee1e565b6..06efdf5089 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -142,7 +142,7 @@ static int pix_fmt_to_mfx_fourcc(int format)
 return MFX_FOURCC_NV12;
 case AV_PIX_FMT_YUYV422:
 return MFX_FOURCC_YUY2;
-case AV_PIX_FMT_RGB32:
+case AV_PIX_FMT_BGRA:
 return MFX_FOURCC_RGB4;
 }
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index a581d2a401..33e121b416 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -100,6 +100,7 @@ static const struct {
 uint32_t   fourcc;
 } supported_pixel_formats[] = {
 { AV_PIX_FMT_NV12, MFX_FOURCC_NV12 },
+{ AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
 { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
 { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
 };
@@ -751,6 +752,37 @@ static int qsv_transfer_data_child(AVHWFramesContext *ctx, 
AVFrame *dst,
 return ret;
 }
 
+static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 
*surface)
+{
+switch (frame->format) {
+case AV_PIX_FMT_NV12:
+case AV_PIX_FMT_P010:
+surface->Data.Y  = frame->data[0];
+surface->Data.UV = frame->data[1];
+break;
+
+case AV_PIX_FMT_YUV420P:
+surface->Data.Y = frame->data[0];
+surface->Data.U = frame->data[1];
+surface->Data.V = frame->data[2];
+break;
+
+case AV_PIX_FMT_BGRA:
+surface->Data.B = frame->data[0];
+surface->Data.G = frame->data[0] + 1;
+surface->Data.R = frame->data[0] + 2;
+surface->Data.A = frame->data[0] + 3;
+break;
+
+default:
+return MFX_ERR_UNSUPPORTED;
+}
+surface->Data.Pitch = frame->linesize[0];
+surface->Data.TimeStamp = frame->pts;
+
+return 0;
+}
+
 static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
   const AVFrame *src)
 {
@@ -796,11 +828,7 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, 
AVFrame *dst,
 }
 
 out.Info = in->Info;
-out.Data.PitchLow = dst->linesize[0];
-out.Data.Y= dst->data[0];
-out.Data.U= dst->data[1];
-out.Data.V= dst->data[2];
-out.Data.A= dst->data[3];
+map_frame_to_surface(dst, );
 
 do {
 err = MFXVideoVPP_RunFrameVPPAsync(s->session_download, in, , 
NULL, );
@@ -868,11 +896,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 }
 
 in.Info = out->Info;
-in.Data.PitchLow = src->linesize[0];
-in.Data.Y= src->data[0];
-in.Data.U= src->data[1];
-in.Data.V= src->data[2];
-in.Data.A= src->data[3];
+map_frame_to_surface(src, );
 
 do {
 err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, , out, NULL, 
);

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


[FFmpeg-cvslog] lavu/qsv: make a copy as libmfx alignment requirement for uploading

2018-10-10 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Sep 17 19:16:44 
2018 +0800| [681aa7d14f97fd98181ca6d61e11be48fe65692d] | committer: Zhong Li

lavu/qsv: make a copy as libmfx alignment requirement for uploading

Libmfx requires 16 bytes aligned input/output for uploading.
Currently only output is 16 byte aligned and assigning same width/height to
input with smaller buffer size actually, thus definitely will cause segment 
fault.

Can reproduce with any 1080p nv12 rawvideo input:
ffmpeg -init_hw_device qsv=qsv:hw -hwaccel qsv -filter_hw_device qsv -f 
rawvideo -pix_fmt nv12 -s:v 1920x1080
-i 1080p_nv12.yuv -vf 
'format=nv12,hwupload=extra_hw_frames=16,hwdownload,format=nv12' -an -y 
out_nv12.yuv

It can fix #7418

Signed-off-by: Zhong Li 

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

 libavutil/hwcontext_qsv.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 33e121b416..814ce215ce 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -862,6 +862,10 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 mfxSyncPoint sync = NULL;
 mfxStatus err;
 int ret = 0;
+/* make a copy if the input is not padded as libmfx requires */
+AVFrame tmp_frame, *src_frame;
+int realigned = 0;
+
 
 while (!s->session_upload_init && !s->session_upload && !ret) {
 #if HAVE_PTHREADS
@@ -887,16 +891,36 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 if (ret < 0)
 return ret;
 
+
+if (src->height & 16 || src->linesize[0] & 16) {
+realigned = 1;
+memset(_frame, 0, sizeof(tmp_frame));
+tmp_frame.format = src->format;
+tmp_frame.width  = FFALIGN(src->width, 16);
+tmp_frame.height = FFALIGN(src->height, 16);
+ret = av_frame_get_buffer(_frame, 32);
+if (ret < 0)
+return ret;
+
+ret = av_frame_copy(_frame, src);
+if (ret < 0) {
+av_frame_unref(_frame);
+return ret;
+}
+}
+
+src_frame = realigned ? _frame : src;
+
 if (!s->session_upload) {
 if (s->child_frames_ref)
-return qsv_transfer_data_child(ctx, dst, src);
+return qsv_transfer_data_child(ctx, dst, src_frame);
 
 av_log(ctx, AV_LOG_ERROR, "Surface upload not possible\n");
 return AVERROR(ENOSYS);
 }
 
 in.Info = out->Info;
-map_frame_to_surface(src, );
+map_frame_to_surface(src_frame, );
 
 do {
 err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, , out, NULL, 
);
@@ -917,6 +941,9 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 return AVERROR_UNKNOWN;
 }
 
+if (realigned)
+av_frame_unref(_frame);
+
 return 0;
 }
 

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


[FFmpeg-cvslog] lavu/qsv: fix a random hwupload failure regression

2018-10-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Sun Sep 30 17:59:52 
2018 +0800| [21733b39d0af5211d7b9f168ff3667ea86362e2b] | committer: Luca Barbato

lavu/qsv: fix a random hwupload failure regression

Variable 'ret' hasn't been initialized,thus introducing a random
hwupload failure regression due to qsv session uninitialized.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavutil/hwcontext_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 1887936e33..f550bac572 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -833,7 +833,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 
 mfxSyncPoint sync = NULL;
 mfxStatus err;
-int ret;
+int ret = 0;
 
 while (!s->session_upload_init && !s->session_upload && !ret) {
 #if HAVE_PTHREADS

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


[FFmpeg-cvslog] lavc/qsvenc: allow to set qp range for h264 BRC

2018-09-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Aug 27 16:23:31 
2018 +0800| [e16b20782a597e36a9c7488487c3179375a25b97] | committer: Maxym 
Dmytrychenko

lavc/qsvenc: allow to set qp range for h264 BRC

Signed-off-by: Zhong Li 
Signed-off-by: Maxym Dmytrychenko 

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

 libavcodec/qsvenc.c  | 14 ++
 libavcodec/qsvenc_h264.c |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e7ca62fedf..c2c2911229 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -665,6 +665,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
 q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 #endif
 
+#if QSV_VERSION_ATLEAST(1, 9)
+if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > 
avctx->qmax) {
+av_log(avctx, AV_LOG_ERROR, "qmin and or qmax are set but 
invalid, please make sure min <= max\n");
+return AVERROR(EINVAL);
+}
+if (avctx->qmin >= 0) {
+q->extco2.MinQPI = avctx->qmin > 51 ? 51 : avctx->qmin;
+q->extco2.MinQPP = q->extco2.MinQPB = q->extco2.MinQPI;
+}
+if (avctx->qmax >= 0) {
+q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax;
+q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI;
+}
+#endif
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco2;
 }
 #endif
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 2b9401ff99..164f57332f 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -118,6 +118,8 @@ static const AVCodecDefault qsv_enc_defaults[] = {
 // same as the x264 default
 { "g", "250"   },
 { "bf","3" },
+{ "qmin",  "-1"},
+{ "qmax",  "-1"},
 #if FF_API_CODER_TYPE
 { "coder", "-1"},
 #endif

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


[FFmpeg-cvslog] lavc/qsvenc: dump BufferSizeInKB message

2018-09-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Aug 27 19:15:46 
2018 +0800| [c8bca9fe466f810fd484e2c6db7ef7bc83b5a943] | committer: Maxym 
Dmytrychenko

lavc/qsvenc: dump BufferSizeInKB message

Signed-off-by: Zhong Li 
Signed-off-by: Maxym Dmytrychenko 

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

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

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c2c2911229..611449cbeb 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -160,8 +160,8 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 #endif
 ) {
 av_log(avctx, AV_LOG_VERBOSE,
-   "InitialDelayInKB: %"PRIu16"; TargetKbps: %"PRIu16"; MaxKbps: 
%"PRIu16"\n",
-   info->InitialDelayInKB, info->TargetKbps, info->MaxKbps);
+   "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; 
TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"\n",
+   info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, 
info->MaxKbps);
 } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
 av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: 
%"PRIu16"\n",
info->QPI, info->QPP, info->QPB);

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


[FFmpeg-cvslog] qsv: Error out if getting session handle failed in avfilter

2018-09-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Aug 15 17:39:33 
2018 +0800| [e05e5920a4e1f1f15cc8a7c843159d519f6ec18e] | committer: Luca Barbato

qsv: Error out if getting session handle failed in avfilter

Solve some issues found by an automated code scansion.
Suppress the complain "variables 'handle' is used but maybe
uninitialized".

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavfilter/qsvvpp.c | 5 +
 libavfilter/vf_deinterlace_qsv.c | 5 +
 libavfilter/vf_scale_qsv.c   | 5 +
 3 files changed, 15 insertions(+)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index f704517aee..75966b352d 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -503,6 +503,11 @@ static int init_vpp_session(AVFilterContext *avctx, 
QSVVPPContext *s)
 }
 }
 
+if (ret != MFX_ERR_NONE) {
+av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n");
+return AVERROR_UNKNOWN;
+}
+
 /* create a "slave" session with those same properties, to be used for vpp 
*/
 ret = MFXInit(impl, , >session);
 if (ret != MFX_ERR_NONE) {
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index bb26a4dbfe..b659d424be 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -201,6 +201,11 @@ static int init_out_session(AVFilterContext *ctx)
 }
 }
 
+if (err != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
+return AVERROR_UNKNOWN;
+}
+
 /* create a "slave" session with those same properties, to be used for
  * actual deinterlacing */
 err = MFXInit(impl, , >session);
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 381844cdc4..e9bfff867d 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -300,6 +300,11 @@ static int init_out_session(AVFilterContext *ctx)
 }
 }
 
+if (err != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
+return AVERROR_UNKNOWN;
+}
+
 /* create a "slave" session with those same properties, to be used for
  * actual scaling */
 err = MFXInit(impl, , >session);

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


[FFmpeg-cvslog] qsvenc: Fix a misleading log message

2018-09-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Aug 15 17:39:34 
2018 +0800| [76eef04f30a768fa80366d679f3de7e9447b67d5] | committer: Luca Barbato

qsvenc: Fix a misleading log message

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c74b3ae31a..e7ca62fedf 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1142,7 +1142,7 @@ static void print_interlace_msg(AVCodecContext *avctx, 
QSVEncContext *q)
 q->param.mfx.CodecLevel > MFX_LEVEL_AVC_41)
 av_log(avctx, AV_LOG_WARNING,
"Interlaced coding is supported"
-   " at Main/High Profile Level 2.1-4.1\n");
+   " at Main/High Profile Level 2.2-4.0\n");
 }
 }
 

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


[FFmpeg-cvslog] qsvdec: Release packet on decoding failure for mpeg2/vp8/vc1

2018-09-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Aug 15 17:39:35 
2018 +0800| [69caad8959982580504643d36aef22528e4aa6ce] | committer: Luca Barbato

qsvdec: Release packet on decoding failure for  mpeg2/vp8/vc1

H264/265 have been fixed such an issue with commit
559370f2c45110afd8308eec7194437736c323d4.
Similar fixing is needed for other codecs.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

 libavcodec/qsvdec_other.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 150ce0d2ad..47934e9530 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -138,8 +138,13 @@ static int qsv_decode_frame(AVCodecContext *avctx, void 
*data,
 }
 
 ret = ff_qsv_process_data(avctx, >qsv, frame, got_frame, 
>input_ref);
-if (ret < 0)
+if (ret < 0) {
+/* Drop input packet when failed to decode the packet. Otherwise,
+   the decoder will keep decoding the failure packet. */
+av_packet_unref(>input_ref);
+
 return ret;
+}
 
 s->input_ref.size -= ret;
 s->input_ref.data += ret;

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


[FFmpeg-cvslog] qsvenc: remove vcm option on Linux

2018-09-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Jun  7 16:51:54 
2018 +0800| [4ce701b4e640d4723a4005d664f31f8342fac40e] | committer: Maxym 
Dmytrychenko

qsvenc: remove vcm option on Linux

1. vcm mode is only available for H264.
2. vcm is not supported on Linux, but it is shown when run "./avconv -h
encoder=h264_qsv |grep vcm". This shouldn't happen.

Signed-off-by: Zhong Li 
Signed-off-by: Maxym Dmytrychenko 

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

 libavcodec/qsvenc.h  | 1 -
 libavcodec/qsvenc_h264.c | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index a7fc57bb48..bac172f941 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -81,7 +81,6 @@
 { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_OFF }, INT_MIN, 
INT_MAX,  VE, "la_ds" }, \
 { "2x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x }, INT_MIN, 
INT_MAX,VE, "la_ds" }, \
 { "4x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_4x }, INT_MIN, 
INT_MAX,VE, "la_ds" }, \
-{ "vcm",  "Use the video conferencing mode ratecontrol",  OFFSET(qsv.vcm), 
 AV_OPT_TYPE_INT, { .i64 = 0  },  0, 1, VE },\
 { "rdo","Enable rate distortion optimization",OFFSET(qsv.rdo), 
   AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE }, \
 { "max_frame_size", "Maximum encoded frame size in bytes",
OFFSET(qsv.max_frame_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE 
}, \
 { "max_slice_size", "Maximum encoded slice size in bytes",
OFFSET(qsv.max_slice_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE 
}, \
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 2ecdb10c5c..2b9401ff99 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -68,6 +68,9 @@ static const AVOption options[] = {
 QSV_COMMON_OPTS
 
 { "cavlc",  "Enable CAVLC",   
OFFSET(qsv.cavlc),  AV_OPT_TYPE_INT, { .i64 = 0 },   0,  1, VE 
},
+#if QSV_HAVE_VCM
+{ "vcm",  "Use the video conferencing mode ratecontrol",  
OFFSET(qsv.vcm),  AV_OPT_TYPE_INT, { .i64 = 0  },  0, 1, VE },
+#endif
 { "idr_interval", "Distance (in I-frames) between IDR frames", 
OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "single_sei_nal_unit","Put all the SEI messages into one NALU",  
  OFFSET(qsv.single_sei_nal_unit), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  
1, VE },
 { "max_dec_frame_buffering", "Maximum number of frames buffered in the 
DPB", OFFSET(qsv.max_dec_frame_buffering), AV_OPT_TYPE_INT, { .i64 = 0 },   0, 
UINT16_MAX, VE },

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


[FFmpeg-cvslog] qsvenc: Add an option to disable MFE mode

2018-09-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed May 23 18:01:32 
2018 +0800| [35ed7f93dbc72d733e454ae464b1324f38af62a0] | committer: Luca Barbato

qsvenc: Add an option to disable MFE mode

Provide proper aliases to enable/disable MFE.

The numeric values are ambiguous and misleading (e.g: user may misunderstand
setting mfmode to 1 is to enable MFE but actually it is to disable MFE, and
set it to be 5 or above is meaningless).

MFX_MF_MANUAL hasn't been exposed since it is to be implemented.

Signed-off-by: Zhong Li 
Signed-off-by: Luca Barbato 

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

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

diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index ae00ff8d54..2ecdb10c5c 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -94,7 +94,9 @@ static const AVOption options[] = {
 { "aud", "Insert the Access Unit Delimiter NAL", OFFSET(qsv.aud), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE},
 
 #if QSV_HAVE_MF
-{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
.i64 = MFX_MF_AUTO }, 0, INT_MAX, VE },
+{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
.i64 = MFX_MF_AUTO }, MFX_MF_DEFAULT, MFX_MF_AUTO, VE, "mfmode"},
+{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_DISABLED }, 
INT_MIN, INT_MAX, VE, "mfmode" },
+{ "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO }, 
INT_MIN, INT_MAX, VE, "mfmode" },
 #endif
 
 { NULL },

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


[FFmpeg-cvslog] qsvenc: use the compression_level to replace private option

2018-09-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Jun  8 07:00:18 
2018 +0800| [f8060865f3e1a16c62e0d337ef0979b6ee4ba457] | committer: Maxym 
Dmytrychenko

qsvenc: use the compression_level to replace private option

Use a common way to control target_usage, keeping consistent with vaapi
encoders. The private option preset is kept only for compatibility.

Signed-off-by: Zhong Li 
Signed-off-by: Maxym Dmytrychenko 

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

 libavcodec/qsvenc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a8b446c5bd..307ef683f9 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -461,8 +461,19 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 if (avctx->level > 0)
 q->param.mfx.CodecLevel = avctx->level;
 
+if (avctx->compression_level == FF_COMPRESSION_DEFAULT) {
+avctx->compression_level = q->preset;
+} else if (avctx->compression_level >= 0) {
+if (avctx->compression_level > MFX_TARGETUSAGE_BEST_SPEED) {
+av_log(avctx, AV_LOG_WARNING, "Invalid compression level: "
+"valid range is 0-%d, using %d instead\n",
+MFX_TARGETUSAGE_BEST_SPEED, MFX_TARGETUSAGE_BEST_SPEED);
+avctx->compression_level = MFX_TARGETUSAGE_BEST_SPEED;
+}
+}
+
 q->param.mfx.CodecProfile   = q->profile;
-q->param.mfx.TargetUsage= q->preset;
+q->param.mfx.TargetUsage= avctx->compression_level;
 q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size);
 q->param.mfx.GopRefDist = FFMAX(-1, avctx->max_b_frames) + 1;
 q->param.mfx.GopOptFlag = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ?

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


[FFmpeg-cvslog] lavc/encode: fix frame_number double-counted

2018-08-27 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Thu Jun 28 17:01:46 
2018 +0800| [d91370e0f12a3fedd477616011566d9f2fb5e3e5] | committer: Zhong Li

lavc/encode: fix frame_number double-counted

Encoder frame_number may be double-counted if some frames are cached and then 
flushed.
Take qsv encoder (some frames are cached firsty for asynchronism) as example,
./ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -i in.mp4 -vframes 100 
-c:v h264_qsv out.mp4
frame_number passed to encoder is double-counted and larger than the accurate 
value.
Libx264 encoding with B frames can also reproduce it.

Signed-off-by: Zhong Li 

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

 libavcodec/encode.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 0ebd8dd6a5..d12c42526b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -234,8 +234,8 @@ int attribute_align_arg 
avcodec_encode_audio2(AVCodecContext *avctx,
 if (ret >= 0)
 avpkt->data = avpkt->buf->data;
 }
-
-avctx->frame_number++;
+if (frame)
+avctx->frame_number++;
 }
 
 if (ret < 0 || !*got_packet_ptr) {
@@ -329,7 +329,8 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 avpkt->data = avpkt->buf->data;
 }
 
-avctx->frame_number++;
+if (frame)
+avctx->frame_number++;
 }
 
 if (ret < 0 || !*got_packet_ptr)

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


[FFmpeg-cvslog] lavc/qsvenc: add quality status to side_data

2018-08-22 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Aug  8 22:42:47 
2018 +0800| [900487043b6e531fe3edf8c8d38288ef915f6f25] | committer: Zhong Li

lavc/qsvenc: add quality status to side_data

Add fix a memory leak issue as James's comments.

V2: use a local pict_type since coded_frame is deprecated.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 34 --
 libavcodec/qsvenc.h  |  2 --
 libavcodec/qsvenc_h264.c |  5 -
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c4fc2c5299..3c82173379 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1175,6 +1175,8 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 enc_info->Header.BufferSz = sizeof (*enc_info);
 bs->NumExtParam = 1;
 enc_buf = av_mallocz(sizeof(mfxExtBuffer *));
+if (!enc_buf)
+return AVERROR(ENOMEM);
 enc_buf[0] = (mfxExtBuffer *)enc_info;
 
 bs->ExtParam = enc_buf;
@@ -1189,8 +1191,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 if (!sync) {
 av_freep();
  #if QSV_VERSION_ATLEAST(1, 26)
-if (avctx->codec_id == AV_CODEC_ID_H264)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
 av_freep(_info);
+av_freep(_buf);
+}
  #endif
 av_packet_unref(_pkt);
 return AVERROR(ENOMEM);
@@ -1209,8 +1213,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 av_packet_unref(_pkt);
 av_freep();
 #if QSV_VERSION_ATLEAST(1, 26)
-if (avctx->codec_id == AV_CODEC_ID_H264)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
 av_freep(_info);
+av_freep(_buf);
+}
 #endif
 av_freep();
 return (ret == MFX_ERR_MORE_DATA) ?
@@ -1229,8 +1235,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 av_packet_unref(_pkt);
 av_freep();
 #if QSV_VERSION_ATLEAST(1, 26)
-if (avctx->codec_id == AV_CODEC_ID_H264)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
 av_freep(_info);
+av_freep(_buf);
+}
 #endif
 }
 
@@ -1253,7 +1261,9 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
 mfxSyncPoint *sync;
 #if QSV_VERSION_ATLEAST(1, 26)
 mfxExtAVCEncodedFrameInfo *enc_info;
+mfxExtBuffer **enc_buf;
 #endif
+enum AVPictureType pict_type;
 
 av_fifo_generic_read(q->async_fifo, _pkt, sizeof(new_pkt), NULL);
 av_fifo_generic_read(q->async_fifo, ,sizeof(sync),NULL);
@@ -1271,23 +1281,27 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext 
*q,
 bs->FrameType & MFX_FRAMETYPE_xIDR)
 new_pkt.flags |= AV_PKT_FLAG_KEY;
 
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
 if (bs->FrameType & MFX_FRAMETYPE_I || bs->FrameType & 
MFX_FRAMETYPE_xI)
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+pict_type = AV_PICTURE_TYPE_I;
 else if (bs->FrameType & MFX_FRAMETYPE_P || bs->FrameType & 
MFX_FRAMETYPE_xP)
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+pict_type = AV_PICTURE_TYPE_P;
 else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & 
MFX_FRAMETYPE_xB)
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+pict_type = AV_PICTURE_TYPE_B;
+
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx->coded_frame->pict_type = pict_type;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 #if QSV_VERSION_ATLEAST(1, 26)
 if (avctx->codec_id == AV_CODEC_ID_H264) {
+enc_buf = bs->ExtParam;
 enc_info = (mfxExtAVCEncodedFrameInfo *)(*bs->ExtParam);
-av_log(avctx, AV_LOG_DEBUG, "QP is %d\n", enc_info->QP);
-q->sum_frame_qp += enc_info->QP;
+ff_side_data_set_encoder_stats(_pkt,
+enc_info->QP * FF_QP2LAMBDA, NULL, 0, pict_type);
 av_freep(_info);
+av_freep(_buf);
 }
 #endif
 av_freep();
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index d1c8a0c998..bb175c5df8 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -103,8 +103,6 @@ typedef struct QSVEncContext {
 int width_align;
 int height_align;
 
-int sum_frame_qp;
-
 mfxVideoParam param;
 mfxFrameAllocRequest req;
 
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 985f4aca9c..7aa65e96bc 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -94,11 +94,6 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
 {
 QSVH264EncContext *q = avctx->priv_data;
 
-#

[FFmpeg-cvslog] lavc/qsvenc: expose qp of encoded frames

2018-08-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Fri Jun  1 18:21:28 
2018 +0800| [6088b7b0373faad7a8e62a8c4eb4ced9084ad2d9] | committer: Zhong Li

lavc/qsvenc: expose qp of encoded frames

Requirement from ticket #7254.
Currently only H264 supported by MSDK.

Signed-off-by: Zhong Li 

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

 libavcodec/qsvenc.c  | 43 +++
 libavcodec/qsvenc.h  |  2 ++
 libavcodec/qsvenc_h264.c |  5 +
 3 files changed, 50 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 3ce5ffecd5..c4fc2c5299 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1128,6 +1128,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 {
 AVPacket new_pkt = { 0 };
 mfxBitstream *bs;
+#if QSV_VERSION_ATLEAST(1, 26)
+mfxExtAVCEncodedFrameInfo *enc_info;
+mfxExtBuffer **enc_buf;
+#endif
 
 mfxFrameSurface1 *surf = NULL;
 mfxSyncPoint *sync = NULL;
@@ -1161,6 +1165,22 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 bs->Data  = new_pkt.data;
 bs->MaxLength = new_pkt.size;
 
+#if QSV_VERSION_ATLEAST(1, 26)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
+enc_info = av_mallocz(sizeof(*enc_info));
+if (!enc_info)
+return AVERROR(ENOMEM);
+
+enc_info->Header.BufferId = MFX_EXTBUFF_ENCODED_FRAME_INFO;
+enc_info->Header.BufferSz = sizeof (*enc_info);
+bs->NumExtParam = 1;
+enc_buf = av_mallocz(sizeof(mfxExtBuffer *));
+enc_buf[0] = (mfxExtBuffer *)enc_info;
+
+bs->ExtParam = enc_buf;
+}
+#endif
+
 if (q->set_encode_ctrl_cb) {
 q->set_encode_ctrl_cb(avctx, frame, _frame->enc_ctrl);
 }
@@ -1168,6 +1188,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 sync = av_mallocz(sizeof(*sync));
 if (!sync) {
 av_freep();
+ #if QSV_VERSION_ATLEAST(1, 26)
+if (avctx->codec_id == AV_CODEC_ID_H264)
+av_freep(_info);
+ #endif
 av_packet_unref(_pkt);
 return AVERROR(ENOMEM);
 }
@@ -1184,6 +1208,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 if (ret < 0) {
 av_packet_unref(_pkt);
 av_freep();
+#if QSV_VERSION_ATLEAST(1, 26)
+if (avctx->codec_id == AV_CODEC_ID_H264)
+av_freep(_info);
+#endif
 av_freep();
 return (ret == MFX_ERR_MORE_DATA) ?
0 : ff_qsv_print_error(avctx, ret, "Error during encoding");
@@ -1200,6 +1228,10 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 av_freep();
 av_packet_unref(_pkt);
 av_freep();
+#if QSV_VERSION_ATLEAST(1, 26)
+if (avctx->codec_id == AV_CODEC_ID_H264)
+av_freep(_info);
+#endif
 }
 
 return 0;
@@ -1219,6 +1251,9 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
 AVPacket new_pkt;
 mfxBitstream *bs;
 mfxSyncPoint *sync;
+#if QSV_VERSION_ATLEAST(1, 26)
+mfxExtAVCEncodedFrameInfo *enc_info;
+#endif
 
 av_fifo_generic_read(q->async_fifo, _pkt, sizeof(new_pkt), NULL);
 av_fifo_generic_read(q->async_fifo, ,sizeof(sync),NULL);
@@ -1247,6 +1282,14 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+#if QSV_VERSION_ATLEAST(1, 26)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
+enc_info = (mfxExtAVCEncodedFrameInfo *)(*bs->ExtParam);
+av_log(avctx, AV_LOG_DEBUG, "QP is %d\n", enc_info->QP);
+q->sum_frame_qp += enc_info->QP;
+av_freep(_info);
+}
+#endif
 av_freep();
 av_freep();
 
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index bb175c5df8..d1c8a0c998 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -103,6 +103,8 @@ typedef struct QSVEncContext {
 int width_align;
 int height_align;
 
+int sum_frame_qp;
+
 mfxVideoParam param;
 mfxFrameAllocRequest req;
 
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 7aa65e96bc..985f4aca9c 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -94,6 +94,11 @@ static av_cold int qsv_enc_close(AVCodecContext *avctx)
 {
 QSVH264EncContext *q = avctx->priv_data;
 
+#if QSV_VERSION_ATLEAST(1, 26)
+av_log(avctx, AV_LOG_VERBOSE, "encoded %d frames, avarge qp is %.2f\n",
+avctx->frame_number,(double)q->qsv.sum_frame_qp / avctx->frame_number);
+#endif
+
 return ff_qsv_enc_close(avctx, >qsv);
 }
 

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


[FFmpeg-cvslog] fftools/qsv: add extra_hw_frames support

2018-08-06 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed Jul 25 16:05:38 
2018 +0800| [6434b84460bb8b996bc52b33b2012e6b05d3a459] | committer: Zhong Li

fftools/qsv: add extra_hw_frames support

Currently extra_hw_frames can't be applied to qsv since it
doesn't call function avcodec_get_hw_frames_parameters().

Give an option to fix ticket #7261 though it is not a perfect soultion
(allocate the minimum pool size internally and automatically).

Signed-off-by: Zhong Li 

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

 fftools/ffmpeg_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 7442750029..9c4285b6c7 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -93,7 +93,7 @@ int qsv_init(AVCodecContext *s)
 frames_ctx->height= FFALIGN(s->coded_height, 32);
 frames_ctx->format= AV_PIX_FMT_QSV;
 frames_ctx->sw_format = s->sw_pix_fmt;
-frames_ctx->initial_pool_size = 64;
+frames_ctx->initial_pool_size = 64 + s->extra_hw_frames;
 frames_hwctx->frame_type  = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
 
 ret = av_hwframe_ctx_init(ist->hw_frames_ctx);

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


[FFmpeg-cvslog] lavc/qsv: handle MFX_FRAMETYPE_UNKNOWN case

2018-07-12 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Tue Jul  3 16:01:30 
2018 +0800| [3c26ce464435673fe1c0e96a4d5f435b964db8d1] | committer: Zhong Li

lavc/qsv: handle MFX_FRAMETYPE_UNKNOWN case

Signed-off-by: Zhong Li 

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

 libavcodec/qsv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 3ff4f2c092..bb0d79588c 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -198,7 +198,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame 
*frame)
 
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 {
-enum AVPictureType type = AV_PICTURE_TYPE_NONE;
+enum AVPictureType type;
 switch (mfx_pic_type & 0x7) {
 case MFX_FRAMETYPE_I:
 if (mfx_pic_type & MFX_FRAMETYPE_S)
@@ -215,6 +215,9 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 else
 type = AV_PICTURE_TYPE_P;
 break;
+case MFX_FRAMETYPE_UNKNOWN:
+type = AV_PICTURE_TYPE_NONE;
+break;
 default:
 av_assert0(0);
 }

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


[FFmpeg-cvslog] lavc/qsv: suppress code scan complain

2018-06-12 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Wed May  9 14:07:40 
2018 +0800| [8a0c2901f1fa1cd4b2cf8f347840e4465d65cbae] | committer: Zhong Li

lavc/qsv: suppress code scan complain

Suppress the complain "variables 'type' is used but maybe uninitialized".

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

 libavcodec/qsv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 45e1c25c68..3ff4f2c092 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -31,6 +31,7 @@
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_qsv.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/avassert.h"
 
 #include "avcodec.h"
 #include "qsv_internal.h"
@@ -197,7 +198,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame 
*frame)
 
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 {
-enum AVPictureType type;
+enum AVPictureType type = AV_PICTURE_TYPE_NONE;
 switch (mfx_pic_type & 0x7) {
 case MFX_FRAMETYPE_I:
 if (mfx_pic_type & MFX_FRAMETYPE_S)
@@ -214,6 +215,8 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 else
 type = AV_PICTURE_TYPE_P;
 break;
+default:
+av_assert0(0);
 }
 
 return type;

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


[FFmpeg-cvslog] MAINTAINERS: add myself to qsv section

2018-06-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li  | Mon Jun  4 17:41:57 
2018 +0800| [550372d0c436b6edad1e0265488d0c38a414855c] | committer: Mark 
Thompson

MAINTAINERS: add myself to qsv section

Signed-off-by: Zhong Li 

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

 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2172901fe7..78f450dda6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -219,7 +219,7 @@ Codecs:
   ptx.c Ivo van Poorten
   qcelp*Reynaldo H. Verdejo Pinochet
   qdm2.c, qdm2data.hRoberto Togni
-  qsv*  Mark Thompson
+  qsv*  Mark Thompson, Zhong Li
   qtrle.c   Mike Melanson
   ra144.c, ra144.h, ra288.c, ra288.hRoberto Togni
   resample2.c   Michael Niedermayer

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


[FFmpeg-cvslog] lavc/qsvenc: set corret maximum value of look_ahead_downsampling

2018-05-07 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Wed May  2 16:42:35 
2018 +0800| [06344f705e66f6c90e978a9155155858cfb9be94] | committer: Mark 
Thompson

lavc/qsvenc: set corret maximum value of look_ahead_downsampling

Option "4x(MFX_LOOKAHEAD_DS_4x)" is provided but can't be set due to
wrong maximum value.

Signed-off-by: Zhong Li <zhong...@intel.com>

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

 libavcodec/qsvenc_h264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 718bf9cb21..7aa65e96bc 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -114,7 +114,7 @@ static const AVOption options[] = {
 #endif
 #if QSV_HAVE_LA_DS
 { "look_ahead_downsampling", "Downscaling factor for the frames saved for 
the lookahead analysis", OFFSET(qsv.look_ahead_downsampling),
-  AV_OPT_TYPE_INT,   { .i64 = 
MFX_LOOKAHEAD_DS_UNKNOWN }, MFX_LOOKAHEAD_DS_UNKNOWN, MFX_LOOKAHEAD_DS_2x, VE, 
"look_ahead_downsampling" },
+  AV_OPT_TYPE_INT,   { .i64 = 
MFX_LOOKAHEAD_DS_UNKNOWN }, MFX_LOOKAHEAD_DS_UNKNOWN, MFX_LOOKAHEAD_DS_4x, VE, 
"look_ahead_downsampling" },
 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_LOOKAHEAD_DS_UNKNOWN }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" 
},
 { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_LOOKAHEAD_DS_UNKNOWN }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" 
},
 { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_LOOKAHEAD_DS_OFF }, INT_MIN, INT_MAX, VE, "look_ahead_downsampling" 
},

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


[FFmpeg-cvslog] lavc/qsvdec: set complete_frame flags for progressive picture

2018-04-13 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Sat Apr  7 19:38:55 
2018 +0200| [54307b35311e9a871b3d8ecb2b2eecfc16de0163] | committer: Maxym 
Dmytrychenko

lavc/qsvdec: set complete_frame flags for progressive picture

Set the flag MFX_BITSTREAM_COMPLETE_FRAME when it is a progressive picture.
This can fix vc1 decoding segment fault issues because can't set the start
code correctly.

See: ./avconv -hwaccel qsv -c:v vc1_qsv -i /fate-suite/vc1/SA00040.vc1
-vf "hwdownload, format=nv12" -f rawvideo /dev/null

v2: fix some h264 interlaced clips regression
a. field_order of some h264 interlaced video (e.g: cama3_vtc_b.avc) is marked 
as AV_FIELD_UNKNOWN
   in h264_parser.c. This is not a completed frames.
   So only set the MFX_BITSTREAM_COMPLETE_FRAME when it is progressive.
b. some clips have both progressive and interlaced frames 
(e.g.CAPAMA3_Sand_F.264),
   the parsed field_order maybe changed druing the decoding progress.

This patch has been verified for other codecs(mpeg2/hevc/vp8).

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim@gmail.com>

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

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

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index c1b6238cfb..31cce2d838 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -323,6 +323,8 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
 bs.DataLength = avpkt->size;
 bs.MaxLength  = bs.DataLength;
 bs.TimeStamp  = avpkt->pts;
+if (avctx->field_order == AV_FIELD_PROGRESSIVE)
+bs.DataFlag   |= MFX_BITSTREAM_COMPLETE_FRAME;
 }
 
 sync = av_mallocz(sizeof(*sync));
@@ -516,6 +518,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
  pkt->data, pkt->size, pkt->pts, pkt->dts,
  pkt->pos);
 
+avctx->field_order  = q->parser->field_order;
 /* TODO: flush delayed frames on reinit */
 if (q->parser->format   != q->orig_pix_fmt||
 FFALIGN(q->parser->coded_width, 16)  != FFALIGN(avctx->coded_width, 
16) ||
@@ -540,7 +543,6 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 avctx->height   = q->parser->height;
 avctx->coded_width  = FFALIGN(q->parser->coded_width, 16);
 avctx->coded_height = FFALIGN(q->parser->coded_height, 16);
-avctx->field_order  = q->parser->field_order;
 avctx->level= q->avctx_internal->level;
 avctx->profile  = q->avctx_internal->profile;
 

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


[FFmpeg-cvslog] lavf/qsvvpp: bypass vpp if not needed.

2018-04-13 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Wed Apr  4 17:51:30 
2018 +0800| [29a8ed766354c45c9be4b8512c5b2eb25a450cdc] | committer: Maxym 
Dmytrychenko

lavf/qsvvpp: bypass vpp if not needed.

Currently vpp pipeline is always created, even for the unnecessary
cases such as setting the option "vpp_qsv=w=1280:h=720" for an input
with native resolution 1280x720. Thus introduces unnecessary performance
dropping, so bypass vpp if not needed.

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim@gmail.com>

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

 libavfilter/vf_vpp_qsv.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 610e821c1a..568dee5d29 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -27,6 +27,7 @@
 #include "libavutil/eval.h"
 #include "libavutil/avassert.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/mathematics.h"
 
 #include "formats.h"
 #include "internal.h"
@@ -249,6 +250,7 @@ static int config_output(AVFilterLink *outlink)
 QSVVPPParam param = { NULL };
 QSVVPPCrop  crop  = { 0 };
 mfxExtBuffer*ext_buf[ENH_FILTERS_COUNT];
+AVFilterLink*inlink = ctx->inputs[0];
 
 outlink->w  = vpp->out_width;
 outlink->h  = vpp->out_height;
@@ -320,14 +322,34 @@ static int config_output(AVFilterLink *outlink)
 param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)>procamp_conf;
 }
 
-return ff_qsvvpp_create(ctx, >qsv, );
+if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
+vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != 
outlink->h)
+return ff_qsvvpp_create(ctx, >qsv, );
+else {
+av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n");
+if (inlink->hw_frames_ctx)
+outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+}
+
+return 0;
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
 {
-VPPContext *vpp = inlink->dst->priv;
+int  ret = 0;
+AVFilterContext  *ctx = inlink->dst;
+VPPContext   *vpp = inlink->dst->priv;
+AVFilterLink *outlink = ctx->outputs[0];
+
+if (vpp->qsv)
+ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+else {
+if (picref->pts != AV_NOPTS_VALUE)
+picref->pts = av_rescale_q(picref->pts, inlink->time_base, 
outlink->time_base);
+ret = ff_filter_frame(outlink, picref);
+}
 
-return ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+return ret;
 }
 
 static int query_formats(AVFilterContext *ctx)

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


[FFmpeg-cvslog] lavc/qsvdec: expose frame pic_type and key_frame

2018-04-13 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Wed Apr  4 17:51:29 
2018 +0800| [52ed83fa1a7f5170447eff6fad0b6c57119596e9] | committer: Maxym 
Dmytrychenko

lavc/qsvdec: expose frame pic_type and key_frame

Currently pict_type and key_frame are unset.
Add an extra param to fetch the picture type from qsv decoder

The judgement “key frame is equal to IDR frame” only suitable for H264.
For HEVC, all IRAP frames are key frames, and other codecs have no IDR
frame.

Signed-off-by: ChaoX A Liu <chaox.a@intel.com>
Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim@gmail.com>

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

 libavcodec/qsv.c  | 24 
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c   |  9 +
 3 files changed, 36 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index e78633d62a..e578ab15f5 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, 
QSVFrame *frame)
 return AVERROR_BUG;
 }
 
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
+{
+enum AVPictureType type;
+switch (mfx_pic_type & 0x7) {
+case MFX_FRAMETYPE_I:
+if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SI;
+else
+type = AV_PICTURE_TYPE_I;
+break;
+case MFX_FRAMETYPE_B:
+type = AV_PICTURE_TYPE_B;
+break;
+case MFX_FRAMETYPE_P:
+if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SP;
+else
+type = AV_PICTURE_TYPE_P;
+break;
+}
+
+return type;
+}
+
 static int qsv_load_plugins(mfxSession session, const char *load_plugins,
 void *logctx)
 {
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 975c8de441..07ddc59044 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -48,6 +48,8 @@ typedef struct QSVMid {
 typedef struct QSVFrame {
 AVFrame *frame;
 mfxFrameSurface1 surface;
+mfxExtDecodedFrameInfo dec_info;
+mfxExtBuffer *ext_param;
 
 int queued;
 int used;
@@ -83,6 +85,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
 int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
  const char *load_plugins);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index f31172de29..c1b6238cfb 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -232,6 +232,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext 
*q, QSVFrame *frame)
 
 frame->surface.Data.MemId = >frames_ctx.mids[ret];
 }
+frame->surface.Data.ExtParam= >ext_param;
+frame->surface.Data.NumExtParam = 1;
+frame->ext_param= (mfxExtBuffer*)>dec_info;
+frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
+frame->dec_info.Header.BufferSz = sizeof(frame->dec_info);
 
 frame->used = 1;
 
@@ -416,6 +421,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
 frame->interlaced_frame =
 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
+frame->pict_type = ff_qsv_map_pictype(out_frame->dec_info.FrameType);
+//Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs 
are key frames.
+if (avctx->codec_id == AV_CODEC_ID_H264)
+frame->key_frame = !!(out_frame->dec_info.FrameType & 
MFX_FRAMETYPE_IDR);
 
 /* update the surface properties */
 if (avctx->pix_fmt == AV_PIX_FMT_QSV)

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


[FFmpeg-cvslog] qsvenc: Fix a typo of FrameRateExtD/FrameRateExtN

2018-03-29 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Mar 15 18:02:11 
2018 +0800| [3d6e76b953afd36e23ef8532b81aea58a6338931] | committer: Luca Barbato

qsvenc: Fix a typo of FrameRateExtD/FrameRateExtN

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index d4dd4a3b94..baa2c6307f 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -374,7 +374,7 @@ static int check_enc_param(AVCodecContext *avctx, 
QSVEncContext *q)
 av_log(avctx, AV_LOG_ERROR, "Selected ratecontrol mode is 
unsupported\n");
 if (UNMATCH(LowPower))
   av_log(avctx, AV_LOG_ERROR, "Low power mode is unsupported\n");
-if (UNMATCH(FrameInfo.FrameRateExtN) || 
UNMATCH(FrameInfo.FrameRateExtN))
+if (UNMATCH(FrameInfo.FrameRateExtN) || 
UNMATCH(FrameInfo.FrameRateExtD))
   av_log(avctx, AV_LOG_ERROR, "Current frame rate is 
unsupported\n");
 if (UNMATCH(FrameInfo.PicStruct))
   av_log(avctx, AV_LOG_ERROR, "Current picture structure is 
unsupported\n");

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


[FFmpeg-cvslog] qsvenc: add the Access Unit Delimiter NAL Unit support

2018-03-29 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Mar 15 18:02:12 
2018 +0800| [deefca02c275ce4bc5ccbee690463ffef81a18b8] | committer: Luca Barbato

qsvenc: add the Access Unit Delimiter NAL Unit support

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 libavcodec/qsvenc.c  | 1 +
 libavcodec/qsvenc.h  | 2 ++
 libavcodec/qsvenc_h264.c | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index baa2c6307f..f6b1a0d676 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -600,6 +600,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (q->recovery_point_sei >= 0)
 q->extco.RecoveryPointSEI = q->recovery_point_sei ? 
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
 q->extco.MaxDecFrameBuffering = q->max_dec_frame_buffering;
+q->extco.AUDelimiter  = q->aud ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 }
 
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 31537b2663..ab55795950 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -137,6 +137,8 @@ typedef struct QSVEncContext {
 int max_frame_size;
 int max_slice_size;
 
+int aud;
+
 int single_sei_nal_unit;
 int max_dec_frame_buffering;
 int trellis;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 1552d7691d..634a7d3f91 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -91,6 +91,8 @@ static const AVOption options[] = {
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_MAIN
 }, INT_MIN, INT_MAX, VE, "profile" },
 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH
 }, INT_MIN, INT_MAX, VE, "profile" },
 
+{ "aud", "Insert the Access Unit Delimiter NAL", OFFSET(qsv.aud), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE},
+
 { NULL },
 };
 

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


[FFmpeg-cvslog] lavc/qsvenc: disable h264 look_ahead by default

2018-03-05 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Mar  1 13:20:19 
2018 +0800| [0645698ecc2021ec422b625a6c1d235d2f252563] | committer: Mark 
Thompson

lavc/qsvenc: disable h264 look_ahead by default

Look_ahead can provide quality improvements, but would better disable it by 
default due to some reasons:
1. It is only available for some codecs (e.g. HEVC is not supported) on Intel
   Haswell and plus platforms. Thus means it will be failed on some platforms.
2. It significantly increases encoding latency and memory consumption.
3. It may overwrite some other options such as CBR and CAVLC.

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Mark Thompson <s...@jkqxz.net>

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

 libavcodec/qsvenc_h264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 09e4c0e599..e01a2a3369 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -109,7 +109,7 @@ static const AVOption options[] = {
 { "max_dec_frame_buffering", "Maximum number of frames buffered in the 
DPB", OFFSET(qsv.max_dec_frame_buffering), AV_OPT_TYPE_INT, { .i64 = 0 },   0, 
UINT16_MAX, VE },
 
 #if QSV_HAVE_LA
-{ "look_ahead",   "Use VBR algorithm with look ahead",
OFFSET(qsv.look_ahead),   AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
+{ "look_ahead",   "Use VBR algorithm with look ahead",
OFFSET(qsv.look_ahead),   AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
 { "look_ahead_depth", "Depth of look ahead in number frames", 
OFFSET(qsv.look_ahead_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, VE },
 #endif
 #if QSV_HAVE_LA_DS

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


[FFmpeg-cvslog] qsvenc: Provide a detailed error message if the parameters are invalid

2018-03-05 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Fri Mar  2 11:26:27 
2018 +0800| [2d6b3f3a9dce409ca51d70ef4b85c0593bb4b109] | committer: Luca Barbato

qsvenc: Provide a detailed error message if the parameters are invalid

Currently it always shows "Selected ratecontrol mode is not supported
by the QSV runtime. Choose a different mode", but sometimes it is not
accurate.

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 libavcodec/qsvenc.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 16d942f00a..d4dd4a3b94 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -356,15 +356,34 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 return 0;
 }
 
-static int rc_supported(QSVEncContext *q)
+static int check_enc_param(AVCodecContext *avctx, QSVEncContext *q)
 {
 mfxVideoParam param_out = { .mfx.CodecId = q->param.mfx.CodecId };
 mfxStatus ret;
 
+#define UNMATCH(x) (param_out.mfx.x != q->param.mfx.x)
+
 ret = MFXVideoENCODE_Query(q->session, >param, _out);
-if (ret < 0 ||
-param_out.mfx.RateControlMethod != q->param.mfx.RateControlMethod)
+
+if (ret < 0) {
+if (UNMATCH(CodecId))
+av_log(avctx, AV_LOG_ERROR, "Current codec type is unsupported\n");
+if (UNMATCH(CodecProfile))
+av_log(avctx, AV_LOG_ERROR, "Current profile is unsupported\n");
+if (UNMATCH(RateControlMethod))
+av_log(avctx, AV_LOG_ERROR, "Selected ratecontrol mode is 
unsupported\n");
+if (UNMATCH(LowPower))
+  av_log(avctx, AV_LOG_ERROR, "Low power mode is unsupported\n");
+if (UNMATCH(FrameInfo.FrameRateExtN) || 
UNMATCH(FrameInfo.FrameRateExtN))
+  av_log(avctx, AV_LOG_ERROR, "Current frame rate is 
unsupported\n");
+if (UNMATCH(FrameInfo.PicStruct))
+  av_log(avctx, AV_LOG_ERROR, "Current picture structure is 
unsupported\n");
+if (UNMATCH(FrameInfo.Width) || UNMATCH(FrameInfo.Height))
+  av_log(avctx, AV_LOG_ERROR, "Current resolution is 
unsupported\n");
+if (UNMATCH(FrameInfo.FourCC))
+  av_log(avctx, AV_LOG_ERROR, "Current pixel format is 
unsupported\n");
 return 0;
+}
 return 1;
 }
 
@@ -639,10 +658,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
 
-if (!rc_supported(q)) {
+if (!check_enc_param(avctx,q)) {
 av_log(avctx, AV_LOG_ERROR,
-   "Selected ratecontrol mode is not supported by the QSV "
-   "runtime. Choose a different mode.\n");
+   "some encoding parameters are not supported by the QSV "
+   "runtime. Please double check the input parameters.\n");
 return AVERROR(ENOSYS);
 }
 

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


[FFmpeg-cvslog] qsvenc: AVBR is not supported on non-windows OS

2018-02-12 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Tue Jan 30 18:07:23 
2018 +0800| [8bb9824fcbc5a6ebf68391d70a2c4f03447990d2] | committer: Maxym 
Dmytrychenko

qsvenc: AVBR is not supported on non-windows OS

AVBR is supported from API 1.3 but only available for Windows

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim@gmail.com>

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

 libavcodec/qsvenc.c | 17 ++---
 libavcodec/qsvenc.h |  2 ++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 24d9ec4d71..16d942f00a 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -84,7 +84,9 @@ static const struct {
 { MFX_RATECONTROL_CBR, "CBR" },
 { MFX_RATECONTROL_VBR, "VBR" },
 { MFX_RATECONTROL_CQP, "CQP" },
+#if QSV_HAVE_AVBR
 { MFX_RATECONTROL_AVBR,"AVBR" },
+#endif
 #if QSV_HAVE_LA
 { MFX_RATECONTROL_LA,  "LA" },
 #endif
@@ -163,11 +165,14 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 } else if (info->RateControlMethod == MFX_RATECONTROL_CQP) {
 av_log(avctx, AV_LOG_VERBOSE, "QPI: %"PRIu16"; QPP: %"PRIu16"; QPB: 
%"PRIu16"\n",
info->QPI, info->QPP, info->QPB);
-} else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
+}
+#if QSV_HAVE_AVBR
+else if (info->RateControlMethod == MFX_RATECONTROL_AVBR) {
 av_log(avctx, AV_LOG_VERBOSE,
"TargetKbps: %"PRIu16"; Accuracy: %"PRIu16"; Convergence: 
%"PRIu16"\n",
info->TargetKbps, info->Accuracy, info->Convergence);
 }
+#endif
 #if QSV_HAVE_LA
 else if (info->RateControlMethod == MFX_RATECONTROL_LA
 #if QSV_HAVE_LA_HRD
@@ -333,10 +338,14 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 else if (avctx->rc_max_rate == avctx->bit_rate) {
 rc_mode = MFX_RATECONTROL_CBR;
 rc_desc = "constant bitrate (CBR)";
-} else if (!avctx->rc_max_rate) {
+}
+#if QSV_HAVE_AVBR
+else if (!avctx->rc_max_rate) {
 rc_mode = MFX_RATECONTROL_AVBR;
 rc_desc = "average variable bitrate (AVBR)";
-} else {
+}
+#endif
+else {
 rc_mode = MFX_RATECONTROL_VBR;
 rc_desc = "variable bitrate (VBR)";
 }
@@ -522,11 +531,13 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 q->param.mfx.QPB = av_clip(quant * fabs(avctx->b_quant_factor) + 
avctx->b_quant_offset, 0, 51);
 
 break;
+#if QSV_HAVE_AVBR
 case MFX_RATECONTROL_AVBR:
 q->param.mfx.TargetKbps  = avctx->bit_rate / 1000;
 q->param.mfx.Convergence = q->avbr_convergence;
 q->param.mfx.Accuracy= q->avbr_accuracy;
 break;
+#endif
 #if QSV_HAVE_LA
 case MFX_RATECONTROL_LA:
 q->param.mfx.TargetKbps  = avctx->bit_rate / 1000;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 088a61de54..725651e2e1 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -46,10 +46,12 @@
 #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
 
 #if defined(_WIN32)
+#define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
 #define QSV_HAVE_ICQQSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_VCMQSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_QVBR   QSV_VERSION_ATLEAST(1, 11)
 #else
+#define QSV_HAVE_AVBR   0
 #define QSV_HAVE_ICQ0
 #define QSV_HAVE_VCM0
 #define QSV_HAVE_QVBR   0

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


[FFmpeg-cvslog] qsvdec: Relax the surface vs coded dimension check

2018-02-11 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Jan 25 18:19:12 
2018 +0800| [6829a079444e10818a847e153121fb458cc5c0a8] | committer: Luca Barbato

qsvdec: Relax the surface vs coded dimension check

Fix a common vp8 decoding failure.

Many vp8 clips cannot decode if hw_frames_ctx is enabled, reporting
"Error during QSV decoding.: incompatible video parameters (-14)".

It is due to mfx.FrameInfo.Width/Height not matching coded_w/coded_h.

See: avconv -hwaccel qsv -init_hw_device qsv -c:v vp8_qsv -i 
vp8-test-vectors-r1/vp80-00-comprehensive-001.ivf
-vf "hwdownload,format=nv12" -pix_fmt yuv420p -f md5 -

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 libavcodec/qsv.c| 2 +-
 libavcodec/qsvdec.c | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 96dca14e9a..e78633d62a 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -389,7 +389,7 @@ static mfxStatus qsv_frame_alloc(mfxHDL pthis, 
mfxFrameAllocRequest *req,
 mfxFrameInfo  *i  = >Info;
 mfxFrameInfo  *i1 = _hwctx->surfaces[0].Info;
 
-if (i->Width  != i1->Width  || i->Height != i1->Height ||
+if (i->Width  > i1->Width  || i->Height > i1->Height ||
 i->FourCC != i1->FourCC || i->ChromaFormat != i1->ChromaFormat) {
 av_log(ctx->logctx, AV_LOG_ERROR, "Mismatching surface properties 
in an "
"allocation request: %dx%d %d %d vs %dx%d %d %d\n",
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 9741f33109..f31172de29 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -149,9 +149,6 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 else if (frames_hwctx->frame_type & 
MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
 }
-
-frame_width  = frames_hwctx->surfaces[0].Info.Width;
-frame_height = frames_hwctx->surfaces[0].Info.Height;
 }
 
 if (!iopattern)

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


[FFmpeg-cvslog] ffprobe: Initialize coded_width/height

2018-02-02 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Fri Jan 19 13:05:55 
2018 +0800| [19b1d905b88d32a86511219585eae6afda23dfbd] | committer: James Almer

ffprobe: Initialize coded_width/height

coded_width/height are unnitialized and will be overwritten by
dec_ctx->width/height in avcodec_open2()

This fixes tiket #6958.

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: James Almer <jamr...@gmail.com>

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

 fftools/ffprobe.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index acb403e3b1..fc3a14a807 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w, 
AVFormatContext *fmt_ctx, int stream_id
 case AVMEDIA_TYPE_VIDEO:
 print_int("width",par->width);
 print_int("height",   par->height);
+#if FF_API_LAVF_AVCTX
 if (dec_ctx) {
 print_int("coded_width",  dec_ctx->coded_width);
 print_int("coded_height", dec_ctx->coded_height);
 }
+#endif
 print_int("has_b_frames", par->video_delay);
 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 if (sar.den) {
@@ -2912,6 +2914,12 @@ static int open_input_file(InputFile *ifile, const char 
*filename)
 
 ist->dec_ctx->pkt_timebase = stream->time_base;
 ist->dec_ctx->framerate = stream->avg_frame_rate;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ist->dec_ctx->coded_width = stream->codec->coded_width;
+ist->dec_ctx->coded_height = stream->codec->coded_height;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 if (avcodec_open2(ist->dec_ctx, codec, ) < 0) {
 av_log(NULL, AV_LOG_WARNING, "Could not open codec for input 
stream %d\n",

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


[FFmpeg-cvslog] examples/qsvdec: do not set the deprecated field refcounted_frames

2018-01-16 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Dec 28 17:38:33 
2017 +0800| [1efbbfedcaf4a3cecab980273ad809ba3ade2f74] | committer: Luca Barbato

examples/qsvdec: do not set the deprecated field refcounted_frames

It is used by the deprecated API avcodec_decode_video2 and ignored by the
new decode APIs (avcodec_send_packet/avcodec_receive_frame).

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 doc/examples/qsvdec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c
index 46e6ddcb0d..cede6153be 100644
--- a/doc/examples/qsvdec.c
+++ b/doc/examples/qsvdec.c
@@ -210,7 +210,6 @@ int main(int argc, char **argv)
video_st->codecpar->extradata_size);
 decoder_ctx->extradata_size = video_st->codecpar->extradata_size;
 }
-decoder_ctx->refcounted_frames = 1;
 
 decoder_ctx->opaque  = 
 decoder_ctx->get_format  = get_format;

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


[FFmpeg-cvslog] lavu/qsv: add log message for libmfx version

2018-01-16 Thread Zhong Li
ffmpeg | branch: master | Zhong Li <zhong...@intel.com> | Thu Dec 28 17:38:32 
2017 +0800| [e23190269fb6e8217d080918893641ba3e0e3556] | committer: Luca Barbato

lavu/qsv: add log message for libmfx version

It is benefit to diagnose issues related to different libmfx version.

Signed-off-by: Zhong Li <zhong...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

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

 libavutil/hwcontext_qsv.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 5018a05b9a..9270b2258f 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1036,6 +1036,10 @@ static int 
qsv_device_derive_from_child(AVHWDeviceContext *ctx,
 goto fail;
 }
 
+av_log(ctx, AV_LOG_VERBOSE,
+   "Initialize MFX session: API version is %d.%d, implementation 
version is %d.%d\n",
+   MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
+
 MFXClose(hwctx->session);
 
 err = MFXInit(implementation, , >session);

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


  1   2   >