[FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the initialization postion of profile_string

2018-11-05 Thread Linjie Fu
Currently, profile_string was initialized in the "for" loop. If
it didn't enter this loop or accidently break, profile_string may be
uninitialized.

Modify to initialize the profile_string after the loop to avoid
using the uninitialized value when calling av_log.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_encode.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 2c34cdce2c..b43b52f0e5 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1066,6 +1066,7 @@ static av_cold int 
vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
 }
 
 av_assert0(ctx->codec->profiles);
+
 for (i = 0; (ctx->codec->profiles[i].av_profile !=
  FF_PROFILE_UNKNOWN); i++) {
 profile = >codec->profiles[i];
@@ -1080,12 +1081,6 @@ static av_cold int 
vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
 avctx->profile != FF_PROFILE_UNKNOWN)
 continue;
 
-#if VA_CHECK_VERSION(1, 0, 0)
-profile_string = vaProfileStr(profile->va_profile);
-#else
-profile_string = "(no profile names)";
-#endif
-
 for (j = 0; j < n; j++) {
 if (va_profiles[j] == profile->va_profile)
 break;
@@ -1107,6 +1102,11 @@ static av_cold int 
vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
 
 avctx->profile  = profile->av_profile;
 ctx->va_profile = profile->va_profile;
+#if VA_CHECK_VERSION(1, 0, 0)
+profile_string = vaProfileStr(profile->va_profile);
+#else
+profile_string = "(no profile names)";
+#endif
 av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
profile_string, ctx->va_profile);
 
-- 
2.17.1

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


[FFmpeg-devel] [PATCH] avfilter/vf_overlay_qsv: initialize default pix_fmt

2018-11-05 Thread Linjie Fu
add default initiaization for pix_fmt in function have_alpha_panar
to avoid using uninitialized value.

Signed-off-by: Linjie Fu 
---
 libavfilter/vf_overlay_qsv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 20871786ee..79d6a58ec3 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -167,7 +167,8 @@ static int have_alpha_planar(AVFilterLink *link)
 if (link->format == AV_PIX_FMT_QSV) {
 fctx= (AVHWFramesContext *)link->hw_frames_ctx->data;
 pix_fmt = fctx->sw_format;
-}
+} else
+pix_fmt = AV_PIX_FMT_NONE;
 
 desc = av_pix_fmt_desc_get(pix_fmt);
 if (!desc)
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH] [V2] avcodec/qsvenc: add VDENC support for H264 and HEVC

2018-11-05 Thread Moritz Barsnick
On Mon, Nov 05, 2018 at 09:50:13 +0800, Linjie Fu wrote:
> It's an experimental function(like lowpower in vaapi) with

Should it be under "-strict experimental" then?

> module parameter(i915.enable_guc=2 for linux kerner version >= 4.16)
   ^ kernel

> [V2]: modified the commit message and option comments, use AV_OPT_TYPE_BOOL
> to replace AV_OPT_TYPE_INT.

This remark belongs below the "---" line, so it doesn't show up in the
actual final commit.

> Signed-off-by: Linjie Fu 
> ---

(Right here.)

> +{ "low_power", "enable low power mode (experimental, many limitations by 
> mfx version, HW platform, BRC modes, etc.", OFFSET(qsv.low_power), 
> AV_OPT_TYPE_BOOL, { .i64 =  0 }, 0, 1, VE},
 ^ please also add a closing bracket
> +++ b/libavcodec/qsvenc_hevc.c
[...]
> +{ "low_power", "enable low power mode (experimental, many limitations by 
> mfx version, HW platform, BRC modes, etc.", OFFSET(qsv.low_power), 
> AV_OPT_TYPE_BOOL, { .i64 =  0 },  0,  1, VE },
Same here.

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


[FFmpeg-devel] [PATCH] avcodec/qsvenc: add default initiaize for pict_type

2018-11-05 Thread Linjie Fu
add default initiaize for pict_type in function ff_qsv_encode
to avoid using uninitialized value:

FF_DISABLE_DEPRECATION_WARNINGS
avctx->coded_frame->pict_type = pict_type;
FF_ENABLE_DEPRECATION_WARNINGS

Signed-off-by: Linjie Fu 
---
 libavcodec/qsvenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 7a031297fe..564222ca10 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1333,6 +1333,8 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
 pict_type = AV_PICTURE_TYPE_P;
 else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & 
MFX_FRAMETYPE_xB)
 pict_type = AV_PICTURE_TYPE_B;
+else
+pict_type = AV_PICTURE_TYPE_NONE;
 
 #if FF_API_CODED_FRAME
 FF_DISABLE_DEPRECATION_WARNINGS
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH] [V2] avcodec/qsvenc: add VDENC support for H264 and HEVC

2018-11-05 Thread Fu, Linjie
> -Original Message- 
> On Mon, Nov 05, 2018 at 09:50:13 +0800, Linjie Fu wrote:
> > It's an experimental function(like lowpower in vaapi) with
> 
> Should it be under "-strict experimental" then?
> 
> > module parameter(i915.enable_guc=2 for linux kerner version >= 4.16)
>^ kernel
> 
> > [V2]: modified the commit message and option comments, use
> AV_OPT_TYPE_BOOL
> > to replace AV_OPT_TYPE_INT.
> 
> This remark belongs below the "---" line, so it doesn't show up in the
> actual final commit.
> 
> > Signed-off-by: Linjie Fu 
> > ---
> 
> (Right here.)

Thanks, got it.

> > +{ "low_power", "enable low power mode (experimental, many
> limitations by mfx version, HW platform, BRC modes, etc.",
> OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =  0 }, 0, 1, VE},
>  ^ please also add a closing 
> bracket
> > +++ b/libavcodec/qsvenc_hevc.c
> [...]
> > +{ "low_power", "enable low power mode (experimental, many
> limitations by mfx version, HW platform, BRC modes, etc.",
> OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =  0 },  0,  1, VE },
> Same here.
> 
> Moritz

Thanks for your review, and I'm so sorry for these mistakes. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 0/7] qsv encoder enhancement and code refine

2018-11-05 Thread Zhong Li
Zhong Li (7):
  lavc/qsvenc: enable ICQ and ICQ_LA on Linux
  lavc/qsvenc: add forced_idr opiton
  lavc/qsvenc: remove redundant code
  lavc/qsvenc: make hevc alignment same as h264 for 1.19+ version
  lavc/qsvenc: dump log for frame rate
  lavc/qsvenc: add an option to set h264 pps for every frame
  lavc/qsvenc: add an option to set MB numbers of each slice

 libavcodec/qsvenc.c  | 41 -
 libavcodec/qsvenc.h  |  7 ++-
 libavcodec/qsvenc_h264.c |  3 +++
 libavcodec/version.h |  2 +-
 4 files changed, 38 insertions(+), 15 deletions(-)

-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 2/7] lavc/qsvenc: add forced_idr opiton

2018-11-05 Thread Zhong Li
This option can be used to repect original input I/IDR frame type.

Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc.c | 7 +++
 libavcodec/qsvenc.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 948751d..7098ec7 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 (q->forced_idr && frame->pict_type == AV_PICTURE_TYPE_I) {
+enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
+if (q->forced_idr || frame->key_frame)
+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 055b4a6..fbdc199 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);
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 5/7] lavc/qsvenc: dump log for frame rate

2018-11-05 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 3e7d623..7745086 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)
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 1/7] lavc/qsvenc: enable ICQ and ICQ_LA on Linux

2018-11-05 Thread Zhong Li
ICQ/ICQ_LA are enabled with MSDK V1.28

One example of ICQ_LA:
ffmpeg -hwaccel qsv -c:v h264_qsv -i in.mp4 -c:v h264_qsv -global_quality 25 
-look_ahead 1 out.mp4

Signed-off-by: Zhong Li 
---
ICQ mode will fail with some cases: 
https://github.com/Intel-Media-SDK/MediaSDK/issues/863. Don't merge this patch 
before it resolved.

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

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 50cc426..055b4a6 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)
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 3/7] lavc/qsvenc: remove redundant code

2018-11-05 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 7098ec7..d160db3 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;
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 7/7] lavc/qsvenc: add an option to set MB numbers of each slice

2018-11-05 Thread Zhong Li
This option specifies suggested macroblocks numbers in each slice.
MSDK may adjust it based on platform capability.
And slice_number will be ignored if this option set to a non-zero
value.

Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc.c  | 1 +
 libavcodec/qsvenc.h  | 1 +
 libavcodec/qsvenc_h264.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 7d74068..1797279 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -655,6 +655,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;
+q->extco2.NumMbPerSlice = q->num_mb_per_slice;
 
 #if FF_API_PRIVATE_OPT
 FF_DISABLE_DEPRECATION_WARNINGS
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 4316a10..c2aa88e 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -163,6 +163,7 @@ typedef struct QSVEncContext {
 int recovery_point_sei;
 
 int repeat_pps;
+int num_mb_per_slice;
 
 int a53_cc;
 
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 13217b4..693a9e3 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -156,6 +156,7 @@ static const AVOption options[] = {
 #endif
 
 { "repeat_pps", "repeat pps for every frame", OFFSET(qsv.repeat_pps), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+{ "num_mb_per_slice","Suggested macroblocks numbers of each slice", 
OFFSET(qsv.num_mb_per_slice), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 
 { NULL },
 };
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 4/7] lavc/qsvenc: make hevc alignment same as h264 for 1.19+ version

2018-11-05 Thread Zhong Li
It is to clean up to the code and To-Do list.

Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index d160db3..3e7d623 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);
 
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 6/7] lavc/qsvenc: add an option to set h264 pps for every frame

2018-11-05 Thread Zhong Li
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.

Signed-off-by: Zhong Li 
---
 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 7745086..7d74068 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 fbdc199..4316a10 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 ac7023e..13217b4 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -155,6 +155,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 fddc67d..10d88d5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  36
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.7.4

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


[FFmpeg-devel] [PATCH] avcodec/mips: [loongson] refine optimization in h264_chroma.

2018-11-05 Thread Shiyou Yin
Remove invalid operation in the case x and y all equal 0,
this refine made about 2% speedup for H264 decode on loongson platform.
---
 libavcodec/mips/h264chroma_mmi.c | 970 +--
 1 file changed, 426 insertions(+), 544 deletions(-)

diff --git a/libavcodec/mips/h264chroma_mmi.c b/libavcodec/mips/h264chroma_mmi.c
index 91b2cc4..afda5be 100644
--- a/libavcodec/mips/h264chroma_mmi.c
+++ b/libavcodec/mips/h264chroma_mmi.c
@@ -30,74 +30,177 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t 
*src, ptrdiff_t stride,
 int h, int x, int y)
 {
 int A = 64, B, C, D, E;
-double ftmp[10];
+double ftmp[12];
 uint64_t tmp[1];
 
 if (!(x || y)) {
 /* x=0, y=0, A=64 */
 __asm__ volatile (
-"xor%[ftmp0],   %[ftmp0],   %[ftmp0]   \n\t"
-"dli%[tmp0],0x06   \n\t"
-"mtc1   %[tmp0],%[ftmp4]   \n\t"
-
 "1:\n\t"
+MMI_ULDC1(%[ftmp0], %[src], 0x00)
+PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
 MMI_ULDC1(%[ftmp1], %[src], 0x00)
-"addi   %[h],   %[h],   -0x04  \n\t"
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp5], %[src], 0x00)
+MMI_ULDC1(%[ftmp2], %[src], 0x00)
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp6], %[src], 0x00)
+MMI_ULDC1(%[ftmp3], %[src], 0x00)
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp7], %[src], 0x00)
 
-"punpcklbh  %[ftmp2],   %[ftmp1],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp1],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
-"paddh  %[ftmp1],   %[ftmp1],   %[ff_pw_32]\n\t"
-"paddh  %[ftmp2],   %[ftmp2],   %[ff_pw_32]\n\t"
-"psrlh  %[ftmp1],   %[ftmp1],   %[ftmp4]   \n\t"
-"psrlh  %[ftmp2],   %[ftmp2],   %[ftmp4]   \n\t"
-"packushb   %[ftmp1],   %[ftmp1],   %[ftmp2]   \n\t"
-MMI_SDC1(%[ftmp1], %[dst], 0x00)
+"addi   %[h],   %[h],   -0x04  \n\t"
 
