Re: [FFmpeg-devel] [PATCH 9/9] avfilter/avfilter: Remove unused partial_buf

2021-08-05 Thread Nicolas George
Andreas Rheinhardt (12021-08-05):
> It is unused since 02aa0701ae0dc2def8db640c9e3c06dc1b5de70c.
> The corresponding size field is write-only since then.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> I was quite surprised to find this.

LGTM, good catch.

Regards,

-- 
  Nicolas George


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

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


[FFmpeg-devel] [PATCH v5 00/20] clean-up QSV filters

2021-08-05 Thread Haihao Xiang
This patchset clean up scale_qsv and deinterlace_qsv filters, and take
the two filters as the special cases of vpp_qsv, so vf_scale_qsv.c and
vf_deinterlace_qsv.c can be deleted from FFmpeg. In addition, a few
small features are added in this patchset.
---
v5:
* Rebased this patchset against the latest master branch and fixed conflicts

Haihao Xiang (20):
  lavfi/qsv: use QSVVPPContext as base context in
vf_vpp_qsv/vf_overlay_qsv
  lavfi/scale_qsv: simplify scale_qsv filter
  lavfi/scale_qsv: don't need variables for constants in FFmpeg
  lavfi/vpp_qsv: add "a", "dar" and "sar" variables
  lavfi/vpp_qsv: handle NULL pointer when evaluating an expression
  lavfi/vpp_qsv: allow special values for the output dimensions
  lavfi/vpp_qsv: factorize extra MFX configuration
  lavfi/vpp_qsv: allow user to set scale_mode with constant
  lavfi/vpp_qsv: add vpp_preinit callback
  lavfi/scale_qsv: re-use VPPContext for scale_qsv filter
  lavfi/vpp_qsv: factor common QSV filter definition
  lavfi/scale_qsv: add new options for scale_qsv filter
  lavfi/scale_qsv: add more input / output pixel formats
  lavfi/qsvvpp: avoid overriding the returned value
  lavfi/qsvvpp: set PTS for output frame
  lavfi/vpp_qsv: check output format string against NULL pointer
  lavfi/deinterlace_qsv: simplify deinterlace_qsv filter
  lavfi/deinterlace_qsv: re-use VPPContext for deinterlace_qsv filter
  lavfi/deinterlace_qsv: add async_depth option
  lavfi/deinterlace_qsv: add more input / output pixel formats

 libavfilter/Makefile |   4 +-
 libavfilter/qsvvpp.c |  57 ++-
 libavfilter/qsvvpp.h |  11 +-
 libavfilter/vf_deinterlace_qsv.c | 611 ---
 libavfilter/vf_overlay_qsv.c |  11 +-
 libavfilter/vf_scale_qsv.c   | 685 ---
 libavfilter/vf_vpp_qsv.c | 473 +
 7 files changed, 347 insertions(+), 1505 deletions(-)
 delete mode 100644 libavfilter/vf_deinterlace_qsv.c
 delete mode 100644 libavfilter/vf_scale_qsv.c

-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 01/20] lavfi/qsv: use QSVVPPContext as base context in vf_vpp_qsv/vf_overlay_qsv

2021-08-05 Thread Haihao Xiang
The same members between QSVVPPContext and VPPContext are removed from
VPPContext, and async_depth is moved from QSVVPPParam to QSVVPPContext
so that all QSV filters using QSVVPPContext may support async depth. In
addition we may use QSVVPPContext as base context in other QSV filters
in the future.
---
 libavfilter/qsvvpp.c | 25 -
 libavfilter/qsvvpp.h |  8 
 libavfilter/vf_overlay_qsv.c | 11 +--
 libavfilter/vf_vpp_qsv.c | 34 +-
 4 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 4768f6208b..5b0b30e23c 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -647,15 +647,11 @@ static unsigned int qsv_fifo_size(const AVFifoBuffer* 
fifo)
 return  av_fifo_size(fifo)/qsv_fifo_item_size();
 }
 
-int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam 
*param)
+int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
 {
 int i;
 int ret;
-QSVVPPContext *s;
-
-s = av_mallocz(sizeof(*s));
-if (!s)
-return AVERROR(ENOMEM);
+QSVVPPContext *s = avctx->priv;
 
 s->filter_frame  = param->filter_frame;
 if (!s->filter_frame)
@@ -722,14 +718,13 @@ int ff_qsvvpp_create(AVFilterContext *avctx, 
QSVVPPContext **vpp, QSVVPPParam *p
 s->got_frame = 0;
 
 /** keep fifo size at least 1. Even when async_depth is 0, fifo is used. */
-s->async_fifo  = av_fifo_alloc((param->async_depth + 1) * 
qsv_fifo_item_size());
-s->async_depth = param->async_depth;
+s->async_fifo  = av_fifo_alloc((s->async_depth + 1) * 
qsv_fifo_item_size());
 if (!s->async_fifo) {
 ret = AVERROR(ENOMEM);
 goto failed;
 }
 
-s->vpp_param.AsyncDepth = param->async_depth;
+s->vpp_param.AsyncDepth = s->async_depth;
 
 if (IS_SYSTEM_MEMORY(s->in_mem_mode))
 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_SYSTEM_MEMORY;
@@ -756,25 +751,22 @@ int ff_qsvvpp_create(AVFilterContext *avctx, 
QSVVPPContext **vpp, QSVVPPParam *p
 } else if (ret > 0)
 ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
 
-*vpp = s;
 return 0;
 
 failed:
-ff_qsvvpp_free(&s);
+ff_qsvvpp_close(avctx);
 
 return ret;
 }
 
-int ff_qsvvpp_free(QSVVPPContext **vpp)
+int ff_qsvvpp_close(AVFilterContext *avctx)
 {
-QSVVPPContext *s = *vpp;
-
-if (!s)
-return 0;
+QSVVPPContext *s = avctx->priv;
 
 if (s->session) {
 MFXVideoVPP_Close(s->session);
 MFXClose(s->session);
+s->session = NULL;
 }
 
 /* release all the resources */
@@ -785,7 +777,6 @@ int ff_qsvvpp_free(QSVVPPContext **vpp)
 av_freep(&s->ext_buffers);
 av_freep(&s->frame_infos);
 av_fifo_free(s->async_fifo);
-av_freep(vpp);
 
 return 0;
 }
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index e0f4c8f5bb..b6fe0d3fa7 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -48,6 +48,8 @@ typedef struct QSVFrame {
 } QSVFrame;
 
 typedef struct QSVVPPContext {
+const AVClass  *class;
+
 mfxSession  session;
 int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback 
*/
 enum AVPixelFormat  out_sw_format;   /**< Real output format */
@@ -95,15 +97,13 @@ typedef struct QSVVPPParam {
 /* Crop information for each input, if needed */
 int num_crop;
 QSVVPPCrop *crop;
-
-   int async_depth;
 } QSVVPPParam;
 
 /* create and initialize the QSV session */
-int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam 
*param);
+int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param);
 
 /* release the resources (eg.surfaces) */
-int ff_qsvvpp_free(QSVVPPContext **vpp);
+int ff_qsvvpp_close(AVFilterContext *avctx);
 
 /* vpp filter frame and call the cb if needed */
 int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame 
*frame);
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 14c4c37a3c..e7db6adf4b 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -57,10 +57,9 @@ enum var_name {
 };
 
 typedef struct QSVOverlayContext {
-const AVClass  *class;
+QSVVPPContext  qsv;
 
 FFFrameSync fs;
-QSVVPPContext  *qsv;
 QSVVPPParamqsv_param;
 mfxExtVPPComposite comp_conf;
 double var_values[VAR_VARS_NB];
@@ -230,14 +229,14 @@ static int config_overlay_input(AVFilterLink *inlink)
 static int process_frame(FFFrameSync *fs)
 {
 AVFilterContext  *ctx = fs->parent;
-QSVOverlayContext  *s = fs->opaque;
+QSVVPPContext*qsv = fs->opaque;
 AVFrame*frame = NULL;
 int   ret = 0, i;
 
 for (i = 0; i < ctx->nb_inputs; i++) {
 ret = ff_framesync_get_frame(fs, i, &frame, 0);
 if (ret == 0)
-ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
+ 

[FFmpeg-devel] [PATCH v5 02/20] lavfi/scale_qsv: simplify scale_qsv filter

2021-08-05 Thread Haihao Xiang
Use QSVVPPContext as a base context of QSVScaleContext, hence we may
re-use functions defined for QSVVPPContext to manage MFX session for
scale_qsv filter too. Because system memory is taken into account in
QSVVVPPContext, we may add support for non-QSV pixel formats in the
future
---
 libavfilter/vf_scale_qsv.c | 456 +
 1 file changed, 57 insertions(+), 399 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 189223a58a..77a782aa58 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -72,35 +72,13 @@ enum var_name {
 #define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
 
 typedef struct QSVScaleContext {
-const AVClass *class;
-
-/* a clone of the main session, used internally for scaling */
-mfxSession   session;
-
-mfxMemId *mem_ids_in;
-int nb_mem_ids_in;
-
-mfxMemId *mem_ids_out;
-int nb_mem_ids_out;
-
-mfxFrameSurface1 **surface_ptrs_in;
-int nb_surface_ptrs_in;
-
-mfxFrameSurface1 **surface_ptrs_out;
-int nb_surface_ptrs_out;
-
-mfxExtOpaqueSurfaceAlloc opaque_alloc;
+QSVVPPContext qsv;
 
 #if QSV_HAVE_SCALING_CONFIG
 mfxExtVPPScaling scale_conf;
 #endif
 int  mode;
 
-mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
-int  num_ext_buf;
-
-int shift_width, shift_height;
-
 /**
  * New dimensions. Special values are:
  *   0 = original width/height
@@ -137,22 +115,7 @@ static av_cold int qsvscale_init(AVFilterContext *ctx)
 
 static av_cold void qsvscale_uninit(AVFilterContext *ctx)
 {
-QSVScaleContext *s = ctx->priv;
-
-if (s->session) {
-MFXClose(s->session);
-s->session = NULL;
-}
-
-av_freep(&s->mem_ids_in);
-av_freep(&s->mem_ids_out);
-s->nb_mem_ids_in  = 0;
-s->nb_mem_ids_out = 0;
-
-av_freep(&s->surface_ptrs_in);
-av_freep(&s->surface_ptrs_out);
-s->nb_surface_ptrs_in  = 0;
-s->nb_surface_ptrs_out = 0;
+ff_qsvvpp_close(ctx);
 }
 
 static int qsvscale_query_formats(AVFilterContext *ctx)
@@ -169,313 +132,20 @@ static int qsvscale_query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-static int init_out_pool(AVFilterContext *ctx,
- int out_width, int out_height)
-{
-QSVScaleContext *s = ctx->priv;
-AVFilterLink *outlink = ctx->outputs[0];
-
-AVHWFramesContext *in_frames_ctx;
-AVHWFramesContext *out_frames_ctx;
-AVQSVFramesContext *in_frames_hwctx;
-AVQSVFramesContext *out_frames_hwctx;
-enum AVPixelFormat in_format;
-enum AVPixelFormat out_format;
-int i, ret;
-
-/* check that we have a hw context */
-if (!ctx->inputs[0]->hw_frames_ctx) {
-av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
-return AVERROR(EINVAL);
-}
-in_frames_ctx   = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
-in_frames_hwctx = in_frames_ctx->hwctx;
-
-in_format = in_frames_ctx->sw_format;
-out_format= (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
-
-outlink->hw_frames_ctx = av_hwframe_ctx_alloc(in_frames_ctx->device_ref);
-if (!outlink->hw_frames_ctx)
-return AVERROR(ENOMEM);
-out_frames_ctx   = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
-out_frames_hwctx = out_frames_ctx->hwctx;
-
-out_frames_ctx->format= AV_PIX_FMT_QSV;
-out_frames_ctx->width = FFALIGN(out_width,  16);
-out_frames_ctx->height= FFALIGN(out_height, 16);
-out_frames_ctx->sw_format = out_format;
-out_frames_ctx->initial_pool_size = 4;
-
-out_frames_hwctx->frame_type = in_frames_hwctx->frame_type;
-
-ret = ff_filter_init_hw_frames(ctx, outlink, 32);
-if (ret < 0)
-return ret;
-
-ret = av_hwframe_ctx_init(outlink->hw_frames_ctx);
-if (ret < 0)
-return ret;
-
-for (i = 0; i < out_frames_hwctx->nb_surfaces; i++) {
-mfxFrameInfo *info = &out_frames_hwctx->surfaces[i].Info;
-info->CropW = out_width;
-info->CropH = out_height;
-}
-
-return 0;
-}
-
-static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
- mfxFrameAllocResponse *resp)
-{
-AVFilterContext *ctx = pthis;
-QSVScaleContext   *s = ctx->priv;
-
-if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) ||
-!(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
-!(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
-return MFX_ERR_UNSUPPORTED;
-
-if (req->Type & MFX_MEMTYPE_FROM_VPPIN) {
-resp->mids   = s->mem_ids_in;
-resp->NumFrameActual = s->nb_mem_ids_in;
-} else {
-resp->mids   = s->mem_ids_out;
-resp->NumFrameActual = s->nb_mem_ids_out;
-}
-
-return MFX_ERR_NONE;
-}
-
-static mfxStatus frame_free(mfxHDL pthis, mfx

[FFmpeg-devel] [PATCH v5 03/20] lavfi/scale_qsv: don't need variables for constants in FFmpeg

2021-08-05 Thread Haihao Xiang
PI, PHI and E are defined in FFmpeg
---
 libavfilter/vf_scale_qsv.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 77a782aa58..f8e937e40e 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -44,9 +44,6 @@
 #include "video.h"
 
 static const char *const var_names[] = {
-"PI",
-"PHI",
-"E",
 "in_w",   "iw",
 "in_h",   "ih",
 "out_w",  "ow",
@@ -57,9 +54,6 @@ static const char *const var_names[] = {
 };
 
 enum var_name {
-VAR_PI,
-VAR_PHI,
-VAR_E,
 VAR_IN_W,   VAR_IW,
 VAR_IN_H,   VAR_IH,
 VAR_OUT_W,  VAR_OW,
@@ -147,9 +141,6 @@ static int qsvscale_config_props(AVFilterLink *outlink)
 int ret;
 enum AVPixelFormat in_format;
 
-var_values[VAR_PI]= M_PI;
-var_values[VAR_PHI]   = M_PHI;
-var_values[VAR_E] = M_E;
 var_values[VAR_IN_W]  = var_values[VAR_IW] = inlink->w;
 var_values[VAR_IN_H]  = var_values[VAR_IH] = inlink->h;
 var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 04/20] lavfi/vpp_qsv: add "a", "dar" and "sar" variables

2021-08-05 Thread Haihao Xiang
Also fix the coding style for VAR index. This is in preparation for
re-using VPPContext for scale_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 5b0b07adf5..5f0502089c 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -147,18 +147,22 @@ static const char *const var_names[] = {
 "ch",
 "cx",
 "cy",
+"a", "dar",
+"sar",
 NULL
 };
 
 enum var_name {
-VAR_iW, VAR_IN_W,
-VAR_iH, VAR_IN_H,
-VAR_oW, VAR_OUT_W, VAR_W,
-VAR_oH, VAR_OUT_H, VAR_H,
+VAR_IW, VAR_IN_W,
+VAR_IH, VAR_IN_H,
+VAR_OW, VAR_OUT_W, VAR_W,
+VAR_OH, VAR_OUT_H, VAR_H,
 CW,
 CH,
 CX,
 CY,
+VAR_A, VAR_DAR,
+VAR_SAR,
 VAR_VARS_NB
 };
 
@@ -190,12 +194,17 @@ static int eval_expr(AVFilterContext *ctx)
 PASS_EXPR(cx_expr, vpp->cx);
 PASS_EXPR(cy_expr, vpp->cy);
 
-var_values[VAR_iW] =
+var_values[VAR_IW] =
 var_values[VAR_IN_W] = ctx->inputs[0]->w;
 
-var_values[VAR_iH] =
+var_values[VAR_IH] =
 var_values[VAR_IN_H] = ctx->inputs[0]->h;
 
+var_values[VAR_A] = (double)var_values[VAR_IN_W] / var_values[VAR_IN_H];
+var_values[VAR_SAR] = ctx->inputs[0]->sample_aspect_ratio.num ?
+(double)ctx->inputs[0]->sample_aspect_ratio.num / 
ctx->inputs[0]->sample_aspect_ratio.den : 1;
+var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
+
 /* crop params */
 CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
 CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h);
@@ -204,15 +213,15 @@ static int eval_expr(AVFilterContext *ctx)
 CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
 
 CALC_EXPR(w_expr,
-var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],
+var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
 vpp->out_width);
 CALC_EXPR(h_expr,
-var_values[VAR_OUT_H] = var_values[VAR_oH] = var_values[VAR_H],
+var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H],
 vpp->out_height);
 
 /* calc again in case ow is relative to oh */
 CALC_EXPR(w_expr,
-var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],
+var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
 vpp->out_width);
 
 
@@ -222,7 +231,7 @@ static int eval_expr(AVFilterContext *ctx)
 /* calc again in case cx is relative to cy */
 CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);
 
-if ((vpp->crop_w != var_values[VAR_iW]) || (vpp->crop_h != 
var_values[VAR_iH]))
+if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != 
var_values[VAR_IH]))
 vpp->use_crop = 1;
 
 release:
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 05/20] lavfi/vpp_qsv: handle NULL pointer when evaluating an expression

2021-08-05 Thread Haihao Xiang
This is in preparation for re-using VPPContext but with a different
option array for scale_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 36 
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 5f0502089c..5d3c314ae8 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -169,14 +169,19 @@ enum var_name {
 static int eval_expr(AVFilterContext *ctx)
 {
 #define PASS_EXPR(e, s) {\
-ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
-if (ret < 0) {\
-av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s);\
-goto release;\
+if (s) {\
+ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); 
\
+if (ret < 0) {  \
+av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s); \
+goto release;   \
+}   \
 }\
 }
-#define CALC_EXPR(e, v, i) {\
-i = v = av_expr_eval(e, var_values, NULL); \
+#define CALC_EXPR(e, v, i, d) {\
+if (e)\
+i = v = av_expr_eval(e, var_values, NULL);  \
+else\
+i = v = d;\
 }
 VPPContext *vpp = ctx->priv;
 double  var_values[VAR_VARS_NB] = { NAN };
@@ -206,30 +211,29 @@ static int eval_expr(AVFilterContext *ctx)
 var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
 
 /* crop params */
-CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
-CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h);
+CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w, var_values[VAR_IW]);
+CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h, var_values[VAR_IH]);
 
 /* calc again in case cw is relative to ch */
-CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);
+CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w, var_values[VAR_IW]);
 
 CALC_EXPR(w_expr,
 var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
-vpp->out_width);
+vpp->out_width, var_values[CW]);
 CALC_EXPR(h_expr,
 var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H],
-vpp->out_height);
+vpp->out_height, var_values[CH]);
 
 /* calc again in case ow is relative to oh */
 CALC_EXPR(w_expr,
 var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
-vpp->out_width);
+vpp->out_width, var_values[CW]);
 
-
-CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);
-CALC_EXPR(cy_expr, var_values[CY], vpp->crop_y);
+CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x, (var_values[VAR_IW] - 
var_values[VAR_OW]) / 2);
+CALC_EXPR(cy_expr, var_values[CY], vpp->crop_y, (var_values[VAR_IH] - 
var_values[VAR_OH]) / 2);
 
 /* calc again in case cx is relative to cy */
-CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);
+CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x, (var_values[VAR_IW] - 
var_values[VAR_OW]) / 2);
 
 if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != 
var_values[VAR_IH]))
 vpp->use_crop = 1;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 08/20] lavfi/vpp_qsv: allow user to set scale_mode with constant

2021-08-05 Thread Haihao Xiang
In addtion, update the help text for scale_mode

$ ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264 -vf \
"vpp_qsv=scale_mode=hq" -f null -
---
 libavfilter/vf_vpp_qsv.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index e8cba3c360..ea4948f2fe 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -138,7 +138,17 @@ static const AVOption options[] = {
 { "height", "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = 
FLAGS },
 { "format", "Output pixel format", OFFSET(output_format_str), 
AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
 { "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, .flags = FLAGS },
-{ "scale_mode", "scale mode: 0=auto, 1=low power, 2=high quality", 
OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT }, 
MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale 
mode" },
+#if QSV_HAVE_SCALING_CONFIG
+{ "scale_mode", "scale mode", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 
= MFX_SCALING_MODE_DEFAULT }, MFX_SCALING_MODE_DEFAULT, 
MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale mode" },
+{ "auto",  "auto mode", 0,AV_OPT_TYPE_CONST,  { .i64 = 
MFX_SCALING_MODE_DEFAULT},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
+{ "low_power", "low power mode",0,AV_OPT_TYPE_CONST,  { .i64 = 
MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
+{ "hq","high quality mode", 0,AV_OPT_TYPE_CONST,  { .i64 = 
MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
+#else
+{ "scale_mode", "(not supported)",OFFSET(scale_mode), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS, "scale mode" },
+{ "auto",  "",  0,AV_OPT_TYPE_CONST,  { .i64 = 
0}, 0,   0, FLAGS, "scale mode"},
+{ "low_power", "",  0,AV_OPT_TYPE_CONST,  { .i64 = 
1}, 0,   0, FLAGS, "scale mode"},
+{ "hq","",  0,AV_OPT_TYPE_CONST,  { .i64 = 
2}, 0,   0, FLAGS, "scale mode"},
+#endif
 
 { NULL }
 };
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 09/20] lavfi/vpp_qsv: add vpp_preinit callback

2021-08-05 Thread Haihao Xiang
Set the expected default value for options in this callback, hence we
have the right values even if these options are not included in the
option arrray. This is in preparation for re-using VPPContext but with a
different option array for other QSV filters
---
 libavfilter/vf_vpp_qsv.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index ea4948f2fe..e254e5bbcb 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -266,6 +266,19 @@ release:
 return ret;
 }
 
+static av_cold int vpp_preinit(AVFilterContext *ctx)
+{
+VPPContext  *vpp  = ctx->priv;
+/* For AV_OPT_TYPE_STRING options, NULL is handled in other way so
+ * we needn't set default value here
+ */
+vpp->saturation = 1.0;
+vpp->contrast = 1.0;
+vpp->transpose = -1;
+
+return 0;
+}
+
 static av_cold int vpp_init(AVFilterContext *ctx)
 {
 VPPContext  *vpp  = ctx->priv;
@@ -646,6 +659,7 @@ const AVFilter ff_vf_vpp_qsv = {
 .description   = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."),
 .priv_size = sizeof(VPPContext),
 .query_formats = query_formats,
+.preinit   = vpp_preinit,
 .init  = vpp_init,
 .uninit= vpp_uninit,
 .inputs= vpp_inputs,
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 06/20] lavfi/vpp_qsv: allow special values for the output dimensions

2021-08-05 Thread Haihao Xiang
Special values are:
0 = original width/height
-1 = keep original aspect

This is in preparation for re-using VPPContext for scale_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 47 ++--
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 5d3c314ae8..5409ecf569 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -62,6 +62,11 @@ typedef struct VPPContext{
 mfxExtVPPScaling scale_conf;
 #endif
 
+/**
+ * New dimensions. Special values are:
+ *   0 = original width/height
+ *  -1 = keep original aspect
+ */
 int out_width;
 int out_height;
 /**
@@ -127,10 +132,10 @@ static const AVOption options[] = {
 { "cx",   "set the x crop area expression",   OFFSET(cx), 
AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS },
 { "cy",   "set the y crop area expression",   OFFSET(cy), 
AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS },
 
-{ "w",  "Output video width",  OFFSET(ow), AV_OPT_TYPE_STRING, { 
.str="cw" }, 0, 255, .flags = FLAGS },
-{ "width",  "Output video width",  OFFSET(ow), AV_OPT_TYPE_STRING, { 
.str="cw" }, 0, 255, .flags = FLAGS },
-{ "h",  "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { 
.str="w*ch/cw" }, 0, 255, .flags = FLAGS },
-{ "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { 
.str="w*ch/cw" }, 0, 255, .flags = FLAGS },
+{ "w",  "Output video width(0=input video width, -1=keep input video 
aspect)",  OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = 
FLAGS },
+{ "width",  "Output video width(0=input video width, -1=keep input video 
aspect)",  OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = 
FLAGS },
+{ "h",  "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = 
FLAGS },
+{ "height", "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = 
FLAGS },
 { "format", "Output pixel format", OFFSET(output_format_str), 
AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
 { "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, .flags = FLAGS },
 { "scale_mode", "scale mode: 0=auto, 1=low power, 2=high quality", 
OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT }, 
MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale 
mode" },
@@ -273,6 +278,7 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 VPPContext  *vpp = ctx->priv;
 int  ret;
+int64_t  ow, oh;
 
 if (vpp->framerate.den == 0 || vpp->framerate.num == 0)
 vpp->framerate = inlink->frame_rate;
@@ -286,11 +292,38 @@ static int config_input(AVFilterLink *inlink)
 return ret;
 }
 
-if (vpp->out_height == 0 || vpp->out_width == 0) {
-vpp->out_width  = inlink->w;
-vpp->out_height = inlink->h;
+ow = vpp->out_width;
+oh = vpp->out_height;
+
+/* sanity check params */
+if (ow <  -1 || oh <  -1) {
+av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not 
acceptable.\n");
+return AVERROR(EINVAL);
 }
 
+if (ow == -1 && oh == -1)
+vpp->out_width = vpp->out_height = 0;
+
+if (!(ow = vpp->out_width))
+ow = inlink->w;
+
+if (!(oh = vpp->out_height))
+oh = inlink->h;
+
+if (ow == -1)
+ow = av_rescale(oh, inlink->w, inlink->h);
+
+if (oh == -1)
+oh = av_rescale(ow, inlink->h, inlink->w);
+
+if (ow > INT_MAX || oh > INT_MAX ||
+(oh * inlink->w) > INT_MAX  ||
+(ow * inlink->h) > INT_MAX)
+av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too 
big.\n");
+
+vpp->out_width = ow;
+vpp->out_height = oh;
+
 if (vpp->use_crop) {
 vpp->crop_x = FFMAX(vpp->crop_x, 0);
 vpp->crop_y = FFMAX(vpp->crop_y, 0);
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 10/20] lavfi/scale_qsv: re-use VPPContext for scale_qsv filter

2021-08-05 Thread Haihao Xiang
All features are implemented in vpp_qsv filter, scale_qsv can be taken
as a special case of vpp_qsv filter now, we re-use VPPContext with a
different option arrary and pixel formats
---
 libavfilter/Makefile   |   2 +-
 libavfilter/vf_scale_qsv.c | 334 -
 libavfilter/vf_vpp_qsv.c   |  55 ++
 3 files changed, 56 insertions(+), 335 deletions(-)
 delete mode 100644 libavfilter/vf_scale_qsv.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 49c0c8342b..760099ba2c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -398,7 +398,7 @@ OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o 
scale_eval.o
 OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o scale_eval.o \
 vf_scale_cuda.ptx.o 
cuda/load_helper.o
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
-OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
+OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_vpp_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale_eval.o 
vaapi_vpp.o
 OBJS-$(CONFIG_SCALE_VULKAN_FILTER)   += vf_scale_vulkan.o vulkan.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale_eval.o
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
deleted file mode 100644
index f8e937e40e..00
--- a/libavfilter/vf_scale_qsv.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * scale video filter - QSV
- */
-
-#include 
-
-#include 
-#include 
-
-#include "libavutil/avstring.h"
-#include "libavutil/common.h"
-#include "libavutil/eval.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_qsv.h"
-#include "libavutil/internal.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/time.h"
-#include "libavfilter/qsvvpp.h"
-
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-static const char *const var_names[] = {
-"in_w",   "iw",
-"in_h",   "ih",
-"out_w",  "ow",
-"out_h",  "oh",
-"a", "dar",
-"sar",
-NULL
-};
-
-enum var_name {
-VAR_IN_W,   VAR_IW,
-VAR_IN_H,   VAR_IH,
-VAR_OUT_W,  VAR_OW,
-VAR_OUT_H,  VAR_OH,
-VAR_A, VAR_DAR,
-VAR_SAR,
-VARS_NB
-};
-
-#define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
-
-typedef struct QSVScaleContext {
-QSVVPPContext qsv;
-
-#if QSV_HAVE_SCALING_CONFIG
-mfxExtVPPScaling scale_conf;
-#endif
-int  mode;
-
-/**
- * New dimensions. Special values are:
- *   0 = original width/height
- *  -1 = keep original aspect
- */
-int w, h;
-
-/**
- * Output sw format. AV_PIX_FMT_NONE for no conversion.
- */
-enum AVPixelFormat format;
-
-char *w_expr;   ///< width  expression string
-char *h_expr;   ///< height expression string
-char *format_str;
-} QSVScaleContext;
-
-static av_cold int qsvscale_init(AVFilterContext *ctx)
-{
-QSVScaleContext *s = ctx->priv;
-
-if (!strcmp(s->format_str, "same")) {
-s->format = AV_PIX_FMT_NONE;
-} else {
-s->format = av_get_pix_fmt(s->format_str);
-if (s->format == AV_PIX_FMT_NONE) {
-av_log(ctx, AV_LOG_ERROR, "Unrecognized pixel format: %s\n", 
s->format_str);
-return AVERROR(EINVAL);
-}
-}
-
-return 0;
-}
-
-static av_cold void qsvscale_uninit(AVFilterContext *ctx)
-{
-ff_qsvvpp_close(ctx);
-}
-
-static int qsvscale_query_formats(AVFilterContext *ctx)
-{
-static const enum AVPixelFormat pixel_formats[] = {
-AV_PIX_FMT_QSV, AV_PIX_FMT_NONE,
-};
-AVFilterFormats *pix_fmts  = ff_make_format_list(pixel_formats);
-int ret;
-
-if ((ret = ff_set_common_formats(ctx, pix_fmts)) < 0)
-return ret;
-
-return 0;
-}
-
-static int qsvscale_config_props(AVFilterLink *outlink)
-{
-AVFilterContext *ctx = outlink->src;
-AVFilterLink *inlink = outlink->src->inputs[0];
-QSVScaleContext   *s = ctx->priv;
-QSVVPPParamparam = { NULL };
-#if QSV_HAVE_SCALING_CONFIG
-mfxExtBuffer  

[FFmpeg-devel] [PATCH v5 12/20] lavfi/scale_qsv: add new options for scale_qsv filter

2021-08-05 Thread Haihao Xiang
Allow user to set crop area and async depth
---
 libavfilter/vf_vpp_qsv.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index e9a802d507..d72ddad517 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -684,6 +684,10 @@ static int qsvscale_query_formats(AVFilterContext *ctx)
 static const AVOption qsvscale_options[] = {
 { "w",  "Output video width(0=input video width, -1=keep input video 
aspect)",  OFFSET(ow), AV_OPT_TYPE_STRING, { .str = "iw"   }, .flags = FLAGS },
 { "h",  "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags = FLAGS },
+{ "cw", "set the width crop area expression",   OFFSET(cw), 
AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
+{ "ch", "set the height crop area expression",  OFFSET(ch), 
AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
+{ "cx", "set the x crop area expression",   OFFSET(cx), 
AV_OPT_TYPE_STRING, { .str = "(iw-ow)/2" }, .flags = FLAGS },
+{ "cy", "set the y crop area expression",   OFFSET(cy), 
AV_OPT_TYPE_STRING, { .str = "(ih-oh)/2" }, .flags = FLAGS },
 { "format", "Output pixel format", OFFSET(output_format_str), 
AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
 
 #if QSV_HAVE_SCALING_CONFIG
@@ -696,6 +700,8 @@ static const AVOption qsvscale_options[] = {
 { "hq","",  0, AV_OPT_TYPE_CONST,  
{ .i64 = 2}, 0,   0, FLAGS, "mode"},
 #endif
 
+{ "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, .flags = FLAGS },
+
 { NULL },
 };
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 07/20] lavfi/vpp_qsv: factorize extra MFX configuration

2021-08-05 Thread Haihao Xiang
This is in preparation for re-using VPPContext for scale_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 86 
 1 file changed, 34 insertions(+), 52 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 5409ecf569..e8cba3c360 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -379,53 +379,44 @@ static int config_output(AVFilterLink *outlink)
 param.crop = &crop;
 }
 
-if (vpp->deinterlace) {
-memset(&vpp->deinterlace_conf, 0, sizeof(mfxExtVPPDeinterlacing));
-vpp->deinterlace_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING;
-vpp->deinterlace_conf.Header.BufferSz = sizeof(mfxExtVPPDeinterlacing);
-vpp->deinterlace_conf.Mode = vpp->deinterlace == 1 ?
- MFX_DEINTERLACING_BOB : 
MFX_DEINTERLACING_ADVANCED;
+#define INIT_MFX_EXTBUF(extbuf, id) do { \
+memset(&vpp->extbuf, 0, sizeof(vpp->extbuf)); \
+vpp->extbuf.Header.BufferId = id; \
+vpp->extbuf.Header.BufferSz = sizeof(vpp->extbuf); \
+param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->extbuf; \
+} while (0)
+
+#define SET_MFX_PARAM_FIELD(extbuf, field, value) do { \
+vpp->extbuf.field = value; \
+} while (0)
 
-param.ext_buf[param.num_ext_buf++] = 
(mfxExtBuffer*)&vpp->deinterlace_conf;
+if (vpp->deinterlace) {
+INIT_MFX_EXTBUF(deinterlace_conf, MFX_EXTBUFF_VPP_DEINTERLACING);
+SET_MFX_PARAM_FIELD(deinterlace_conf, Mode, (vpp->deinterlace == 1 ?
+MFX_DEINTERLACING_BOB : 
MFX_DEINTERLACING_ADVANCED));
 }
 
 if (vpp->use_frc) {
-memset(&vpp->frc_conf, 0, sizeof(mfxExtVPPFrameRateConversion));
-vpp->frc_conf.Header.BufferId = MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION;
-vpp->frc_conf.Header.BufferSz = sizeof(mfxExtVPPFrameRateConversion);
-vpp->frc_conf.Algorithm = MFX_FRCALGM_DISTRIBUTED_TIMESTAMP;
-
-param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->frc_conf;
+INIT_MFX_EXTBUF(frc_conf, MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION);
+SET_MFX_PARAM_FIELD(frc_conf, Algorithm, 
MFX_FRCALGM_DISTRIBUTED_TIMESTAMP);
 }
 
 if (vpp->denoise) {
-memset(&vpp->denoise_conf, 0, sizeof(mfxExtVPPDenoise));
-vpp->denoise_conf.Header.BufferId = MFX_EXTBUFF_VPP_DENOISE;
-vpp->denoise_conf.Header.BufferSz = sizeof(mfxExtVPPDenoise);
-vpp->denoise_conf.DenoiseFactor   = vpp->denoise;
-
-param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->denoise_conf;
+INIT_MFX_EXTBUF(denoise_conf, MFX_EXTBUFF_VPP_DENOISE);
+SET_MFX_PARAM_FIELD(denoise_conf, DenoiseFactor, vpp->denoise);
 }
 
 if (vpp->detail) {
-memset(&vpp->detail_conf, 0, sizeof(mfxExtVPPDetail));
-vpp->detail_conf.Header.BufferId  = MFX_EXTBUFF_VPP_DETAIL;
-vpp->detail_conf.Header.BufferSz  = sizeof(mfxExtVPPDetail);
-vpp->detail_conf.DetailFactor = vpp->detail;
-
-param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->detail_conf;
+INIT_MFX_EXTBUF(detail_conf, MFX_EXTBUFF_VPP_DETAIL);
+SET_MFX_PARAM_FIELD(detail_conf, DetailFactor, vpp->detail);
 }
 
 if (vpp->procamp) {
-memset(&vpp->procamp_conf, 0, sizeof(mfxExtVPPProcAmp));
-vpp->procamp_conf.Header.BufferId  = MFX_EXTBUFF_VPP_PROCAMP;
-vpp->procamp_conf.Header.BufferSz  = sizeof(mfxExtVPPProcAmp);
-vpp->procamp_conf.Hue  = vpp->hue;
-vpp->procamp_conf.Saturation   = vpp->saturation;
-vpp->procamp_conf.Contrast = vpp->contrast;
-vpp->procamp_conf.Brightness   = vpp->brightness;
-
-param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->procamp_conf;
+INIT_MFX_EXTBUF(procamp_conf, MFX_EXTBUFF_VPP_PROCAMP);
+SET_MFX_PARAM_FIELD(procamp_conf, Hue, vpp->hue);
+SET_MFX_PARAM_FIELD(procamp_conf, Saturation, vpp->saturation);
+SET_MFX_PARAM_FIELD(procamp_conf, Contrast, vpp->contrast);
+SET_MFX_PARAM_FIELD(procamp_conf, Brightness, vpp->brightness);
 }
 
 if (vpp->transpose >= 0) {
@@ -472,18 +463,14 @@ static int config_output(AVFilterLink *outlink)
 
 if (vpp->rotate) {
 #ifdef QSV_HAVE_ROTATION
-memset(&vpp->rotation_conf, 0, sizeof(mfxExtVPPRotation));
-vpp->rotation_conf.Header.BufferId  = MFX_EXTBUFF_VPP_ROTATION;
-vpp->rotation_conf.Header.BufferSz  = sizeof(mfxExtVPPRotation);
-vpp->rotation_conf.Angle = vpp->rotate;
+INIT_MFX_EXTBUF(rotation_conf, MFX_EXTBUFF_VPP_ROTATION);
+SET_MFX_PARAM_FIELD(rotation_conf, Angle, vpp->rotate);
 
 if (MFX_ANGLE_90 == vpp->rotate || MFX_ANGLE_270 == vpp->rotate) {
 FFSWAP(int, vpp->out_width, vpp->out_height);
 FFSWAP(int, outlink->w, outlink->h);
 av_log(ctx, AV_LOG_DEBUG, "Swap width and height for clock/cclock 

[FFmpeg-devel] [PATCH v5 11/20] lavfi/vpp_qsv: factor common QSV filter definition

2021-08-05 Thread Haihao Xiang
---
 libavfilter/vf_vpp_qsv.c | 223 ++-
 1 file changed, 100 insertions(+), 123 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 43465f3276..e9a802d507 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -104,55 +104,6 @@ typedef struct VPPContext{
 char *output_format_str;
 } VPPContext;
 
-static const AVOption options[] = {
-{ "deinterlace", "deinterlace mode: 0=off, 1=bob, 2=advanced", 
OFFSET(deinterlace), AV_OPT_TYPE_INT,  { .i64 = 0 }, 0, 
MFX_DEINTERLACING_ADVANCED, .flags = FLAGS, "deinterlace" },
-{ "bob", "Bob deinterlace mode.",  0,  
 AV_OPT_TYPE_CONST,{ .i64 = MFX_DEINTERLACING_BOB },
.flags = FLAGS, "deinterlace" },
-{ "advanced","Advanced deinterlace mode. ",0,  
 AV_OPT_TYPE_CONST,{ .i64 = MFX_DEINTERLACING_ADVANCED },   
.flags = FLAGS, "deinterlace" },
-
-{ "denoise", "denoise level [0, 100]",   OFFSET(denoise), 
AV_OPT_TYPE_INT,  { .i64 = 0 }, 0, 100, .flags = FLAGS },
-{ "detail",  "enhancement level [0, 100]",   OFFSET(detail),  
AV_OPT_TYPE_INT,  { .i64 = 0 }, 0, 100, .flags = FLAGS },
-{ "framerate",   "output framerate", OFFSET(framerate),   
AV_OPT_TYPE_RATIONAL, { .dbl = 0.0 },0, DBL_MAX, .flags = FLAGS },
-{ "procamp", "Enable ProcAmp",   OFFSET(procamp), 
AV_OPT_TYPE_INT,  { .i64 = 0 }, 0, 1, .flags = FLAGS},
-{ "hue", "ProcAmp hue",  OFFSET(hue), 
AV_OPT_TYPE_FLOAT,{ .dbl = 0.0 }, -180.0, 180.0, .flags = FLAGS},
-{ "saturation",  "ProcAmp saturation",   OFFSET(saturation),  
AV_OPT_TYPE_FLOAT,{ .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
-{ "contrast","ProcAmp contrast", OFFSET(contrast),
AV_OPT_TYPE_FLOAT,{ .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
-{ "brightness",  "ProcAmp brightness",   OFFSET(brightness),  
AV_OPT_TYPE_FLOAT,{ .dbl = 0.0 }, -100.0, 100.0, .flags = FLAGS},
-
-{ "transpose",  "set transpose direction",   OFFSET(transpose),   
AV_OPT_TYPE_INT,  { .i64 = -1 }, -1, 6, FLAGS, "transpose"},
-{ "cclock_hflip",  "rotate counter-clockwise with horizontal flip",  
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = 
"transpose" },
-{ "clock", "rotate clockwise",   
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK   }, .flags=FLAGS, .unit = 
"transpose" },
-{ "cclock","rotate counter-clockwise",   
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK  }, .flags=FLAGS, .unit = 
"transpose" },
-{ "clock_hflip",   "rotate clockwise with horizontal flip",  
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = 
"transpose" },
-{ "reversal",  "rotate by half-turn",
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL}, .flags=FLAGS, .unit = 
"transpose" },
-{ "hflip", "flip horizontally",  
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP   }, .flags=FLAGS, .unit = 
"transpose" },
-{ "vflip", "flip vertically",
0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP   }, .flags=FLAGS, .unit = 
"transpose" },
-
-{ "cw",   "set the width crop area expression",   OFFSET(cw), 
AV_OPT_TYPE_STRING, { .str = "iw" }, 0, 0, FLAGS },
-{ "ch",   "set the height crop area expression",  OFFSET(ch), 
AV_OPT_TYPE_STRING, { .str = "ih" }, 0, 0, FLAGS },
-{ "cx",   "set the x crop area expression",   OFFSET(cx), 
AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS },
-{ "cy",   "set the y crop area expression",   OFFSET(cy), 
AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS },
-
-{ "w",  "Output video width(0=input video width, -1=keep input video 
aspect)",  OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = 
FLAGS },
-{ "width",  "Output video width(0=input video width, -1=keep input video 
aspect)",  OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = 
FLAGS },
-{ "h",  "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = 
FLAGS },
-{ "height", "Output video height(0=input video height, -1=keep input video 
aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = 
FLAGS },
-{ "format", "Output pixel format", OFFSET(output_format_str), 
AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
-{ "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, .flags = FLAGS },
-#if QSV_HAVE_SCALING_CO

[FFmpeg-devel] [PATCH v5 13/20] lavfi/scale_qsv: add more input / output pixel formats

2021-08-05 Thread Haihao Xiang
NV12 and P010 are added

$ ffmpeg -init_hw_device qsv -c:v h264_qsv -i input.h264 -vf
"scale_qsv=format=p010" -f null -
---
 libavfilter/vf_vpp_qsv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index d72ddad517..c642d4e2a4 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -674,7 +674,10 @@ DEFINE_QSV_FILTER(vpp, vpp, "VPP");
 static int qsvscale_query_formats(AVFilterContext *ctx)
 {
 static const enum AVPixelFormat pixel_formats[] = {
-AV_PIX_FMT_QSV, AV_PIX_FMT_NONE,
+AV_PIX_FMT_NV12,
+AV_PIX_FMT_P010,
+AV_PIX_FMT_QSV,
+AV_PIX_FMT_NONE,
 };
 AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 14/20] lavfi/qsvvpp: avoid overriding the returned value

2021-08-05 Thread Haihao Xiang
Currently the returned value from MFXVideoVPP_RunFrameVPPAsync() is
overridden, so the check of 'ret == MFX_ERR_MORE_SURFACE' is always
false when MFX_ERR_MORE_SURFACE is returned from
MFXVideoVPP_RunFrameVPPAsync()
---
 libavfilter/qsvvpp.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 5b0b30e23c..82a8e29387 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -787,7 +787,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 AVFilterLink *outlink = ctx->outputs[0];
 mfxSyncPoint  sync;
 QSVFrame *in_frame, *out_frame, *tmp;
-int   ret, filter_ret;
+int   ret, ret1, filter_ret;
 
 while (s->eof && qsv_fifo_size(s->async_fifo)) {
 av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL);
@@ -849,8 +849,13 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 av_fifo_generic_read(s->async_fifo, &sync, sizeof(sync), NULL);
 
 do {
-ret = MFXVideoCORE_SyncOperation(s->session, sync, 1000);
-} while (ret == MFX_WRN_IN_EXECUTION);
+ret1 = MFXVideoCORE_SyncOperation(s->session, sync, 1000);
+} while (ret1 == MFX_WRN_IN_EXECUTION);
+
+if (ret1 < 0) {
+ret = ret1;
+break;
+}
 
 filter_ret = s->filter_frame(outlink, tmp->frame);
 if (filter_ret < 0) {
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 15/20] lavfi/qsvvpp: set PTS for output frame

2021-08-05 Thread Haihao Xiang
When the SDK returns MFX_ERR_MORE_SURFACE, the PTS is not set for the
output frame. We assign a PTS calculated from the input frame to the
output frame. After applying this patch, we may avoid the error below:

[null @ 0x56395cab4ae0] Application provided invalid, non monotonically
increasing dts to muxer in stream 0: 456 >= 0

Note this patch only fixes PTS issue when deinterlacing is enabled
---
 libavfilter/qsvvpp.c | 21 +++--
 libavfilter/qsvvpp.h |  3 +++
 libavfilter/vf_vpp_qsv.c |  2 ++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 82a8e29387..01d9d754d3 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -653,6 +653,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam 
*param)
 int ret;
 QSVVPPContext *s = avctx->priv;
 
+s->last_in_pts   = AV_NOPTS_VALUE;
 s->filter_frame  = param->filter_frame;
 if (!s->filter_frame)
 s->filter_frame = ff_filter_frame;
@@ -769,6 +770,8 @@ int ff_qsvvpp_close(AVFilterContext *avctx)
 s->session = NULL;
 }
 
+s->last_in_pts = AV_NOPTS_VALUE;
+
 /* release all the resources */
 clear_frame_list(&s->in_frame_list);
 clear_frame_list(&s->out_frame_list);
@@ -788,6 +791,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 mfxSyncPoint  sync;
 QSVFrame *in_frame, *out_frame, *tmp;
 int   ret, ret1, filter_ret;
+int64_t   dpts = 0;
 
 while (s->eof && qsv_fifo_size(s->async_fifo)) {
 av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL);
@@ -836,8 +840,19 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 ret = AVERROR(EAGAIN);
 break;
 }
-out_frame->frame->pts = av_rescale_q(out_frame->surface.Data.TimeStamp,
- default_tb, outlink->time_base);
+
+/* TODO: calculate the PTS for other cases */
+if (s->deinterlace_enabled &&
+s->last_in_pts != AV_NOPTS_VALUE &&
+ret == MFX_ERR_MORE_SURFACE &&
+out_frame->surface.Data.TimeStamp == MFX_TIMESTAMP_UNKNOWN)
+dpts = (in_frame->frame->pts - s->last_in_pts) / 2;
+else
+dpts = 0;
+
+out_frame->frame->pts = av_rescale_q(in_frame->frame->pts - dpts,
+ inlink->time_base,
+ outlink->time_base);
 
 out_frame->queued++;
 av_fifo_generic_write(s->async_fifo, &out_frame, sizeof(out_frame), 
NULL);
@@ -870,5 +885,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 }
 } while(ret == MFX_ERR_MORE_SURFACE);
 
+s->last_in_pts = in_frame->frame->pts;
+
 return ret;
 }
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index b6fe0d3fa7..8627c8c868 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -74,8 +74,11 @@ typedef struct QSVVPPContext {
 int got_frame;
 int async_depth;
 int eof;
+int deinterlace_enabled;
 /** order with frame_out, sync */
 AVFifoBuffer *async_fifo;
+
+int64_t last_in_pts;
 } QSVVPPContext;
 
 typedef struct QSVVPPCrop {
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index c642d4e2a4..3eddefea31 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -364,6 +364,8 @@ static int config_output(AVFilterLink *outlink)
 vpp->extbuf.field = value; \
 } while (0)
 
+vpp->qsv.deinterlace_enabled = !!vpp->deinterlace;
+
 if (vpp->deinterlace) {
 INIT_MFX_EXTBUF(deinterlace_conf, MFX_EXTBUFF_VPP_DEINTERLACING);
 SET_MFX_PARAM_FIELD(deinterlace_conf, Mode, (vpp->deinterlace == 1 ?
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 17/20] lavfi/deinterlace_qsv: simplify deinterlace_qsv filter

2021-08-05 Thread Haihao Xiang
Like what we did for scale_qsv filter, we use QSVVPPContext as a base
context to manage MFX session for deinterlace_qsv filter
---
 libavfilter/vf_deinterlace_qsv.c | 492 ++-
 1 file changed, 30 insertions(+), 462 deletions(-)

diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 3c2d87c7c8..50ff553e6a 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -42,34 +42,10 @@
 #include "internal.h"
 #include "video.h"
 
-enum {
-QSVDEINT_MORE_OUTPUT = 1,
-QSVDEINT_MORE_INPUT,
-};
-
 typedef struct QSVDeintContext {
-const AVClass *class;
-
-AVBufferRef *hw_frames_ctx;
-/* a clone of the main session, used internally for deinterlacing */
-mfxSession   session;
-
-mfxMemId *mem_ids;
-intnb_mem_ids;
-
-mfxFrameSurface1 **surface_ptrs;
-int nb_surface_ptrs;
+QSVVPPContext qsv;
 
-mfxExtOpaqueSurfaceAlloc opaque_alloc;
-mfxExtVPPDeinterlacing   deint_conf;
-mfxExtBuffer*ext_buffers[2];
-int  num_ext_buffers;
-
-QSVFrame *work_frames;
-
-int64_t last_pts;
-
-int eof;
+mfxExtVPPDeinterlacing deint_conf;
 
 /* option for Deinterlacing algorithm to be used */
 int mode;
@@ -77,28 +53,7 @@ typedef struct QSVDeintContext {
 
 static av_cold void qsvdeint_uninit(AVFilterContext *ctx)
 {
-QSVDeintContext *s = ctx->priv;
-QSVFrame *cur;
-
-if (s->session) {
-MFXClose(s->session);
-s->session = NULL;
-}
-av_buffer_unref(&s->hw_frames_ctx);
-
-cur = s->work_frames;
-while (cur) {
-s->work_frames = cur->next;
-av_frame_free(&cur->frame);
-av_freep(&cur);
-cur = s->work_frames;
-}
-
-av_freep(&s->mem_ids);
-s->nb_mem_ids = 0;
-
-av_freep(&s->surface_ptrs);
-s->nb_surface_ptrs = 0;
+ff_qsvvpp_close(ctx);
 }
 
 static int qsvdeint_query_formats(AVFilterContext *ctx)
@@ -115,441 +70,54 @@ static int qsvdeint_query_formats(AVFilterContext *ctx)
 return 0;
 }
 
-static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
- mfxFrameAllocResponse *resp)
-{
-AVFilterContext *ctx = pthis;
-QSVDeintContext   *s = ctx->priv;
-
-if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) ||
-!(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
-!(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
-return MFX_ERR_UNSUPPORTED;
-
-resp->mids   = s->mem_ids;
-resp->NumFrameActual = s->nb_mem_ids;
-
-return MFX_ERR_NONE;
-}
-
-static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
-{
-return MFX_ERR_NONE;
-}
-
-static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
-{
-return MFX_ERR_UNSUPPORTED;
-}
-
-static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
-{
-return MFX_ERR_UNSUPPORTED;
-}
-
-static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
-{
-*hdl = mid;
-return MFX_ERR_NONE;
-}
-
-static const mfxHandleType handle_types[] = {
-MFX_HANDLE_VA_DISPLAY,
-MFX_HANDLE_D3D9_DEVICE_MANAGER,
-MFX_HANDLE_D3D11_DEVICE,
-};
-
-static int init_out_session(AVFilterContext *ctx)
-{
-
-QSVDeintContext  *s = ctx->priv;
-AVHWFramesContext*hw_frames_ctx = 
(AVHWFramesContext*)s->hw_frames_ctx->data;
-AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx;
-AVQSVDeviceContext*device_hwctx = hw_frames_ctx->device_ctx->hwctx;
-
-int opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
-
-mfxHDL handle = NULL;
-mfxHandleType handle_type;
-mfxVersion ver;
-mfxIMPL impl;
-mfxVideoParam par;
-mfxStatus err;
-int i;
-
-/* extract the properties of the "master" session given to us */
-err = MFXQueryIMPL(device_hwctx->session, &impl);
-if (err == MFX_ERR_NONE)
-err = MFXQueryVersion(device_hwctx->session, &ver);
-if (err != MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_ERROR, "Error querying the session attributes\n");
-return AVERROR_UNKNOWN;
-}
-
-for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) {
-err = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], 
&handle);
-if (err == MFX_ERR_NONE) {
-handle_type = handle_types[i];
-break;
-}
-}
-
-if (err < 0)
-return ff_qsvvpp_print_error(ctx, err, "Error getting the session 
handle");
-else if (err > 0) {
-ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session 
handle");
-return AVERROR_UNKNOWN;
-}
-
-/* create a "slave" session with those same properties, to be used for
- * actual deinterlacing */
-err = MFXInit(impl, &ver, &s->session);
-if (err < 0)
-return ff_qsvvpp_print_error(ctx, err, "Error initializing a session 
for

[FFmpeg-devel] [PATCH v5 19/20] lavfi/deinterlace_qsv: add async_depth option

2021-08-05 Thread Haihao Xiang
Allow user to set async depth for deinterlace_qsv
---
 libavfilter/vf_vpp_qsv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 518595d91e..edd10f5af6 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -730,6 +730,7 @@ static const AVOption qsvdeint_options[] = {
 { "field", "Output at field rate (one frame of output for each field)",
   0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "rate" },
 
+{ "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, .flags = FLAGS },
 { NULL },
 };
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 18/20] lavfi/deinterlace_qsv: re-use VPPContext for deinterlace_qsv filter

2021-08-05 Thread Haihao Xiang
All features are implemented in vpp_qsv filter now, so deinterlace_qsv
can be taken as a specical case of vpp_qsv filter, we re-use VPPContext
with a different option array and pix formats for deinterlace_qsv filter

A new option -rate is used to control the output frame rate, by default
it will output frame for each field
---
 libavfilter/Makefile |   2 +-
 libavfilter/vf_deinterlace_qsv.c | 179 ---
 libavfilter/vf_vpp_qsv.c |  35 +-
 3 files changed, 35 insertions(+), 181 deletions(-)
 delete mode 100644 libavfilter/vf_deinterlace_qsv.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 760099ba2c..dafd0c610c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -230,7 +230,7 @@ OBJS-$(CONFIG_DECONVOLVE_FILTER) += 
vf_convolve.o framesync.o
 OBJS-$(CONFIG_DEDOT_FILTER)  += vf_dedot.o
 OBJS-$(CONFIG_DEFLATE_FILTER)+= vf_neighbor.o
 OBJS-$(CONFIG_DEFLICKER_FILTER)  += vf_deflicker.o
-OBJS-$(CONFIG_DEINTERLACE_QSV_FILTER)+= vf_deinterlace_qsv.o
+OBJS-$(CONFIG_DEINTERLACE_QSV_FILTER)+= vf_vpp_qsv.o
 OBJS-$(CONFIG_DEINTERLACE_VAAPI_FILTER)  += vf_deinterlace_vaapi.o 
vaapi_vpp.o
 OBJS-$(CONFIG_DEJUDDER_FILTER)   += vf_dejudder.o
 OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
deleted file mode 100644
index 50ff553e6a..00
--- a/libavfilter/vf_deinterlace_qsv.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * deinterlace video filter - QSV
- */
-
-#include 
-
-#include 
-#include 
-
-#include "libavutil/avstring.h"
-#include "libavutil/common.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_qsv.h"
-#include "libavutil/internal.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/time.h"
-#include "libavfilter/qsvvpp.h"
-
-#include "avfilter.h"
-#include "formats.h"
-#include "internal.h"
-#include "video.h"
-
-typedef struct QSVDeintContext {
-QSVVPPContext qsv;
-
-mfxExtVPPDeinterlacing deint_conf;
-
-/* option for Deinterlacing algorithm to be used */
-int mode;
-} QSVDeintContext;
-
-static av_cold void qsvdeint_uninit(AVFilterContext *ctx)
-{
-ff_qsvvpp_close(ctx);
-}
-
-static int qsvdeint_query_formats(AVFilterContext *ctx)
-{
-static const enum AVPixelFormat pixel_formats[] = {
-AV_PIX_FMT_QSV, AV_PIX_FMT_NONE,
-};
-AVFilterFormats *pix_fmts  = ff_make_format_list(pixel_formats);
-int ret;
-
-if ((ret = ff_set_common_formats(ctx, pix_fmts)) < 0)
-return ret;
-
-return 0;
-}
-
-static int qsvdeint_config_props(AVFilterLink *outlink)
-{
-AVFilterContext *ctx = outlink->src;
-AVFilterLink *inlink = ctx->inputs[0];
-QSVDeintContext   *s = ctx->priv;
-QSVVPPParamparam = { NULL };
-mfxExtBuffer *ext_buf[1];
-enum AVPixelFormat in_format;
-
-qsvdeint_uninit(ctx);
-
-outlink->w  = inlink->w;
-outlink->h  = inlink->h;
-outlink->frame_rate = av_mul_q(inlink->frame_rate,
-   (AVRational){ 2, 1 });
-outlink->time_base  = av_mul_q(inlink->time_base,
-   (AVRational){ 1, 2 });
-
-if (inlink->format == AV_PIX_FMT_QSV) {
-if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data)
-return AVERROR(EINVAL);
-else
-in_format = 
((AVHWFramesContext*)inlink->hw_frames_ctx->data)->sw_format;
-} else
-in_format = inlink->format;
-
-param.out_sw_format = in_format;
-param.ext_buf   = ext_buf;
-
-memset(&s->deint_conf, 0, sizeof(mfxExtVPPDeinterlacing));
-s->deint_conf.Header.BufferId  = MFX_EXTBUFF_VPP_DEINTERLACING;
-s->deint_conf.Header.BufferSz  = sizeof(s->deint_conf);
-s->deint_conf.Mode = s->mode;
-param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&s->deint_conf;
-
-return ff_qsvvpp_init(ctx, ¶m);
-}
-
-static int qsvdeint_filter_frame(AVFilterLink *link, AVFrame *in)
-{
-AVFilterContext  *ctx = link->dst

[FFmpeg-devel] [PATCH v5 16/20] lavfi/vpp_qsv: check output format string against NULL pointer

2021-08-05 Thread Haihao Xiang
This is in preparation for re-using VPPContext but with a different
option array for deinterlacing_qsv filter
---
 libavfilter/vf_vpp_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 3eddefea31..f7854f81bf 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -234,7 +234,7 @@ static av_cold int vpp_init(AVFilterContext *ctx)
 {
 VPPContext  *vpp  = ctx->priv;
 
-if (!strcmp(vpp->output_format_str, "same")) {
+if (!vpp->output_format_str || !strcmp(vpp->output_format_str, "same")) {
 vpp->out_format = AV_PIX_FMT_NONE;
 } else {
 vpp->out_format = av_get_pix_fmt(vpp->output_format_str);
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH v5 20/20] lavfi/deinterlace_qsv: add more input / output pixel formats

2021-08-05 Thread Haihao Xiang
NV12 is added in system memory and the command below may work now.

$ ffmpeg -init_hw_device qsv -c:v h264_qsv -i input.h264 -vf
deinterlace_qsv -f null -
---
 libavfilter/vf_vpp_qsv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index edd10f5af6..619d530745 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -737,7 +737,9 @@ static const AVOption qsvdeint_options[] = {
 static int qsvdeint_query_formats(AVFilterContext *ctx)
 {
 static const enum AVPixelFormat pixel_formats[] = {
-AV_PIX_FMT_QSV, AV_PIX_FMT_NONE,
+AV_PIX_FMT_NV12,
+AV_PIX_FMT_QSV,
+AV_PIX_FMT_NONE,
 };
 AVFilterFormats *pix_fmts  = ff_make_format_list(pixel_formats);
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/3] checkasm: collapse hevc pel tests

2021-08-05 Thread J. Dekker
Also add to `make fate-checkasm' target.

Signed-off-by: J. Dekker 
---
 tests/checkasm/checkasm.c | 11 +--
 tests/checkasm/checkasm.h | 11 +--
 tests/checkasm/hevc_pel.c | 34 --
 tests/fate/checkasm.mak   |  1 +
 4 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index be5c17cd2a..b1353f7cbe 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -116,16 +116,7 @@ static const struct {
 #if CONFIG_HEVC_DECODER
 { "hevc_add_res", checkasm_check_hevc_add_res },
 { "hevc_idct", checkasm_check_hevc_idct },
-{ "hevc_qpel", checkasm_check_hevc_qpel },
-{ "hevc_qpel_uni", checkasm_check_hevc_qpel_uni },
-{ "hevc_qpel_uni_w", checkasm_check_hevc_qpel_uni_w },
-{ "hevc_qpel_bi", checkasm_check_hevc_qpel_bi },
-{ "hevc_qpel_bi_w", checkasm_check_hevc_qpel_bi_w },
-{ "hevc_epel", checkasm_check_hevc_epel },
-{ "hevc_epel_uni", checkasm_check_hevc_epel_uni },
-{ "hevc_epel_uni_w", checkasm_check_hevc_epel_uni_w },
-{ "hevc_epel_bi", checkasm_check_hevc_epel_bi },
-{ "hevc_epel_bi_w", checkasm_check_hevc_epel_bi_w },
+{ "hevc_pel", checkasm_check_hevc_pel },
 { "hevc_sao", checkasm_check_hevc_sao },
 #endif
 #if CONFIG_HUFFYUV_DECODER
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index b747ed1986..68b0697d3e 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -61,16 +61,7 @@ void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
 void checkasm_check_hevc_add_res(void);
 void checkasm_check_hevc_idct(void);
-void checkasm_check_hevc_qpel(void);
-void checkasm_check_hevc_qpel_uni(void);
-void checkasm_check_hevc_qpel_uni_w(void);
-void checkasm_check_hevc_qpel_bi(void);
-void checkasm_check_hevc_qpel_bi_w(void);
-void checkasm_check_hevc_epel(void);
-void checkasm_check_hevc_epel_uni(void);
-void checkasm_check_hevc_epel_uni_w(void);
-void checkasm_check_hevc_epel_bi(void);
-void checkasm_check_hevc_epel_bi_w(void);
+void checkasm_check_hevc_pel(void);
 void checkasm_check_hevc_sao(void);
 void checkasm_check_huffyuvdsp(void);
 void checkasm_check_jpeg2000dsp(void);
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
index 4d1545e467..ec24309081 100644
--- a/tests/checkasm/hevc_pel.c
+++ b/tests/checkasm/hevc_pel.c
@@ -65,7 +65,7 @@ static const int offsets[] = {0, 255, -1 };
 #define src0 (buf0 + 2 * 4 * MAX_PB_SIZE) /* hevc qpel functions read data 
from negative src pointer offsets */
 #define src1 (buf1 + 2 * 4 * MAX_PB_SIZE)
 
-void checkasm_check_hevc_qpel(void)
+static void checkasm_check_hevc_qpel(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -109,7 +109,7 @@ void checkasm_check_hevc_qpel(void)
 report("qpel");
 }
 
-void checkasm_check_hevc_qpel_uni(void)
+static void checkasm_check_hevc_qpel_uni(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -150,7 +150,7 @@ void checkasm_check_hevc_qpel_uni(void)
 report("qpel_uni");
 }
 
-void checkasm_check_hevc_qpel_uni_w(void)
+static void checkasm_check_hevc_qpel_uni_w(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -198,7 +198,7 @@ void checkasm_check_hevc_qpel_uni_w(void)
 report("qpel_uni_w");
 }
 
-void checkasm_check_hevc_qpel_bi(void)
+static void checkasm_check_hevc_qpel_bi(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -242,7 +242,7 @@ void checkasm_check_hevc_qpel_bi(void)
 report("qpel_bi");
 }
 
-void checkasm_check_hevc_qpel_bi_w(void)
+static void checkasm_check_hevc_qpel_bi_w(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -294,7 +294,7 @@ void checkasm_check_hevc_qpel_bi_w(void)
 report("qpel_bi_w");
 }
 
-void checkasm_check_hevc_epel(void)
+static void checkasm_check_hevc_epel(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -338,7 +338,7 @@ void checkasm_check_hevc_epel(void)
 report("epel");
 }
 
-void checkasm_check_hevc_epel_uni(void)
+static void checkasm_check_hevc_epel_uni(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -379,7 +379,7 @@ void checkasm_check_hevc_epel_uni(void)
 report("epel_uni");
 }
 
-void checkasm_check_hevc_epel_uni_w(void)
+static void checkasm_check_hevc_epel_uni_w(void)
 {
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
@@ -427,7 +427,7 @@ void checkasm_check_hevc_epel_uni_w(void)
 report("epel_uni_w");
 }
 
-void checkasm_check_hevc_epel_bi(void)
+static void checkasm_che

[FFmpeg-devel] [PATCH 2/3] checkasm: add h264 chroma test

2021-08-05 Thread J. Dekker
Signed-off-by: J. Dekker 
---
 tests/checkasm/Makefile |   1 +
 tests/checkasm/checkasm.c   |   3 +
 tests/checkasm/checkasm.h   |   1 +
 tests/checkasm/h264chroma.c | 109 
 tests/fate/checkasm.mak |   1 +
 5 files changed, 115 insertions(+)
 create mode 100644 tests/checkasm/h264chroma.c

What should I do for other codecs here, or just ignore non-h264?

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 4ef5fa87da..41222c3827 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -6,6 +6,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
 AVCODECOBJS-$(CONFIG_FLACDSP)   += flacdsp.o
 AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
 AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
+AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
 AVCODECOBJS-$(CONFIG_H264DSP)   += h264dsp.o
 AVCODECOBJS-$(CONFIG_H264PRED)  += h264pred.o
 AVCODECOBJS-$(CONFIG_H264QPEL)  += h264qpel.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b1353f7cbe..154c4a5c01 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -104,6 +104,9 @@ static const struct {
 #if CONFIG_G722DSP
 { "g722dsp", checkasm_check_g722dsp },
 #endif
+#if CONFIG_H264CHROMA
+{ "h264chroma", checkasm_check_h264chroma },
+#endif
 #if CONFIG_H264DSP
 { "h264dsp", checkasm_check_h264dsp },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 68b0697d3e..ac2f22af05 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
 void checkasm_check_float_dsp(void);
 void checkasm_check_fmtconvert(void);
 void checkasm_check_g722dsp(void);
+void checkasm_check_h264chroma(void);
 void checkasm_check_h264dsp(void);
 void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
new file mode 100644
index 00..0bd27d
--- /dev/null
+++ b/tests/checkasm/h264chroma.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2015 Henrik Gramner
+ * Copyright (c) 2021 J. Dekker
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include "checkasm.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/h264chroma.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+// static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, 
AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 };
+static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_SIZE (3 * 16 * 17)
+
+#define randomize_buffers()\
+do {   \
+uint32_t mask = pixel_mask[bit_depth - 8]; \
+int i; \
+for (i = 0; i < BUF_SIZE; i += 4) {\
+uint32_t r = rnd() & mask; \
+AV_WN32A(buf0 + i, r); \
+AV_WN32A(buf1 + i, r); \
+}  \
+} while (0)
+
+#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */
+#define src1 (buf1 + 4 * 16)
+
+static void check_avg()
+{
+int i, bit_depth, x, y;
+LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
+H264ChromaContext h;
+
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, 
ptrdiff_t stride, int h, int x, int y);
+for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
+ff_h264chroma_init(&h, bit_depth);
+for (i = 0; i < 4; i++) {
+if (check_func(h.avg_h264_chroma_pixels_tab[i], 
"avg_chroma_mc%d_%d", 1 << (3 - i), bit_depth)) {
+randomize_buffers();
+x = rnd() & 0x7; y = rnd() & 0x7;
+call_ref(dst0, src0, 8, 4, x, y);
+call_new(dst1, src1, 8, 4, x, y);
+if (memcmp(buf0, buf1, B

[FFmpeg-devel] [PATCH 3/3] checkasm: add hevc_deblock tests

2021-08-05 Thread J. Dekker
Signed-off-by: J. Dekker 
---
 0001-checkasm-add-hevc_deblock-tests.patch | 186 +
 tests/checkasm/Makefile|   2 +-
 tests/checkasm/checkasm.c  |   1 +
 tests/checkasm/checkasm.h  |   1 +
 tests/checkasm/hevc_deblock.c  | 126 ++
 tests/fate/checkasm.mak|   1 +
 6 files changed, 316 insertions(+), 1 deletion(-)
 create mode 100644 0001-checkasm-add-hevc_deblock-tests.patch
 create mode 100644 tests/checkasm/hevc_deblock.c

diff --git a/0001-checkasm-add-hevc_deblock-tests.patch 
b/0001-checkasm-add-hevc_deblock-tests.patch
new file mode 100644
index 00..29441e53f6
--- /dev/null
+++ b/0001-checkasm-add-hevc_deblock-tests.patch
@@ -0,0 +1,186 @@
+From a8b2d2259cb8ca5e30b2efae8aa8813eaa768615 Mon Sep 17 00:00:00 2001
+From: "J. Dekker" 
+Date: Mon, 28 Jun 2021 04:46:49 +0200
+Subject: [PATCH] checkasm: add hevc_deblock tests
+
+Signed-off-by: J. Dekker 
+---
+ tests/checkasm/Makefile   |   2 +-
+ tests/checkasm/checkasm.c |   1 +
+ tests/checkasm/checkasm.h |   1 +
+ tests/checkasm/hevc_deblock.c | 126 ++
+ 4 files changed, 129 insertions(+), 1 deletion(-)
+ create mode 100644 tests/checkasm/hevc_deblock.c
+
+diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
+index 4ef5fa87da..481a96e36e 100644
+--- a/tests/checkasm/Makefile
 b/tests/checkasm/Makefile
+@@ -24,7 +24,7 @@ AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuvdsp.o
+ AVCODECOBJS-$(CONFIG_JPEG2000_DECODER)  += jpeg2000dsp.o
+ AVCODECOBJS-$(CONFIG_OPUS_DECODER)  += opusdsp.o
+ AVCODECOBJS-$(CONFIG_PIXBLOCKDSP)   += pixblockdsp.o
+-AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_idct.o 
hevc_sao.o hevc_pel.o
++AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_deblock.o 
hevc_idct.o hevc_sao.o hevc_pel.o
+ AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER)   += utvideodsp.o
+ AVCODECOBJS-$(CONFIG_V210_DECODER)  += v210dec.o
+ AVCODECOBJS-$(CONFIG_V210_ENCODER)  += v210enc.o
+diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
+index eb9e2cd677..1fe67007cc 100644
+--- a/tests/checkasm/checkasm.c
 b/tests/checkasm/checkasm.c
+@@ -115,6 +115,7 @@ static const struct {
+ #endif
+ #if CONFIG_HEVC_DECODER
+ { "hevc_add_res", checkasm_check_hevc_add_res },
++{ "hevc_deblock", checkasm_check_hevc_deblock },
+ { "hevc_idct", checkasm_check_hevc_idct },
+ { "hevc_qpel", checkasm_check_hevc_qpel },
+ { "hevc_qpel_uni", checkasm_check_hevc_qpel_uni },
+diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
+index b747ed1986..8ecb4f0cf0 100644
+--- a/tests/checkasm/checkasm.h
 b/tests/checkasm/checkasm.h
+@@ -60,6 +60,7 @@ void checkasm_check_h264dsp(void);
+ void checkasm_check_h264pred(void);
+ void checkasm_check_h264qpel(void);
+ void checkasm_check_hevc_add_res(void);
++void checkasm_check_hevc_deblock(void);
+ void checkasm_check_hevc_idct(void);
+ void checkasm_check_hevc_qpel(void);
+ void checkasm_check_hevc_qpel_uni(void);
+diff --git a/tests/checkasm/hevc_deblock.c b/tests/checkasm/hevc_deblock.c
+new file mode 100644
+index 00..98f612921b
+--- /dev/null
 b/tests/checkasm/hevc_deblock.c
+@@ -0,0 +1,126 @@
++/*
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License along
++ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++ */
++
++#include 
++
++#include "libavutil/intreadwrite.h"
++#include "libavutil/mem_internal.h"
++
++#include "libavcodec/avcodec.h"
++#include "libavcodec/hevcdsp.h"
++
++#include "checkasm.h"
++
++static const uint32_t pixel_mask[3] = { 0x, 0x03ff03ff, 0x0fff0fff };
++
++#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
++#define BUF_STRIDE (8 * 2)
++#define BUF_LINES (8)
++#define BUF_OFFSET (BUF_STRIDE * BUF_LINES)
++#define BUF_SIZE (BUF_STRIDE * BUF_LINES + BUF_OFFSET * 2)
++
++#define randomize_buffers(buf0, buf1, size) \
++do {\
++uint32_t mask = pixel_mask[(bit_depth - 8) >> 1];   \
++int k;  \
++for (k = 0; k < size; k += 4) { \
++uint32_t r = rnd() & mask;  \
++AV_WN32A(buf0 + k, r

[FFmpeg-devel] [PATCH] mxf : correct previous commit

2021-08-05 Thread Michael Krebs
* Let older tags on the same place as originally
* Add new fate tests for rawvideo and v210 and update checksum for mxf tests
---
 libavformat/mxfenc.c| 37 +++--
 tests/fate/lavf-container.mak   |  7 +
 tests/ref/fate/copy-trac4914|  2 +-
 tests/ref/fate/mxf-d10-user-comments|  2 +-
 tests/ref/fate/mxf-opatom-user-comments |  2 +-
 tests/ref/fate/mxf-reel_name|  2 +-
 tests/ref/fate/mxf-user-comments|  2 +-
 tests/ref/fate/time_base|  2 +-
 tests/ref/lavf/mxf  |  6 ++--
 tests/ref/lavf/mxf_d10  |  2 +-
 tests/ref/lavf/mxf_dv25 |  2 +-
 tests/ref/lavf/mxf_dvcpro50 |  2 +-
 tests/ref/lavf/mxf_opatom   |  2 +-
 tests/ref/lavf/mxf_opatom_audio |  2 +-
 tests/ref/lavf/mxf_rawvideo_uyvy422 |  3 ++
 tests/ref/lavf/mxf_rawvideo_yuv420p |  3 ++
 tests/ref/lavf/mxf_rawvideo_yuv422p |  3 ++
 tests/ref/lavf/mxf_rawvideo_yuyv422 |  3 ++
 tests/ref/lavf/mxf_v210 |  3 ++
 19 files changed, 59 insertions(+), 28 deletions(-)
 create mode 100644 tests/ref/lavf/mxf_rawvideo_uyvy422
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv420p
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv422p
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuyv422
 create mode 100644 tests/ref/lavf/mxf_v210

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index a2ec7b89d7..2f042a7dc4 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1122,7 +1122,9 @@ static inline uint32_t rescale_mastering_luma(AVRational 
q)
 return av_rescale(q.num, FF_MXF_MASTERING_LUMA_DEN, q.den);
 }
 
-static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const 
UID key)
+typedef void (*generic_desc_extra_tags_func)(AVFormatContext *, AVStream *, 
const UID, MXFStreamContext *, AVIOContext *, void*);
+
+static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const 
UID key, generic_desc_extra_tags_func write_extra_tags_func, void* 
extra_tags_func_context)
 {
 MXFStreamContext *sc = st->priv_data;
 AVIOContext *pb = s->pb;
@@ -1214,6 +1216,10 @@ static int64_t mxf_write_generic_desc(AVFormatContext 
*s, AVStream *st, const UI
 avio_wb32(pb, -((st->codecpar->height - display_height)&1));
 }
 
+if(write_extra_tags_func != NULL) {
+(*write_extra_tags_func)(s, st, key, sc, pb, extra_tags_func_context);
+}
+
 if (sc->signal_standard) {
 mxf_write_local_tag(s, 1, 0x3215);
 avio_w8(pb, sc->signal_standard);
@@ -1239,6 +1245,7 @@ static int64_t mxf_write_generic_desc(AVFormatContext *s, 
AVStream *st, const UI
 f1 *= 2;
 }
 
+
 mxf_write_local_tag(s, 16, 0x320D);
 avio_wb32(pb, 2);
 avio_wb32(pb, 4);
@@ -1310,12 +1317,8 @@ static int64_t mxf_write_generic_desc(AVFormatContext 
*s, AVStream *st, const UI
 return pos;
 }
 
-static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const 
UID key)
+static void mxf_write_extra_cdci_tags(AVFormatContext *s, AVStream *st, const 
UID key, MXFStreamContext *sc, AVIOContext *pb, void* extra_tags_func_context)
 {
-MXFStreamContext *sc = st->priv_data;
-AVIOContext *pb = s->pb;
-int64_t pos = mxf_write_generic_desc(s, st, key);
-
 // component depth
 mxf_write_local_tag(s, 4, 0x3301);
 avio_wb32(pb, sc->component_depth);
@@ -1352,8 +1355,11 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, 
AVStream *st, const UID
 mxf_write_local_tag(s, 4, 0x3306);
 avio_wb32(pb, color);
 }
+}
 
-return pos;
+static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const 
UID key)
+{
+return mxf_write_generic_desc(s, st, key, &mxf_write_extra_cdci_tags, 
NULL);
 }
 
 static void mxf_update_klv_size(AVIOContext *pb, int64_t pos)
@@ -1389,20 +1395,23 @@ static void mxf_write_avc_subdesc(AVFormatContext *s, 
AVStream *st)
 mxf_update_klv_size(s->pb, pos);
 }
 
+static void mxf_write_extra_rgba_tags(AVFormatContext *s, AVStream *st, const 
UID key, MXFStreamContext *sc, AVIOContext *pb, void* extra_tags_func_context)
+{
+const char* pixelLayoutData = extra_tags_func_context;
+
+// pixel layout
+mxf_write_local_tag(s, 16, 0x3401);
+avio_write(pb, pixelLayoutData, 16);
+}
+
 static void mxf_write_cdci_or_rgba_desc(AVFormatContext *s, AVStream *st)
 {
-AVIOContext *pb = s->pb;
 const char* pixelLayoutData = NULL;
 int64_t pos;
 
 if(ff_mxf_find_pixel_layout(&pixelLayoutData, st->codecpar->format) >= 0)
 {
-pos = mxf_write_generic_desc(s, st, mxf_rgba_descriptor_key);
-
-// pixel layout
-mxf_write_local_tag(s, 16, 0x3401);
-avio_write(pb, pixelLayoutData, 16);
-
+pos = mxf_write_generic_desc(s, st, mxf_rgba_descriptor_key, 
&mxf_write_extra_rgba_tags, (void*)pixelLayoutData);
 mxf_update_klv_size(s->pb, pos);
 return;
  

Re: [FFmpeg-devel] [PATCH v3 33/34] avdevice/dshow: prevent NULL access

2021-08-05 Thread Diederick C. Niehorster
On Tue, Aug 3, 2021 at 4:22 PM Andreas Rheinhardt
 wrote:
>
> Diederick Niehorster:
> > list_options true would crash when both a video and an audio device were
> > specified as input. Crash would occur on line 1588 (in this new rev)
> > because ctx->device_unique_name[otherDevType] would be NULL
> >
> > Signed-off-by: Diederick Niehorster 
> > ---
> >  libavdevice/dshow.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> > index f900e89988..a66f7b81fd 100644
> > --- a/libavdevice/dshow.c
> > +++ b/libavdevice/dshow.c
> > @@ -1519,9 +1519,9 @@ dshow_list_device_options(AVFormatContext *avctx, 
> > ICreateDevEnum *devenum,
> >  if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, 
> > &device_filter, &device_unique_name, NULL)) < 0)
> >  return r;
> >  ctx->device_filter[devtype] = device_filter;
> > +ctx->device_unique_name[devtype] = device_unique_name;
> >  if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, 
> > ranges ? &device_pin : NULL, ranges, query_type)) < 0)
> >  return r;
> > -av_freep(&device_unique_name);
> >  return 0;
> >  }
> >
> > @@ -2043,6 +2043,7 @@ static int dshow_read_header(AVFormatContext *avctx)
> >  }
> >  }
> >  }
> > +// don't exit yet, allow it to list crossbar options in 
> > dshow_open_device
> >  }
> >  ctx->is_running = 0;
> >  if (ctx->device_name[VideoDevice]) {
> >
> Is this an issue that can also happen on current git master? If so, then
> it should be the first of this whole series, so that it can be
> backported to the still supported release branches. If not, then you
> should incorporate this into the patch that introduces the crash in
> order to make sure that it never exists (we do not knowingly commit bugs).

Thanks for the comment! Yes, the crash it fixes also occurs with
current master, I'll make it the first patch in the series.

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

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


[FFmpeg-devel] [PATCH] avfilter/avfilter: add sample_count_in and sample_count_out

2021-08-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avfilter.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index b82f72d040..a71745283c 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -584,6 +584,11 @@ struct AVFilterLink {
  */
 int64_t frame_count_in, frame_count_out;
 
+/**
+ * Number of past samples sent through the link.
+ */
+int64_t sample_count_in, sample_count_out;
+
 /**
  * A pointer to a FFFramePool struct.
  */
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] avfilter/avfilter: add sample_count_in and sample_count_out

2021-08-05 Thread Nicolas George
Paul B Mahol (12021-08-05):
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avfilter.h | 5 +
>  1 file changed, 5 insertions(+)

Ok for the principle, but you seem to have forgotten to update
avfilter.c to make these fields useful.

Regards,

-- 
  Nicolas George


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

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


[FFmpeg-devel] [PATCH v2 2/3] checkasm: add h264 chroma test

2021-08-05 Thread J. Dekker
Signed-off-by: J. Dekker 
---
 tests/checkasm/Makefile |   1 +
 tests/checkasm/checkasm.c   |   3 +
 tests/checkasm/checkasm.h   |   1 +
 tests/checkasm/h264chroma.c | 109 
 tests/fate/checkasm.mak |   1 +
 5 files changed, 115 insertions(+)
 create mode 100644 tests/checkasm/h264chroma.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 4ef5fa87da..41222c3827 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -6,6 +6,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
 AVCODECOBJS-$(CONFIG_FLACDSP)   += flacdsp.o
 AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
 AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
+AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
 AVCODECOBJS-$(CONFIG_H264DSP)   += h264dsp.o
 AVCODECOBJS-$(CONFIG_H264PRED)  += h264pred.o
 AVCODECOBJS-$(CONFIG_H264QPEL)  += h264qpel.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b1353f7cbe..154c4a5c01 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -104,6 +104,9 @@ static const struct {
 #if CONFIG_G722DSP
 { "g722dsp", checkasm_check_g722dsp },
 #endif
+#if CONFIG_H264CHROMA
+{ "h264chroma", checkasm_check_h264chroma },
+#endif
 #if CONFIG_H264DSP
 { "h264dsp", checkasm_check_h264dsp },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 68b0697d3e..ac2f22af05 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
 void checkasm_check_float_dsp(void);
 void checkasm_check_fmtconvert(void);
 void checkasm_check_g722dsp(void);
+void checkasm_check_h264chroma(void);
 void checkasm_check_h264dsp(void);
 void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
new file mode 100644
index 00..1f9773e345
--- /dev/null
+++ b/tests/checkasm/h264chroma.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2015 Henrik Gramner
+ * Copyright (c) 2021 J. Dekker
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include "checkasm.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/h264chroma.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+// static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, 
AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 };
+static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_SIZE (3 * 16 * 17)
+
+#define randomize_buffers()\
+do {   \
+uint32_t mask = pixel_mask[bit_depth - 8]; \
+int i; \
+for (i = 0; i < BUF_SIZE; i += 4) {\
+uint32_t r = rnd() & mask; \
+AV_WN32A(buf0 + i, r); \
+AV_WN32A(buf1 + i, r); \
+}  \
+} while (0)
+
+#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */
+#define src1 (buf1 + 4 * 16)
+
+static void check_avg(void)
+{
+int i, bit_depth, x, y;
+LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
+H264ChromaContext h;
+
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, 
ptrdiff_t stride, int h, int x, int y);
+for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
+ff_h264chroma_init(&h, bit_depth);
+for (i = 0; i < 4; i++) {
+if (check_func(h.avg_h264_chroma_pixels_tab[i], 
"avg_chroma_mc%d_%d", 1 << (3 - i), bit_depth)) {
+randomize_buffers();
+x = rnd() & 0x7; y = rnd() & 0x7;
+call_ref(dst0, src0, 8, 4, x, y);
+call_new(dst1, src1, 8, 4, x, y);
+if (memcmp(buf0, buf1, BUF_SIZE))
+fail();
+bench_new(

[FFmpeg-devel] [PATCH v2 3/3] checkasm: add hevc_deblock tests

2021-08-05 Thread J. Dekker
Signed-off-by: J. Dekker 
---
 tests/checkasm/Makefile   |   2 +-
 tests/checkasm/checkasm.c |   1 +
 tests/checkasm/checkasm.h |   1 +
 tests/checkasm/hevc_deblock.c | 126 ++
 tests/fate/checkasm.mak   |   1 +
 5 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 tests/checkasm/hevc_deblock.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 41222c3827..862142d8e6 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -25,7 +25,7 @@ AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuvdsp.o
 AVCODECOBJS-$(CONFIG_JPEG2000_DECODER)  += jpeg2000dsp.o
 AVCODECOBJS-$(CONFIG_OPUS_DECODER)  += opusdsp.o
 AVCODECOBJS-$(CONFIG_PIXBLOCKDSP)   += pixblockdsp.o
-AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_idct.o 
hevc_sao.o hevc_pel.o
+AVCODECOBJS-$(CONFIG_HEVC_DECODER)  += hevc_add_res.o hevc_deblock.o 
hevc_idct.o hevc_sao.o hevc_pel.o
 AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER)   += utvideodsp.o
 AVCODECOBJS-$(CONFIG_V210_DECODER)  += v210dec.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER)  += v210enc.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 154c4a5c01..a1e8c4d92e 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -118,6 +118,7 @@ static const struct {
 #endif
 #if CONFIG_HEVC_DECODER
 { "hevc_add_res", checkasm_check_hevc_add_res },
+{ "hevc_deblock", checkasm_check_hevc_deblock },
 { "hevc_idct", checkasm_check_hevc_idct },
 { "hevc_pel", checkasm_check_hevc_pel },
 { "hevc_sao", checkasm_check_hevc_sao },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index ac2f22af05..386ecbf69a 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -61,6 +61,7 @@ void checkasm_check_h264dsp(void);
 void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
 void checkasm_check_hevc_add_res(void);
+void checkasm_check_hevc_deblock(void);
 void checkasm_check_hevc_idct(void);
 void checkasm_check_hevc_pel(void);
 void checkasm_check_hevc_sao(void);
diff --git a/tests/checkasm/hevc_deblock.c b/tests/checkasm/hevc_deblock.c
new file mode 100644
index 00..98f612921b
--- /dev/null
+++ b/tests/checkasm/hevc_deblock.c
@@ -0,0 +1,126 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/hevcdsp.h"
+
+#include "checkasm.h"
+
+static const uint32_t pixel_mask[3] = { 0x, 0x03ff03ff, 0x0fff0fff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_STRIDE (8 * 2)
+#define BUF_LINES (8)
+#define BUF_OFFSET (BUF_STRIDE * BUF_LINES)
+#define BUF_SIZE (BUF_STRIDE * BUF_LINES + BUF_OFFSET * 2)
+
+#define randomize_buffers(buf0, buf1, size) \
+do {\
+uint32_t mask = pixel_mask[(bit_depth - 8) >> 1];   \
+int k;  \
+for (k = 0; k < size; k += 4) { \
+uint32_t r = rnd() & mask;  \
+AV_WN32A(buf0 + k, r);  \
+AV_WN32A(buf1 + k, r);  \
+}   \
+} while (0)
+
+
+static void check_deblock_luma(HEVCDSPContext h, int bit_depth)
+{
+int32_t tc[2] = { 1, 1 };
+uint8_t no_p[2] = { 0, 0 };
+uint8_t no_q[2] = { 0, 0 };
+int beta = rnd() & (0x40 - 1);
+LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
+LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
+
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *pix, ptrdiff_t stride, 
int beta, int32_t *tc, uint8_t *no_p, uint8_t *no_q);
+
+randomize_buffers(buf0, buf1, BUF_SIZE);
+if (check_func(h.hevc_h_loop_filter_luma, "hevc_h_loop_filter_luma_%d", 
bit_depth)) {
+call_ref(buf0 + BUF_OFFSET, BUF_STRIDE, beta, tc, no_p, no_q);
+call_new(buf1 + BUF_OFFSET, BUF_STRIDE, beta, tc, no_p, no_q);
+if (memcmp(buf0, buf1, BUF_SIZE))
+fail();
+bench_new(buf1 + BUF_OFFSET, BUF_STRIDE, beta, tc, no_p, no_q)

Re: [FFmpeg-devel] [PATCH v2 1/1] return value check for init_get_bits in adts_decode_extradata

2021-08-05 Thread Maryam Ebrahimzadeh
Ping.

> On Aug 5, 2021, at 12:45 AM, maryam ebrahimzadeh  wrote:
> 
> version2:
> As second argument for init_get_bits (buf) can be crafted, return value check 
> for this function call is necessary.
> 'buf' is  part of  'AVPacket pkt'.
> replace init_get_bits with init_get_bits8.
> ---
> libavformat/adtsenc.c | 6 --
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
> index ba15c0a724..3924e678d9 100644
> --- a/libavformat/adtsenc.c
> +++ b/libavformat/adtsenc.c
> @@ -53,9 +53,11 @@ static int adts_decode_extradata(AVFormatContext *s, 
> ADTSContext *adts, const ui
> GetBitContext gb;
> PutBitContext pb;
> MPEG4AudioConfig m4ac;
> -int off;
> +int off, ret;
> 
> -init_get_bits(&gb, buf, size * 8);
> +ret = init_get_bits8(&gb, buf, size);
> +if (ret < 0)
> +return ret;
> off = avpriv_mpeg4audio_get_config2(&m4ac, buf, size, 1, s);
> if (off < 0)
> return off;
> -- 
> 2.17.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


[FFmpeg-devel] [PATCH 1/3] avfilter/avfilter: add sample_count_in and sample_count_out

2021-08-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avfilter.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index b82f72d040..a71745283c 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -584,6 +584,11 @@ struct AVFilterLink {
  */
 int64_t frame_count_in, frame_count_out;
 
+/**
+ * Number of past samples sent through the link.
+ */
+int64_t sample_count_in, sample_count_out;
+
 /**
  * A pointer to a FFFramePool struct.
  */
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 2/3] avfilter/avfilter: update sample_count_in/out

2021-08-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/avfilter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 24de8ebee3..e0847c724b 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1013,6 +1013,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
 
 link->frame_blocked_in = link->frame_wanted_out = 0;
 link->frame_count_in++;
+link->sample_count_in += frame->nb_samples;
 filter_unblock(link->dst);
 ret = ff_framequeue_add(&link->fifo, frame);
 if (ret < 0) {
@@ -1372,6 +1373,7 @@ static void consume_update(AVFilterLink *link, const 
AVFrame *frame)
 ff_inlink_process_commands(link, frame);
 link->dst->is_disabled = !ff_inlink_evaluate_timeline_at_frame(link, 
frame);
 link->frame_count_out++;
+link->sample_count_out += frame->nb_samples;
 }
 
 int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 3/3] avfilter/f_graphmonitor: use sample_count_in/out

2021-08-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  6 ++
 libavfilter/f_graphmonitor.c | 14 ++
 2 files changed, 20 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 7a266c2a32..28996a4a64 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -13020,6 +13020,12 @@ Display video frame rate or sample rate in case of 
audio used by filter link.
 
 @item eof
 Display link output status.
+
+@item sample_count_in
+Display number of samples taken from filter.
+
+@item sample_count_out
+Display number of samples given out from filter.
 @end table
 
 @item rate, r
diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index ba17f1f638..90e93a4ac3 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -62,6 +62,8 @@ enum {
 MODE_SIZE  = 1 << 7,
 MODE_RATE  = 1 << 8,
 MODE_EOF   = 1 << 9,
+MODE_SCIN  = 1 << 10,
+MODE_SCOUT = 1 << 11,
 };
 
 #define OFFSET(x) offsetof(GraphMonitorContext, x)
@@ -88,6 +90,8 @@ static const AVOption graphmonitor_options[] = {
 { "size", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SIZE},
0, 0, VF, "flags" },
 { "rate", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_RATE},
0, 0, VF, "flags" },
 { "eof",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_EOF}, 
0, 0, VF, "flags" },
+{ "sample_count_in",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCOUT},   
0, 0, VF, "flags" },
+{ "sample_count_out", NULL, 0, AV_OPT_TYPE_CONST, {.i64=MODE_SCIN},
0, 0, VF, "flags" },
 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, 
{.str = "25"}, 0, INT_MAX, VF },
 { "r","set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, 
{.str = "25"}, 0, INT_MAX, VF },
 { NULL }
@@ -229,6 +233,16 @@ static void draw_items(AVFilterContext *ctx, AVFrame *out,
 drawtext(out, xpos, ypos, buffer, s->white);
 xpos += strlen(buffer) * 8;
 }
+if (s->flags & MODE_SCIN) {
+snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, 
l->sample_count_in);
+drawtext(out, xpos, ypos, buffer, s->white);
+xpos += strlen(buffer) * 8;
+}
+if (s->flags & MODE_SCOUT) {
+snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, 
l->sample_count_out);
+drawtext(out, xpos, ypos, buffer, s->white);
+xpos += strlen(buffer) * 8;
+}
 if (s->flags & MODE_PTS) {
 snprintf(buffer, sizeof(buffer)-1, " | pts: %s", 
av_ts2str(l->current_pts_us));
 drawtext(out, xpos, ypos, buffer, s->white);
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH] avformat/movenc: Fix tfdt out of sync

2021-08-05 Thread Martin Storsjö

Hi,

On Tue, 20 Jul 2021, 胡玮文 wrote:


After compile and run this code, run this command to inspect the dts (which 
comes from the out of sync tfdt)

ffprobe -show_packets bug.mp4 | grep dts=

The output is:

dts=0
dts=1
dts=2
dts=2
dts=3
dts=4

With this patch applied, the output is:

dts=0
dts=1
dts=2
dts=10
dts=11
dts=12


Thanks for the repro case, and sorry for the delay in looking at it.

I do see the issue, but I disagree with your suggested solution. While 
your patch does create the correct, intended value in tfdt, you will 
instead create a file where the dts calculated from adding up previous 
sample durations differ from what's written in tfdt. So depending on 
whether the demuxer just accumulates durations or reads tfdt, it will 
produce a different result.


I guess it can be argued that if a demuxer reads a fragmented file, then 
tfdt should be more authoritative than duration and any other reader is 
buggy, but nevertheless, the code as is is designed to make sure that tfdt 
is consistent with the sum of durations.


It seems it's possible to fix the same issue differently though, by not 
adjusting track_duration and end_pts when autoflushing, if there's no 
samples in the track that are going to be flushed. That way, we retain the 
existing intended logic of the muxer, while avoiding diverging.


The result of your repro example, with my movenc modification, produces 
this dts sequence:


dts=0
dts=1
dts=2
dts=2
dts=11
dts=12

This is, of course less nice than what we had before, but after flushing 
the fragment containing tfdt=2, duration=0, the only consistent choice we 
have is to start the next fragment at tfdt/dts=2.



However, I'm open to add an option to ignore the end of the previous 
fragment and make the new fragment start at the exact desired timestamp.


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

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


[FFmpeg-devel] [PATCH] movenc: Don't try to fix the fragment end duration if none will be written

2021-08-05 Thread Martin Storsjö
If autoflushing on a new packet (e.g. due to the frag_every_frame
flag being set), there's no samples to be written in the new fragment,
so we can't overwrite the track duration in order to make it line
up with the next packet to be written.

Signed-off-by: Martin Storsjö 
---
 libavformat/movenc.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 57062f45c5..bcc202300b 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5931,16 +5931,21 @@ static int mov_write_single_packet(AVFormatContext *s, 
AVPacket *pkt)
  trk->entry && pkt->flags & AV_PKT_FLAG_KEY) ||
 (mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME)) {
 if (frag_duration >= mov->min_fragment_duration) {
-// Set the duration of this track to line up with the next
-// sample in this track. This avoids relying on AVPacket
-// duration, but only helps for this particular track, not
-// for the other ones that are flushed at the same time.
-trk->track_duration = pkt->dts - trk->start_dts;
-if (pkt->pts != AV_NOPTS_VALUE)
-trk->end_pts = pkt->pts;
-else
-trk->end_pts = pkt->dts;
-trk->end_reliable = 1;
+if (trk->entry) {
+// Set the duration of this track to line up with the next
+// sample in this track. This avoids relying on AVPacket
+// duration, but only helps for this particular track, not
+// for the other ones that are flushed at the same time.
+//
+// If we have trk->entry == 0, no fragment will be written
+// for this track, and we can't adjust the track end here.
+trk->track_duration = pkt->dts - trk->start_dts;
+if (pkt->pts != AV_NOPTS_VALUE)
+trk->end_pts = pkt->pts;
+else
+trk->end_pts = pkt->dts;
+trk->end_reliable = 1;
+}
 mov_auto_flush_fragment(s, 0);
 }
 }
-- 
2.30.1 (Apple Git-130)

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

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


Re: [FFmpeg-devel] [PATCH 2/3] avfilter/avfilter: update sample_count_in/out

2021-08-05 Thread Nicolas George
Paul B Mahol (12021-08-05):
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/avfilter.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 24de8ebee3..e0847c724b 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1013,6 +1013,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
>  
>  link->frame_blocked_in = link->frame_wanted_out = 0;
>  link->frame_count_in++;
> +link->sample_count_in += frame->nb_samples;
>  filter_unblock(link->dst);
>  ret = ff_framequeue_add(&link->fifo, frame);
>  if (ret < 0) {
> @@ -1372,6 +1373,7 @@ static void consume_update(AVFilterLink *link, const 
> AVFrame *frame)
>  ff_inlink_process_commands(link, frame);
>  link->dst->is_disabled = !ff_inlink_evaluate_timeline_at_frame(link, 
> frame);
>  link->frame_count_out++;
> +link->sample_count_out += frame->nb_samples;
>  }
>  
>  int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)

LGTM if you squash 1 and 2 together.

-- 
  Nicolas George


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

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Nicolas George
Linjie Fu (12021-08-05):
> ffmpeg | branch: master | Linjie Fu  | Thu Aug  5 
> 00:37:29 2021 +0800| [5b0e6b0d82dfcc5c6b999e2678b52b0cff38ae0a] | committer: 
> Linjie Fu
> 
> fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay
> 
> Signed-off-by: Linjie Fu 
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b0e6b0d82dfcc5c6b999e2678b52b0cff38ae0a
> ---
> 
>  fftools/cmdutils.c | 8 
>  fftools/ffplay.c   | 2 --
>  fftools/ffprobe.c  | 1 -
>  3 files changed, 11 deletions(-)

Why did you push? Did somebody approve the fftools patches?

Regards,

-- 
  Nicolas George


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

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Linjie Fu
On Thu, Aug 5, 2021 at 10:32 PM Nicolas George  wrote:

> Linjie Fu (12021-08-05):
> > ffmpeg | branch: master | Linjie Fu  | Thu
> Aug  5 00:37:29 2021 +0800| [5b0e6b0d82dfcc5c6b999e2678b52b0cff38ae0a] |
> committer: Linjie Fu
> >
> > fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay
> >
> > Signed-off-by: Linjie Fu 
> >
> > >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5b0e6b0d82dfcc5c6b999e2678b52b0cff38ae0a
> > ---
> >
> >  fftools/cmdutils.c | 8 
> >  fftools/ffplay.c   | 2 --
> >  fftools/ffprobe.c  | 1 -
> >  3 files changed, 11 deletions(-)
>
> Why did you push? Did somebody approve the fftools patches?

This initials from your review comments to remove setting defaults in
ffmpeg (etc) and use the default flags in swscale,
and I didn't see objections at least till now. Did I misunderstand?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Nicolas George
Linjie Fu (12021-08-05):
> This initials from your review comments to remove setting defaults in
> ffmpeg (etc) and use the default flags in swscale,
> and I didn't see objections at least till now. Did I misunderstand?

I approved the general principle and the lavfi parts. I do not maintain
the fftools part and did not approve it.

Since nobody approved it, you should not have pushed.

At a glance, it was wrong about the placement of the FATE change.

Be ready to revert if there is any objection, and in the future be more
careful.

Regards,

-- 
  Nicolas George


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

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


Re: [FFmpeg-devel] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Linjie Fu
On Thu, Aug 5, 2021 at 10:54 PM Nicolas George  wrote:

> Linjie Fu (12021-08-05):
> > This initials from your review comments to remove setting defaults in
> > ffmpeg (etc) and use the default flags in swscale,
> > and I didn't see objections at least till now. Did I misunderstand?
>
> I approved the general principle and the lavfi parts. I do not maintain
> the fftools part and did not approve it.
>
> Since nobody approved it, you should not have pushed.
>
> At a glance, it was wrong about the placement of the FATE change.

Where is supposed to be the right placement?

Be ready to revert if there is any objection, and in the future be more
> careful.
>
 Will keep in mind, thanks.

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

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


Re: [FFmpeg-devel] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Nicolas George
Linjie Fu (12021-08-05):
> Where is supposed to be the right placement?

In the commit that makes the results change.

Just do this: checkout the first commit, build, run FATE. Does it pass?

Regards,

-- 
  Nicolas George


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

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


[FFmpeg-devel] [PATCH 1/3] avcodec/cbs: add a helper to read extradata within packet side data

2021-08-05 Thread James Almer
Using ff_cbs_read() on the raw buffer will not parse it as extradata,
resulting in parsing errors for example when handling ISOBMFF avcC.
This helper works around that.

Signed-off-by: James Almer 
---
 libavcodec/cbs.c | 13 +
 libavcodec/cbs.h |  4 
 2 files changed, 17 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 8d50ea1432..f6e371ddef 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -294,6 +294,19 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx,
  pkt->data, pkt->size, 0);
 }
 
+int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ const AVPacket *pkt)
+{
+size_t side_data_size;
+const uint8_t *side_data =
+av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+&side_data_size);
+
+return cbs_read_data(ctx, frag, NULL,
+ side_data, side_data_size, 1);
+}
+
 int ff_cbs_read(CodedBitstreamContext *ctx,
 CodedBitstreamFragment *frag,
 const uint8_t *data, size_t size)
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index b7acf98347..bd97d163b1 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -276,6 +276,10 @@ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext 
*ctx,
  CodedBitstreamFragment *frag,
  const struct AVCodecContext *avctx);
 
+int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ const AVPacket *pkt);
+
 /**
  * Read the data bitstream from a packet into a fragment, then
  * split into units and decompose.
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 2/3] avcodec/cbs_bsf: use ff_cbs_read_packet_side_data() to parse extradata in packet side data

2021-08-05 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/cbs_bsf.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c
index 86ec3f2a4d..069f6e9918 100644
--- a/libavcodec/cbs_bsf.c
+++ b/libavcodec/cbs_bsf.c
@@ -25,15 +25,12 @@ static int cbs_bsf_update_side_data(AVBSFContext *bsf, 
AVPacket *pkt)
 CBSBSFContext   *ctx = bsf->priv_data;
 CodedBitstreamFragment *frag = &ctx->fragment;
 uint8_t *side_data;
-size_t side_data_size;
 int err;
 
-side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
-&side_data_size);
-if (!side_data_size)
+if (!av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, NULL))
 return 0;
 
-err = ff_cbs_read(ctx->input, frag, side_data, side_data_size);
+err = ff_cbs_read_packet_side_data(ctx->input, frag, pkt);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR,
"Failed to read extradata from packet side data.\n");
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 3/3] avcodec/trace_headers_bsf: also parse extradata in packet side data

2021-08-05 Thread James Almer
Certain mov/mp4 files have parameter sets out of band, and when required for a
sample it may be propagated within the relevant packet's side data.
This fixes parsing said files if the SPS and/or PPS in the side data is
different than the one in extradata.

Signed-off-by: James Almer 
---
 libavcodec/trace_headers_bsf.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index b891730bac..a9b0247412 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -95,6 +95,19 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *pkt)
 
 av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", pkt->size, tmp);
 
+if (av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
+av_log(bsf, AV_LOG_INFO, "Side data:\n");
+
+err = ff_cbs_read_packet_side_data(ctx->cbc, frag, pkt);
+ff_cbs_fragment_reset(frag);
+
+if (err < 0) {
+av_packet_unref(pkt);
+return err;
+}
+av_log(bsf, AV_LOG_INFO, "Payload:\n");
+}
+
 err = ff_cbs_read_packet(ctx->cbc, frag, pkt);
 
 ff_cbs_fragment_reset(frag);
-- 
2.32.0

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

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


Re: [FFmpeg-devel] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Linjie Fu
On Thu, Aug 5, 2021 at 11:22 PM Nicolas George  wrote:

> Linjie Fu (12021-08-05):
> > Where is supposed to be the right placement?
>
> In the commit that makes the results change.
>
> Just do this: checkout the first commit, build, run FATE. Does it pass?
>

Double confirmed locally,  Yes, and the first commit has passed the
patchwork too:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210804170311.86426-1-fulin...@zju.edu.cn/


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

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/cbs: add a helper to read extradata within packet side data

2021-08-05 Thread Andreas Rheinhardt
James Almer:
> Using ff_cbs_read() on the raw buffer will not parse it as extradata,
> resulting in parsing errors for example when handling ISOBMFF avcC.
> This helper works around that.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/cbs.c | 13 +
>  libavcodec/cbs.h |  4 
>  2 files changed, 17 insertions(+)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 8d50ea1432..f6e371ddef 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -294,6 +294,19 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx,
>   pkt->data, pkt->size, 0);
>  }
>  
> +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,
> + CodedBitstreamFragment *frag,
> + const AVPacket *pkt)
> +{
> +size_t side_data_size;
> +const uint8_t *side_data =
> +av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
> +&side_data_size);
> +
> +return cbs_read_data(ctx, frag, NULL,
> + side_data, side_data_size, 1);
> +}
> +
>  int ff_cbs_read(CodedBitstreamContext *ctx,
>  CodedBitstreamFragment *frag,
>  const uint8_t *data, size_t size)
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index b7acf98347..bd97d163b1 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -276,6 +276,10 @@ int 
> ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx,
>   CodedBitstreamFragment *frag,
>   const struct AVCodecContext *avctx);
>  
> +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,
> + CodedBitstreamFragment *frag,
> + const AVPacket *pkt);
> +
>  /**
>   * Read the data bitstream from a packet into a fragment, then
>   * split into units and decompose.
> 
Despite using this function in both 2 and 3 the callers still have to
check for whether extradata exists in the first place; in patch 3 this
is unavoidable. This makes me wonder whether it might not be better to
expose the header flag in ff_cbs_read().

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

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


Re: [FFmpeg-devel] [PATCH v2 2/3] checkasm: add h264 chroma test

2021-08-05 Thread Andreas Rheinhardt
J. Dekker:
> Signed-off-by: J. Dekker 
> ---
>  tests/checkasm/Makefile |   1 +
>  tests/checkasm/checkasm.c   |   3 +
>  tests/checkasm/checkasm.h   |   1 +
>  tests/checkasm/h264chroma.c | 109 
>  tests/fate/checkasm.mak |   1 +
>  5 files changed, 115 insertions(+)
>  create mode 100644 tests/checkasm/h264chroma.c
> 
> diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
> index 4ef5fa87da..41222c3827 100644
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -6,6 +6,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
>  AVCODECOBJS-$(CONFIG_FLACDSP)   += flacdsp.o
>  AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
>  AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
> +AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
>  AVCODECOBJS-$(CONFIG_H264DSP)   += h264dsp.o
>  AVCODECOBJS-$(CONFIG_H264PRED)  += h264pred.o
>  AVCODECOBJS-$(CONFIG_H264QPEL)  += h264qpel.o
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index b1353f7cbe..154c4a5c01 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -104,6 +104,9 @@ static const struct {
>  #if CONFIG_G722DSP
>  { "g722dsp", checkasm_check_g722dsp },
>  #endif
> +#if CONFIG_H264CHROMA
> +{ "h264chroma", checkasm_check_h264chroma },
> +#endif
>  #if CONFIG_H264DSP
>  { "h264dsp", checkasm_check_h264dsp },
>  #endif
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index 68b0697d3e..ac2f22af05 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
>  void checkasm_check_float_dsp(void);
>  void checkasm_check_fmtconvert(void);
>  void checkasm_check_g722dsp(void);
> +void checkasm_check_h264chroma(void);
>  void checkasm_check_h264dsp(void);
>  void checkasm_check_h264pred(void);
>  void checkasm_check_h264qpel(void);
> diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
> new file mode 100644
> index 00..1f9773e345
> --- /dev/null
> +++ b/tests/checkasm/h264chroma.c
> @@ -0,0 +1,109 @@
> +/*
> + * Copyright (c) 2015 Henrik Gramner
> + * Copyright (c) 2021 J. Dekker
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include 
> +#include "checkasm.h"
> +#include "libavcodec/avcodec.h"

What is this header needed for?

> +#include "libavcodec/h264chroma.h"
> +#include "libavutil/common.h"
> +#include "libavutil/internal.h"

And these two?

> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/mem_internal.h"
> +
> +// static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, 
> AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 };
> +static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff };
> +
> +#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
> +#define BUF_SIZE (3 * 16 * 17)
> +
> +#define randomize_buffers()\
> +do {   \
> +uint32_t mask = pixel_mask[bit_depth - 8]; \
> +int i; \
> +for (i = 0; i < BUF_SIZE; i += 4) {\
> +uint32_t r = rnd() & mask; \
> +AV_WN32A(buf0 + i, r); \
> +AV_WN32A(buf1 + i, r); \
> +}  \
> +} while (0)
> +
> +#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */
> +#define src1 (buf1 + 4 * 16)
> +
> +static void check_avg(void)
> +{
> +int i, bit_depth, x, y;
> +LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
> +LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
> +LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
> +LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
> +H264ChromaContext h;
> +
> +declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, 
> ptrdiff_t stride, int h, int x, int y);
> +for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
> +ff_h264chroma_init(&h, bit_depth);
> +for (i = 0; i < 4; i++) {
> +if (check_func(h.avg_h264_chroma_pixels_tab[i], 
> "avg_chroma_mc%d_%d", 1 << (3 - i), bit_dept

Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the stack filters

2021-08-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xiang, Haihao
> Sent: Thursday, 5 August 2021 04:33
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the
> stack filters
> 
> On Wed, 2021-08-04 at 09:17 +, Soft Works wrote:
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Haihao Xiang
> > > Sent: Wednesday, 4 August 2021 10:33
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Haihao Xiang 
> > > Subject: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the
> > > stack filters
> > >
> > > Include hstack_qsv, vstack_qsv and xstack_qsv, some code is copy and
> > > pasted from other filters
> > >
> > > Example:
> > > $> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -filter_complex
> > > "[0:v][0:v]hstack_qsv" -f null -
> > > ---
> >
> > [...]
> >
> > > +
> > > +/*
> > > + * Callback for qsvvpp
> > > + * @Note: qsvvpp composition does not generate PTS for result frame.
> > > + *so we assign the PTS from framesync to the output frame.
> > > + */
> > > +
> > > +static int filter_callback(AVFilterLink *outlink, AVFrame *frame) {
> > > +QSVStackContext *sctx = outlink->src->priv;
> > > +
> > > +frame->pts = av_rescale_q(sctx->fs.pts,
> > > +  sctx->fs.time_base, outlink->time_base);
> > > +return ff_filter_frame(outlink, frame); }
> >
> > If the surface.Data.TimeStamp gets overwritten by libMFX, why not copy
> > the PTS from the input frame in ff_qsvvpp_filter_frame ?
> >
> > That would apply the timestamp from the last input, though. Preferably
> > would it be taken from the first input instead. For 2-n, you could
> > perhaps clone the frames and assign the pts from the first input's
> > frame?
> 
> Thanks for the comment and suggestion. This callback function was copy-
> and- pasted from overlay_qsv filter because MSDK composition is also used
> by this filter, I'd like to use the same way to generate pts for these 
> filters, but
> I'll try your suggestion for these filters in the future.

Yea I see - the overlay_qsv filter does it the same way. This has probably been
ok earlier because the callback happened synchronously. This is no longer the
case since the async_depth patch which introduced the fifo processing. Now it
can happen that the calback is performed for an earlier frame than the one
that is currently gated by framesync.

I agree that this should be addressed in another patch.

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/cbs: add a helper to read extradata within packet side data

2021-08-05 Thread James Almer

On 8/5/2021 12:43 PM, Andreas Rheinhardt wrote:

James Almer:

Using ff_cbs_read() on the raw buffer will not parse it as extradata,
resulting in parsing errors for example when handling ISOBMFF avcC.
This helper works around that.

Signed-off-by: James Almer 
---
  libavcodec/cbs.c | 13 +
  libavcodec/cbs.h |  4 
  2 files changed, 17 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 8d50ea1432..f6e371ddef 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -294,6 +294,19 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx,
   pkt->data, pkt->size, 0);
  }
  
+int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,

+ CodedBitstreamFragment *frag,
+ const AVPacket *pkt)
+{
+size_t side_data_size;
+const uint8_t *side_data =
+av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+&side_data_size);
+
+return cbs_read_data(ctx, frag, NULL,
+ side_data, side_data_size, 1);
+}
+
  int ff_cbs_read(CodedBitstreamContext *ctx,
  CodedBitstreamFragment *frag,
  const uint8_t *data, size_t size)
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index b7acf98347..bd97d163b1 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -276,6 +276,10 @@ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext 
*ctx,
   CodedBitstreamFragment *frag,
   const struct AVCodecContext *avctx);
  
+int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx,

+ CodedBitstreamFragment *frag,
+ const AVPacket *pkt);
+
  /**
   * Read the data bitstream from a packet into a fragment, then
   * split into units and decompose.


Despite using this function in both 2 and 3 the callers still have to
check for whether extradata exists in the first place; in patch 3 this
is unavoidable. This makes me wonder whether it might not be better to
expose the header flag in ff_cbs_read().

- Andreas


It's no different than existing callers of ff_cbs_read_extradata and 
ff_cbs_read_extradata_from_codec(), which check for avctx/par->extradata 
before calling either of them.

I personally prefer these helpers as is.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg and SDK error code

2021-08-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xiang, Haihao
> Sent: Thursday, 5 August 2021 07:24
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg
> and SDK error code
> 
> On Wed, 2021-08-04 at 06:34 +, Soft Works wrote:
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Haihao Xiang
> > > Sent: Friday, 30 July 2021 04:39
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Haihao Xiang 
> > > Subject: [FFmpeg-devel] [PATCH] lavfi/qsvvpp: do not mix up FFmpeg
> > > and SDK error code
> > >
> > > The function ff_qsvvpp_filter_frame should return a FFmpeg error
> > > code if there is an error. However it might return a SDK error code
> > > without this patch.
> > > ---
> > >  libavfilter/qsvvpp.c | 15 +--
> > >  1 file changed, 9 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > > 4768f6208b..c7ef8a915f 100644
> > > --- a/libavfilter/qsvvpp.c
> > > +++ b/libavfilter/qsvvpp.c
> > > @@ -807,8 +807,7 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s,
> > > AVFilterLink *inlink, AVFrame *picr
> > >if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0)
> > >av_log(ctx, AV_LOG_WARNING, "Sync failed.\n");
> >
> > Why no looping and no checking for MFX_WRN_IN_EXECUTION like
> below?
> 
> Thanks for catching this, I think it should check for
> MFX_WRN_IN_EXECUTION, but it should be fixed in another patch.

OK. 

> > >
> > >  filter_ret = s->filter_frame(outlink, tmp->frame);
> > >  if (filter_ret < 0) {
> > >  av_frame_free(&tmp->frame);
> > > -ret = filter_ret;
> > > -break;
> > > +return filter_ret;
> >
> > The title is about not to mix error codes, but this is a behavioral change.
> > After the patch, the input frame would no longer be processed in case
> > of a sync error.
> 
> The condition is 's->eof && qsv_fifo_size(s->async_fifo)'. When s->eof is
> true, the input frame is actually NULL. So without this patch, this function
> returns 0 for this case, the error code is ignored.

My bad, I missed the eof condition. 


All details clarified. Patch LGTM.

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

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


Re: [FFmpeg-devel] [PATCH v5 00/20] clean-up QSV filters

2021-08-05 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Haihao Xiang
> Sent: Thursday, 5 August 2021 10:19
> To: ffmpeg-devel@ffmpeg.org
> Cc: Haihao Xiang 
> Subject: [FFmpeg-devel] [PATCH v5 00/20] clean-up QSV filters
> 
> This patchset clean up scale_qsv and deinterlace_qsv filters, and take the
> two filters as the special cases of vpp_qsv, so vf_scale_qsv.c and
> vf_deinterlace_qsv.c can be deleted from FFmpeg. In addition, a few small
> features are added in this patchset.
> ---
> v5:
> * Rebased this patchset against the latest master branch and fixed conflicts
> 
> Haihao Xiang (20):
>   lavfi/qsv: use QSVVPPContext as base context in
> vf_vpp_qsv/vf_overlay_qsv
>   lavfi/scale_qsv: simplify scale_qsv filter
>   lavfi/scale_qsv: don't need variables for constants in FFmpeg
>   lavfi/vpp_qsv: add "a", "dar" and "sar" variables
>   lavfi/vpp_qsv: handle NULL pointer when evaluating an expression
>   lavfi/vpp_qsv: allow special values for the output dimensions
>   lavfi/vpp_qsv: factorize extra MFX configuration
>   lavfi/vpp_qsv: allow user to set scale_mode with constant
>   lavfi/vpp_qsv: add vpp_preinit callback
>   lavfi/scale_qsv: re-use VPPContext for scale_qsv filter
>   lavfi/vpp_qsv: factor common QSV filter definition
>   lavfi/scale_qsv: add new options for scale_qsv filter
>   lavfi/scale_qsv: add more input / output pixel formats
>   lavfi/qsvvpp: avoid overriding the returned value
>   lavfi/qsvvpp: set PTS for output frame
>   lavfi/vpp_qsv: check output format string against NULL pointer
>   lavfi/deinterlace_qsv: simplify deinterlace_qsv filter
>   lavfi/deinterlace_qsv: re-use VPPContext for deinterlace_qsv filter
>   lavfi/deinterlace_qsv: add async_depth option
>   lavfi/deinterlace_qsv: add more input / output pixel formats
> 
>  libavfilter/Makefile |   4 +-
>  libavfilter/qsvvpp.c |  57 ++-
>  libavfilter/qsvvpp.h |  11 +-
>  libavfilter/vf_deinterlace_qsv.c | 611 ---
>  libavfilter/vf_overlay_qsv.c |  11 +-
>  libavfilter/vf_scale_qsv.c   | 685 ---
>  libavfilter/vf_vpp_qsv.c | 473 +
>  7 files changed, 347 insertions(+), 1505 deletions(-)  delete mode 100644
> libavfilter/vf_deinterlace_qsv.c  delete mode 100644
> libavfilter/vf_scale_qsv.c
> 
> --
> 2.17.1

Hi Hihao,

The general idea of this patch makes sense to me.

Currently there are implementation differences between these filters, 
and there are cases where vpp_qsv  doesn't work and I need to use 
scale_qsv instead.

I have never analyzed the actual reason, but this should be done 
before replacing scale_qsv with an aliased vpp_qsv.

I'll try to dig out an example..

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

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


Re: [FFmpeg-devel] [PATCH] avformat/yuv4mpegenc: Write data generically via AVPixFmtDescriptor

2021-08-05 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/yuv4mpegenc.c | 87 +++
>  1 file changed, 14 insertions(+), 73 deletions(-)
> 
> diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
> index efa05133d5..fca0ee3120 100644
> --- a/libavformat/yuv4mpegenc.c
> +++ b/libavformat/yuv4mpegenc.c
> @@ -181,9 +181,8 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  AVStream *st = s->streams[pkt->stream_index];
>  AVIOContext *pb = s->pb;
>  const AVFrame *frame = (const AVFrame *)pkt->data;
> -int width, height, h_chroma_shift, v_chroma_shift;
> -int i;
> -const uint8_t *ptr, *ptr1, *ptr2;
> +int width, height;
> +const AVPixFmtDescriptor *desc;
>  
>  /* construct frame header */
>  
> @@ -191,79 +190,21 @@ static int yuv4_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  
>  width  = st->codecpar->width;
>  height = st->codecpar->height;
> +desc   = av_pix_fmt_desc_get(st->codecpar->format);
>  
> -ptr = frame->data[0];
> +/* The following code presumes all planes to be non-interleaved. */
> +for (int k = 0; k < desc->nb_components; k++) {
> +int plane_height = height, plane_width = width * desc->comp[k].step;
> +const uint8_t *ptr = frame->data[k];
>  
> -switch (st->codecpar->format) {
> -case AV_PIX_FMT_GRAY8:
> -case AV_PIX_FMT_YUV411P:
> -case AV_PIX_FMT_YUV420P:
> -case AV_PIX_FMT_YUV422P:
> -case AV_PIX_FMT_YUV444P:
> -case AV_PIX_FMT_YUVA444P:
> -// TODO: remove YUVJ pixel formats when they are completely removed from 
> the codebase.
> -case AV_PIX_FMT_YUVJ420P:
> -case AV_PIX_FMT_YUVJ422P:
> -case AV_PIX_FMT_YUVJ444P:
> -break;
> -case AV_PIX_FMT_GRAY9:
> -case AV_PIX_FMT_GRAY10:
> -case AV_PIX_FMT_GRAY12:
> -case AV_PIX_FMT_GRAY16:
> -case AV_PIX_FMT_YUV420P9:
> -case AV_PIX_FMT_YUV422P9:
> -case AV_PIX_FMT_YUV444P9:
> -case AV_PIX_FMT_YUV420P10:
> -case AV_PIX_FMT_YUV422P10:
> -case AV_PIX_FMT_YUV444P10:
> -case AV_PIX_FMT_YUV420P12:
> -case AV_PIX_FMT_YUV422P12:
> -case AV_PIX_FMT_YUV444P12:
> -case AV_PIX_FMT_YUV420P14:
> -case AV_PIX_FMT_YUV422P14:
> -case AV_PIX_FMT_YUV444P14:
> -case AV_PIX_FMT_YUV420P16:
> -case AV_PIX_FMT_YUV422P16:
> -case AV_PIX_FMT_YUV444P16:
> -width *= 2;
> -break;
> -default:
> -av_log(s, AV_LOG_ERROR, "The pixel format '%s' is not supported.\n",
> -   av_get_pix_fmt_name(st->codecpar->format));
> -return AVERROR(EINVAL);
> -}
> -
> -for (i = 0; i < height; i++) {
> -avio_write(pb, ptr, width);
> -ptr += frame->linesize[0];
> -}
> -
> -if (st->codecpar->format != AV_PIX_FMT_GRAY8 && st->codecpar->format != 
> AV_PIX_FMT_GRAY9 &&
> -st->codecpar->format != AV_PIX_FMT_GRAY10 && st->codecpar->format != 
> AV_PIX_FMT_GRAY12 &&
> -st->codecpar->format != AV_PIX_FMT_GRAY16) {
> -// Adjust for smaller Cb and Cr planes
> -av_pix_fmt_get_chroma_sub_sample(st->codecpar->format, 
> &h_chroma_shift,
> - &v_chroma_shift);
> -// Shift right, rounding up
> -width  = AV_CEIL_RSHIFT(width,  h_chroma_shift);
> -height = AV_CEIL_RSHIFT(height, v_chroma_shift);
> -
> -ptr1 = frame->data[1];
> -ptr2 = frame->data[2];
> -for (i = 0; i < height; i++) { /* Cb */
> -avio_write(pb, ptr1, width);
> -ptr1 += frame->linesize[1];
> +if (desc->nb_components >= 3 && (k == 1 || k == 2)) { /* chroma? */
> +plane_width  = AV_CEIL_RSHIFT(plane_width,  desc->log2_chroma_w);
> +plane_height = AV_CEIL_RSHIFT(plane_height, desc->log2_chroma_h);
>  }
> -for (i = 0; i < height; i++) { /* Cr */
> -avio_write(pb, ptr2, width);
> -ptr2 += frame->linesize[2];
> -}
> -if (st->codecpar->format == AV_PIX_FMT_YUVA444P) {
> -ptr = frame->data[3];
> -for (i = 0; i < height; i++) { /* A */
> -avio_write(pb, ptr, width);
> -ptr += frame->linesize[3];
> -}
> +
> +for (int i = 0; i < plane_height; i++) {
> +avio_write(pb, ptr, plane_width);
> +ptr += frame->linesize[k];
>  }
>  }
>  
> 
Will apply tomorrow unless there are objections.

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

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


Re: [FFmpeg-devel] fftools: Don't set default swscale flags in ffmpeg/ffprobe/ffplay

2021-08-05 Thread Nicolas George
Linjie Fu (12021-08-05):
> Double confirmed locally,  Yes, and the first commit has passed the
> patchwork too:
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210804170311.86426-1-fulin...@zju.edu.cn/

Thanks. I find very surprising that the second patch, which changes a
default too, does not cause another ref change, but I will leave it
there.

Please just be more careful about which patches were approved and which
were not.

Regards,

-- 
  Nicolas George


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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mfenc: remove usage of avctx->pkt_timebase

2021-08-05 Thread James Almer

On 8/2/2021 11:07 PM, James Almer wrote:

The field is documented to be for decoding only.

Signed-off-by: James Almer 
---
  libavcodec/mfenc.c | 2 --
  1 file changed, 2 deletions(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 26f1c8057f..410ad64d8d 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -100,8 +100,6 @@ static int mf_wait_events(AVCodecContext *avctx)
  
  static AVRational mf_get_tb(AVCodecContext *avctx)

  {
-if (avctx->pkt_timebase.num > 0 && avctx->pkt_timebase.den > 0)
-return avctx->pkt_timebase;
  if (avctx->time_base.num > 0 && avctx->time_base.den > 0)
  return avctx->time_base;
  return MF_TIMEBASE;


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

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


Re: [FFmpeg-devel] [PATCH 1/3] cbs_h265: add support for Film Grain Characteristics SEI message

2021-08-05 Thread James Almer

On 8/2/2021 9:12 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/cbs_h2645.c|  6 +++
  libavcodec/cbs_h265.h | 21 +
  libavcodec/cbs_h265_syntax_template.c | 65 +++
  3 files changed, 92 insertions(+)


Will apply the set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/audiotoolbox Support float sample format

2021-08-05 Thread jason



0001-avcodec-audiotoolbox-Support-float-sample-format.patch
Description: Binary data


0001-avcodec-audiotoolbox-Support-float-sample-format.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/audiotoolbox Support float sample format

2021-08-05 Thread jason
From 9ee25b6b3002cd4c629caf850b637877b7a3 Mon Sep 17 00:00:00 2001
From: Jason Fry 
Date: Thu, 5 Aug 2021 15:01:11 +0100
Subject: [PATCH] avcodec/audiotoolbox Support float sample format

Signed-off-by: Jason Fry 
---
libavcodec/audiotoolboxdec.c | 19 +++
libavcodec/audiotoolboxenc.c |  2 +-
2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index a222cde62e..f2a897c8c1 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -304,8 +304,16 @@ static av_cold int ffat_create_decoder(AVCodecContext 
*avctx,
 OSStatus status;
 int i;

-    enum AVSampleFormat sample_fmt = (avctx->bits_per_raw_sample == 32) ?
+    enum AVSampleFormat sample_fmt = avctx->sample_fmt;
+    if (sample_fmt == AV_SAMPLE_FMT_NONE) {
+  sample_fmt = (avctx->bits_per_raw_sample == 32) ?
  AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
+  avctx->sample_fmt = sample_fmt;
+    } else if (sample_fmt != AV_SAMPLE_FMT_S16 &&
+   sample_fmt != AV_SAMPLE_FMT_S32 &&
+   sample_fmt != AV_SAMPLE_FMT_FLT) {
+  return AVERROR_UNKNOWN;
+    }

 AudioStreamBasicDescription in_format = {
 .mFormatID = ffat_get_format_id(avctx->codec_id, avctx->profile),
@@ -313,12 +321,13 @@ static av_cold int ffat_create_decoder(AVCodecContext 
*avctx,
 };
 AudioStreamBasicDescription out_format = {
 .mFormatID = kAudioFormatLinearPCM,
-    .mFormatFlags = kAudioFormatFlagIsSignedInteger | 
kAudioFormatFlagIsPacked,
+    .mFormatFlags = (sample_fmt == AV_SAMPLE_FMT_FLT) ?
+    kAudioFormatFlagIsFloat :
+    kAudioFormatFlagIsSignedInteger | 
kAudioFormatFlagIsPacked,
 .mFramesPerPacket = 1,
 .mBitsPerChannel = av_get_bytes_per_sample(sample_fmt) * 8,
 };

-    avctx->sample_fmt = sample_fmt;

 if (ffat_usable_extradata(avctx)) {
 UInt32 format_size = sizeof(in_format);
@@ -468,8 +477,10 @@ static void ffat_copy_samples(AVCodecContext *avctx, 
AVFrame *frame)
 ATDecodeContext *at = avctx->priv_data;
 if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) {
 COPY_SAMPLES(int32_t);
-    } else {
+    } else if (avctx->sample_fmt == AV_SAMPLE_FMT_S16) {
 COPY_SAMPLES(int16_t);
+    } else {
+    COPY_SAMPLES(float_t);
 }
}

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 9245aa9dc4..fddbd390f6 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -632,7 +632,7 @@ static const AVOption options[] = {
 .capabilities   = AV_CODEC_CAP_DELAY | \
   AV_CODEC_CAP_ENCODER_FLUSH __VA_ARGS__, \
 .sample_fmts    = (const enum AVSampleFormat[]) { \
-    AV_SAMPLE_FMT_S16, \
+    AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, \
 AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
 }, \
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE, \
--
2.30.0


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

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


Re: [FFmpeg-devel] [PATCH] ffprobe: Rename Audio Service Type 'type' field to 'service_type'

2021-08-05 Thread Derek Buitenhuis
On 8/4/2021 4:25 PM, Derek Buitenhuis wrote:
>> ---
>>  fftools/ffprobe.c   | 2 +-
>>  tests/ref/fate/hls-fmp4_ac3 | 2 +-
> 
> Ping.

Will push tomorrow if nobody objects.

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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] avformat/movenc: add support for TTML muxing

2021-08-05 Thread Andreas Rheinhardt
Jan Ekström:
> From: Jan Ekström 
> 
> Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp')
> methods. This initial version also foregoes fragmentation support
> in case the built-in sample squashing is to be utilized, as this
> eases the initial review.
> 
> Additionally, add basic tests for both muxing modes in MP4.
> 
> Signed-off-by: Jan Ekström 
> ---
>  libavformat/Makefile |   2 +-
>  libavformat/isom.h   |   3 +
>  libavformat/movenc.c | 179 ++-
>  libavformat/movenc.h |   5 +
>  libavformat/movenc_ttml.c| 178 ++
>  libavformat/movenc_ttml.h|  31 ++
>  tests/fate/subtitles.mak |   4 +
>  tests/ref/fate/sub-ttml-mp4-dfxp |  44 
>  tests/ref/fate/sub-ttml-mp4-stpp |  44 
>  9 files changed, 487 insertions(+), 3 deletions(-)
>  create mode 100644 libavformat/movenc_ttml.c
>  create mode 100644 libavformat/movenc_ttml.h
>  create mode 100644 tests/ref/fate/sub-ttml-mp4-dfxp
>  create mode 100644 tests/ref/fate/sub-ttml-mp4-stpp
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 813ddd3c20..7e0f587b41 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -337,7 +337,7 @@ OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o 
> mov_chan.o mov_esds.o \
>  qtpalette.o replaygain.o
>  OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o 
> vpcc.o \
>  movenchint.o mov_chan.o rtp.o \
> -movenccenc.o rawutils.o
> +movenccenc.o movenc_ttml.o 
> rawutils.o
>  OBJS-$(CONFIG_MP2_MUXER) += rawenc.o
>  OBJS-$(CONFIG_MP3_DEMUXER)   += mp3dec.o replaygain.o
>  OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index ac1b3f3d56..34a58c79b7 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -387,4 +387,7 @@ static inline enum AVCodecID ff_mov_get_lpcm_codec_id(int 
> bps, int flags)
>  return ff_get_pcm_codec_id(bps, flags & 1, flags & 2, flags & 4 ? -1 : 
> 0);
>  }
>  
> +#define MOV_ISMV_TTML_TAG MKTAG('d', 'f', 'x', 'p')
> +#define MOV_MP4_TTML_TAG  MKTAG('s', 't', 'p', 'p')
> +
>  #endif /* AVFORMAT_ISOM_H */
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index c85efe8748..f3e295ad80 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -56,6 +56,8 @@
>  #include "hevc.h"
>  #include "rtpenc.h"
>  #include "mov_chan.h"
> +#include "movenc_ttml.h"
> +#include "ttmlenc.h"
>  #include "vpcc.h"
>  
>  static const AVOption options[] = {
> @@ -119,6 +121,7 @@ static const AVClass mov_isobmff_muxer_class = {
>  };
>  
>  static int get_moov_size(AVFormatContext *s);
> +static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt);
>  
>  static int utf8len(const uint8_t *b)
>  {
> @@ -1787,7 +1790,29 @@ static int mov_write_subtitle_tag(AVIOContext *pb, 
> MOVTrack *track)
>  
>  if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
>  mov_write_esds_tag(pb, track);
> -else if (track->par->extradata_size)
> +else if (track->par->codec_id == AV_CODEC_ID_TTML) {
> +switch (track->par->codec_tag) {
> +case MOV_ISMV_TTML_TAG:
> +// ISMV dfxp requires no extradata.
> +break;
> +case MOV_MP4_TTML_TAG:
> +// As specified in 14496-30, XMLSubtitleSampleEntry
> +// Namespace
> +avio_put_str(pb, "http://www.w3.org/ns/ttml";);
> +// Empty schema_location
> +avio_w8(pb, 0);
> +// Empty auxiliary_mime_types
> +avio_w8(pb, 0);
> +break;
> +default:
> +av_log(NULL, AV_LOG_ERROR,
> +   "Unknown codec tag '%s' utilized for TTML stream with "
> +   "index %d (track id %d)!\n",
> +   av_fourcc2str(track->par->codec_tag), track->st->index,
> +   track->track_id);
> +return AVERROR(EINVAL);
> +}
> +} else if (track->par->extradata_size)
>  avio_write(pb, track->par->extradata, track->par->extradata_size);
>  
>  if (track->mode == MODE_MP4 &&
> @@ -2661,6 +2686,14 @@ static int mov_write_nmhd_tag(AVIOContext *pb)
>  return 12;
>  }
>  
> +static int mov_write_sthd_tag(AVIOContext *pb)
> +{
> +avio_wb32(pb, 12);
> +ffio_wfourcc(pb, "sthd");
> +avio_wb32(pb, 0);
> +return 12;
> +}
> +
>  static int mov_write_tcmi_tag(AVIOContext *pb, MOVTrack *track)
>  {
>  int64_t pos = avio_tell(pb);
> @@ -2787,6 +2820,8 @@ static int mov_write_hdlr_tag(AVFormatContext *s, 
> AVIOContext *pb, MOVTrack *tra
>  hdlr_type = "sbtl";
>  } else if (track->tag == MKTAG('m','p','4','s')

Re: [FFmpeg-devel] [PATCH 1/3] checkasm: collapse hevc pel tests

2021-08-05 Thread Martin Storsjö

On Thu, 5 Aug 2021, J. Dekker wrote:


Also add to `make fate-checkasm' target.

Signed-off-by: J. Dekker 
---
tests/checkasm/checkasm.c | 11 +--
tests/checkasm/checkasm.h | 11 +--
tests/checkasm/hevc_pel.c | 34 --
tests/fate/checkasm.mak   |  1 +
4 files changed, 27 insertions(+), 30 deletions(-)


LGTM

// Martin

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

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


Re: [FFmpeg-devel] Fix for PES packets with too much padding

2021-08-05 Thread Michael Niedermayer
On Tue, Aug 03, 2021 at 10:07:34AM -0400, Sergio M. Ammirata, Ph.D. wrote:
> PES packet with too much padding trigger unlimited error
> messages "PES packet size mismatch" because the code that
> corrects the length is wrong.
> Here is a sample file: http://99.93.62.129/smpte2038.ts
> PID 300 is the one triggering the errors.
> I am attaching a patch that fixes the problem.
> 

>  mpegts.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 8f8c73a5e78d7c740958054764defa3571979fc4  
> 0001-Fix-setting-the-correct-size-for-PES-packets-with-to.patch
> From 3a2760d42b38023c73f9a3ab18de01a44526dbc9 Mon Sep 17 00:00:00 2001
> From: Sergio Ammirata 
> Date: Tue, 3 Aug 2021 13:43:44 +
> Subject: [PATCH] Fix setting the correct size for PES packets with too much
>  padding
> 
> ---
>  libavformat/mpegts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 640c9afa5d..40439c26c0 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1355,7 +1355,7 @@ skip:
> buf_size > pes->total_size) {
>  // pes packet size is < ts size packet and pes data is 
> padded with 0xff
>  // not sure if this is legal in ts but see issue #2392
> -buf_size = pes->total_size;
> +buf_size = PES_START_SIZE + pes->total_size - 
> pes->pes_header_size;
>  }
>  memcpy(pes->buffer->data + pes->data_index, p, buf_size);
>  pes->data_index += buf_size;

This causes segfaults

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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

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


Re: [FFmpeg-devel] Fix for PES packets with too much padding

2021-08-05 Thread Michael Niedermayer
On Thu, Aug 05, 2021 at 11:08:30PM +0200, Michael Niedermayer wrote:
> On Tue, Aug 03, 2021 at 10:07:34AM -0400, Sergio M. Ammirata, Ph.D. wrote:
> > PES packet with too much padding trigger unlimited error
> > messages "PES packet size mismatch" because the code that
> > corrects the length is wrong.
> > Here is a sample file: http://99.93.62.129/smpte2038.ts
> > PID 300 is the one triggering the errors.
> > I am attaching a patch that fixes the problem.
> > 
> 
> >  mpegts.c |2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 8f8c73a5e78d7c740958054764defa3571979fc4  
> > 0001-Fix-setting-the-correct-size-for-PES-packets-with-to.patch
> > From 3a2760d42b38023c73f9a3ab18de01a44526dbc9 Mon Sep 17 00:00:00 2001
> > From: Sergio Ammirata 
> > Date: Tue, 3 Aug 2021 13:43:44 +
> > Subject: [PATCH] Fix setting the correct size for PES packets with too much
> >  padding
> > 
> > ---
> >  libavformat/mpegts.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index 640c9afa5d..40439c26c0 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -1355,7 +1355,7 @@ skip:
> > buf_size > pes->total_size) {
> >  // pes packet size is < ts size packet and pes data is 
> > padded with 0xff
> >  // not sure if this is legal in ts but see issue #2392
> > -buf_size = pes->total_size;
> > +buf_size = PES_START_SIZE + pes->total_size - 
> > pes->pes_header_size;
> >  }
> >  memcpy(pes->buffer->data + pes->data_index, p, buf_size);
> >  pes->data_index += buf_size;
> 
> This causes segfaults

==5552== Invalid write of size 2
==5552==at 0x4C38753: memmove (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5552==by 0x62DD54: mpegts_push_data (in ffmpeg_g)
==5552==by 0x62B832: handle_packet (in ffmpeg_g)
==5552==by 0x62BCD4: handle_packets (in ffmpeg_g)
==5552==by 0x62BE11: mpegts_read_packet (in ffmpeg_g)
==5552==by 0x6BADB9: ff_read_packet (in ffmpeg_g)
==5552==by 0x6BBAFA: read_frame_internal (in ffmpeg_g)
==5552==by 0x6C05EC: avformat_find_stream_info (in ffmpeg_g)
==5552==by 0x2DB175: open_input_file (in ffmpeg_g)
==5552==by 0x2DEA5B: ffmpeg_parse_options (in ffmpeg_g)
==5552==by 0x2D3151: main (in ffmpeg_g)
==5552==  Address 0x2d25cb80 is 0 bytes after a block of size 128 alloc'd
==5552==at 0x4C33E76: memalign (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5552==by 0x4C33F91: posix_memalign (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5552==by 0x11166C2: av_malloc (in ffmpeg_g)
==5552==by 0x1100F65: av_buffer_alloc (in ffmpeg_g)
==5552==by 0x11017A4: av_buffer_pool_get (in ffmpeg_g)
==5552==by 0x62E16F: mpegts_push_data (in ffmpeg_g)
==5552==by 0x62B832: handle_packet (in ffmpeg_g)
==5552==by 0x62BCD4: handle_packets (in ffmpeg_g)
==5552==by 0x62BE11: mpegts_read_packet (in ffmpeg_g)
==5552==by 0x6BADB9: ff_read_packet (in ffmpeg_g)
==5552==by 0x6BBAFA: read_frame_internal (in ffmpeg_g)
==5552==by 0x6C05EC: avformat_find_stream_info (in ffmpeg_g)
==5552==by 0x2DB175: open_input_file (in ffmpeg_g)
==5552==by 0x2DEA5B: ffmpeg_parse_options (in ffmpeg_g)
==5552==by 0x2D3151: main (in ffmpeg_g)


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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

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


Re: [FFmpeg-devel] Fix for PES packets with too much padding

2021-08-05 Thread Sergio M. Ammirata, Ph.D.
You are right ... the if statement would have to change as
well.
On Tue, 2021-08-03 at 14:20 +, 
ffmpegandmahanstreamer@e.email wrote:
> August 3, 2021 10:07 AM, "Sergio M. Ammirata, Ph.D." <
> ser...@ammirata.net> wrote:
> PES packet with too much padding trigger unlimited
> errormessages "PES packet size mismatch" because the code
> thatcorrects the length is wrong.Here is a sample file: 
> http://99.93.62.129/smpte2038.tsPID 300 is the one
> triggering the errors.I am attaching a patch that fixes
> the problem.
> On the if statement right above your change,  are you
> sure that the condition should still be buf_size > pes-
> >total_size? Especially if the old change was just
> buf_size = pes->total_size (so clipping according to
> condition); and the new one is setting it to something
> different. 
> thx for patch.
> ___ffmpeg-
> devel mailing listffmpeg-de...@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or emailffmpeg-devel-
> requ...@ffmpeg.org with subject
> "unsubscribe".___
> ffmpeg-devel mailing listffmpeg-de...@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or 
> emailffmpeg-devel-requ...@ffmpeg.org with subject
> "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] Fix for PES packets with too much padding

2021-08-05 Thread Sergio M. Ammirata, Ph.D.
Can you share the video file you are using to get the
segfault?
On Thu, 2021-08-05 at 23:10 +0200, Michael Niedermayer
wrote:
> On Thu, Aug 05, 2021 at 11:08:30PM +0200, Michael
> Niedermayer wrote:
> On Tue, Aug 03, 2021 at 10:07:34AM -0400, Sergio M.
> Ammirata, Ph.D. wrote:
> PES packet with too much padding trigger unlimited
> errormessages "PES packet size mismatch" because the code
> thatcorrects the length is wrong.Here is a sample file: 
> http://99.93.62.129/smpte2038.tsPID 300 is the one
> triggering the errors.I am attaching a patch that fixes
> the problem.
> 
>  mpegts.c |2 +- 1 file changed, 1 insertion(+), 1
> deletion(-
> )8f8c73a5e78d7c740958054764defa3571979fc4  0001-Fix-
> setting-the-correct-size-for-PES-packets-with-
> to.patchFrom 3a2760d42b38023c73f9a3ab18de01a44526dbc9 Mon
> Sep 17 00:00:00 2001From: Sergio Ammirata <
> ser...@ammirata.net>Date: Tue, 3 Aug 2021 13:43:44
> +Subject: [PATCH] Fix setting the correct size for
> PES packets with too much padding
> --- libavformat/mpegts.c | 2 +- 1 file changed, 1
> insertion(+), 1 deletion(-)
> diff --git a/libavformat/mpegts.c
> b/libavformat/mpegts.cindex 640c9afa5d..40439c26c0
> 100644--- a/libavformat/mpegts.c+++
> b/libavformat/mpegts.c@@ -1355,7 +1355,7 @@
> skip:buf_size > pes-
> >total_size) { // pes packet size is
> < ts size packet and pes data is padded with
> 0xff // not sure if this is legal in
> ts but see issue #2392-buf_size =
> pes->total_size;+buf_size =
> PES_START_SIZE + pes->total_size - pes-
> >pes_header_size; } memcp
> y(pes->buffer->data + pes->data_index, p,
> buf_size); pes->data_index += buf_size;
> This causes segfaults
> ==5552== Invalid write of size 2==5552==at 0x4C38753:
> memmove (in /usr/lib/valgrind/vgpreload_memcheck-amd64-
> linux.so)==5552==by 0x62DD54: mpegts_push_data (in
> ffmpeg_g)==5552==by 0x62B832: handle_packet (in
> ffmpeg_g)==5552==by 0x62BCD4: handle_packets (in
> ffmpeg_g)==5552==by 0x62BE11: mpegts_read_packet (in
> ffmpeg_g)==5552==by 0x6BADB9: ff_read_packet (in
> ffmpeg_g)==5552==by 0x6BBAFA: read_frame_internal (in
> ffmpeg_g)==5552==by 0x6C05EC:
> avformat_find_stream_info (in ffmpeg_g)==5552==by
> 0x2DB175: open_input_file (in ffmpeg_g)==5552==by
> 0x2DEA5B: ffmpeg_parse_options (in
> ffmpeg_g)==5552==by 0x2D3151: main (in
> ffmpeg_g)==5552==  Address 0x2d25cb80 is 0 bytes after a
> block of size 128 alloc'd==5552==at 0x4C33E76:
> memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-
> linux.so)==5552==by 0x4C33F91: posix_memalign (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-
> linux.so)==5552==by 0x11166C2: av_malloc (in
> ffmpeg_g)==5552==by 0x1100F65: av_buffer_alloc (in
> ffmpeg_g)==5552==by 0x11017A4: av_buffer_pool_get (in
> ffmpeg_g)==5552==by 0x62E16F: mpegts_push_data (in
> ffmpeg_g)==5552==by 0x62B832: handle_packet (in
> ffmpeg_g)==5552==by 0x62BCD4: handle_packets (in
> ffmpeg_g)==5552==by 0x62BE11: mpegts_read_packet (in
> ffmpeg_g)==5552==by 0x6BADB9: ff_read_packet (in
> ffmpeg_g)==5552==by 0x6BBAFA: read_frame_internal (in
> ffmpeg_g)==5552==by 0x6C05EC:
> avformat_find_stream_info (in ffmpeg_g)==5552==by
> 0x2DB175: open_input_file (in ffmpeg_g)==5552==by
> 0x2DEA5B: ffmpeg_parse_options (in
> ffmpeg_g)==5552==by 0x2D3151: main (in ffmpeg_g)
> 
> [...]
> 
> ___ffmpeg-
> devel mailing listffmpeg-de...@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> To unsubscribe, visit link above, or 
> emailffmpeg-devel-requ...@ffmpeg.org with subject
> "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/3] checkasm: add h264 chroma test

2021-08-05 Thread Martin Storsjö

On Thu, 5 Aug 2021, J. Dekker wrote:


Signed-off-by: J. Dekker 
---
tests/checkasm/Makefile |   1 +
tests/checkasm/checkasm.c   |   3 +
tests/checkasm/checkasm.h   |   1 +
tests/checkasm/h264chroma.c | 109 
tests/fate/checkasm.mak |   1 +
5 files changed, 115 insertions(+)
create mode 100644 tests/checkasm/h264chroma.c

   What should I do for other codecs here, or just ignore non-h264?


What do you mean here?


diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 4ef5fa87da..41222c3827 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -6,6 +6,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
AVCODECOBJS-$(CONFIG_FLACDSP)   += flacdsp.o
AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
+AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
AVCODECOBJS-$(CONFIG_H264DSP)   += h264dsp.o
AVCODECOBJS-$(CONFIG_H264PRED)  += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL)  += h264qpel.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b1353f7cbe..154c4a5c01 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -104,6 +104,9 @@ static const struct {
#if CONFIG_G722DSP
{ "g722dsp", checkasm_check_g722dsp },
#endif
+#if CONFIG_H264CHROMA
+{ "h264chroma", checkasm_check_h264chroma },
+#endif
#if CONFIG_H264DSP
{ "h264dsp", checkasm_check_h264dsp },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 68b0697d3e..ac2f22af05 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
void checkasm_check_float_dsp(void);
void checkasm_check_fmtconvert(void);
void checkasm_check_g722dsp(void);
+void checkasm_check_h264chroma(void);
void checkasm_check_h264dsp(void);
void checkasm_check_h264pred(void);
void checkasm_check_h264qpel(void);
diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
new file mode 100644
index 00..0bd27d
--- /dev/null
+++ b/tests/checkasm/h264chroma.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2015 Henrik Gramner
+ * Copyright (c) 2021 J. Dekker
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+#include "checkasm.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/h264chroma.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+// static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, 
AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 };


I guess the comment above refers to this somehow, but I don't see what it 
does as it's unused and commented out?



+static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_SIZE (3 * 16 * 17)
+
+#define randomize_buffers()\
+do {   \
+uint32_t mask = pixel_mask[bit_depth - 8]; \
+int i; \
+for (i = 0; i < BUF_SIZE; i += 4) {\
+uint32_t r = rnd() & mask; \
+AV_WN32A(buf0 + i, r); \
+AV_WN32A(buf1 + i, r); \
+}  \
+} while (0)
+
+#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */
+#define src1 (buf1 + 4 * 16)
+
+static void check_avg()
+{
+int i, bit_depth, x, y;
+LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
+LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
+H264ChromaContext h;
+
+declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, 
ptrdiff_t stride, int h, int x, int y);
+for (bit_depth = 8; bit_depth <= 10; bit_depth++) {
+ff_h264chroma_init(&h, bit_depth);
+for (i = 0; i < 4; i++) {
+if (check_func(h.avg_h264_chroma_pixels_tab[i], "avg_chroma_mc%d_%d", 1 
<< (3 - i), bit_depth)) {
+randomize_buffers();
+x = rnd() & 0x7; y

Re: [FFmpeg-devel] [PATCH v2 3/3] checkasm: add hevc_deblock tests

2021-08-05 Thread Martin Storsjö

On Thu, 5 Aug 2021, J. Dekker wrote:


Signed-off-by: J. Dekker 
---
tests/checkasm/Makefile   |   2 +-
tests/checkasm/checkasm.c |   1 +
tests/checkasm/checkasm.h |   1 +
tests/checkasm/hevc_deblock.c | 126 ++
tests/fate/checkasm.mak   |   1 +
5 files changed, 130 insertions(+), 1 deletion(-)
create mode 100644 tests/checkasm/hevc_deblock.c

new file mode 100644
index 00..98f612921b
--- /dev/null
+++ b/tests/checkasm/hevc_deblock.c
@@ -0,0 +1,126 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include 
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/hevcdsp.h"
+
+#include "checkasm.h"
+
+static const uint32_t pixel_mask[3] = { 0x, 0x03ff03ff, 0x0fff0fff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define BUF_STRIDE (8 * 2)
+#define BUF_LINES (8)
+#define BUF_OFFSET (BUF_STRIDE * BUF_LINES)
+#define BUF_SIZE (BUF_STRIDE * BUF_LINES + BUF_OFFSET * 2)
+
+#define randomize_buffers(buf0, buf1, size) \
+do {\
+uint32_t mask = pixel_mask[(bit_depth - 8) >> 1];   \
+int k;  \
+for (k = 0; k < size; k += 4) { \
+uint32_t r = rnd() & mask;  \
+AV_WN32A(buf0 + k, r);  \
+AV_WN32A(buf1 + k, r);  \


Plain random input is pretty bad test data for deblocking, since it 
doesn't actually trigger the deblocking in most cases. To make it actually 
do the deblocking, the pixels across the edge need to have the right 
properties.


Have a look at how the vp9dsp checkasm test initializes its buffers, to 
make sure that one run actually triggers all cases once (d0+d3 >= beta, 
strong filtering, normal filtering).


(For vp9, it initializes all possible cases in one buffer, but you can 
also iterate and run the test multiple times with different input 
patterns.)


// Martin

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

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


[FFmpeg-devel] [PATCH v2 1/4] avdevice/decklink: add link configuration

2021-08-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/outdevs.texi| 5 +
 libavdevice/decklink_common.cpp | 9 +
 libavdevice/decklink_common.h   | 8 
 libavdevice/decklink_common_c.h | 1 +
 libavdevice/decklink_enc.cpp| 2 ++
 libavdevice/decklink_enc_c.c| 5 +
 6 files changed, 30 insertions(+)

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index aaf2479..dd55904 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -205,6 +205,11 @@ Defaults to @samp{unset}.
 Sets the genlock timing pixel offset on the used output.
 Defaults to @samp{unset}.
 
+@item link
+Sets the video link configuration on the used output. Must be @samp{unset}, 
@samp{single},
+@samp{dual}, @samp{quad}.
+Defaults to @samp{unset}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 24aa9b1..d7b4829 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -214,6 +214,15 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
 if (res != S_OK)
 av_log(avctx, AV_LOG_WARNING, "Setting timing offset failed.\n");
 }
+
+if (direction == DIRECTION_OUT && ctx->link > 0 ) {
+res = ctx->cfg->SetInt(bmdDeckLinkConfigSDIOutputLinkConfiguration, 
ctx->link);
+if (res != S_OK)
+av_log(avctx, AV_LOG_WARNING, "Setting link configuration 
failed.\n");
+else
+av_log(avctx, AV_LOG_VERBOSE, "Successfully set link 
configuration: 0x%x.\n", ctx->link);
+}
+
 return 0;
 }
 
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 6e03295..ad8b33c 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -131,6 +131,7 @@ struct decklink_ctx {
 int64_t teletext_lines;
 double preroll;
 int duplex_mode;
+BMDLinkConfiguration link;
 DecklinkPtsSource audio_pts_source;
 DecklinkPtsSource video_pts_source;
 int draw_bars;
@@ -200,6 +201,13 @@ static const BMDTimecodeFormat 
decklink_timecode_format_map[] = {
 #endif
 };
 
+static const BMDLinkConfiguration decklink_link_conf_map[] = {
+(BMDLinkConfiguration)0,
+bmdLinkConfigurationSingleLink,
+bmdLinkConfigurationDualLink,
+bmdLinkConfigurationQuadLink
+};
+
 int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t 
direction);
 int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int 
tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t 
direction = DIRECTION_OUT);
 int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t 
direction);
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 68978fa..f37e0c0 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -48,6 +48,7 @@ struct decklink_cctx {
 int audio_channels;
 int audio_depth;
 int duplex_mode;
+int link;
 DecklinkPtsSource audio_pts_source;
 DecklinkPtsSource video_pts_source;
 int audio_input;
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 4c1eb05..6dec5f3 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -559,6 +559,8 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
 ctx->list_formats = cctx->list_formats;
 ctx->preroll  = cctx->preroll;
 ctx->duplex_mode  = cctx->duplex_mode;
+if (cctx->link > 0 && (unsigned int)cctx->link < 
FF_ARRAY_ELEMS(decklink_link_conf_map))
+ctx->link = decklink_link_conf_map[cctx->link];
 cctx->ctx = ctx;
 #if CONFIG_LIBKLVANC
 if (klvanc_context_create(&ctx->vanc_ctx) < 0) {
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index 828cf5d..d85d540 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -35,6 +35,11 @@ static const AVOption options[] = {
 { "unset"   ,  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "duplex_mode"},
 { "half",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "duplex_mode"},
 { "full",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "duplex_mode"},
+{ "link" , "link configure" , OFFSET(link), 
AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 3, ENC, "link"},
+{ "unset"   ,  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "link"},
+{ "single"  ,  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "link"},
+{ "dual",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "link"},
+{ "quad",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "link"},

[FFmpeg-devel] [PATCH v2 2/4] avdevice/decklink: add sqd configure

2021-08-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/outdevs.texi|  4 
 libavdevice/decklink_common.cpp | 11 +++
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_enc_c.c|  1 +
 4 files changed, 17 insertions(+)

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index dd55904..c4c1eba 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -210,6 +210,10 @@ Sets the video link configuration on the used output. Must 
be @samp{unset}, @sam
 @samp{dual}, @samp{quad}.
 Defaults to @samp{unset}.
 
+@item sqd
+If set to @option{true}, Quad-link SDI is output in Square Division Quad Split 
mode.
+Defaults to @option{false}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index d7b4829..bb69a54 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -221,6 +221,17 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
 av_log(avctx, AV_LOG_WARNING, "Setting link configuration 
failed.\n");
 else
 av_log(avctx, AV_LOG_VERBOSE, "Successfully set link 
configuration: 0x%x.\n", ctx->link);
+if (ctx->link == bmdLinkConfigurationQuadLink && cctx->sqd) {
+#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a0b0400
+res = 
ctx->cfg->SetFlag(bmdDeckLinkConfigQuadLinkSDIVideoOutputSquareDivisionSplit, 
cctx->sqd);
+if (res != S_OK)
+av_log(avctx, AV_LOG_WARNING, "Setting SquareDivisionSplit 
failed.\n");
+else
+av_log(avctx, AV_LOG_VERBOSE, "Successfully set 
SquareDivisionSplit.\n");
+#else
+av_log(avctx, AV_LOG_VERBOSE, "Unable to set SquareDivisionSplit, 
require version of SDK  >= 10.11.4.\n");
+#endif
+}
 }
 
 return 0;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index f37e0c0..fdaa1f9 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -49,6 +49,7 @@ struct decklink_cctx {
 int audio_depth;
 int duplex_mode;
 int link;
+int sqd;
 DecklinkPtsSource audio_pts_source;
 DecklinkPtsSource video_pts_source;
 int audio_input;
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index d85d540..b26c93b 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -40,6 +40,7 @@ static const AVOption options[] = {
 { "single"  ,  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "link"},
 { "dual",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "link"},
 { "quad",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "link"},
+{ "sqd" , "set Square Division" , OFFSET(sqd) , 
AV_OPT_TYPE_BOOL,   { .i64 = 0   }, 0, 1, ENC },
 { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), 
AV_OPT_TYPE_INT,   { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"},
 { "unset"   ,  NULL , 0, 
AV_OPT_TYPE_CONST, { .i64 = INT_MIN },   0,   0, ENC, "timing_offset"},
 { NULL },
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 3/4] avdevice/decklink: add levelA configure

2021-08-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
just rebase the code to the master branch to fix the first warning.

 doc/outdevs.texi|  4 
 libavdevice/decklink_common.cpp | 17 +
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_enc_c.c|  1 +
 4 files changed, 23 insertions(+)

diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index c4c1eba..dee9de3 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -214,6 +214,10 @@ Defaults to @samp{unset}.
 If set to @option{true}, Quad-link SDI is output in Square Division Quad Split 
mode.
 Defaults to @option{false}.
 
+@item levelA
+If set to @option{true}, SMPTE Level A is enable on the used output.
+Defaults to @option{false}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index bb69a54..46e9768 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -234,6 +234,23 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
 }
 }
 
+if (direction == DIRECTION_OUT && cctx->levelA) {
+DECKLINK_BOOL levelA_supported = false;
+
+if (ctx->attr->GetFlag(BMDDeckLinkSupportsSMPTELevelAOutput, 
&levelA_supported) != S_OK)
+levelA_supported = false;
+
+if (levelA_supported) {
+res = ctx->cfg->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, 
cctx->levelA);
+if (res != S_OK)
+av_log(avctx, AV_LOG_WARNING, "Setting SMPTE levelA 
failed.\n");
+else
+av_log(avctx, AV_LOG_VERBOSE, "Successfully set SMPTE 
levelA.\n");
+} else {
+av_log(avctx, AV_LOG_WARNING, "Unable to set SMPTE levelA mode, 
because it is not supported.\n");
+}
+}
+
 return 0;
 }
 
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index fdaa1f9..d855311 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -50,6 +50,7 @@ struct decklink_cctx {
 int duplex_mode;
 int link;
 int sqd;
+int levelA;
 DecklinkPtsSource audio_pts_source;
 DecklinkPtsSource video_pts_source;
 int audio_input;
diff --git a/libavdevice/decklink_enc_c.c b/libavdevice/decklink_enc_c.c
index b26c93b..614a84a 100644
--- a/libavdevice/decklink_enc_c.c
+++ b/libavdevice/decklink_enc_c.c
@@ -40,6 +40,7 @@ static const AVOption options[] = {
 { "single"  ,  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "link"},
 { "dual",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "link"},
 { "quad",  NULL , 0   , 
AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "link"},
+{ "levelA"  , "set SMPTE LevelA", OFFSET(levelA)  , 
AV_OPT_TYPE_BOOL,   { .i64 = 0   }, 0, 1, ENC },
 { "sqd" , "set Square Division" , OFFSET(sqd) , 
AV_OPT_TYPE_BOOL,   { .i64 = 0   }, 0, 1, ENC },
 { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), 
AV_OPT_TYPE_INT,   { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"},
 { "unset"   ,  NULL , 0, 
AV_OPT_TYPE_CONST, { .i64 = INT_MIN },   0,   0, ENC, "timing_offset"},
-- 
1.8.3.1

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

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


[FFmpeg-devel] [PATCH v2 4/4] avdevice/decklink: support for more duplex mode for Decklink 8K Pro

2021-08-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/indevs.texi | 16 +++-
 doc/outdevs.texi| 16 +++-
 libavdevice/decklink_common.cpp |  8 
 libavdevice/decklink_common.h   | 11 +++
 libavdevice/decklink_dec_c.c| 10 ++
 libavdevice/decklink_enc_c.c| 10 ++
 6 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index b377924..af0380a 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -344,9 +344,23 @@ Defines number of audio channels to capture. Must be 
@samp{2}, @samp{8} or @samp
 Defaults to @samp{2}.
 
 @item duplex_mode
-Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or 
@samp{full}.
+Sets the decklink device duplex/profile mode. Must be @samp{unset}, 
@samp{half}, @samp{full},
+@samp{one_sub_device_full}, @samp{one_sub_device_half}, 
@samp{two_sub_device_full},
+@samp{four_sub_device_half}
 Defaults to @samp{unset}.
 
+Note: DeckLink SDK 11.2 have replaced the duplex property by a profile 
property.
+For the DeckLink Duo 2 and DeckLink Quad 2, a profile is shared between any 2
+sub-devices that utilize the same connectors. For the DeckLink 8K Pro, a 
profile
+is shared between all 4 sub-devices. So DeckLink 8K Pro support four profiles.
+
+Valid profile mode for DeckLink 8K Pro(Updated DeckLink SDK to >= 11.2):
+@samp{one_sub_device_full}, @samp{one_sub_device_half}, 
@samp{two_sub_device_full},
+@samp{four_sub_device_half}
+
+Valid profile mode for DeckLink Quad 2 and DeckLink Duo 2:
+@samp{half}, @samp{full}
+
 @item timecode_format
 Timecode type to include in the frame and video stream metadata. Must be
 @samp{none}, @samp{rp188vitc}, @samp{rp188vitc2}, @samp{rp188ltc},
diff --git a/doc/outdevs.texi b/doc/outdevs.texi
index dee9de3..76a9d7d 100644
--- a/doc/outdevs.texi
+++ b/doc/outdevs.texi
@@ -198,9 +198,23 @@ Amount of time to preroll video in seconds.
 Defaults to @option{0.5}.
 
 @item duplex_mode
-Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or 
@samp{full}.
+Sets the decklink device duplex/profile mode. Must be @samp{unset}, 
@samp{half}, @samp{full},
+@samp{one_sub_device_full}, @samp{one_sub_device_half}, 
@samp{two_sub_device_full},
+@samp{four_sub_device_half}
 Defaults to @samp{unset}.
 
+Note: DeckLink SDK 11.2 have replaced the duplex property by a profile 
property.
+For the DeckLink Duo 2 and DeckLink Quad 2, a profile is shared between any 2
+sub-devices that utilize the same connectors. For the DeckLink 8K Pro, a 
profile
+is shared between all 4 sub-devices. So DeckLink 8K Pro support four profiles.
+
+Valid profile mode for DeckLink 8K Pro(Updated DeckLink SDK to >= 11.2):
+@samp{one_sub_device_full}, @samp{one_sub_device_half}, 
@samp{two_sub_device_full},
+@samp{four_sub_device_half}
+
+Valid profile mode for DeckLink Quad 2 and DeckLink Duo 2:
+@samp{half}, @samp{full}
+
 @item timing_offset
 Sets the genlock timing pixel offset on the used output.
 Defaults to @samp{unset}.
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 46e9768..de7d2f4 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -182,7 +182,11 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
 if (duplex_supported) {
 #if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b00
 IDeckLinkProfile *profile = NULL;
+#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b02
+BMDProfileID bmd_profile_id = 
decklink_profile_id_map[ctx->duplex_mode];
+#else
 BMDProfileID bmd_profile_id = ctx->duplex_mode == 2 ? 
bmdProfileOneSubDeviceFullDuplex : bmdProfileTwoSubDevicesHalfDuplex;
+#endif
 res = manager->GetProfile(bmd_profile_id, &profile);
 if (res == S_OK) {
 res = profile->SetActive();
@@ -195,7 +199,11 @@ int ff_decklink_set_configs(AVFormatContext *avctx,
 if (res != S_OK)
 av_log(avctx, AV_LOG_WARNING, "Setting duplex mode failed.\n");
 else
+#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b02
+av_log(avctx, AV_LOG_VERBOSE, "Successfully set duplex mode to 
%s duplex.\n", ctx->duplex_mode == 2  || ctx->duplex_mode == 4 ? "full" : 
"half");
+#else
 av_log(avctx, AV_LOG_VERBOSE, "Successfully set duplex mode to 
%s duplex.\n", ctx->duplex_mode == 2 ? "full" : "half");
+#endif
 } else {
 av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because 
it is not supported.\n");
 }
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index ad8b33c..a2d6509 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -208,6 +208,17 @@ static const BMDLinkConfiguration decklink_link_conf_map[] 
= {
 bmdLinkConfigurationQuadLink
 };
 
+#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b02
+static const BMDProfileID decklink_profile_id_map[] = {
+   

[FFmpeg-devel] [PATCH] lavc/qsvenc_hevc: add -pic_timing_sei option

2021-08-05 Thread Haihao Xiang
The SDK may insert picture timing SEI for hevc and the code to set mfx
parameter has been added in qsvenc, however the corresponding option is
missing in the hevc option array
---
 libavcodec/qsvenc_hevc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index b7b2f5633e..1e31968673 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -248,6 +248,7 @@ static const AVOption options[] = {
 { "tile_rows",  "Number of rows for tiled encoding",  
OFFSET(qsv.tile_rows),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE },
 { "recovery_point_sei", "Insert recovery point SEI messages",   
OFFSET(qsv.recovery_point_sei),  AV_OPT_TYPE_INT, { .i64 = -1 },
   -1,  1, VE },
 { "aud", "Insert the Access Unit Delimiter NAL", OFFSET(qsv.aud), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE},
+{ "pic_timing_sei","Insert picture timing SEI with pic_struct_syntax 
element", OFFSET(qsv.pic_timing_sei), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
 
 { NULL },
 };
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the stack filters

2021-08-05 Thread Xiang, Haihao
On Thu, 2021-08-05 at 15:53 +, Soft Works wrote:
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Xiang, Haihao
> > Sent: Thursday, 5 August 2021 04:33
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the
> > stack filters
> > 
> > On Wed, 2021-08-04 at 09:17 +, Soft Works wrote:
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf Of
> > > > Haihao Xiang
> > > > Sent: Wednesday, 4 August 2021 10:33
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Haihao Xiang 
> > > > Subject: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the
> > > > stack filters
> > > > 
> > > > Include hstack_qsv, vstack_qsv and xstack_qsv, some code is copy and
> > > > pasted from other filters
> > > > 
> > > > Example:
> > > > $> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -filter_complex
> > > > "[0:v][0:v]hstack_qsv" -f null -
> > > > ---
> > > 
> > > [...]
> > > 
> > > > +
> > > > +/*
> > > > + * Callback for qsvvpp
> > > > + * @Note: qsvvpp composition does not generate PTS for result frame.
> > > > + *so we assign the PTS from framesync to the output frame.
> > > > + */
> > > > +
> > > > +static int filter_callback(AVFilterLink *outlink, AVFrame *frame) {
> > > > +QSVStackContext *sctx = outlink->src->priv;
> > > > +
> > > > +frame->pts = av_rescale_q(sctx->fs.pts,
> > > > +  sctx->fs.time_base, outlink->time_base);
> > > > +return ff_filter_frame(outlink, frame); }
> > > 
> > > If the surface.Data.TimeStamp gets overwritten by libMFX, why not copy
> > > the PTS from the input frame in ff_qsvvpp_filter_frame ?
> > > 
> > > That would apply the timestamp from the last input, though. Preferably
> > > would it be taken from the first input instead. For 2-n, you could
> > > perhaps clone the frames and assign the pts from the first input's
> > > frame?
> > 
> > Thanks for the comment and suggestion. This callback function was copy-
> > and- pasted from overlay_qsv filter because MSDK composition is also used
> > by this filter, I'd like to use the same way to generate pts for these
> > filters, but
> > I'll try your suggestion for these filters in the future.
> 
> Yea I see - the overlay_qsv filter does it the same way. This has probably
> been
> ok earlier because the callback happened synchronously. This is no longer the
> case since the async_depth patch which introduced the fifo processing. Now it
> can happen that the calback is performed for an earlier frame than the one
> that is currently gated by framesync.

async_depth is not enabled for overlay_qsv and stack qsv filters, 
s->async_depth 
is 0, so the callback is still performed synchronously for these filters. 

Thanks
Haihao

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

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


[FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the stack filters

2021-08-05 Thread Haihao Xiang
Include hstack_qsv, vstack_qsv and xstack_qsv, some code is copy and
pasted from other filters

Example:
$> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -filter_complex
"[0:v][0:v]hstack_qsv" -f null -
---
v2: fix wrong reference in filters.texi

 configure  |   6 +
 doc/filters.texi   |  81 ++
 libavfilter/Makefile   |   3 +
 libavfilter/allfilters.c   |   3 +
 libavfilter/vf_stack_qsv.c | 498 +
 5 files changed, 591 insertions(+)
 create mode 100644 libavfilter/vf_stack_qsv.c

diff --git a/configure b/configure
index f9fdf58bc3..96c95ac062 100755
--- a/configure
+++ b/configure
@@ -3696,6 +3696,12 @@ vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
 yadif_cuda_filter_deps="ffnvcodec"
 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
+hstack_qsv_filter_deps="libmfx"
+hstack_qsv_filter_select="qsvvpp"
+vstack_qsv_filter_deps="libmfx"
+vstack_qsv_filter_select="qsvvpp"
+xstack_qsv_filter_deps="libmfx"
+xstack_qsv_filter_select="qsvvpp"
 
 # examples
 avio_list_dir_deps="avformat avutil"
diff --git a/doc/filters.texi b/doc/filters.texi
index 790d165433..5d656a9351 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -13487,6 +13487,7 @@ Set the scaling dimension: @code{2} for @code{hq2x}, 
@code{3} for
 Default is @code{3}.
 @end table
 
+@anchor{hstack}
 @section hstack
 Stack input videos horizontally.
 
@@ -21861,6 +21862,7 @@ Example:
 ffmpeg -i ref.mpg -vf vmafmotion -f null -
 @end example
 
+@anchor{vstack}
 @section vstack
 Stack input videos vertically.
 
@@ -22307,6 +22309,7 @@ minimum values, and @code{1} maximum values.
 
 This filter supports all above options as @ref{commands}, excluding option 
@code{inputs}.
 
+@anchor{xstack}
 @section xstack
 Stack video inputs into custom layout.
 
@@ -24004,6 +24007,84 @@ tonemap_vaapi=format=p010:t=bt2020-10
 
 @c man end VAAPI VIDEO FILTERS
 
+@chapter QSV Video Filters
+@c man begin QSV VIDEO FILTERS
+
+Below is a description of the currently available QSV video filters.
+
+To enable compilation of these filters you need to configure FFmpeg with
+@code{--enable-libmfx}.
+
+To use QSV filters, you need to setup the QSV device correctly. For more 
information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/QuickSync}
+
+@section hstack_qsv
+Stack input videos horizontally.
+
+This is the QSV variant of the @ref{hstack} filter.
+
+It accepts the following options:
+
+@table @option
+@item inputs
+Set number of input streams. Allowed range is from 2 to 72.
+Default value is 2.
+
+@item shortest
+See @ref{hstack}.
+
+@item scale
+Set factor to zoom in or out all videos. Allowed range is from 0.125 to 8.
+Default value is 1.
+@end table
+
+@section vstack_qsv
+Stack input videos vertically.
+
+This is the QSV variant of the @ref{vstack} filter.
+
+It accepts the following options:
+
+@table @option
+@item inputs
+Set number of input streams. Allowed range is from 2 to 72.
+Default value is 2.
+
+@item shortest
+See @ref{vstack}.
+
+@item scale
+Set factor to zoom in or out all videos. Allowed range is from 0.125 to 8.
+Default value is 1.
+@end table
+
+@section xstack_qsv
+Stack video inputs into custom layout.
+
+This is the QSV variant of the @ref{xstack} filter.
+
+It accepts the following options:
+
+@table @option
+@item inputs
+Set number of input streams. Allowed range is from 2 to 72.
+Default value is 2.
+
+@item shortest
+See @ref{xstack}.
+
+@item scale
+Set factor to zoom in or out all videos. Allowed range is from 0.125 to 8.
+Default value is 1.
+
+@item layout
+See @ref{xstack}.
+
+@item fill
+See @ref{xstack}.
+@end table
+
+@c man end QSV VIDEO FILTERS
+
 @chapter Video Sources
 @c man begin VIDEO SOURCES
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 49c0c8342b..03e8558635 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -496,6 +496,9 @@ OBJS-$(CONFIG_YAEPBLUR_FILTER)   += 
vf_yaepblur.o
 OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
 OBJS-$(CONFIG_ZOOMPAN_FILTER)+= vf_zoompan.o
 OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
+OBJS-$(CONFIG_HSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
+OBJS-$(CONFIG_VSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
+OBJS-$(CONFIG_XSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o
 
 OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index ae74f9c891..16bc0c6429 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -472,6 +472,9 @@ extern const AVFilter ff_vf_yaepblur;
 extern const AVFilter ff_vf_zmq;
 extern const AVFilter ff_vf_zoompan;
 extern const AVFilter ff_vf_zscale;
+extern const AVFilter ff_vf_hstack_qsv;
+extern const AVFilter ff_vf_vstack_qsv;
+extern const AVFilter ff_vf_xstack_qsv;
 
 extern const AVFilter ff_vsrc_allrgb

Re: [FFmpeg-devel] [PATCH v2] avfilter: add QSV variants of the stack filters

2021-08-05 Thread Xiang, Haihao
On Fri, 2021-08-06 at 13:17 +0800, Haihao Xiang wrote:
> Include hstack_qsv, vstack_qsv and xstack_qsv, some code is copy and
> pasted from other filters
> 
> Example:
> $> ffmpeg -hwaccel qsv -c:v hevc_qsv -i input.h265 -filter_complex
> "[0:v][0:v]hstack_qsv" -f null -
> ---
> v2: fix wrong reference in filters.texi

It is v3, not v2 :-(

Thanks
Haihao



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

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