-"punpcklbh  %[ftmp2],   %[ftmp5],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp5],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
-"paddh  %[ftmp1],   %[ftmp1],   %[ff_pw_32]\n\t"
-"paddh  %[ftmp2],   %[ftmp2],   %[ff_pw_32]\n\t"
-"psrlh  %[ftmp1],   %[ftmp1],   %[ftmp4]   \n\t"
-"psrlh  %[ftmp2],   %[ftmp2],   %[ftmp4]   \n\t"
-"packushb   %[ftmp1],   %[ftmp1],   %[ftmp2]   \n\t"
+MMI_SDC1(%[ftmp0], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 MMI_SDC1(%[ftmp1], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+MMI_SDC1(%[ftmp2], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+MMI_SDC1(%[ftmp3], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+"bnez   %[h],   1b \n\t"
+: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+  [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
+  [dst]"+"(dst),  [src]"+"(src),
+  [h]"+"(h)
+: [stride]"r"((mips_reg)stride)
+: "memory"
+);
+} else if (x && y) {
+/* x!=0, y!=0 */
+D = x * y;
+B = (x << 3) - D;
+C = (y << 3) - D;
+A = 64 - D - B - C;
 
-"punpcklbh  %[ftmp2],   %[ftmp6],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp6],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
+__asm__ volatile (
+"xor%[ftmp0],   %[ftmp0],   %[ftmp0]   \n\t"
+"dli%[tmp0],0x06   \n\t"
+"pshufh %[A],   %[A],   %[ftmp0]   \n\t"
+"pshufh %[B],   %[B],   %[ftmp0] 

Re: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the initialization postion of profile_string

2018-11-05 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, November 5, 2018 5:39 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the
> initialization postion of profile_string
> 
> Currently, profile_string was initialized in the "for" loop. If it didn't 
> enter this
> loop or accidently break, profile_string may be uninitialized.
> 
> Modify to initialize the profile_string after the loop to avoid using the
> uninitialized value when calling av_log.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_encode.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2c34cdce2c..b43b52f0e5 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1066,6 +1066,7 @@ static av_cold int
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>  }
> 
>  av_assert0(ctx->codec->profiles);
> +

Please don't introduce redundant line.

>  for (i = 0; (ctx->codec->profiles[i].av_profile !=
>   FF_PROFILE_UNKNOWN); i++) {
>  profile = >codec->profiles[i]; @@ -1080,12 +1081,6 @@
> static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>  avctx->profile != FF_PROFILE_UNKNOWN)
>  continue;
> 
> -#if VA_CHECK_VERSION(1, 0, 0)
> -profile_string = vaProfileStr(profile->va_profile);
> -#else
> -profile_string = "(no profile names)";
> -#endif
> -
>  for (j = 0; j < n; j++) {
>  if (va_profiles[j] == profile->va_profile)
>  break;
> @@ -1107,6 +1102,11 @@ static av_cold int
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
> 
>  avctx->profile  = profile->av_profile;
>  ctx->va_profile = profile->va_profile;
> +#if VA_CHECK_VERSION(1, 0, 0)
> +profile_string = vaProfileStr(profile->va_profile);
> +#else
> +profile_string = "(no profile names)"; #endif
>  av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
> profile_string, ctx->va_profile);
> 
> --
> 2.17.1

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


Re: [FFmpeg-devel] [PATCH 1/3] cbs_av1: Fix header writing when already aligned

2018-11-05 Thread James Almer
On 11/5/2018 11:12 AM, Mark Thompson wrote:
> On 05/11/18 13:14, James Almer wrote:
>> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>>> ---
>>> Previously it lost the trailing bits byte but did include it in the OBU 
>>> size, completely breaking the stream.
>>>
>>>
>>>  libavcodec/cbs_av1.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
>>> index 9bac9dde09..1c49d90f51 100644
>>> --- a/libavcodec/cbs_av1.c
>>> +++ b/libavcodec/cbs_av1.c
>>> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext 
>>> *ctx,
>>>  if (err < 0)
>>>  return err;
>>>  end_pos = put_bits_count(pbc);
>>> -obu->obu_size = (end_pos - start_pos + 7) / 8;
>>> +obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>>>  } else {
>>>  // Empty OBU.
>>>  obu->obu_size = 0;
>>>
>>
>> What samples was this breaking? The few i tried have matching checksum
>> after an av1_metadata passthrough.
> 
> Your s6Nh.ivf file with redundant headers requires it.  (I spent quite a 
> while banging my head against that one, because the write trace showed 
> exactly the right thing but then reading it back was messed up.)
> 
> - Mark

Right, it was a dep for patch 2.

LGTM then.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/3] doc/encoders: Add libaom-av1

2018-11-05 Thread Mark Thompson
---
Updated to add some more explanation of the rate control mode selection.


 doc/encoders.texi | 108 ++
 1 file changed, 108 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 1ca0ef1543..f2e4199017 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1370,6 +1370,114 @@ makes it possible to store non-rgb pix_fmts.
 
 @end table
 
+@section libaom-av1
+
+libaom AV1 encoder wrapper.
+
+Requires the presence of the libaom headers and library during
+configuration.  You need to explicitly configure the build with
+@code{--enable-libaom}.
+
+@subsection Options
+
+The wrapper supports the following standard libavcodec options:
+
+@table @option
+
+@item b
+Set bitrate target in bits/second.  By default this will use
+variable-bitrate mode.  If @option{maxrate} and @option{minrate} are
+also set to the same value then it will use constant-bitrate mode,
+otherwise if @option{crf} is set as well then it will use
+constrained-quality mode.
+
+@item g
+Set GOP size (maximum distance between key frames).
+
+@item qmin qmax
+Set minimum/maximum quantisation values.  Valid range is from 0 to 63
+(warning: this does not match the quantiser values actually used by AV1
+- divide by four to map real quantiser values to this range).  Defaults
+to min/max (no constraint).
+
+@item minrate maxrate bufsize rc_init_occupancy
+Set rate control buffering parameters.  Not used if not set - defaults
+to unconstrained variable bitrate.
+
+@item threads
+Set the number of threads to use while encoding.  This may require the
+@option{tiles} option to also be set to actually use the specified
+number of threads fully.  Defaults to the number of hardware threads
+supported by the host machine.
+
+@item profile
+Set the encoding profile.  Defaults to using the profile which matches
+the bit depth and chroma subsampling of the input.
+
+@item color_range color_primaries colorspace color_trc
+Set colour properties.  Defaults to using the properties from the input,
+if available.
+
+@end table
+
+The wrapper also has some specific options:
+
+@table @option
+
+@item cpu-used
+Set the quality/encoding speed tradeoff.  Valid range is from 0 to 8,
+higher numbers indicating greater speed and lower quality.  The default
+value is 1, which will be slow and high quality.
+
+@item auto-alt-ref
+Enable use of alternate reference frames.  Defaults to the internal
+default of the library.
+
+@item lag-in-frames
+Set the maximum number of frames which the encoder may keep in flight
+at any one time for lookahead purposes.  Defaults to the internal
+default of the library.
+
+@item error-resilience
+Enable error resilience features:
+@table @option
+@item default
+Improve resilience against losses of whole frames.
+@end table
+Not enabled by default.
+
+@item crf
+Set the quality/size tradeoff for constant-quality (no bitrate target)
+and constrained-quality (with maximum bitrate target) modes. Valid
+range is 0 to 63, higher numbers indicating lower quality and smaller
+output size.  Only used if set; by default only the bitrate target is
+used.
+
+@item static-thresh
+Set a change threshold on blocks below which they will be skipped by
+the encoder.  Defined in arbitrary units as a nonnegative integer,
+defaulting to zero (no blocks are skipped).
+
+@item drop-threshold
+Set a threshold for dropping frames when close to rate control bounds.
+Defined as a percentage of the target buffer - when the rate control
+buffer falls below this percentage, frames will be dropped until it
+has refilled above the threshold.  Defaults to zero (no frames are
+dropped).
+
+@item tiles
+Set the number of tiles to encode the input video with, as colums x
+rows.  Larger numbers allow greater parallelism in both encoding and
+decoding, but may decrease coding efficiency.  Defaults to the minimum
+number of tiles required by the size of the input video (this is 1x1
+(that is, a single tile) for sizes up to and including 4K).
+
+@item tile-columns tile-rows
+Set the number of tiles as log2 of the number of tile rows and columns.
+Provided for compatibility with libvpx/VP9.
+
+@end table
+
 @section libkvazaar
 
 Kvazaar H.265/HEVC encoder.
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/3] doc/encoders: Move libxavs2 to correct place in alphabetical order

2018-11-05 Thread Mark Thompson
---
 doc/encoders.texi | 92 +++
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 899faac49b..1ca0ef1543 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2180,6 +2180,52 @@ ffmpeg -i input -c:v libx265 -x265-params 
crf=26:psy-rd=1 output.mp4
 @end example
 @end table
 
+@section libxavs2
+
+xavs2 AVS2-P2/IEEE1857.4 encoder wrapper.
+
+This encoder requires the presence of the libxavs2 headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxavs2}.
+
+@subsection Options
+
+@table @option
+@item lcu_row_threads
+Set the number of parallel threads for rows from 1 to 8 (default 5).
+
+@item initial_qp
+Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
+used to set the initial qp for the first frame.
+
+@item qp
+Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
+used to set the qp value under constant-QP mode.
+
+@item max_qp
+Set the max qp for rate control from 1 to 63 (default 55).
+
+@item min_qp
+Set the min qp for rate control from 1 to 63 (default 20).
+
+@item speed_level
+Set the Speed level from 0 to 9 (default 0). Higher is better but slower.
+
+@item log_level
+Set the log level from -1 to 3 (default 0). -1: none, 0: error,
+1: warning, 2: info, 3: debug.
+
+@item xavs2-params
+Set xavs2 options using a list of @var{key}=@var{value} couples separated
+by ":".
+
+For example to specify libxavs2 encoding options with @option{-xavs2-params}:
+
+@example
+ffmpeg -i input -c:v libxavs2 -xavs2-params preset_level=5 output.avs2
+@end example
+@end table
+
 @section libxvid
 
 Xvid MPEG-4 Part 2 encoder wrapper.
@@ -2791,52 +2837,6 @@ Reduces detail but attempts to preserve color at 
extremely low bitrates.
 
 @end table
 
-@section libxavs2
-
-xavs2 AVS2-P2/IEEE1857.4 encoder wrapper.
-
-This encoder requires the presence of the libxavs2 headers and library
-during configuration. You need to explicitly configure the build with
-@option{--enable-libxavs2}.
-
-@subsection Options
-
-@table @option
-@item lcu_row_threads
-Set the number of parallel threads for rows from 1 to 8 (default 5).
-
-@item initial_qp
-Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
-used to set the initial qp for the first frame.
-
-@item qp
-Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
-used to set the qp value under constant-QP mode.
-
-@item max_qp
-Set the max qp for rate control from 1 to 63 (default 55).
-
-@item min_qp
-Set the min qp for rate control from 1 to 63 (default 20).
-
-@item speed_level
-Set the Speed level from 0 to 9 (default 0). Higher is better but slower.
-
-@item log_level
-Set the log level from -1 to 3 (default 0). -1: none, 0: error,
-1: warning, 2: info, 3: debug.
-
-@item xavs2-params
-Set xavs2 options using a list of @var{key}=@var{value} couples separated
-by ":".
-
-For example to specify libxavs2 encoding options with @option{-xavs2-params}:
-
-@example
-ffmpeg -i input -c:v libxavs2 -xavs2-params preset_level=5 output.avs2
-@end example
-@end table
-
 @c man end VIDEO ENCODERS
 
 @chapter Subtitles Encoders
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 3/3] libaomenc: Drop unused noise-sensitivity option

2018-11-05 Thread Mark Thompson
---
On 28/10/18 21:02, Carl Eugen Hoyos wrote:
> 2018-10-28 21:08 GMT+01:00, Mark Thompson :
>> ---
>> This was in the 4.0 release, unfortunately (and did nothing there as well).
> 
> If it has never worked, it can be removed imo.

Sure, here is a new version.

Thanks,

- Mark


 libavcodec/libaomenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index c5458766cb..4cad053a48 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -71,7 +71,6 @@ typedef struct AOMEncoderContext {
 int crf;
 int static_thresh;
 int drop_threshold;
-int noise_sensitivity;
 uint64_t sse[4];
 int have_sse; /**< true if we have pending sse[] */
 uint64_t frame_number;
@@ -980,7 +979,6 @@ static const AVOption options[] = {
 { "crf",  "Select the quality for constant quality mode", 
offsetof(AOMContext, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE },
 { "static-thresh","A change threshold on blocks below which they will 
be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, INT_MAX, VE },
 { "drop-threshold",   "Frame drop threshold", offsetof(AOMContext, 
drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
-{ "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 4, VE},
 { "tiles","Tile columns x rows", OFFSET(tile_cols), 
AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE },
 { "tile-columns", "Log2 of number of tile columns to use", 
OFFSET(tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { "tile-rows","Log2 of number of tile rows to use",
OFFSET(tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_qsv: initialize default pix_fmt

2018-11-05 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, November 5, 2018 5:37 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_qsv: initialize default
> pix_fmt
> 
> add default initiaization for pix_fmt in function have_alpha_panar to avoid
> using uninitialized value.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/vf_overlay_qsv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c index
> 20871786ee..79d6a58ec3 100644
> --- a/libavfilter/vf_overlay_qsv.c
> +++ b/libavfilter/vf_overlay_qsv.c
> @@ -167,7 +167,8 @@ static int have_alpha_planar(AVFilterLink *link)
>  if (link->format == AV_PIX_FMT_QSV) {
>  fctx= (AVHWFramesContext *)link->hw_frames_ctx->data;
>  pix_fmt = fctx->sw_format;
> -}
> +} else
> +pix_fmt = AV_PIX_FMT_NONE;
> 
>  desc = av_pix_fmt_desc_get(pix_fmt);
>  if (!desc)
> --
> 2.17.1

I believe https://patchwork.ffmpeg.org/patch/9069/ should be better (If nobody 
against, I prefer to merge it). 

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


Re: [FFmpeg-devel] [PATCH] avcodec/qsvenc: add default initiaize for pict_type

2018-11-05 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, November 5, 2018 5:41 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] avcodec/qsvenc: add default initiaize for
> pict_type
> 
> add default initiaize for pict_type in function ff_qsv_encode to avoid using
> uninitialized value:
> 
> FF_DISABLE_DEPRECATION_WARNINGS
> avctx->coded_frame->pict_type = pict_type;
> FF_ENABLE_DEPRECATION_WARNINGS
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/qsvenc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> 7a031297fe..564222ca10 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1333,6 +1333,8 @@ int ff_qsv_encode(AVCodecContext *avctx,
> QSVEncContext *q,
>  pict_type = AV_PICTURE_TYPE_P;
>  else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType
> & MFX_FRAMETYPE_xB)
>  pict_type = AV_PICTURE_TYPE_B;
> +else
> +pict_type = AV_PICTURE_TYPE_NONE;

Should be better to give an assert? 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] libx264: Pass the reordered_opaque field through the encoder

2018-11-05 Thread Martin Storsjö

On Thu, 1 Nov 2018, Martin Storsjö wrote:


On Thu, 1 Nov 2018, Derek Buitenhuis wrote:


On 31/10/2018 21:41, Martin Storsjö wrote:

Even though we do allow reconfiguration, it doesn't look like we support
changing any parameters which would actually affect the delay, only RC
method and targets (CRF, bitrate, etc). So given that, the current patch
probably should be safe - what do you think? Or the current patch, with an
added margin of 16 on top just in case?


We allow reconfiguring to/from interlaced. I'm not sure if this can modify 

delay?

Not really sure either... So perhaps it'd be safest with some bit of extra 
margin/overestimate of the delay here? It just costs a couple bytes in the 
mapping array anyway.


Pushed, with a bit over overestimation of the buffer size, just in case.

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


Re: [FFmpeg-devel] [PATCH 1/3] cbs_av1: Fix header writing when already aligned

2018-11-05 Thread James Almer
On 11/4/2018 9:10 PM, Mark Thompson wrote:
> ---
> Previously it lost the trailing bits byte but did include it in the OBU size, 
> completely breaking the stream.
> 
> 
>  libavcodec/cbs_av1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index 9bac9dde09..1c49d90f51 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>  if (err < 0)
>  return err;
>  end_pos = put_bits_count(pbc);
> -obu->obu_size = (end_pos - start_pos + 7) / 8;
> +obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>  } else {
>  // Empty OBU.
>  obu->obu_size = 0;
> 

What samples was this breaking? The few i tried have matching checksum
after an av1_metadata passthrough.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] cbs_av1: Fix header writing when already aligned

2018-11-05 Thread Mark Thompson
On 05/11/18 13:14, James Almer wrote:
> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>> ---
>> Previously it lost the trailing bits byte but did include it in the OBU 
>> size, completely breaking the stream.
>>
>>
>>  libavcodec/cbs_av1.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
>> index 9bac9dde09..1c49d90f51 100644
>> --- a/libavcodec/cbs_av1.c
>> +++ b/libavcodec/cbs_av1.c
>> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext 
>> *ctx,
>>  if (err < 0)
>>  return err;
>>  end_pos = put_bits_count(pbc);
>> -obu->obu_size = (end_pos - start_pos + 7) / 8;
>> +obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>>  } else {
>>  // Empty OBU.
>>  obu->obu_size = 0;
>>
> 
> What samples was this breaking? The few i tried have matching checksum
> after an av1_metadata passthrough.

Your s6Nh.ivf file with redundant headers requires it.  (I spent quite a while 
banging my head against that one, because the write trace showed exactly the 
right thing but then reading it back was messed up.)

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


[FFmpeg-devel] Reimbursement request

2018-11-05 Thread Pedro Arthur
Hi,
I'm requesting the reimbursement of travel expenses for the Google
Mentor Summit.
I mentored the Super Resolution project, more details can be found in [1].


Flight   (BRL) R$ 3271.03
One night Airbnb (BRL) R$   235.70
Trasnportation (USD)  $  23.00

Total(USD)  $  971.46

BRL to USD conversion done according to the brazilian central bank [2]
on 1st November (1 USD = 3.6973 BRL).

[1] - https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2018/Results
[2] - https://www4.bcb.gov.br/pec/taxas/port/ptaxnpesq.asp?id=txcotacao


Thanks,
Pedro.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Reimbursement request

2018-11-05 Thread Michael Niedermayer
On Mon, Nov 05, 2018 at 12:06:46PM -0200, Pedro Arthur wrote:
> Hi,
> I'm requesting the reimbursement of travel expenses for the Google
> Mentor Summit.
> I mentored the Super Resolution project, more details can be found in [1].
> 
> 
> Flight   (BRL) R$ 3271.03
> One night Airbnb (BRL) R$   235.70
> Trasnportation (USD)  $  23.00
> 
> Total(USD)  $  971.46

LGTM

thanks

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

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


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] doc/encoders: Move libxavs2 to correct place in alphabetical order

2018-11-05 Thread Gyan
On Mon, Nov 5, 2018 at 8:23 PM Mark Thompson  wrote:

> ---
>  doc/encoders.texi | 92 +++
>  1 file changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 899faac49b..1ca0ef1543 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -2180,6 +2180,52 @@ ffmpeg -i input -c:v libx265 -x265-params
> crf=26:psy-rd=1 output.mp4
>  @end example
>  @end table
>
> +@section libxavs2
> +
> +xavs2 AVS2-P2/IEEE1857.4 encoder wrapper.
> +
> +This encoder requires the presence of the libxavs2 headers and library
> +during configuration. You need to explicitly configure the build with
> +@option{--enable-libxavs2}.
> +
> +@subsection Options
> +
> +@table @option
> +@item lcu_row_threads
> +Set the number of parallel threads for rows from 1 to 8 (default 5).
> +
> +@item initial_qp
> +Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
> +used to set the initial qp for the first frame.
> +
> +@item qp
> +Set the xavs2 quantization parameter from 1 to 63 (default 34). This is
> +used to set the qp value under constant-QP mode.
> +
> +@item max_qp
> +Set the max qp for rate control from 1 to 63 (default 55).
> +
> +@item min_qp
> +Set the min qp for rate control from 1 to 63 (default 20).
> +
> +@item speed_level
> +Set the Speed level from 0 to 9 (default 0). Higher is better but slower.
> +
> +@item log_level
> +Set the log level from -1 to 3 (default 0). -1: none, 0: error,
> +1: warning, 2: info, 3: debug.
> +
> +@item xavs2-params
> +Set xavs2 options using a list of @var{key}=@var{value} couples separated
> +by ":".
> +
> +For example to specify libxavs2 encoding options with
> @option{-xavs2-params}:
> +
> +@example
> +ffmpeg -i input -c:v libxavs2 -xavs2-params preset_level=5 output.avs2
> +@end example
> +@end table
> +
>  @section libxvid
>

LGTM.

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


[FFmpeg-devel] [PATCH v2 1/2] cbs_av1: Fix header writing when already aligned

2018-11-05 Thread Mark Thompson
---
 libavcodec/cbs_av1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 9bac9dde09..1c49d90f51 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 if (err < 0)
 return err;
 end_pos = put_bits_count(pbc);
-obu->obu_size = (end_pos - start_pos + 7) / 8;
+obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
 } else {
 // Empty OBU.
 obu->obu_size = 0;
-- 
2.19.1

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


[FFmpeg-devel] [PATCH v2 2/2] cbs_av1: Support redundant frame headers

2018-11-05 Thread Mark Thompson
---
On 05/11/18 00:55, James Almer wrote:
> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>> ...
>> +xf(1, frame_header_copy[k], b, b, b, 1, k);
> 
> This is making a lot of noise in the trace output for no real gain,
> since it prints every single bit as its own line. Can you silence it?

I think it's sensible to keep some trace output here to reflect what's actually 
happening, so I've made it go by bytes rather than bits to be less spammy.

>> +priv->frame_header_size = fh_bits;
>> +priv->frame_header =
>> +av_mallocz(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
>> +if (!priv->frame_header)
>> +return AVERROR(ENOMEM);
>> +memcpy(priv->frame_header, fh_start, fh_bytes);
> 
> No way to use AVBufferRef for this?

Refcounting added only for reading.  It's a bit nasty because it passes the 
bufferref down into the template code which shouldn't really have it, but I 
don't see any better way to make that work.

>> ...

Also fixed the memory leak.

Thanks,

- Mark


 libavcodec/cbs_av1.c | 16 --
 libavcodec/cbs_av1.h |  5 +-
 libavcodec/cbs_av1_syntax_template.c | 82 +---
 3 files changed, 91 insertions(+), 12 deletions(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 1c49d90f51..ff32a6fca5 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -996,7 +996,10 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 case AV1_OBU_REDUNDANT_FRAME_HEADER:
 {
 err = cbs_av1_read_frame_header_obu(ctx, ,
->obu.frame_header);
+>obu.frame_header,
+obu->header.obu_type ==
+AV1_OBU_REDUNDANT_FRAME_HEADER,
+unit->data_ref);
 if (err < 0)
 return err;
 }
@@ -1016,7 +1019,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
 break;
 case AV1_OBU_FRAME:
 {
-err = cbs_av1_read_frame_obu(ctx, , >obu.frame);
+err = cbs_av1_read_frame_obu(ctx, , >obu.frame,
+ unit->data_ref);
 if (err < 0)
 return err;
 
@@ -1124,7 +1128,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 case AV1_OBU_REDUNDANT_FRAME_HEADER:
 {
 err = cbs_av1_write_frame_header_obu(ctx, pbc,
- >obu.frame_header);
+ >obu.frame_header,
+ obu->header.obu_type ==
+ 
AV1_OBU_REDUNDANT_FRAME_HEADER,
+ NULL);
 if (err < 0)
 return err;
 }
@@ -1141,7 +1148,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 break;
 case AV1_OBU_FRAME:
 {
-err = cbs_av1_write_frame_obu(ctx, pbc, >obu.frame);
+err = cbs_av1_write_frame_obu(ctx, pbc, >obu.frame, NULL);
 if (err < 0)
 return err;
 
@@ -1302,6 +1309,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
 CodedBitstreamAV1Context *priv = ctx->priv_data;
 
 av_buffer_unref(>sequence_header_ref);
+av_buffer_unref(>frame_header_ref);
 
 av_freep(>write_buffer);
 }
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 614a0bf108..f662265f75 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -399,7 +399,10 @@ typedef struct CodedBitstreamAV1Context {
 AV1RawSequenceHeader *sequence_header;
 AVBufferRef  *sequence_header_ref;
 
-int seen_frame_header;
+int seen_frame_header;
+AVBufferRef *frame_header_ref;
+uint8_t *frame_header;
+size_t   frame_header_size;
 
 int temporal_id;
 int spatial_id;
diff --git a/libavcodec/cbs_av1_syntax_template.c 
b/libavcodec/cbs_av1_syntax_template.c
index e146bbf8bb..0da79b615d 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1463,24 +1463,90 @@ static int 
FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
 }
 
 static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
-  AV1RawFrameHeader *current)
+  AV1RawFrameHeader *current, int redundant,
+  AVBufferRef *rw_buffer_ref)
 {
 CodedBitstreamAV1Context *priv = ctx->priv_data;
-int err;
-
-HEADER("Frame Header");
+int start_pos, fh_bits, fh_bytes, err;
+uint8_t *fh_start;
 
 if (priv->seen_frame_header) {
-// Nothing to do.
+if (!redundant) {
+

Re: [FFmpeg-devel] [PATCH 2/3] doc/encoders: Add libaom-av1

2018-11-05 Thread Gyan
On Mon, Nov 5, 2018 at 8:23 PM Mark Thompson  wrote:

> ---
> Updated to add some more explanation of the rate control mode selection.
>
>
>  doc/encoders.texi | 108 ++
>  1 file changed, 108 insertions(+)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 1ca0ef1543..f2e4199017 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1370,6 +1370,114 @@ makes it possible to store non-rgb pix_fmts.
>
>  @end table
>
> +@section libaom-av1
> +
> +libaom AV1 encoder wrapper.
> +
> +Requires the presence of the libaom headers and library during
> +configuration.  You need to explicitly configure the build with
> +@code{--enable-libaom}.
> +
> +@subsection Options
> +
> +The wrapper supports the following standard libavcodec options:
>

Do we really need to duplicate the text for the generic options? That will
lead to bloat if widely adopted.


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


Re: [FFmpeg-devel] [PATCH 2/3] doc/encoders: Add libaom-av1

2018-11-05 Thread Mark Thompson
On 05/11/18 15:20, Gyan wrote:
> On Mon, Nov 5, 2018 at 8:23 PM Mark Thompson  wrote:
> 
>> ---
>> Updated to add some more explanation of the rate control mode selection.
>>
>>
>>  doc/encoders.texi | 108 ++
>>  1 file changed, 108 insertions(+)
>>
>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>> index 1ca0ef1543..f2e4199017 100644
>> --- a/doc/encoders.texi
>> +++ b/doc/encoders.texi
>> @@ -1370,6 +1370,114 @@ makes it possible to store non-rgb pix_fmts.
>>
>>  @end table
>>
>> +@section libaom-av1
>> +
>> +libaom AV1 encoder wrapper.
>> +
>> +Requires the presence of the libaom headers and library during
>> +configuration.  You need to explicitly configure the build with
>> +@code{--enable-libaom}.
>> +
>> +@subsection Options
>> +
>> +The wrapper supports the following standard libavcodec options:
>>
> 
> Do we really need to duplicate the text for the generic options? That will
> lead to bloat if widely adopted.

Which parts do you object to?  This text is trying to explain how the standard 
options apply to libaom and what their defaults are.

Thanks,

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


Re: [FFmpeg-devel] [PATCH v2 2/7] lavc/qsvenc: add forced_idr opiton

2018-11-05 Thread Mark Thompson
On 05/11/18 12:15, Zhong Li wrote:
> This option can be used to repect original input I/IDR frame type.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvenc.c | 7 +++
>  libavcodec/qsvenc.h | 2 ++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 948751d..7098ec7 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 (q->forced_idr && frame->pict_type == AV_PICTURE_TYPE_I) {
> +enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
> +if (q->forced_idr || frame->key_frame)
> +enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR;
> +}

This still seems confused.  I think you don't want the q->forced_idr in the 
first condition?

I wouldn't include the check against frame->key_frame either, since no other 
encoder uses that.

>  }
>  
>  ret = av_new_packet(_pkt, q->packet_size);
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 055b4a6..fbdc199 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);
> 

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


[FFmpeg-devel] [PATCH] lavf/isom: add "dvhe" fourCC for HEVC

2018-11-05 Thread Rodger Combs
This refers to "Dolby Vision", which can have some additional extensions,
but (usually?) is also valid HEVC.
---
 libavformat/isom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index ca9d22e4f7..fbfa0dc057 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -163,6 +163,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which 
indicates parameter sets may be in ES */
 { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which 
indicates parameter sets shall not be in ES */
+{ AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC/H.265 with Dolby 
Vision extensions */
 
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 4/4] mjpeg: Use profile names in the encoder and decoder

2018-11-05 Thread Vittorio Giovara
On Fri, Nov 2, 2018 at 5:29 PM Carl Eugen Hoyos  wrote:

> 2018-11-02 20:35 GMT+01:00, Vittorio Giovara :
> > ---
> >  libavcodec/codec_desc.c | 1 +
> >  libavcodec/mjpegdec.c   | 2 ++
> >  libavcodec/profiles.c   | 9 +
> >  libavcodec/profiles.h   | 1 +
> >  libavcodec/version.h| 2 +-
> >  5 files changed, 14 insertions(+), 1 deletion(-)
>
> How does this patch affect the encoder?
>

sorry forgot to fold in these changes

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index d2fcb8e191..0ea7bd3d10 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -38,6 +38,7 @@
 #include "mpegvideo.h"
 #include "mjpeg.h"
 #include "mjpegenc.h"
+#include "profiles.h"

 static int alloc_huffman(MpegEncContext *s)
 {
@@ -418,6 +419,7 @@ AVCodec ff_mjpeg_encoder = {
 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
AV_PIX_FMT_NONE
 },
 .priv_class = _class,
+.profiles   = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles),
 };
 #endif

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


Re: [FFmpeg-devel] [PATCH] lavf/isom: add "dvhe" fourCC for HEVC

2018-11-05 Thread Jan Ekström
On Mon, Nov 5, 2018 at 6:34 PM Rodger Combs  wrote:
>
> This refers to "Dolby Vision", which can have some additional extensions,
> but (usually?) is also valid HEVC.

This probably will have to be referenced against
https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.0.pdf
.

It seems to define additional boxes which most likely contain the
information regarding if the Base Layer (BL) is compatible with
standard SDR or HDR AVC/HEVC.

The referenced Dolby Vision profile defitions seem to be defined in
https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-profiles-levels.pdf
.

Best regards,
Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 7/7] lavc/qsvenc: add an option to set MB numbers of each slice

2018-11-05 Thread Mark Thompson
On 05/11/18 12:15, Zhong Li wrote:
> This option specifies suggested macroblocks numbers in each slice.
> MSDK may adjust it based on platform capability.
> And slice_number will be ignored if this option set to a non-zero
> value.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvenc.c  | 1 +
>  libavcodec/qsvenc.h  | 1 +
>  libavcodec/qsvenc_h264.c | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 7d74068..1797279 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -655,6 +655,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;
> +q->extco2.NumMbPerSlice = q->num_mb_per_slice;
>  
>  #if FF_API_PRIVATE_OPT
>  FF_DISABLE_DEPRECATION_WARNINGS
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 4316a10..c2aa88e 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -163,6 +163,7 @@ typedef struct QSVEncContext {
>  int recovery_point_sei;
>  
>  int repeat_pps;
> +int num_mb_per_slice;
>  
>  int a53_cc;
>  
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> index 13217b4..693a9e3 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -156,6 +156,7 @@ static const AVOption options[] = {
>  #endif
>  
>  { "repeat_pps", "repeat pps for every frame", OFFSET(qsv.repeat_pps), 
> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
> +{ "num_mb_per_slice","Suggested macroblocks numbers of each slice", 
> OFFSET(qsv.num_mb_per_slice), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
>  
>  { NULL },
>  };
> 

From the point of view of just passing in opaque magic options, sure.

Still, I feel like this option wants a bit more explanation somewhere.  How 
does it interact with the normal -slices option?  If it's just a suggestion, 
can the library ignore it?

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


[FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Aaron Boushley
When parsing a fragmented MP4 with the use_mfra_for option set so that
the mfra box is parsed we currently continue to parse all the top level
boxes in the mp4. We also avoid using the index in mov_seek_fragment
unless the fragment index is marked as complete, which the mfra parsing
code never does.

This updates the mfra parsing code to mark the fragment index as
complete, similar to the way the sidx parsing code does.

With this change in place mov_read_default stops parsing top level boxes
in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls
(assuming a use_mfra_for option is passed). When loading the file over a
network this results in significantly better performance since
avformat_open_input doesn't require a scan of the entire file.

Signed-off-by: Aaron Boushley 
---
 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ec57a05803..1def594626 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c, AVIOContext
*f)
 if (ret < 0)
 goto fail;
 } while (!ret);
+
+c->frag_index.complete = 1;
 ret = 0;
 fail:
 seek_ret = avio_seek(f, original_pos, SEEK_SET);
-- 
2.18.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] proresenc_nanatoliy: Rename a profile name with the correct one

2018-11-05 Thread Vittorio Giovara
On Sat, Nov 3, 2018 at 10:23 AM Paul B Mahol  wrote:

> On 11/2/18, Vittorio Giovara  wrote:
> > In all Apple documentation, this profile is called Prores .
> > ---
> >  libavcodec/proresenc_anatoliy.c | 16 
> >  1 file changed, 8 insertions(+), 8 deletions(-)
>
>
> There is typo in log message, with that fixed patchset lgtm.
>

thanks, fixed and pushed
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] vaapi_encode: Improve log message for unsupported profiles

2018-11-05 Thread Mark Thompson
---
For example:

[h264_vaapi @ 0x563e95f73d00] Compatible profile VAProfileH264High (7) is not 
supported by driver.
[h264_vaapi @ 0x563e95f73d00] Compatible profile VAProfileH264Main (6) is not 
supported by driver.
[h264_vaapi @ 0x563e95f73d00] Using VAAPI profile 
VAProfileH264ConstrainedBaseline (13).
[h264_vaapi @ 0x563e95f73d00] Using VAAPI entrypoint VAEntrypointEncSlice (6).


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

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 2fe8501287..eda8a36299 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1135,8 +1135,9 @@ static av_cold int 
vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
 break;
 }
 if (j >= n) {
-av_log(avctx, AV_LOG_VERBOSE, "Matching profile %d is "
-   "not supported by driver.\n", profile->va_profile);
+av_log(avctx, AV_LOG_VERBOSE, "Compatible profile %s (%d) "
+   "is not supported by driver.\n", profile_string,
+   profile->va_profile);
 continue;
 }
 
-- 
2.19.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the initialization postion of profile_string

2018-11-05 Thread Mark Thompson
On 05/11/18 09:39, Linjie Fu wrote:
> Currently, profile_string was initialized in the "for" loop. If
> it didn't enter this loop or accidently break, profile_string may be
> uninitialized.
> 
> Modify to initialize the profile_string after the loop to avoid
> using the uninitialized value when calling av_log.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_encode.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 2c34cdce2c..b43b52f0e5 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1066,6 +1066,7 @@ static av_cold int 
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>  }
>  
>  av_assert0(ctx->codec->profiles);
> +
>  for (i = 0; (ctx->codec->profiles[i].av_profile !=
>   FF_PROFILE_UNKNOWN); i++) {
>  profile = >codec->profiles[i];
> @@ -1080,12 +1081,6 @@ static av_cold int 
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>  avctx->profile != FF_PROFILE_UNKNOWN)
>  continue;
>  
> -#if VA_CHECK_VERSION(1, 0, 0)
> -profile_string = vaProfileStr(profile->va_profile);
> -#else
> -profile_string = "(no profile names)";
> -#endif
> -
>  for (j = 0; j < n; j++) {
>  if (va_profiles[j] == profile->va_profile)
>  break;
> @@ -1107,6 +1102,11 @@ static av_cold int 
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>  
>  avctx->profile  = profile->av_profile;
>  ctx->va_profile = profile->va_profile;
> +#if VA_CHECK_VERSION(1, 0, 0)
> +profile_string = vaProfileStr(profile->va_profile);
> +#else
> +profile_string = "(no profile names)";
> +#endif
>  av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
> profile_string, ctx->va_profile);
>  
> 

I'm not seeing where this goes wrong?  ctx->profile isn't set if you exit the 
loop early.

The profile string name should be in the message about unsupported profiles, 
though.  I'll send a patch for that.

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


Re: [FFmpeg-devel] [PATCH 0/7] Enhancement VA-API encoder bitrate control

2018-11-05 Thread Mark Thompson
On 03/11/18 02:52, Jun Zhao wrote:
> V1:
> - add codec-specific bit rate control callback.

I don't understand why you want this to be codec-specific at all?  No option is 
always supported in any particular case, and both of these options are at least 
queryable.

> - enable macro block level bit rate control in h264_vaapi encoder and update 
> the docs.
> - enable sliding windows in [h264|hevc]_vaapi encoder and update the docs.
> 
> Jun Zhao (7):
>   lavc/vaapi_encode: Add codec-specific bit rate control callback.
>   lavc/vaapi_encode_h264: Enable macro block level bit rate control.
>   doc/encoders: Add docs for mb_rate_control option
>   lavc/vaapi_encode_h264: Enable sliding window control.
>   doc/encoders: Add sliding_window docs for h264_vaapi.
>   lavc/vaapi_encode_h265: Enable sliding window control.
>   doc/encoders: Add sliding_window docs for hevc_vaapi.
> 
>  doc/encoders.texi  |   12 
>  libavcodec/vaapi_encode.c  |9 +
>  libavcodec/vaapi_encode.h  |3 +++
>  libavcodec/vaapi_encode_h264.c |   34 ++
>  libavcodec/vaapi_encode_h265.c |   24 
>  5 files changed, 82 insertions(+), 0 deletions(-)

More generally, all of the "lets just throw random shit in here" RC options 
(that is: basic_unit_size, disable_frame_skip, disable_bit_stuffing, 
mb_rate_control, cfs_I_frames, enable_parallel_brc, enable_dynamic_scaling, 
frame_tolerance_mode, quality_factor) need some more thought on how to expose 
them sensibly.  I have some outstanding patches around RC (in particular, 
supporting more cases and making the RC mode explicit with a common -rc_mode 
option), I'll see if I can work something in with that.

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


Re: [FFmpeg-devel] [PATCH v2 6/7] lavc/qsvenc: add an option to set h264 pps for every frame

2018-11-05 Thread Mark Thompson
On 05/11/18 12:15, Zhong Li wrote:
> 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.
> 
> Signed-off-by: Zhong Li 
> ---
>  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 7745086..7d74068 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 fbdc199..4316a10 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 ac7023e..13217b4 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -155,6 +155,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 },
>  };

LGTM now.

Thanks,

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


Re: [FFmpeg-devel] [PATCH v2 2/2] cbs_av1: Support redundant frame headers

2018-11-05 Thread Mark Thompson
On 05/11/18 18:16, James Almer wrote:
> On 11/5/2018 12:25 PM, Mark Thompson wrote:
>> ---
>> On 05/11/18 00:55, James Almer wrote:
>>> On 11/4/2018 9:10 PM, Mark Thompson wrote:
 ...
 +xf(1, frame_header_copy[k], b, b, b, 1, k);
>>> This is making a lot of noise in the trace output for no real gain,
>>> since it prints every single bit as its own line. Can you silence it?
>> I think it's sensible to keep some trace output here to reflect what's 
>> actually happening, so I've made it go by bytes rather than bits to be less 
>> spammy.
>>
 +priv->frame_header_size = fh_bits;
 +priv->frame_header =
 +av_mallocz(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
 +if (!priv->frame_header)
 +return AVERROR(ENOMEM);
 +memcpy(priv->frame_header, fh_start, fh_bytes);
>>> No way to use AVBufferRef for this?
>> Refcounting added only for reading.  It's a bit nasty because it passes the 
>> bufferref down into the template code which shouldn't really have it, but I 
>> don't see any better way to make that work.
>>
 ...
>> Also fixed the memory leak.
>>
>> Thanks,
>>
>> - Mark
>>
>>
>>  libavcodec/cbs_av1.c | 16 --
>>  libavcodec/cbs_av1.h |  5 +-
>>  libavcodec/cbs_av1_syntax_template.c | 82 +---
>>  3 files changed, 91 insertions(+), 12 deletions(-)
>>
>> ...
>> diff --git a/libavcodec/cbs_av1_syntax_template.c 
>> b/libavcodec/cbs_av1_syntax_template.c
>> index e146bbf8bb..0da79b615d 100644
>> --- a/libavcodec/cbs_av1_syntax_template.c
>> +++ b/libavcodec/cbs_av1_syntax_template.c
>> @@ -1463,24 +1463,90 @@ static int 
>> FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
>>  }
>>  
>>  static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
>> -  AV1RawFrameHeader *current)
>> +  AV1RawFrameHeader *current, int redundant,
>> +  AVBufferRef *rw_buffer_ref)
>>  {
>>  CodedBitstreamAV1Context *priv = ctx->priv_data;
>> -int err;
>> -
>> -HEADER("Frame Header");
>> +int start_pos, fh_bits, fh_bytes, err;
>> +uint8_t *fh_start;
>>  
>>  if (priv->seen_frame_header) {
>> -// Nothing to do.
>> +if (!redundant) {
>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated "
>> +   "frame header OBU.\n");
>> +return AVERROR_INVALIDDATA;
>> +} else {
>> +GetBitContext fh;
>> +size_t i, b;
>> +uint32_t val;
>> +
>> +HEADER("Redundant Frame Header");
>> +
>> +av_assert0(priv->frame_header_ref && priv->frame_header);
>> +
>> +init_get_bits(, priv->frame_header,
>> +  priv->frame_header_size);
>> +for (i = 0; i < priv->frame_header_size; i += 8) {
>> +b = FFMIN(priv->frame_header_size - i, 8);
>> +val = get_bits(, b);
>> +xf(b, frame_header_copy[i],
>> +   val, val, val, 1, i / 8);
>> +}
>> +}
>>  } else {
>> +if (redundant)
>> +HEADER("Redundant Frame Header (used as Frame Header)");
>> +else
>> +HEADER("Frame Header");
>> +
>>  priv->seen_frame_header = 1;
>>  
>> +#ifdef READ
>> +start_pos = get_bits_count(rw);
>> +#else
>> +start_pos = put_bits_count(rw);
>> +#endif
>> +
>>  CHECK(FUNC(uncompressed_header)(ctx, rw, current));
>>  
>>  if (current->show_existing_frame) {
>>  priv->seen_frame_header = 0;
>>  } else {
>>  priv->seen_frame_header = 1;
>> +
>> +av_buffer_unref(>frame_header_ref);
>> +
>> +#ifdef READ
>> +fh_bits  = get_bits_count(rw) - start_pos;
>> +fh_start = (uint8_t*)rw->buffer + start_pos / 8;
>> +#else
>> +// Need to flush the bitwriter so that we can copy its output,
>> +// but use a copy so we don't affect the caller's structure.
>> +{
>> +PutBitContext tmp = *rw;
>> +flush_put_bits();
>> +}
>> +
>> +fh_bits  = put_bits_count(rw) - start_pos;
>> +fh_start = rw->buf + start_pos / 8;
>> +#endif
>> +fh_bytes = (fh_bits + 7) / 8;
>> +
>> +priv->frame_header_size = fh_bits;
>> +
>> +if (rw_buffer_ref) {
>> +priv->frame_header_ref = av_buffer_ref(rw_buffer_ref);
>> +if (!priv->frame_header_ref)
>> +return AVERROR(ENOMEM);
>> +priv->frame_header = fh_start;
> 
> Is this the reason you can't create the ref outside the template code?
> If it's only to skip the OBU header bits, can't that be done right after
> the call to cbs_av1_read_frame_header_obu()?

... which is also 

Re: [FFmpeg-devel] [PATCH 2/3] doc/encoders: Add libaom-av1

2018-11-05 Thread Gyan
On Mon, Nov 5, 2018 at 9:04 PM Mark Thompson  wrote:

> On 05/11/18 15:20, Gyan wrote:
> > On Mon, Nov 5, 2018 at 8:23 PM Mark Thompson  wrote:
> >
> >> ---
> >> Updated to add some more explanation of the rate control mode selection.
> >>
> >>
> >>  doc/encoders.texi | 108 ++
> >>  1 file changed, 108 insertions(+)
> >>
> >> diff --git a/doc/encoders.texi b/doc/encoders.texi
> >> index 1ca0ef1543..f2e4199017 100644
> >> --- a/doc/encoders.texi
> >> +++ b/doc/encoders.texi
> >> @@ -1370,6 +1370,114 @@ makes it possible to store non-rgb pix_fmts.
> >>
> >>  @end table
> >>
> >> +@section libaom-av1
> >> +
> >> +libaom AV1 encoder wrapper.
> >> +
> >> +Requires the presence of the libaom headers and library during
> >> +configuration.  You need to explicitly configure the build with
> >> +@code{--enable-libaom}.
> >> +
> >> +@subsection Options
> >> +
> >> +The wrapper supports the following standard libavcodec options:
> >>
> >
> > Do we really need to duplicate the text for the generic options? That
> will
> > lead to bloat if widely adopted.
>
> Which parts do you object to?  This text is trying to explain how the
> standard options apply to libaom and what their defaults are.
>

Makes sense. But items like g, the color props or profile are covered by
the generic text. Maybe for completeness' sake, we should keep them here.

LGTM

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/libopenh264enc.c: Handle sample_aspect_ratio in libopenh264 encoder

2018-11-05 Thread Mark Thompson
On 01/11/18 13:24, Valery Kot wrote:
> On Thu, Nov 1, 2018 at 1:55 PM Valery Kot  wrote:
>>
>>> I think this would look nicer (and generate less code) as a table + loop 
>>> rather than an if-ladder making each fraction structure inline?
>>>
>>> E.g. something like 
>>> .
>>
>> Thanks for the suggestion! Here is an updated patch.
> 
> Was too hurry to send a patch, sorry! Here is the correct one.
> 
> 
> From 638277354338bf42020854e5bebec5fe61677135 Mon Sep 17 00:00:00 2001
> From: vkot 

You might want to fix up this name - I corrected it manually.

> Date: Thu, 1 Nov 2018 14:15:11 +0100
> Subject: [PATCH] Handle sample_aspect_ratio in libopenh264-encoder
> 
> ---
>  libavcodec/libopenh264enc.c | 41 +
>  1 file changed, 41 insertions(+)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index 83c3f0ce20..b3ddb4609b 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -164,6 +164,47 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
>  param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
>  
> +#if OPENH264_VER_AT_LEAST(1, 7)
> +if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
> +// Table E-1.
> +static const AVRational sar_idc[] = {
> +{   0,  0 }, // Unspecified (never written here).
> +{   1,  1 }, {  12, 11 }, {  10, 11 }, {  16, 11 },
> +{  40, 33 }, {  24, 11 }, {  20, 11 }, {  32, 11 },
> +{  80, 33 }, {  18, 11 }, {  15, 11 }, {  64, 33 },
> +{ 160, 99 }, // Last 3 are unknown to openh264: {   4,  3 }, {   
> 3,  2 }, {   2,  1 },
> +};
> +static const ESampleAspectRatio asp_idc[] = {
> +ASP_UNSPECIFIED,
> +ASP_1x1,  ASP_12x11,   ASP_10x11,   ASP_16x11,
> +ASP_40x33,ASP_24x11,   ASP_20x11,   ASP_32x11,
> +ASP_80x33,ASP_18x11,   ASP_15x11,   ASP_64x33,
> +ASP_160x99,
> +};
> +int num, den, i;
> +
> +av_reduce(, , avctx->sample_aspect_ratio.num,
> +  avctx->sample_aspect_ratio.den, 65535);
> +
> +for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
> +if (num == sar_idc[i].num &&
> +den == sar_idc[i].den)
> +break;
> +}
> +if (i == FF_ARRAY_ELEMS(sar_idc)) {
> +param.sSpatialLayers[0].eAspectRatio = ASP_EXT_SAR;
> +param.sSpatialLayers[0].sAspectRatioExtWidth = num;
> +param.sSpatialLayers[0].sAspectRatioExtHeight = den;
> +} else {
> +param.sSpatialLayers[0].eAspectRatio = asp_idc[i];
> +}
> +param.sSpatialLayers[0].bAspectRatioPresent = true;
> +}
> +else {
> +param.sSpatialLayers[0].bAspectRatioPresent = false;
> +}
> +#endif
> +
>  if ((avctx->slices > 1) && (s->max_nal_size)) {
>  av_log(avctx, AV_LOG_ERROR,
> "Invalid combination -slices %d and -max_nal_size %d.\n",
> -- 
> 2.15.1.windows.2
> 

LGTM, tested and applied.

(Seems libopenh264 accepts any value in this field, so you can actually just 
use the later values they don't provide in the enum.  Not sure whether that's 
actually an API violation which they might reject in some cases, though...)

Thanks!

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


Re: [FFmpeg-devel] [PATCH v2 1/7] lavc/qsvenc: enable ICQ and ICQ_LA on Linux

2018-11-05 Thread Mark Thompson
On 05/11/18 12:15, Zhong Li wrote:
> ICQ/ICQ_LA are enabled with MSDK V1.28
> 
> One example of ICQ_LA:
> ffmpeg -hwaccel qsv -c:v h264_qsv -i in.mp4 -c:v h264_qsv -global_quality 25 
> -look_ahead 1 out.mp4
> 
> Signed-off-by: Zhong Li 
> ---
> ICQ mode will fail with some cases: 
> https://github.com/Intel-Media-SDK/MediaSDK/issues/863. Don't merge this 
> patch before it resolved.
> 
>  libavcodec/qsvenc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 50cc426..055b4a6 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)
> 

LGTM once the issues with the driver are resolved.

(I guess this is another case in favour of querying the actual capabilities at 
runtime, though.)

Thanks,

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


Re: [FFmpeg-devel] [PATCH v2 2/2] cbs_av1: Support redundant frame headers

2018-11-05 Thread James Almer
On 11/5/2018 12:25 PM, Mark Thompson wrote:
> ---
> On 05/11/18 00:55, James Almer wrote:
>> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>>> ...
>>> +xf(1, frame_header_copy[k], b, b, b, 1, k);
>> This is making a lot of noise in the trace output for no real gain,
>> since it prints every single bit as its own line. Can you silence it?
> I think it's sensible to keep some trace output here to reflect what's 
> actually happening, so I've made it go by bytes rather than bits to be less 
> spammy.
> 
>>> +priv->frame_header_size = fh_bits;
>>> +priv->frame_header =
>>> +av_mallocz(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
>>> +if (!priv->frame_header)
>>> +return AVERROR(ENOMEM);
>>> +memcpy(priv->frame_header, fh_start, fh_bytes);
>> No way to use AVBufferRef for this?
> Refcounting added only for reading.  It's a bit nasty because it passes the 
> bufferref down into the template code which shouldn't really have it, but I 
> don't see any better way to make that work.
> 
>>> ...
> Also fixed the memory leak.
> 
> Thanks,
> 
> - Mark
> 
> 
>  libavcodec/cbs_av1.c | 16 --
>  libavcodec/cbs_av1.h |  5 +-
>  libavcodec/cbs_av1_syntax_template.c | 82 +---
>  3 files changed, 91 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index 1c49d90f51..ff32a6fca5 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -996,7 +996,10 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
>  case AV1_OBU_REDUNDANT_FRAME_HEADER:
>  {
>  err = cbs_av1_read_frame_header_obu(ctx, ,
> ->obu.frame_header);
> +>obu.frame_header,
> +obu->header.obu_type ==
> +
> AV1_OBU_REDUNDANT_FRAME_HEADER,
> +unit->data_ref);
>  if (err < 0)
>  return err;
>  }
> @@ -1016,7 +1019,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
>  break;
>  case AV1_OBU_FRAME:
>  {
> -err = cbs_av1_read_frame_obu(ctx, , >obu.frame);
> +err = cbs_av1_read_frame_obu(ctx, , >obu.frame,
> + unit->data_ref);
>  if (err < 0)
>  return err;
>  
> @@ -1124,7 +1128,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext 
> *ctx,
>  case AV1_OBU_REDUNDANT_FRAME_HEADER:
>  {
>  err = cbs_av1_write_frame_header_obu(ctx, pbc,
> - >obu.frame_header);
> + >obu.frame_header,
> + obu->header.obu_type ==
> + 
> AV1_OBU_REDUNDANT_FRAME_HEADER,
> + NULL);
>  if (err < 0)
>  return err;
>  }
> @@ -1141,7 +1148,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>  break;
>  case AV1_OBU_FRAME:
>  {
> -err = cbs_av1_write_frame_obu(ctx, pbc, >obu.frame);
> +err = cbs_av1_write_frame_obu(ctx, pbc, >obu.frame, NULL);
>  if (err < 0)
>  return err;
>  
> @@ -1302,6 +1309,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
>  CodedBitstreamAV1Context *priv = ctx->priv_data;
>  
>  av_buffer_unref(>sequence_header_ref);
> +av_buffer_unref(>frame_header_ref);
>  
>  av_freep(>write_buffer);
>  }
> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index 614a0bf108..f662265f75 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -399,7 +399,10 @@ typedef struct CodedBitstreamAV1Context {
>  AV1RawSequenceHeader *sequence_header;
>  AVBufferRef  *sequence_header_ref;
>  
> -int seen_frame_header;
> +int seen_frame_header;
> +AVBufferRef *frame_header_ref;
> +uint8_t *frame_header;
> +size_t   frame_header_size;
>  
>  int temporal_id;
>  int spatial_id;
> diff --git a/libavcodec/cbs_av1_syntax_template.c 
> b/libavcodec/cbs_av1_syntax_template.c
> index e146bbf8bb..0da79b615d 100644
> --- a/libavcodec/cbs_av1_syntax_template.c
> +++ b/libavcodec/cbs_av1_syntax_template.c
> @@ -1463,24 +1463,90 @@ static int 
> FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
>  }
>  
>  static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
> -  AV1RawFrameHeader *current)
> +  AV1RawFrameHeader *current, int redundant,
> +  AVBufferRef *rw_buffer_ref)
>  {
> 

Re: [FFmpeg-devel] [PATCH v2 2/2] cbs_av1: Support redundant frame headers

2018-11-05 Thread James Almer
On 11/5/2018 3:33 PM, Mark Thompson wrote:
> On 05/11/18 18:16, James Almer wrote:
>> On 11/5/2018 12:25 PM, Mark Thompson wrote:
>>> ---
>>> On 05/11/18 00:55, James Almer wrote:
 On 11/4/2018 9:10 PM, Mark Thompson wrote:
> ...
> +xf(1, frame_header_copy[k], b, b, b, 1, k);
 This is making a lot of noise in the trace output for no real gain,
 since it prints every single bit as its own line. Can you silence it?
>>> I think it's sensible to keep some trace output here to reflect what's 
>>> actually happening, so I've made it go by bytes rather than bits to be less 
>>> spammy.
>>>
> +priv->frame_header_size = fh_bits;
> +priv->frame_header =
> +av_mallocz(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
> +if (!priv->frame_header)
> +return AVERROR(ENOMEM);
> +memcpy(priv->frame_header, fh_start, fh_bytes);
 No way to use AVBufferRef for this?
>>> Refcounting added only for reading.  It's a bit nasty because it passes the 
>>> bufferref down into the template code which shouldn't really have it, but I 
>>> don't see any better way to make that work.
>>>
> ...
>>> Also fixed the memory leak.
>>>
>>> Thanks,
>>>
>>> - Mark
>>>
>>>
>>>  libavcodec/cbs_av1.c | 16 --
>>>  libavcodec/cbs_av1.h |  5 +-
>>>  libavcodec/cbs_av1_syntax_template.c | 82 +---
>>>  3 files changed, 91 insertions(+), 12 deletions(-)
>>>
>>> ...
>>> diff --git a/libavcodec/cbs_av1_syntax_template.c 
>>> b/libavcodec/cbs_av1_syntax_template.c
>>> index e146bbf8bb..0da79b615d 100644
>>> --- a/libavcodec/cbs_av1_syntax_template.c
>>> +++ b/libavcodec/cbs_av1_syntax_template.c
>>> @@ -1463,24 +1463,90 @@ static int 
>>> FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
>>>  }
>>>  
>>>  static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext 
>>> *rw,
>>> -  AV1RawFrameHeader *current)
>>> +  AV1RawFrameHeader *current, int 
>>> redundant,
>>> +  AVBufferRef *rw_buffer_ref)
>>>  {
>>>  CodedBitstreamAV1Context *priv = ctx->priv_data;
>>> -int err;
>>> -
>>> -HEADER("Frame Header");
>>> +int start_pos, fh_bits, fh_bytes, err;
>>> +uint8_t *fh_start;
>>>  
>>>  if (priv->seen_frame_header) {
>>> -// Nothing to do.
>>> +if (!redundant) {
>>> +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated "
>>> +   "frame header OBU.\n");
>>> +return AVERROR_INVALIDDATA;
>>> +} else {
>>> +GetBitContext fh;
>>> +size_t i, b;
>>> +uint32_t val;
>>> +
>>> +HEADER("Redundant Frame Header");
>>> +
>>> +av_assert0(priv->frame_header_ref && priv->frame_header);
>>> +
>>> +init_get_bits(, priv->frame_header,
>>> +  priv->frame_header_size);
>>> +for (i = 0; i < priv->frame_header_size; i += 8) {
>>> +b = FFMIN(priv->frame_header_size - i, 8);
>>> +val = get_bits(, b);
>>> +xf(b, frame_header_copy[i],
>>> +   val, val, val, 1, i / 8);
>>> +}
>>> +}
>>>  } else {
>>> +if (redundant)
>>> +HEADER("Redundant Frame Header (used as Frame Header)");
>>> +else
>>> +HEADER("Frame Header");
>>> +
>>>  priv->seen_frame_header = 1;
>>>  
>>> +#ifdef READ
>>> +start_pos = get_bits_count(rw);
>>> +#else
>>> +start_pos = put_bits_count(rw);
>>> +#endif
>>> +
>>>  CHECK(FUNC(uncompressed_header)(ctx, rw, current));
>>>  
>>>  if (current->show_existing_frame) {
>>>  priv->seen_frame_header = 0;
>>>  } else {
>>>  priv->seen_frame_header = 1;
>>> +
>>> +av_buffer_unref(>frame_header_ref);
>>> +
>>> +#ifdef READ
>>> +fh_bits  = get_bits_count(rw) - start_pos;
>>> +fh_start = (uint8_t*)rw->buffer + start_pos / 8;
>>> +#else
>>> +// Need to flush the bitwriter so that we can copy its output,
>>> +// but use a copy so we don't affect the caller's structure.
>>> +{
>>> +PutBitContext tmp = *rw;
>>> +flush_put_bits();
>>> +}
>>> +
>>> +fh_bits  = put_bits_count(rw) - start_pos;
>>> +fh_start = rw->buf + start_pos / 8;
>>> +#endif
>>> +fh_bytes = (fh_bits + 7) / 8;
>>> +
>>> +priv->frame_header_size = fh_bits;
>>> +
>>> +if (rw_buffer_ref) {
>>> +priv->frame_header_ref = av_buffer_ref(rw_buffer_ref);
>>> +if (!priv->frame_header_ref)
>>> +return AVERROR(ENOMEM);
>>> +priv->frame_header = fh_start;
>>
>> Is this the reason you can't 

Re: [FFmpeg-devel] [PATCH 3/4] doc/filters: add tonemap_opencl document.

2018-11-05 Thread Lou Logan
On Mon, Oct 29, 2018, at 9:31 PM, Gyan wrote:
>
> LGTM.

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Michael Niedermayer
On Mon, Nov 05, 2018 at 11:17:25AM -0800, Aaron Boushley wrote:
> When parsing a fragmented MP4 with the use_mfra_for option set so that
> the mfra box is parsed we currently continue to parse all the top level
> boxes in the mp4. We also avoid using the index in mov_seek_fragment
> unless the fragment index is marked as complete, which the mfra parsing
> code never does.
> 
> This updates the mfra parsing code to mark the fragment index as
> complete, similar to the way the sidx parsing code does.
> 
> With this change in place mov_read_default stops parsing top level boxes
> in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls
> (assuming a use_mfra_for option is passed). When loading the file over a
> network this results in significantly better performance since
> avformat_open_input doesn't require a scan of the entire file.
> 
> Signed-off-by: Aaron Boushley 
> ---
>  libavformat/mov.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index ec57a05803..1def594626 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c, AVIOContext
> *f)
>  if (ret < 0)

patch is corrupted by a newline

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 1/2] cbs_av1: Fix header writing when already aligned

2018-11-05 Thread James Almer
On 11/5/2018 12:25 PM, Mark Thompson wrote:
> ---
>  libavcodec/cbs_av1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index 9bac9dde09..1c49d90f51 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -1179,7 +1179,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
>  if (err < 0)
>  return err;
>  end_pos = put_bits_count(pbc);
> -obu->obu_size = (end_pos - start_pos + 7) / 8;
> +obu->obu_size = header_size = (end_pos - start_pos + 7) / 8;
>  } else {
>  // Empty OBU.
>  obu->obu_size = 0;

Still LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/qpeg: Optimize full width runs in qpeg_decode_intra()

2018-11-05 Thread Michael Niedermayer
This improves the speed of decoding large patches of constant color

Fixes: Timeout
Fixes: 
10967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QPEG_fuzzer-5630803793936384

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

diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index e1210c1972..cb452621e7 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -85,6 +85,12 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t 
*dst,
 filled = 0;
 dst -= stride;
 rows_to_go--;
+while (run - i > width && rows_to_go > 0) {
+memset(dst, p, width);
+dst -= stride;
+rows_to_go--;
+i += width;
+}
 if(rows_to_go <= 0)
 break;
 }
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH 2/7] lavc/vaapi_encode_h264: Enable macro block level bit rate control.

2018-11-05 Thread Mark Thompson
On 03/11/18 02:52, Jun Zhao wrote:
> Enables macro block level bit rate control, that generally improves
> subjective visual quality. It may have a negative impact on
> performance and objective visual quality metrics. Default is off
> and can't compatible with Constant QP.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/vaapi_encode_h264.c |   21 +
>  1 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 7bb77cf..060277b 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -58,6 +58,7 @@ typedef struct VAAPIEncodeH264Context {
>  int sei;
>  int profile;
>  int level;
> +int mb_rate_control;
>  
>  // Derived settings.
>  int mb_width;
> @@ -889,6 +890,22 @@ static av_cold int 
> vaapi_encode_h264_configure(AVCodecContext *avctx)
>  return 0;
>  }
>  
> +static av_cold int vaapi_encode_h264_bit_rate_control(AVCodecContext *avctx)
> +{
> +VAAPIEncodeContext  *ctx = avctx->priv_data;
> +VAAPIEncodeH264Context *priv = avctx->priv_data;
> +
> +if (priv->mb_rate_control) {
> + #if VA_CHECK_VERSION(0, 39, 2)
> +ctx->rc_params.rc.rc_flags.bits.mb_rate_control = 
> priv->mb_rate_control;
> + #else
> +av_log(avctx, AV_LOG_WARNING, "The MB rate control option is not "
> +   "supported with this VAAPI version.\n");
> + #endif
> +}
> +return 0;
> +}
> +
>  static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = {
>  { FF_PROFILE_H264_HIGH, 8, 3, 1, 1, VAProfileH264High },
>  { FF_PROFILE_H264_MAIN, 8, 3, 1, 1, VAProfileH264Main },
> @@ -904,6 +921,8 @@ static const VAAPIEncodeType vaapi_encode_type_h264 = {
>  
>  .configure = _encode_h264_configure,
>  
> +.bit_rate_control  = _encode_h264_bit_rate_control,
> +
>  .sequence_params_size  = sizeof(VAEncSequenceParameterBufferH264),
>  .init_sequence_params  = _encode_h264_init_sequence_params,
>  
> @@ -1001,6 +1020,8 @@ static const AVOption vaapi_encode_h264_options[] = {
>OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS },
>  { "quality", "Set encode quality (trades off against speed, higher is 
> faster)",
>OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
> +{ "mb_rate_control", "MB level bitrate control (only supported on 
> GEN9+)",
> +  OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, 
> "mb_rate_control" },
>  { "coder", "Entropy coder type",
>OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
>  { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, 
> INT_MAX, FLAGS, "coder" },
> 

Enabling this option still completely kills the GPU on my Skylake (6300) test 
machine (in I think older kernel versions this also caused the whole machine to 
hard-reset immediately, in current ones it only kills the GPU requiring a 
reboot to fix).  See .

- Mark


E.g., from 4.18.10:

[  138.818477] [drm] GPU HANG: ecode 9:0:0x8fd8, in ffmpeg_g [595], reason: 
hang on rcs0, action: reset
[  138.819029] [drm] GPU hangs can indicate a bug anywhere in the entire gfx 
stack, including userspace.
[  138.819604] [drm] Please file a _new_ bug report on bugs.freedesktop.org 
against DRI -> DRM/Intel
[  138.820190] [drm] drm/i915 developers can then reassign to the right 
component if it's not a kernel issue.
[  138.820787] [drm] The gpu crash dump is required to analyze gpu hangs, so 
please always attach it.
[  138.821394] [drm] GPU crash dump saved to /sys/class/drm/card0/error
[  138.822022] i915 :00:02.0: Resetting rcs0 for hang on rcs0
[  146.811837] i915 :00:02.0: Resetting rcs0 for hang on rcs0
[  146.815773] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
timeout
[  146.817686] i915 :00:02.0: Resetting chip for hang on rcs0
[  146.819565] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
timeout
[  146.929115] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
timeout
[  147.041196] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
timeout
[  147.151935] i915 :00:02.0: Failed to reset chip
[  147.156055] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
timeout
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] doc/filters: add document for opencl filters

2018-11-05 Thread Lou Logan
On Sat, Nov 3, 2018, at 8:31 AM, Lou Logan wrote:
> On Thu, Nov 1, 2018, at 9:13 PM, Gyan wrote:
>
> Sure, but I may not get to it until Monday.

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


Re: [FFmpeg-devel] [PATCH] libvpxenc: extend auto-alt-ref range

2018-11-05 Thread James Zern
On Mon, Nov 5, 2018 at 4:45 PM James Zern  wrote:
>
> On Sat, Nov 3, 2018 at 2:31 PM James Almer  wrote:
> >
> > On 11/3/2018 6:04 PM, James Zern wrote:
> > > On Sat, Nov 3, 2018 at 2:02 PM James Zern  wrote:
> > >> [...]
> > >>  #define COMMON_OPTIONS \
> > >>  { "auto-alt-ref","Enable use of alternate reference " \
> > >> - "frames (2-pass only)",   
> > >> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  2,  
> > >>  VE}, \
> > >> + "frames (2-pass only)",   
> > >> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  6,  
> > >>  VE}, \
> > >
> > > This was extended earlier [1], but probably should have been made
> > > codec specific. I can do that, but we might want to keep the 0-2 range
> > > for vp8 now for compatibility. Any preferences?
> >
> > What happens when you use the higher values while encoding VP8? Does it
> > error out or silently clips it to 1 internally?
> >
> > If it errors out then yes, move it out of COMMON_OPTIONS and into each
> > encoder AVOption array.
> >
>
> VP8 is clipped in this file currently because the library will error
> out with values > 1:

More precisely the value will fail to be set and the error will be
logged, but encoding will continue and you'll get the library default.

> codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,
>  avctx->codec_id == AV_CODEC_ID_VP8 ?
> !!ctx->auto_alt_ref : ctx->auto_alt_ref);
>
> So moving it from COMMON_OPTIONS at this point will avoid any more
> drift in the reported range of '-h encoder=libvpx'.
>
> > >
> > > [1] 41da4f8cb3 lavc/libvpxenc: fix -auto-alt-ref option type
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] avcodec: libdav1d AV1 decoder wrapper.

2018-11-05 Thread James Almer
On 10/29/2018 7:16 PM, James Almer wrote:
> From: "Ronald S. Bultje" 
> 
> Originally written by Ronald S. Bultje, with fixes, optimizations and
> improvements by James Almer.
> 
> Signed-off-by: James Almer 
> ---
> - s.n_frame_threads is now mapped to avctx->thread_count.
> - colorspace, color_primaries and color_trc are now cast to avutil enums to
>   silence -Wenum-conversion warnings on Clang.
> - Constified the data pointer in libdav1d_data_free() callback due to recent
>   changes upstream.
> 
> Dav1dData was updated upstream as well, so a { 0 } initialization should not
> emit any kind of warning with old GCC/Clang anymore.
> 
>  configure  |   4 +
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/libdav1d.c  | 270 +
>  4 files changed, 276 insertions(+)
>  create mode 100644 libavcodec/libdav1d.c

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Aaron Boushley
On Mon, Nov 5, 2018 at 2:21 PM Michael Niedermayer
 wrote:
>
> On Mon, Nov 05, 2018 at 11:17:25AM -0800, Aaron Boushley wrote:
> > When parsing a fragmented MP4 with the use_mfra_for option set so that
> > the mfra box is parsed we currently continue to parse all the top level
> > boxes in the mp4. We also avoid using the index in mov_seek_fragment
> > unless the fragment index is marked as complete, which the mfra parsing
> > code never does.
> >
> > This updates the mfra parsing code to mark the fragment index as
> > complete, similar to the way the sidx parsing code does.
> >
> > With this change in place mov_read_default stops parsing top level boxes
> > in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls
> > (assuming a use_mfra_for option is passed). When loading the file over a
> > network this results in significantly better performance since
> > avformat_open_input doesn't require a scan of the entire file.
> >
> > Signed-off-by: Aaron Boushley 
> > ---
> >  libavformat/mov.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index ec57a05803..1def594626 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c, AVIOContext
> > *f)
> >  if (ret < 0)
>
> patch is corrupted by a newline
What's the best way to address this, submit a new patch email thread?
Or is there a way to fix this thread?
[...]

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Aaron Boushley
On Mon, Nov 5, 2018 at 3:13 PM Carl Eugen Hoyos  wrote:
>
> 2018-11-06 0:03 GMT+01:00, Aaron Boushley :
> > On Mon, Nov 5, 2018 at 2:21 PM Michael Niedermayer
> >  wrote:
>
> >> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> >> > index ec57a05803..1def594626 100644
> >> > --- a/libavformat/mov.c
> >> > +++ b/libavformat/mov.c
> >> > @@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c,
> >> > AVIOContext
> >> > *f)
> >> >  if (ret < 0)
> >>
> >> patch is corrupted by a newline
> > What's the best way to address this, submit a new patch email thread?
> > Or is there a way to fix this thread?
>
> Send the patch again as an attachment instead of inlined.

Let me know if there's any problems with this one.

Aaron


libavformat-mov-fragmented-mp4.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libvpxenc: extend auto-alt-ref range

2018-11-05 Thread James Zern
vp9 now supports [0, 6]

Signed-off-by: James Zern 
---
 doc/encoders.texi  | 1 +
 libavcodec/libvpxenc.c | 6 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 899faac49b..3c6f5cd70b 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1641,6 +1641,7 @@ means unlimited.
 @table @option
 @item auto-alt-ref
 Enable use of alternate reference frames (2-pass only).
+Values greater than 1 enable multi-layer alternate reference frames (VP9 only).
 @item arnr-max-frames
 Set altref noise reduction max frame count.
 @item arnr-type
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 09f7a88452..827df21fa5 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1067,8 +1067,6 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
 #define COMMON_OPTIONS \
-{ "auto-alt-ref","Enable use of alternate reference " \
- "frames (2-pass only)",   
OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  2,   
VE}, \
 { "lag-in-frames",   "Number of frames to look ahead for " \
  "alternate reference frame selection",
OFFSET(lag_in_frames),   AV_OPT_TYPE_INT, {.i64 = -1},  -1,  INT_MAX, 
VE}, \
 { "arnr-maxframes",  "altref noise reduction max frame count", 
OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1},  -1,  INT_MAX, 
VE}, \
@@ -1112,6 +1110,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 #if CONFIG_LIBVPX_VP8_ENCODER
 static const AVOption vp8_options[] = {
 COMMON_OPTIONS
+{ "auto-alt-ref","Enable use of alternate reference "
+ "frames (2-pass only)",
OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1,  2, VE},
 { "cpu-used","Quality/Speed ratio modifier",
OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE},
 LEGACY_OPTIONS
 { NULL }
@@ -1121,6 +1121,8 @@ static const AVOption vp8_options[] = {
 #if CONFIG_LIBVPX_VP9_ENCODER
 static const AVOption vp9_options[] = {
 COMMON_OPTIONS
+{ "auto-alt-ref","Enable use of alternate reference "
+ "frames (2-pass only)",
OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { "cpu-used","Quality/Speed ratio modifier",
OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1},  -8, 8, VE},
 { "lossless","Lossless mode",   
OFFSET(lossless),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
 { "tile-columns","Number of tile columns to use, log2", 
OFFSET(tile_columns),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
-- 
2.19.1.930.g4563a0d9d0-goog

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


Re: [FFmpeg-devel] [PATCH] libvpxenc: extend auto-alt-ref range

2018-11-05 Thread James Zern
On Mon, Nov 5, 2018 at 5:02 PM James Zern  wrote:
>
> vp9 now supports [0, 6]
>
> Signed-off-by: James Zern 
> ---
>  doc/encoders.texi  | 1 +
>  libavcodec/libvpxenc.c | 6 --
>  2 files changed, 5 insertions(+), 2 deletions(-)
>

This version moves the option from COMMON_OPTIONS for comparison.

> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 899faac49b..3c6f5cd70b 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1641,6 +1641,7 @@ means unlimited.
>  @table @option
>  @item auto-alt-ref
>  Enable use of alternate reference frames (2-pass only).
> +Values greater than 1 enable multi-layer alternate reference frames (VP9 
> only).
>  @item arnr-max-frames
>  Set altref noise reduction max frame count.
>  @item arnr-type
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 09f7a88452..827df21fa5 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -1067,8 +1067,6 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> *pkt,
>  #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
>
>  #define COMMON_OPTIONS \
> -{ "auto-alt-ref","Enable use of alternate reference " \
> - "frames (2-pass only)",   
> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  2,   
> VE}, \
>  { "lag-in-frames",   "Number of frames to look ahead for " \
>   "alternate reference frame selection",
> OFFSET(lag_in_frames),   AV_OPT_TYPE_INT, {.i64 = -1},  -1,  INT_MAX, 
> VE}, \
>  { "arnr-maxframes",  "altref noise reduction max frame count", 
> OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1},  -1,  INT_MAX, 
> VE}, \
> @@ -1112,6 +1110,8 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> *pkt,
>  #if CONFIG_LIBVPX_VP8_ENCODER
>  static const AVOption vp8_options[] = {
>  COMMON_OPTIONS
> +{ "auto-alt-ref","Enable use of alternate reference "
> + "frames (2-pass only)",
> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1,  2, VE},
>  { "cpu-used","Quality/Speed ratio modifier",
> OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE},
>  LEGACY_OPTIONS
>  { NULL }
> @@ -1121,6 +1121,8 @@ static const AVOption vp8_options[] = {
>  #if CONFIG_LIBVPX_VP9_ENCODER
>  static const AVOption vp9_options[] = {
>  COMMON_OPTIONS
> +{ "auto-alt-ref","Enable use of alternate reference "
> + "frames (2-pass only)",
> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
>  { "cpu-used","Quality/Speed ratio modifier",
> OFFSET(cpu_used),AV_OPT_TYPE_INT, {.i64 = 1},  -8, 8, VE},
>  { "lossless","Lossless mode",   
> OFFSET(lossless),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
>  { "tile-columns","Number of tile columns to use, log2", 
> OFFSET(tile_columns),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
> --
> 2.19.1.930.g4563a0d9d0-goog
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/mips: [loongson] refine optimization in h264_chroma.

2018-11-05 Thread Shiyou Yin
Remove invalid operation in the case x and y all equal 0,
this refine made about 2% speedup for H264 decode on loongson platform.
---
 libavcodec/mips/h264chroma_mmi.c | 970 +--
 1 file changed, 426 insertions(+), 544 deletions(-)

diff --git a/libavcodec/mips/h264chroma_mmi.c b/libavcodec/mips/h264chroma_mmi.c
index 91b2cc4..739dd7d 100644
--- a/libavcodec/mips/h264chroma_mmi.c
+++ b/libavcodec/mips/h264chroma_mmi.c
@@ -30,74 +30,177 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t 
*src, ptrdiff_t stride,
 int h, int x, int y)
 {
 int A = 64, B, C, D, E;
-double ftmp[10];
+double ftmp[12];
 uint64_t tmp[1];
 
 if (!(x || y)) {
 /* x=0, y=0, A=64 */
 __asm__ volatile (
-"xor%[ftmp0],   %[ftmp0],   %[ftmp0]   \n\t"
-"dli%[tmp0],0x06   \n\t"
-"mtc1   %[tmp0],%[ftmp4]   \n\t"
-
 "1:\n\t"
+MMI_ULDC1(%[ftmp0], %[src], 0x00)
+PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
 MMI_ULDC1(%[ftmp1], %[src], 0x00)
-"addi   %[h],   %[h],   -0x04  \n\t"
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp5], %[src], 0x00)
+MMI_ULDC1(%[ftmp2], %[src], 0x00)
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp6], %[src], 0x00)
+MMI_ULDC1(%[ftmp3], %[src], 0x00)
 PTR_ADDU   "%[src], %[src], %[stride]  \n\t"
-MMI_ULDC1(%[ftmp7], %[src], 0x00)
 
-"punpcklbh  %[ftmp2],   %[ftmp1],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp1],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
-"paddh  %[ftmp1],   %[ftmp1],   %[ff_pw_32]\n\t"
-"paddh  %[ftmp2],   %[ftmp2],   %[ff_pw_32]\n\t"
-"psrlh  %[ftmp1],   %[ftmp1],   %[ftmp4]   \n\t"
-"psrlh  %[ftmp2],   %[ftmp2],   %[ftmp4]   \n\t"
-"packushb   %[ftmp1],   %[ftmp1],   %[ftmp2]   \n\t"
-MMI_SDC1(%[ftmp1], %[dst], 0x00)
+"addi   %[h],   %[h],   -0x04  \n\t"
 
-"punpcklbh  %[ftmp2],   %[ftmp5],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp5],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
-"paddh  %[ftmp1],   %[ftmp1],   %[ff_pw_32]\n\t"
-"paddh  %[ftmp2],   %[ftmp2],   %[ff_pw_32]\n\t"
-"psrlh  %[ftmp1],   %[ftmp1],   %[ftmp4]   \n\t"
-"psrlh  %[ftmp2],   %[ftmp2],   %[ftmp4]   \n\t"
-"packushb   %[ftmp1],   %[ftmp1],   %[ftmp2]   \n\t"
+MMI_SDC1(%[ftmp0], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 MMI_SDC1(%[ftmp1], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+MMI_SDC1(%[ftmp2], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+MMI_SDC1(%[ftmp3], %[dst], 0x00)
+PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
+"bnez   %[h],   1b \n\t"
+: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+  [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
+  [dst]"+"(dst),  [src]"+"(src),
+  [h]"+"(h)
+: [stride]"r"((mips_reg)stride)
+: "memory"
+);
+} else if (x && y) {
+/* x!=0, y!=0 */
+D = x * y;
+B = (x << 3) - D;
+C = (y << 3) - D;
+A = 64 - D - B - C;
 
-"punpcklbh  %[ftmp2],   %[ftmp6],   %[ftmp0]   \n\t"
-"punpckhbh  %[ftmp3],   %[ftmp6],   %[ftmp0]   \n\t"
-"psllh  %[ftmp1],   %[ftmp2],   %[ftmp4]   \n\t"
-"psllh  %[ftmp2],   %[ftmp3],   %[ftmp4]   \n\t"
+__asm__ volatile (
+"xor%[ftmp0],   %[ftmp0],   %[ftmp0]   \n\t"
+"dli%[tmp0],0x06   \n\t"
+"pshufh %[A],   %[A],   %[ftmp0]   \n\t"
+"pshufh %[B],   %[B],   %[ftmp0] 

Re: [FFmpeg-devel] [PATCH v2 2/2] cbs_av1: Support redundant frame headers

2018-11-05 Thread Mark Thompson
On 05/11/18 18:51, James Almer wrote:
> On 11/5/2018 3:33 PM, Mark Thompson wrote:
>> On 05/11/18 18:16, James Almer wrote:
>>> On 11/5/2018 12:25 PM, Mark Thompson wrote:
 ---
 On 05/11/18 00:55, James Almer wrote:
> On 11/4/2018 9:10 PM, Mark Thompson wrote:
>> ...
>> +xf(1, frame_header_copy[k], b, b, b, 1, k);
> This is making a lot of noise in the trace output for no real gain,
> since it prints every single bit as its own line. Can you silence it?
 I think it's sensible to keep some trace output here to reflect what's 
 actually happening, so I've made it go by bytes rather than bits to be 
 less spammy.

>> +priv->frame_header_size = fh_bits;
>> +priv->frame_header =
>> +av_mallocz(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
>> +if (!priv->frame_header)
>> +return AVERROR(ENOMEM);
>> +memcpy(priv->frame_header, fh_start, fh_bytes);
> No way to use AVBufferRef for this?
 Refcounting added only for reading.  It's a bit nasty because it passes 
 the bufferref down into the template code which shouldn't really have it, 
 but I don't see any better way to make that work.

>> ...
 Also fixed the memory leak.

 Thanks,

 - Mark


  libavcodec/cbs_av1.c | 16 --
  libavcodec/cbs_av1.h |  5 +-
  libavcodec/cbs_av1_syntax_template.c | 82 +---
  3 files changed, 91 insertions(+), 12 deletions(-)

 ...
 diff --git a/libavcodec/cbs_av1_syntax_template.c 
 b/libavcodec/cbs_av1_syntax_template.c
 index e146bbf8bb..0da79b615d 100644
 --- a/libavcodec/cbs_av1_syntax_template.c
 +++ b/libavcodec/cbs_av1_syntax_template.c
 @@ -1463,24 +1463,90 @@ static int 
 FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
  }
  
  static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext 
 *rw,
 -  AV1RawFrameHeader *current)
 +  AV1RawFrameHeader *current, int 
 redundant,
 +  AVBufferRef *rw_buffer_ref)
  {
  CodedBitstreamAV1Context *priv = ctx->priv_data;
 -int err;
 -
 -HEADER("Frame Header");
 +int start_pos, fh_bits, fh_bytes, err;
 +uint8_t *fh_start;
  
  if (priv->seen_frame_header) {
 -// Nothing to do.
 +if (!redundant) {
 +av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated "
 +   "frame header OBU.\n");
 +return AVERROR_INVALIDDATA;
 +} else {
 +GetBitContext fh;
 +size_t i, b;
 +uint32_t val;
 +
 +HEADER("Redundant Frame Header");
 +
 +av_assert0(priv->frame_header_ref && priv->frame_header);
 +
 +init_get_bits(, priv->frame_header,
 +  priv->frame_header_size);
 +for (i = 0; i < priv->frame_header_size; i += 8) {
 +b = FFMIN(priv->frame_header_size - i, 8);
 +val = get_bits(, b);
 +xf(b, frame_header_copy[i],
 +   val, val, val, 1, i / 8);
 +}
 +}
  } else {
 +if (redundant)
 +HEADER("Redundant Frame Header (used as Frame Header)");
 +else
 +HEADER("Frame Header");
 +
  priv->seen_frame_header = 1;
  
 +#ifdef READ
 +start_pos = get_bits_count(rw);
 +#else
 +start_pos = put_bits_count(rw);
 +#endif
 +
  CHECK(FUNC(uncompressed_header)(ctx, rw, current));
  
  if (current->show_existing_frame) {
  priv->seen_frame_header = 0;
  } else {
  priv->seen_frame_header = 1;
 +
 +av_buffer_unref(>frame_header_ref);
 +
 +#ifdef READ
 +fh_bits  = get_bits_count(rw) - start_pos;
 +fh_start = (uint8_t*)rw->buffer + start_pos / 8;
 +#else
 +// Need to flush the bitwriter so that we can copy its output,
 +// but use a copy so we don't affect the caller's structure.
 +{
 +PutBitContext tmp = *rw;
 +flush_put_bits();
 +}
 +
 +fh_bits  = put_bits_count(rw) - start_pos;
 +fh_start = rw->buf + start_pos / 8;
 +#endif
 +fh_bytes = (fh_bits + 7) / 8;
 +
 +priv->frame_header_size = fh_bits;
 +
 +if (rw_buffer_ref) {
 +priv->frame_header_ref = av_buffer_ref(rw_buffer_ref);
 +

[FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing (Take 2)

2018-11-05 Thread Aaron Boushley
Sorry for the second thread, first one was corrupted with a newline 
because I attempted an inline patch. Hopefully the mime-type will be set 
correctly on this one.

---
When parsing a fragmented MP4 with the use_mfra_for option set so that
the mfra box is parsed we currently continue to parse all the top level
boxes in the mp4. We also avoid using the index in mov_seek_fragment
unless the fragment index is marked as complete, which the mfra parsing
code never does.

This updates the mfra parsing code to mark the fragment index as
complete, similar to the way the sidx parsing code does.

With this change in place mov_read_default stops parsing top level boxes
in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls
(assuming a use_mfra_for option is passed). When loading the file over a
network this results in significantly better performance since
avformat_open_input doesn't require a scan of the entire file.

Aaron


From 61412c5990037484e13c7daa60d83b8ba548b8a6 Mon Sep 17 00:00:00 2001
From: Aaron Boushley 
Date: Mon, 5 Nov 2018 11:02:00 -0800
Subject: [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

When parsing a fragmented MP4 with the use_mfra_for option set so that
the mfra box is parsed we currently continue to parse all the top level
boxes in the mp4. We also avoid using the index in mov_seek_fragment
unless the fragment index is marked as complete, which the mfra parsing
code never does.

This updates the mfra parsing code to mark the fragment index as
complete, similar to the way the sidx parsing code does.

With this change in place mov_read_default stops parsing top level boxes
in a fragmented mp4 and uses the mfra data for mov_seek_fragment calls
(assuming a use_mfra_for option is passed). When loading the file over a
network this results in significantly better performance since
avformat_open_input doesn't require a scan of the entire file.

Signed-off-by: Aaron Boushley 
---
 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ec57a05803..34ba7ffe61 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7344,6 +7344,7 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f)
 if (ret < 0)
 goto fail;
 } while (!ret);
+c->frag_index.complete = 1;
 ret = 0;
 fail:
 seek_ret = avio_seek(f, original_pos, SEEK_SET);
-- 
2.18.0

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Carl Eugen Hoyos
2018-11-06 0:03 GMT+01:00, Aaron Boushley :
> On Mon, Nov 5, 2018 at 2:21 PM Michael Niedermayer
>  wrote:

>> > diff --git a/libavformat/mov.c b/libavformat/mov.c
>> > index ec57a05803..1def594626 100644
>> > --- a/libavformat/mov.c
>> > +++ b/libavformat/mov.c
>> > @@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c,
>> > AVIOContext
>> > *f)
>> >  if (ret < 0)
>>
>> patch is corrupted by a newline
> What's the best way to address this, submit a new patch email thread?
> Or is there a way to fix this thread?

Send the patch again as an attachment instead of inlined.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libvpxenc: extend auto-alt-ref range

2018-11-05 Thread James Zern
On Sat, Nov 3, 2018 at 2:31 PM James Almer  wrote:
>
> On 11/3/2018 6:04 PM, James Zern wrote:
> > On Sat, Nov 3, 2018 at 2:02 PM James Zern  wrote:
> >> [...]
> >>  #define COMMON_OPTIONS \
> >>  { "auto-alt-ref","Enable use of alternate reference " \
> >> - "frames (2-pass only)",   
> >> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  2,
> >>VE}, \
> >> + "frames (2-pass only)",   
> >> OFFSET(auto_alt_ref),AV_OPT_TYPE_INT, {.i64 = -1},  -1,  6,
> >>VE}, \
> >
> > This was extended earlier [1], but probably should have been made
> > codec specific. I can do that, but we might want to keep the 0-2 range
> > for vp8 now for compatibility. Any preferences?
>
> What happens when you use the higher values while encoding VP8? Does it
> error out or silently clips it to 1 internally?
>
> If it errors out then yes, move it out of COMMON_OPTIONS and into each
> encoder AVOption array.
>

VP8 is clipped in this file currently because the library will error
out with values > 1:
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,
 avctx->codec_id == AV_CODEC_ID_VP8 ?
!!ctx->auto_alt_ref : ctx->auto_alt_ref);

So moving it from COMMON_OPTIONS at this point will avoid any more
drift in the reported range of '-h encoder=libvpx'.

> >
> > [1] 41da4f8cb3 lavc/libvpxenc: fix -auto-alt-ref option type
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 0/7] Enhancement VA-API encoder bitrate control

2018-11-05 Thread myp...@gmail.com
On Tue, Nov 6, 2018 at 2:49 AM Mark Thompson  wrote:
>
> On 03/11/18 02:52, Jun Zhao wrote:
> > V1:
> > - add codec-specific bit rate control callback.
>
> I don't understand why you want this to be codec-specific at all?  No option 
> is always supported in any particular case, and both of these options are at 
> least queryable.
Yes, some bit rate control option is codes-specific and without query
support, this is why I add a codec-specific callback
>
> > - enable macro block level bit rate control in h264_vaapi encoder and 
> > update the docs.
> > - enable sliding windows in [h264|hevc]_vaapi encoder and update the docs.
> >
> > Jun Zhao (7):
> >   lavc/vaapi_encode: Add codec-specific bit rate control callback.
> >   lavc/vaapi_encode_h264: Enable macro block level bit rate control.
> >   doc/encoders: Add docs for mb_rate_control option
> >   lavc/vaapi_encode_h264: Enable sliding window control.
> >   doc/encoders: Add sliding_window docs for h264_vaapi.
> >   lavc/vaapi_encode_h265: Enable sliding window control.
> >   doc/encoders: Add sliding_window docs for hevc_vaapi.
> >
> >  doc/encoders.texi  |   12 
> >  libavcodec/vaapi_encode.c  |9 +
> >  libavcodec/vaapi_encode.h  |3 +++
> >  libavcodec/vaapi_encode_h264.c |   34 ++
> >  libavcodec/vaapi_encode_h265.c |   24 
> >  5 files changed, 82 insertions(+), 0 deletions(-)
>
> More generally, all of the "lets just throw random shit in here" RC options 
> (that is: basic_unit_size, disable_frame_skip, disable_bit_stuffing, 
> mb_rate_control, cfs_I_frames, enable_parallel_brc, enable_dynamic_scaling, 
> frame_tolerance_mode, quality_factor) need some more thought on how to expose 
> them sensibly.  I have some outstanding patches around RC (in particular, 
> supporting more cases and making the RC mode explicit with a common -rc_mode 
> option), I'll see if I can work something in with that.
>
> - Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] FFmpeg 4.1

2018-11-05 Thread Michael Niedermayer
On Thu, Nov 01, 2018 at 08:25:34PM +0100, Michael Niedermayer wrote:
> On Fri, Sep 14, 2018 at 03:22:56AM +0200, Michael Niedermayer wrote:
> > Hi all
> > 
> > its almost 5 months since 4.0 so its time to make a new release.
> > 
> > Are there any suggestions for a name ?
> > If not ill pick something from unused past suggestions.
> > 
> > If there are no objections i will likely make that release in the next weeks
> 
> some weeks later ...
> i intend to really really soon(tm) bump minor version and branch to 
> release/4.1
> (if you want me to wait for some reason, ping me on IRC ASAP)
> 
> once the branch is created i intend to wait a few days so everyone can still
> backport and change anything needed. Write release notes and all that stuff.
> And then make 4.1 

4.1 release made, i intend to make 4.1.1 within a few weeks (depending on
severity of bugfixes in it at the time)

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/7] lavc/vaapi_encode_h264: Enable macro block level bit rate control.

2018-11-05 Thread myp...@gmail.com
On Tue, Nov 6, 2018 at 3:40 AM Mark Thompson  wrote:
>
> On 03/11/18 02:52, Jun Zhao wrote:
> > Enables macro block level bit rate control, that generally improves
> > subjective visual quality. It may have a negative impact on
> > performance and objective visual quality metrics. Default is off
> > and can't compatible with Constant QP.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  libavcodec/vaapi_encode_h264.c |   21 +
> >  1 files changed, 21 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> > index 7bb77cf..060277b 100644
> > --- a/libavcodec/vaapi_encode_h264.c
> > +++ b/libavcodec/vaapi_encode_h264.c
> > @@ -58,6 +58,7 @@ typedef struct VAAPIEncodeH264Context {
> >  int sei;
> >  int profile;
> >  int level;
> > +int mb_rate_control;
> >
> >  // Derived settings.
> >  int mb_width;
> > @@ -889,6 +890,22 @@ static av_cold int 
> > vaapi_encode_h264_configure(AVCodecContext *avctx)
> >  return 0;
> >  }
> >
> > +static av_cold int vaapi_encode_h264_bit_rate_control(AVCodecContext 
> > *avctx)
> > +{
> > +VAAPIEncodeContext  *ctx = avctx->priv_data;
> > +VAAPIEncodeH264Context *priv = avctx->priv_data;
> > +
> > +if (priv->mb_rate_control) {
> > + #if VA_CHECK_VERSION(0, 39, 2)
> > +ctx->rc_params.rc.rc_flags.bits.mb_rate_control = 
> > priv->mb_rate_control;
> > + #else
> > +av_log(avctx, AV_LOG_WARNING, "The MB rate control option is not "
> > +   "supported with this VAAPI version.\n");
> > + #endif
> > +}
> > +return 0;
> > +}
> > +
> >  static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = {
> >  { FF_PROFILE_H264_HIGH, 8, 3, 1, 1, VAProfileH264High },
> >  { FF_PROFILE_H264_MAIN, 8, 3, 1, 1, VAProfileH264Main },
> > @@ -904,6 +921,8 @@ static const VAAPIEncodeType vaapi_encode_type_h264 = {
> >
> >  .configure = _encode_h264_configure,
> >
> > +.bit_rate_control  = _encode_h264_bit_rate_control,
> > +
> >  .sequence_params_size  = sizeof(VAEncSequenceParameterBufferH264),
> >  .init_sequence_params  = _encode_h264_init_sequence_params,
> >
> > @@ -1001,6 +1020,8 @@ static const AVOption vaapi_encode_h264_options[] = {
> >OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS },
> >  { "quality", "Set encode quality (trades off against speed, higher is 
> > faster)",
> >OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS 
> > },
> > +{ "mb_rate_control", "MB level bitrate control (only supported on 
> > GEN9+)",
> > +  OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
> > FLAGS, "mb_rate_control" },
> >  { "coder", "Entropy coder type",
> >OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" },
> >  { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, 
> > INT_MAX, FLAGS, "coder" },
> >
>
> Enabling this option still completely kills the GPU on my Skylake (6300) test 
> machine (in I think older kernel versions this also caused the whole machine 
> to hard-reset immediately, in current ones it only kills the GPU requiring a 
> reboot to fix).  See .
>
> - Mark
>
>
> E.g., from 4.18.10:
>
> [  138.818477] [drm] GPU HANG: ecode 9:0:0x8fd8, in ffmpeg_g [595], 
> reason: hang on rcs0, action: reset
> [  138.819029] [drm] GPU hangs can indicate a bug anywhere in the entire gfx 
> stack, including userspace.
> [  138.819604] [drm] Please file a _new_ bug report on bugs.freedesktop.org 
> against DRI -> DRM/Intel
> [  138.820190] [drm] drm/i915 developers can then reassign to the right 
> component if it's not a kernel issue.
> [  138.820787] [drm] The gpu crash dump is required to analyze gpu hangs, so 
> please always attach it.
> [  138.821394] [drm] GPU crash dump saved to /sys/class/drm/card0/error
> [  138.822022] i915 :00:02.0: Resetting rcs0 for hang on rcs0
> [  146.811837] i915 :00:02.0: Resetting rcs0 for hang on rcs0
> [  146.815773] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
> timeout
> [  146.817686] i915 :00:02.0: Resetting chip for hang on rcs0
> [  146.819565] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
> timeout
> [  146.929115] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
> timeout
> [  147.041196] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
> timeout
> [  147.151935] i915 :00:02.0: Failed to reset chip
> [  147.156055] [drm:gen8_reset_engines [i915]] *ERROR* rcs0: reset request 
> timeout
>
I know this GPU hang issue in i965 driver, but i965 drvier is slow
down and  will switch the GPU driver to
iHD(https://github.com/intel/media-driver), I don't know who will fix
this issue in i965.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Speed up fragmented mp4 parsing

2018-11-05 Thread Aaron Boushley
On Mon, Nov 5, 2018 at 3:25 PM Aaron Boushley  wrote:
>
> On Mon, Nov 5, 2018 at 3:13 PM Carl Eugen Hoyos  wrote:
> >
> > 2018-11-06 0:03 GMT+01:00, Aaron Boushley :
> > > On Mon, Nov 5, 2018 at 2:21 PM Michael Niedermayer
> > >  wrote:
> >
> > >> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > >> > index ec57a05803..1def594626 100644
> > >> > --- a/libavformat/mov.c
> > >> > +++ b/libavformat/mov.c
> > >> > @@ -7344,6 +7344,8 @@ static int mov_read_mfra(MOVContext *c,
> > >> > AVIOContext
> > >> > *f)
> > >> >  if (ret < 0)
> > >>
> > >> patch is corrupted by a newline
> > > What's the best way to address this, submit a new patch email thread?
> > > Or is there a way to fix this thread?
> >
> > Send the patch again as an attachment instead of inlined.
>
> Let me know if there's any problems with this one.

Looks like https://patchwork.ffmpeg.org/patch/10942/ didn't update
with the attached version, so I'm going to try a new thread.

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