[FFmpeg-devel] [PATCH v3] libavcodec/qsvenc_hevc: encode RGB format rawvideo

2022-02-17 Thread Wenbin Chen
Add support for hevc_qsv to input RGB format frame. It will
transform frame to yuv inside MediaSDK instead of using auto
scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10
format. The X2RGB10 correspond to the A2RGB20 format and BGRA
correspond to RGB4 format in MediaSDK.

Signed-off-by: Wenbin Chen 
---
 libavcodec/qsv.c | 16 
 libavcodec/qsvenc.c  |  8 
 libavcodec/qsvenc_hevc.c |  6 ++
 3 files changed, 30 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 1a432dbd82..b75877e698 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -189,6 +189,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
 case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
 case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
+#if QSV_VERSION_ATLEAST(1, 9)
+case MFX_FOURCC_A2RGB10: return AV_PIX_FMT_X2RGB10;
+#endif
+#if QSV_VERSION_ATLEAST(1, 17)
+case MFX_FOURCC_RGB4: return AV_PIX_FMT_BGRA;
+#endif
 #if CONFIG_VAAPI
 case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
 #if QSV_VERSION_ATLEAST(1, 27)
@@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t 
*fourcc)
 case AV_PIX_FMT_P010:
 *fourcc = MFX_FOURCC_P010;
 return AV_PIX_FMT_P010;
+#if QSV_VERSION_ATLEAST(1, 9)
+case AV_PIX_FMT_X2RGB10:
+*fourcc = MFX_FOURCC_A2RGB10;
+return AV_PIX_FMT_X2RGB10;
+#endif
+#if QSV_VERSION_ATLEAST(1, 17)
+case AV_PIX_FMT_BGRA:
+*fourcc = MFX_FOURCC_RGB4;
+return AV_PIX_FMT_BGRA;
+#endif
 #if CONFIG_VAAPI
 case AV_PIX_FMT_YUV422P:
 case AV_PIX_FMT_YUYV422:
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 07be4287b7..40d60cde3c 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1616,6 +1616,14 @@ static int submit_frame(QSVEncContext *q, const AVFrame 
*frame,
 qf->surface.Data.V = qf->surface.Data.UV + 2;
 break;
 
+case AV_PIX_FMT_X2RGB10:
+case AV_PIX_FMT_BGRA:
+qf->surface.Data.B = qf->frame->data[0];
+qf->surface.Data.G = qf->frame->data[0] + 1;
+qf->surface.Data.R = qf->frame->data[0] + 2;
+qf->surface.Data.A = qf->frame->data[0] + 3;
+break;
+
 default:
 /* should not reach here */
 av_assert0(0);
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 5cac141c4d..ade546d4ca 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -304,6 +304,12 @@ const AVCodec ff_hevc_qsv_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
 AV_PIX_FMT_P010,
 AV_PIX_FMT_QSV,
+#if QSV_VERSION_ATLEAST(1, 17)
+AV_PIX_FMT_BGRA,
+#endif
+#if QSV_VERSION_ATLEAST(1, 9)
+AV_PIX_FMT_X2RGB10,
+#endif
 AV_PIX_FMT_NONE },
 .priv_class = ,
 .defaults   = qsv_enc_defaults,
-- 
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] [PATCH v1 4/4] vaapi_encode_h265: Query encoding block sizes and features

2022-02-17 Thread Xiang, Haihao
On Fri, 2022-02-18 at 09:43 +0800, Fei Wang wrote:
> From: Mark Thompson 
> 
> Signed-off-by: Fei Wang 
> ---
>  libavcodec/vaapi_encode_h265.c | 107 +++--
>  1 file changed, 102 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index 8319848e4a..e98502503d 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -56,6 +56,9 @@ typedef struct VAAPIEncodeH265Context {
>  VAAPIEncodeContext common;
>  
>  // Encoder features.
> +uint32_t va_features;
> +// Block size info.
> +uint32_t va_bs;
>  uint32_t ctu_size;
>  uint32_t min_cb_size;
>  
> @@ -427,9 +430,9 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  vps->vps_max_latency_increase_plus1[i];
>  }
>  
> -// These have to come from the capabilities of the encoder.  We have no
> -// way to query them, so just hardcode parameters which work on the Intel
> -// driver.
> +// These values come from the capabilities of the first encoder
> +// implementation in the i965 driver on Intel Skylake.  They may
> +// fail badly with other platforms or drivers.
>  // CTB size from 8x8 to 32x32.
>  sps->log2_min_luma_coding_block_size_minus3   = 0;
>  sps->log2_diff_max_min_luma_coding_block_size = 2;
> @@ -447,6 +450,42 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  
>  sps->pcm_enabled_flag = 0;
>  
> +// update sps setting according to queried result
> +#if VA_CHECK_VERSION(1, 13, 0)
> +if (priv->va_features) {
> +VAConfigAttribValEncHEVCFeatures features = { .value = priv-
> >va_features };
> +
> +// Enable feature if get queried result is VA_FEATURE_SUPPORTED |
> VA_FEATURE_REQUIRED
> +sps->amp_enabled_flag =
> +!!features.bits.amp;
> +sps->sample_adaptive_offset_enabled_flag =
> +!!features.bits.sao;
> +sps->sps_temporal_mvp_enabled_flag =
> +!!features.bits.temporal_mvp;
> +sps->pcm_enabled_flag =
> +!!features.bits.pcm;
> +}
> +
> +if (priv->va_bs) {
> +VAConfigAttribValEncHEVCBlockSizes bs = { .value = priv->va_bs };
> +sps->log2_min_luma_coding_block_size_minus3 =
> +ff_ctz(priv->min_cb_size) - 3;
> +sps->log2_diff_max_min_luma_coding_block_size =
> +ff_ctz(priv->ctu_size) - ff_ctz(priv->min_cb_size);
> +
> +sps->log2_min_luma_transform_block_size_minus2 =
> +bs.bits.log2_min_luma_transform_block_size_minus2;
> +sps->log2_diff_max_min_luma_transform_block_size =
> +bs.bits.log2_max_luma_transform_block_size_minus2 -
> +bs.bits.log2_min_luma_transform_block_size_minus2;
> +
> +sps->max_transform_hierarchy_depth_inter =
> +bs.bits.max_max_transform_hierarchy_depth_inter;
> +sps->max_transform_hierarchy_depth_intra =
> +bs.bits.max_max_transform_hierarchy_depth_intra;
> +}
> +#endif
> +
>  // STRPSs should ideally be here rather than defined individually in
>  // each slice, but the structure isn't completely fixed so for now
>  // don't bother.
> @@ -539,6 +578,23 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP);
>  pps->diff_cu_qp_delta_depth   = 0;
>  
> +// update pps setting according to queried result
> +#if VA_CHECK_VERSION(1, 13, 0)
> +if (priv->va_features) {
> +VAConfigAttribValEncHEVCFeatures features = { .value = priv-
> >va_features };
> +if (ctx->va_rc_mode != VA_RC_CQP)
> +pps->cu_qp_delta_enabled_flag =
> +!!features.bits.cu_qp_delta;

Please fix the indentation 

> +
> +pps->transform_skip_enabled_flag =
> +!!features.bits.transform_skip;
> +// set diff_cu_qp_delta_depth as its max value if cu_qp_delta
> enabled. Otherwise
> +// 0 will make cu_qp_delta invalid.
> +if (pps->cu_qp_delta_enabled_flag)
> +pps->diff_cu_qp_delta_depth = sps-
> >log2_diff_max_min_luma_coding_block_size;
> +}
> +#endif
> +
>  if (ctx->tile_rows && ctx->tile_cols) {
>  int uniform_spacing;
>  
> @@ -640,8 +696,8 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  
>  .coded_buf = VA_INVALID_ID,
>  
> -.collocated_ref_pic_index = 0xff,
> -
> +.collocated_ref_pic_index = sps->sps_temporal_mvp_enabled_flag ?
> +0 : 0xff,
>  .last_picture = 0,
>  
>  .pic_init_qp= pps->init_qp_minus26 + 26,
> @@ -674,6 +730,8 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  .entropy_coding_sync_enabled_flag = pps-
> >entropy_coding_sync_enabled_flag,
>  

Re: [FFmpeg-devel] [PATCH v4 2/3] avformat/imf: fix packet pts, dts and muxing

2022-02-17 Thread Zane van Iperen




On 17/2/22 02:54, p...@sandflow.com wrote:

  av_log(s,
 AV_LOG_DEBUG,
 "Switch resource on track %d: re-open context\n",
 track->index);
-if (open_track_resource_context(s, &(track->resources[i])) != 
0)
-return NULL;
+
+ret = open_track_resource_context(s, &(track->resources[i]));


Nit: "track->resources + i" is easier to read imo


+if (ret != 0)
+return ret;
  if (track->current_resource_index > 0)
  
avformat_close_input(>resources[track->current_resource_index].ctx);
  track->current_resource_index = i;
  }
  
-return &(track->resources[track->current_resource_index]);

+*resource = &(track->resources[track->current_resource_index]);


Nit: track->resources + track->current_resource_index



The rest lgtm.

Will apply (with nits fixed) in a few days of no objections.

___
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 2/2] libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase performance

2022-02-17 Thread Wenbin Chen
Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance
decrease. The reason is that vaRenderPicture() and vaSyncBuffer() are
called at the same time (vaRenderPicture() always followed by a
vaSyncBuffer()). Now I changed them to be called in a asynchronous way,
which will make better use of hardware.
Async_depth is added to increase encoder's performance. The frames that
are sent to hardware are stored in a fifo. Encoder will sync output
after async fifo is full.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
 doc/encoders.texi |  6 
 libavcodec/vaapi_encode.c | 64 +++
 libavcodec/vaapi_encode.h | 16 --
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index bfb6c7eef6..6bac2b7f28 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3600,6 +3600,12 @@ will refer only to P- or I-frames.  When set to greater 
values multiple layers
 of B-frames will be present, frames in each layer only referring to frames in
 higher layers.
 
+@item async_depth
+Maximum processing parallelism. Increase this to improve single channel
+performance. This option doesn't work if driver doesn't implement vaSyncBuffer
+function. Please make sure there are enough hw_frames allocated if a large
+number of async_depth is used.
+
 @item rc_mode
 Set the rate control mode to use.  A given driver may only support a subset of
 modes.
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3f8c8ace2a..8c6e881702 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -965,8 +965,10 @@ static int vaapi_encode_pick_next(AVCodecContext *avctx,
 if (!pic && ctx->end_of_stream) {
 --b_counter;
 pic = ctx->pic_end;
-if (pic->encode_issued)
+if (pic->encode_complete)
 return AVERROR_EOF;
+else if (pic->encode_issued)
+return AVERROR(EAGAIN);
 }
 
 if (!pic) {
@@ -1137,7 +1139,8 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, 
AVFrame *frame)
 if (ctx->input_order == ctx->decode_delay)
 ctx->dts_pts_diff = pic->pts - ctx->first_pts;
 if (ctx->output_delay > 0)
-ctx->ts_ring[ctx->input_order % (3 * ctx->output_delay)] = 
pic->pts;
+ctx->ts_ring[ctx->input_order %
+(3 * ctx->output_delay + ctx->async_depth)] = pic->pts;
 
 pic->display_order = ctx->input_order;
 ++ctx->input_order;
@@ -1191,18 +1194,47 @@ int ff_vaapi_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt)
 return AVERROR(EAGAIN);
 }
 
-pic = NULL;
-err = vaapi_encode_pick_next(avctx, );
-if (err < 0)
-return err;
-av_assert0(pic);
+if (ctx->has_sync_buffer_func) {
+pic = NULL;
+
+if (av_fifo_can_write(ctx->encode_fifo)) {
+err = vaapi_encode_pick_next(avctx, );
+if (!err) {
+av_assert0(pic);
+pic->encode_order = ctx->encode_order +
+av_fifo_can_read(ctx->encode_fifo);
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
+av_fifo_write(ctx->encode_fifo, , 1);
+}
+}
 
-pic->encode_order = ctx->encode_order++;
+if (!av_fifo_can_read(ctx->encode_fifo))
+return err;
 
-err = vaapi_encode_issue(avctx, pic);
-if (err < 0) {
-av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
-return err;
+// More frames can be buffered
+if (av_fifo_can_write(ctx->encode_fifo) && !ctx->end_of_stream)
+return AVERROR(EAGAIN);
+
+av_fifo_read(ctx->encode_fifo, , 1);
+ctx->encode_order = pic->encode_order + 1;
+} else {
+pic = NULL;
+err = vaapi_encode_pick_next(avctx, );
+if (err < 0)
+return err;
+av_assert0(pic);
+
+pic->encode_order = ctx->encode_order++;
+
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
 }
 
 err = vaapi_encode_output(avctx, pic, pkt);
@@ -1220,7 +1252,7 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
 } else {
 pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
-(3 * ctx->output_delay)];
+(3 * ctx->output_delay + ctx->async_depth)];
 }
 av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts 
%"PRId64".\n",
pkt->pts, pkt->dts);
@@ -2541,6 +2573,11 @@ av_cold int 

[FFmpeg-devel] [PATCH v5 1/2] libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

2022-02-17 Thread Wenbin Chen
Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait
surface to complete. When surface is used for multiple operation, it
waits all operations to finish. vaSyncBuffer only wait one channel to
finish.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
 libavcodec/vaapi_encode.c | 32 +++-
 libavcodec/vaapi_encode.h |  3 +++
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..3f8c8ace2a 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -150,11 +150,25 @@ static int vaapi_encode_wait(AVCodecContext *avctx,
"(input surface %#x).\n", pic->display_order,
pic->encode_order, pic->input_surface);
 
-vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
-   "%d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
+#if VA_CHECK_VERSION(1, 9, 0)
+if (ctx->has_sync_buffer_func) {
+vas = vaSyncBuffer(ctx->hwctx->display,
+   pic->output_buffer,
+   VA_TIMEOUT_INFINITE);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer 
completion: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+} else
+#endif
+{ // If vaSyncBuffer is not implemented, try old version API.
+vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: 
"
+"%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
 }
 
 // Input is definitely finished with now.
@@ -2522,6 +2536,14 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 }
 }
 
+#if VA_CHECK_VERSION(1, 9, 0)
+// check vaSyncBuffer function
+vas = vaSyncBuffer(ctx->hwctx->display, VA_INVALID_ID, 0);
+if (vas != VA_STATUS_ERROR_UNIMPLEMENTED) {
+ctx->has_sync_buffer_func = 1;
+}
+#endif
+
 return 0;
 
 fail:
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..29d9e9b91c 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -345,6 +345,9 @@ typedef struct VAAPIEncodeContext {
 int roi_warned;
 
 AVFrame *frame;
+
+// Whether the driver support vaSyncBuffer
+int has_sync_buffer_func;
 } VAAPIEncodeContext;
 
 enum {
-- 
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] [PATCH v4 1/2] libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

2022-02-17 Thread Hao Chen

Hey, there are some make errors, pasted as follows:

libavcodec/vaapi_encode.c:2552:1: note: in expansion of macro 'av_cold'
 av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
 ^~~
libavcodec/vaapi_encode.c:2589:1: error: expected declaration or statement at 
end of input
 }
 ^
libavcodec/vaapi_encode.c:2589:1: error: control reaches end of non-void 
function [-Werror=return-type]
 }
 ^
At top level:
libavcodec/vaapi_encode.c:2552:13: warning: 'ff_vaapi_encode_close' defined but 
not used [-Wunused-function]
 av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
 ^
cc1: some warnings being treated as errors

在 2022/2/18 上午10:07, Wenbin Chen 写道:

From: Wenbin Chen 

Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait
surface to complete. When surface is used for multiple operation, it
waits all operations to finish. vaSyncBuffer only wait one channel to
finish.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
  libavcodec/vaapi_encode.c | 31 ++-
  libavcodec/vaapi_encode.h |  3 +++
  2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..335a8e450a 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -150,11 +150,25 @@ static int vaapi_encode_wait(AVCodecContext *avctx,
 "(input surface %#x).\n", pic->display_order,
 pic->encode_order, pic->input_surface);
  
-vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);

-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
-   "%d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
+#if VA_CHECK_VERSION(1, 9, 0)
+if (ctx->has_sync_buffer_func) {
+vas = vaSyncBuffer(ctx->hwctx->display,
+   pic->output_buffer,
+   VA_TIMEOUT_INFINITE);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer 
completion: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+} else
+#endif
+{ // If vaSyncBuffer is not implemented, try old version API.
+vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: 
"
+"%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
  }
  
  // Input is definitely finished with now.

@@ -2522,6 +2536,13 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
  }
  }
  
+#if VA_CHECK_VERSION(1, 9, 0)

+// check vaSyncBuffer function
+vas = vaSyncBuffer(ctx->hwctx->display, VA_INVALID_ID, 0);
+if (vas != VA_STATUS_ERROR_UNIMPLEMENTED) {
+ctx->has_sync_buffer_func = 1;
+#endif
+
  return 0;
  
  fail:

diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..29d9e9b91c 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -345,6 +345,9 @@ typedef struct VAAPIEncodeContext {
  int roi_warned;
  
  AVFrame *frame;

+
+// Whether the driver support vaSyncBuffer
+int has_sync_buffer_func;
  } VAAPIEncodeContext;
  
  enum {

___
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 v4 2/2] libavcodec/vaapi_encode: Add async_depth to vaapi_encoder to increase performance

2022-02-17 Thread Wenbin Chen
From: Wenbin Chen 

Fix: #7706. After commit 5fdcf85bbffe7451c2, vaapi encoder's performance
decrease. The reason is that vaRenderPicture() and vaSyncBuffer() are
called at the same time (vaRenderPicture() always followed by a
vaSyncBuffer()). Now I changed them to be called in a asynchronous way,
which will make better use of hardware.
Async_depth is added to increase encoder's performance. The frames that
are sent to hardware are stored in a fifo. Encoder will sync output
after async fifo is full.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
 doc/encoders.texi |  6 
 libavcodec/vaapi_encode.c | 65 +++
 libavcodec/vaapi_encode.h | 16 --
 3 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index bfb6c7eef6..6bac2b7f28 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3600,6 +3600,12 @@ will refer only to P- or I-frames.  When set to greater 
values multiple layers
 of B-frames will be present, frames in each layer only referring to frames in
 higher layers.
 
+@item async_depth
+Maximum processing parallelism. Increase this to improve single channel
+performance. This option doesn't work if driver doesn't implement vaSyncBuffer
+function. Please make sure there are enough hw_frames allocated if a large
+number of async_depth is used.
+
 @item rc_mode
 Set the rate control mode to use.  A given driver may only support a subset of
 modes.
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 335a8e450a..8c6e881702 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -965,8 +965,10 @@ static int vaapi_encode_pick_next(AVCodecContext *avctx,
 if (!pic && ctx->end_of_stream) {
 --b_counter;
 pic = ctx->pic_end;
-if (pic->encode_issued)
+if (pic->encode_complete)
 return AVERROR_EOF;
+else if (pic->encode_issued)
+return AVERROR(EAGAIN);
 }
 
 if (!pic) {
@@ -1137,7 +1139,8 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, 
AVFrame *frame)
 if (ctx->input_order == ctx->decode_delay)
 ctx->dts_pts_diff = pic->pts - ctx->first_pts;
 if (ctx->output_delay > 0)
-ctx->ts_ring[ctx->input_order % (3 * ctx->output_delay)] = 
pic->pts;
+ctx->ts_ring[ctx->input_order %
+(3 * ctx->output_delay + ctx->async_depth)] = pic->pts;
 
 pic->display_order = ctx->input_order;
 ++ctx->input_order;
@@ -1191,18 +1194,47 @@ int ff_vaapi_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt)
 return AVERROR(EAGAIN);
 }
 
-pic = NULL;
-err = vaapi_encode_pick_next(avctx, );
-if (err < 0)
-return err;
-av_assert0(pic);
+if (ctx->has_sync_buffer_func) {
+pic = NULL;
+
+if (av_fifo_can_write(ctx->encode_fifo)) {
+err = vaapi_encode_pick_next(avctx, );
+if (!err) {
+av_assert0(pic);
+pic->encode_order = ctx->encode_order +
+av_fifo_can_read(ctx->encode_fifo);
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
+av_fifo_write(ctx->encode_fifo, , 1);
+}
+}
 
-pic->encode_order = ctx->encode_order++;
+if (!av_fifo_can_read(ctx->encode_fifo))
+return err;
 
-err = vaapi_encode_issue(avctx, pic);
-if (err < 0) {
-av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
-return err;
+// More frames can be buffered
+if (av_fifo_can_write(ctx->encode_fifo) && !ctx->end_of_stream)
+return AVERROR(EAGAIN);
+
+av_fifo_read(ctx->encode_fifo, , 1);
+ctx->encode_order = pic->encode_order + 1;
+} else {
+pic = NULL;
+err = vaapi_encode_pick_next(avctx, );
+if (err < 0)
+return err;
+av_assert0(pic);
+
+pic->encode_order = ctx->encode_order++;
+
+err = vaapi_encode_issue(avctx, pic);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Encode failed: %d.\n", err);
+return err;
+}
 }
 
 err = vaapi_encode_output(avctx, pic, pkt);
@@ -1220,7 +1252,7 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
 } else {
 pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
-(3 * ctx->output_delay)];
+(3 * ctx->output_delay + ctx->async_depth)];
 }
 av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts 
%"PRId64".\n",
pkt->pts, pkt->dts);
@@ -2541,6 +2573,12 @@ av_cold int 

[FFmpeg-devel] [PATCH v4 1/2] libavcodec/vaapi_encode: Add new API adaption to vaapi_encode

2022-02-17 Thread Wenbin Chen
From: Wenbin Chen 

Add vaSyncBuffer to VAAPI encoder. Old version API vaSyncSurface wait
surface to complete. When surface is used for multiple operation, it
waits all operations to finish. vaSyncBuffer only wait one channel to
finish.

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
 libavcodec/vaapi_encode.c | 31 ++-
 libavcodec/vaapi_encode.h |  3 +++
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..335a8e450a 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -150,11 +150,25 @@ static int vaapi_encode_wait(AVCodecContext *avctx,
"(input surface %#x).\n", pic->display_order,
pic->encode_order, pic->input_surface);
 
-vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: "
-   "%d (%s).\n", vas, vaErrorStr(vas));
-return AVERROR(EIO);
+#if VA_CHECK_VERSION(1, 9, 0)
+if (ctx->has_sync_buffer_func) {
+vas = vaSyncBuffer(ctx->hwctx->display,
+   pic->output_buffer,
+   VA_TIMEOUT_INFINITE);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to output buffer 
completion: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+} else
+#endif
+{ // If vaSyncBuffer is not implemented, try old version API.
+vas = vaSyncSurface(ctx->hwctx->display, pic->input_surface);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to sync to picture completion: 
"
+"%d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
 }
 
 // Input is definitely finished with now.
@@ -2522,6 +2536,13 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 }
 }
 
+#if VA_CHECK_VERSION(1, 9, 0)
+// check vaSyncBuffer function
+vas = vaSyncBuffer(ctx->hwctx->display, VA_INVALID_ID, 0);
+if (vas != VA_STATUS_ERROR_UNIMPLEMENTED) {
+ctx->has_sync_buffer_func = 1;
+#endif
+
 return 0;
 
 fail:
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..29d9e9b91c 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -345,6 +345,9 @@ typedef struct VAAPIEncodeContext {
 int roi_warned;
 
 AVFrame *frame;
+
+// Whether the driver support vaSyncBuffer
+int has_sync_buffer_func;
 } VAAPIEncodeContext;
 
 enum {
-- 
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 v1 4/4] vaapi_encode_h265: Query encoding block sizes and features

2022-02-17 Thread Fei Wang
From: Mark Thompson 

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode_h265.c | 107 +++--
 1 file changed, 102 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 8319848e4a..e98502503d 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -56,6 +56,9 @@ typedef struct VAAPIEncodeH265Context {
 VAAPIEncodeContext common;
 
 // Encoder features.
+uint32_t va_features;
+// Block size info.
+uint32_t va_bs;
 uint32_t ctu_size;
 uint32_t min_cb_size;
 
@@ -427,9 +430,9 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 vps->vps_max_latency_increase_plus1[i];
 }
 
-// These have to come from the capabilities of the encoder.  We have no
-// way to query them, so just hardcode parameters which work on the Intel
-// driver.
+// These values come from the capabilities of the first encoder
+// implementation in the i965 driver on Intel Skylake.  They may
+// fail badly with other platforms or drivers.
 // CTB size from 8x8 to 32x32.
 sps->log2_min_luma_coding_block_size_minus3   = 0;
 sps->log2_diff_max_min_luma_coding_block_size = 2;
@@ -447,6 +450,42 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 
 sps->pcm_enabled_flag = 0;
 
+// update sps setting according to queried result
+#if VA_CHECK_VERSION(1, 13, 0)
+if (priv->va_features) {
+VAConfigAttribValEncHEVCFeatures features = { .value = 
priv->va_features };
+
+// Enable feature if get queried result is VA_FEATURE_SUPPORTED | 
VA_FEATURE_REQUIRED
+sps->amp_enabled_flag =
+!!features.bits.amp;
+sps->sample_adaptive_offset_enabled_flag =
+!!features.bits.sao;
+sps->sps_temporal_mvp_enabled_flag =
+!!features.bits.temporal_mvp;
+sps->pcm_enabled_flag =
+!!features.bits.pcm;
+}
+
+if (priv->va_bs) {
+VAConfigAttribValEncHEVCBlockSizes bs = { .value = priv->va_bs };
+sps->log2_min_luma_coding_block_size_minus3 =
+ff_ctz(priv->min_cb_size) - 3;
+sps->log2_diff_max_min_luma_coding_block_size =
+ff_ctz(priv->ctu_size) - ff_ctz(priv->min_cb_size);
+
+sps->log2_min_luma_transform_block_size_minus2 =
+bs.bits.log2_min_luma_transform_block_size_minus2;
+sps->log2_diff_max_min_luma_transform_block_size =
+bs.bits.log2_max_luma_transform_block_size_minus2 -
+bs.bits.log2_min_luma_transform_block_size_minus2;
+
+sps->max_transform_hierarchy_depth_inter =
+bs.bits.max_max_transform_hierarchy_depth_inter;
+sps->max_transform_hierarchy_depth_intra =
+bs.bits.max_max_transform_hierarchy_depth_intra;
+}
+#endif
+
 // STRPSs should ideally be here rather than defined individually in
 // each slice, but the structure isn't completely fixed so for now
 // don't bother.
@@ -539,6 +578,23 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP);
 pps->diff_cu_qp_delta_depth   = 0;
 
+// update pps setting according to queried result
+#if VA_CHECK_VERSION(1, 13, 0)
+if (priv->va_features) {
+VAConfigAttribValEncHEVCFeatures features = { .value = 
priv->va_features };
+if (ctx->va_rc_mode != VA_RC_CQP)
+pps->cu_qp_delta_enabled_flag =
+!!features.bits.cu_qp_delta;
+
+pps->transform_skip_enabled_flag =
+!!features.bits.transform_skip;
+// set diff_cu_qp_delta_depth as its max value if cu_qp_delta enabled. 
Otherwise
+// 0 will make cu_qp_delta invalid.
+if (pps->cu_qp_delta_enabled_flag)
+pps->diff_cu_qp_delta_depth = 
sps->log2_diff_max_min_luma_coding_block_size;
+}
+#endif
+
 if (ctx->tile_rows && ctx->tile_cols) {
 int uniform_spacing;
 
@@ -640,8 +696,8 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 
 .coded_buf = VA_INVALID_ID,
 
-.collocated_ref_pic_index = 0xff,
-
+.collocated_ref_pic_index = sps->sps_temporal_mvp_enabled_flag ?
+0 : 0xff,
 .last_picture = 0,
 
 .pic_init_qp= pps->init_qp_minus26 + 26,
@@ -674,6 +730,8 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 .entropy_coding_sync_enabled_flag = 
pps->entropy_coding_sync_enabled_flag,
 .loop_filter_across_tiles_enabled_flag =
 pps->loop_filter_across_tiles_enabled_flag,
+.pps_loop_filter_across_slices_enabled_flag =
+pps->pps_loop_filter_across_slices_enabled_flag,
 .scaling_list_data_present_flag = 
(sps->sps_scaling_list_data_present_flag |
  

[FFmpeg-devel] [PATCH v1 3/4] vaapi_encode_h265: Explicitly set and correct some flags

2022-02-17 Thread Fei Wang
From: Mark Thompson 

max_14bit_constraint_flag should be set if the bit depth is not greater than
14 (currently always true).

one_picture_only_flag should not be set because we don't support the still
picture profiles.

general_profile_compatibility_flag should be set according to 
general_profile_idc
instead of bit depth.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode_h265.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 5b8dbe841d..8319848e4a 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -303,17 +303,21 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 ptl->general_profile_idc   = avctx->profile;
 ptl->general_tier_flag = priv->tier;
 
-if (chroma_format == 1) {
-ptl->general_profile_compatibility_flag[1] = bit_depth ==  8;
-ptl->general_profile_compatibility_flag[2] = bit_depth <= 10;
+ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1;
+
+if (ptl->general_profile_compatibility_flag[1])
+ptl->general_profile_compatibility_flag[2] = 1;
+if (ptl->general_profile_compatibility_flag[3]) {
+ptl->general_profile_compatibility_flag[1] = 1;
+ptl->general_profile_compatibility_flag[2] = 1;
 }
-ptl->general_profile_compatibility_flag[4] = 1;
 
 ptl->general_progressive_source_flag= 1;
 ptl->general_interlaced_source_flag = 0;
 ptl->general_non_packed_constraint_flag = 1;
 ptl->general_frame_only_constraint_flag = 1;
 
+ptl->general_max_14bit_constraint_flag = bit_depth <= 14;
 ptl->general_max_12bit_constraint_flag = bit_depth <= 12;
 ptl->general_max_10bit_constraint_flag = bit_depth <= 10;
 ptl->general_max_8bit_constraint_flag  = bit_depth ==  8;
@@ -323,6 +327,7 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 ptl->general_max_monochrome_constraint_flag = chroma_format == 0;
 
 ptl->general_intra_constraint_flag = ctx->gop_size == 1;
+ptl->general_one_picture_only_constraint_flag = 0;
 
 ptl->general_lower_bit_rate_constraint_flag = 1;
 
-- 
2.25.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 v1 2/4] vaapi_encode: Move block size calculation after entrypoint selection

2022-02-17 Thread Fei Wang
From: Mark Thompson 

The block size can be dependent on the profile and entrypoint selected.
It defaults to 16x16, with codecs able to override this choice with their
own function.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c   | 14 ++
 libavcodec/vaapi_encode.h   |  7 +++
 libavcodec/vaapi_encode_h265.c  | 32 ++--
 libavcodec/vaapi_encode_mjpeg.c | 16 +---
 libavcodec/vaapi_encode_mpeg2.c |  3 ---
 libavcodec/vaapi_encode_vp8.c   |  3 ---
 libavcodec/vaapi_encode_vp9.c   | 14 ++
 7 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 95eca7c288..763fe50009 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -2041,6 +2041,8 @@ static av_cold int 
vaapi_encode_init_slice_structure(AVCodecContext *avctx)
 return 0;
 }
 
+av_assert0(ctx->slice_block_height > 0 && ctx->slice_block_width > 0);
+
 ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) /
  ctx->slice_block_height;
 ctx->slice_block_cols = (avctx->width  + ctx->slice_block_width  - 1) /
@@ -2430,6 +2432,18 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 if (err < 0)
 goto fail;
 
+if (ctx->codec->get_encoder_caps) {
+ctx->codec->get_encoder_caps(avctx);
+} else {
+// Assume 16x16 blocks.
+ctx->surface_width  = FFALIGN(avctx->width,  16);
+ctx->surface_height = FFALIGN(avctx->height, 16);
+if (ctx->codec->flags & FLAG_SLICE_CONTROL) {
+ctx->slice_block_width  = 16;
+ctx->slice_block_height = 16;
+}
+}
+
 err = vaapi_encode_init_rate_control(avctx);
 if (err < 0)
 goto fail;
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index 61c5615eb8..2e5cfd7a72 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -376,6 +376,13 @@ typedef struct VAAPIEncodeType {
 // factor depending on RC mode.
 int default_quality;
 
+// Determine encode parameters like block sizes for surface alignment
+// and slices. This may need to query the profile and entrypoint,
+// which will be available when this function is called. If not set,
+// assume that all blocks are 16x16 and that surfaces should be
+// aligned to match this.
+void (*get_encoder_caps)(AVCodecContext *avctx);
+
 // Perform any extra codec-specific configuration after the
 // codec context is initialised (set up the private data and
 // add any necessary global parameters).
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index ea45893508..5b8dbe841d 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -55,6 +55,10 @@ typedef struct VAAPIEncodeH265Picture {
 typedef struct VAAPIEncodeH265Context {
 VAAPIEncodeContext common;
 
+// Encoder features.
+uint32_t ctu_size;
+uint32_t min_cb_size;
+
 // User options.
 int qp;
 int aud;
@@ -1091,6 +1095,27 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
 return 0;
 }
 
+static av_cold void vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx)
+{
+VAAPIEncodeContext  *ctx = avctx->priv_data;
+VAAPIEncodeH265Context *priv = avctx->priv_data;
+
+if (!priv->ctu_size) {
+priv->ctu_size = 32;
+priv->min_cb_size  = 16;
+}
+av_log(avctx, AV_LOG_VERBOSE, "Using CTU size %dx%d, "
+   "min CB size %dx%d.\n", priv->ctu_size, priv->ctu_size,
+   priv->min_cb_size, priv->min_cb_size);
+
+ctx->surface_width  = FFALIGN(avctx->width,  priv->min_cb_size);
+ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
+
+ctx->slice_block_width = ctx->slice_block_height = priv->ctu_size;
+
+return;
+}
+
 static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
 {
 VAAPIEncodeContext  *ctx = avctx->priv_data;
@@ -1160,6 +1185,7 @@ static const VAAPIEncodeType vaapi_encode_type_h265 = {
 
 .default_quality   = 25,
 
+.get_encoder_caps  = _encode_h265_get_encoder_caps,
 .configure = _encode_h265_configure,
 
 .picture_priv_data_size = sizeof(VAAPIEncodeH265Picture),
@@ -1205,12 +1231,6 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext 
*avctx)
 VA_ENC_PACKED_HEADER_SLICE| // Slice headers.
 VA_ENC_PACKED_HEADER_MISC;  // SEI
 
-ctx->surface_width  = FFALIGN(avctx->width,  16);
-ctx->surface_height = FFALIGN(avctx->height, 16);
-
-// CTU size is currently hard-coded to 32.
-ctx->slice_block_width = ctx->slice_block_height = 32;
-
 if (priv->qp > 0)
 ctx->explicit_qp = priv->qp;
 
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
index 6206b23e5f..c4fe879073 100644
--- 

[FFmpeg-devel] [PATCH v1 1/4] lavc/vaapi_encode_h265: Add P frame to GPB frame support for hevc_vaapi

2022-02-17 Thread Fei Wang
From: Linjie Fu 

Use GPB frames to replace regular P frames if backend driver does not
support it.

- GPB:
Generalized P and B picture. P frames replaced by B frames with
forward-predict only, L0 == L1. Normal B frames still have 2
different ref_lists and allow bi-prediction

Signed-off-by: Linjie Fu 
Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c  | 33 +++--
 libavcodec/vaapi_encode.h  |  1 +
 libavcodec/vaapi_encode_h265.c | 15 +++
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 3bf379b1a0..95eca7c288 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1845,6 +1845,30 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
 ref_l1 = attr.value >> 16 & 0x;
 }
 
+ctx->p_to_gpb = 0;
+
+#if VA_CHECK_VERSION(1, 9, 0)
+attr = (VAConfigAttrib) { VAConfigAttribPredictionDirection };
+vas = vaGetConfigAttributes(ctx->hwctx->display,
+ctx->va_profile,
+ctx->va_entrypoint,
+, 1);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_WARNING, "Failed to query prediction direction "
+   "attribute: %d (%s).\n", vas, vaErrorStr(vas));
+} else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
+av_log(avctx, AV_LOG_VERBOSE, "Driver does not report whether "
+   "support GPB, use regular P frames.\n");
+} else {
+if (attr.value & VA_PREDICTION_DIRECTION_BI_NOT_EMPTY) {
+ctx->p_to_gpb = 1;
+av_log(avctx, AV_LOG_VERBOSE, "Use GPB B frames to replace "
+   "regular P frames.\n");
+} else
+av_log(avctx, AV_LOG_VERBOSE, "Use regular P frames.\n");
+}
+#endif
+
 if (ctx->codec->flags & FLAG_INTRA_ONLY ||
 avctx->gop_size <= 1) {
 av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n");
@@ -1861,8 +1885,13 @@ static av_cold int 
vaapi_encode_init_gop_structure(AVCodecContext *avctx)
 ctx->p_per_i  = INT_MAX;
 ctx->b_per_p  = 0;
 } else {
-av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
-   "(supported references: %d / %d).\n", ref_l0, ref_l1);
+   if (ctx->p_to_gpb)
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra, GPB-B-frames and "
+  "B-frames (supported references: %d / %d).\n",
+  ref_l0, ref_l1);
+   else
+   av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames "
+  "(supported references: %d / %d).\n", ref_l0, ref_l1);
 ctx->gop_size = avctx->gop_size;
 ctx->p_per_i  = INT_MAX;
 ctx->b_per_p  = avctx->max_b_frames;
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index b41604a883..61c5615eb8 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -328,6 +328,7 @@ typedef struct VAAPIEncodeContext {
 int idr_counter;
 int gop_counter;
 int end_of_stream;
+int p_to_gpb;
 
 // Whether the driver supports ROI at all.
 int roi_allowed;
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index e1dc53dfa9..ea45893508 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -886,6 +886,7 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
VAAPIEncodePicture *pic,
VAAPIEncodeSlice *slice)
 {
+VAAPIEncodeContext*ctx = avctx->priv_data;
 VAAPIEncodeH265Context   *priv = avctx->priv_data;
 VAAPIEncodeH265Picture   *hpic = pic->priv_data;
 const H265RawSPS  *sps = >raw_sps;
@@ -908,6 +909,9 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
 
 sh->slice_type = hpic->slice_type;
 
+if (sh->slice_type == HEVC_SLICE_P && ctx->p_to_gpb)
+sh->slice_type = HEVC_SLICE_B;
+
 sh->slice_pic_order_cnt_lsb = hpic->pic_order_cnt &
 (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1;
 
@@ -1066,6 +1070,9 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
 av_assert0(pic->type == PICTURE_TYPE_P ||
pic->type == PICTURE_TYPE_B);
 vslice->ref_pic_list0[0] = vpic->reference_frames[0];
+if (ctx->p_to_gpb && pic->type == PICTURE_TYPE_P)
+// Reference for GPB B-frame, L0 == L1
+vslice->ref_pic_list1[0] = vpic->reference_frames[0];
 }
 if (pic->nb_refs >= 2) {
 // Forward reference for B-frame.
@@ -1073,6 +1080,14 @@ static int 
vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
 vslice->ref_pic_list1[0] = vpic->reference_frames[1];
 }
 
+if (pic->type == 

Re: [FFmpeg-devel] [PATCH v2] libavcodec/qsvenc_hevc: encode RGB format rawvideo

2022-02-17 Thread Chen, Wenbin
> On Tue, 2022-02-15 at 15:00 +0800, Wenbin Chen wrote:
> > Add support for hevc_qsv to input RGB format frame. It will
> > transform frame to yuv inside MediaSDK instead of using auto
> > scale. Now hevc_qsv supports directly encoding BGRA and X2RGB10
> > format. X2RGB10 is only supported in VDENC (-low_power 1).
> > The X2RGB10 correspond to the A2RGB20 format in MediaSDK.
> >
> > Signed-off-by: Wenbin Chen 
> > ---
> >  libavcodec/qsv.c | 16 
> >  libavcodec/qsvenc.c  | 13 +
> >  libavcodec/qsvenc_hevc.c |  6 ++
> >  3 files changed, 35 insertions(+)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > index 1a432dbd82..b75877e698 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -189,6 +189,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t
> fourcc)
> >  case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> >  case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> >  case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > +#if QSV_VERSION_ATLEAST(1, 9)
> > +case MFX_FOURCC_A2RGB10: return AV_PIX_FMT_X2RGB10;
> > +#endif
> > +#if QSV_VERSION_ATLEAST(1, 17)
> > +case MFX_FOURCC_RGB4: return AV_PIX_FMT_BGRA;
> > +#endif
> >  #if CONFIG_VAAPI
> >  case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> >  #if QSV_VERSION_ATLEAST(1, 27)
> > @@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat
> format, uint32_t
> > *fourcc)
> >  case AV_PIX_FMT_P010:
> >  *fourcc = MFX_FOURCC_P010;
> >  return AV_PIX_FMT_P010;
> > +#if QSV_VERSION_ATLEAST(1, 9)
> > +case AV_PIX_FMT_X2RGB10:
> > +*fourcc = MFX_FOURCC_A2RGB10;
> > +return AV_PIX_FMT_X2RGB10;
> > +#endif
> > +#if QSV_VERSION_ATLEAST(1, 17)
> > +case AV_PIX_FMT_BGRA:
> > +*fourcc = MFX_FOURCC_RGB4;
> > +return AV_PIX_FMT_BGRA;
> > +#endif
> >  #if CONFIG_VAAPI
> >  case AV_PIX_FMT_YUV422P:
> >  case AV_PIX_FMT_YUYV422:
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > index 07be4287b7..104133fc59 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -715,6 +715,11 @@ static int init_video_param(AVCodecContext
> *avctx,
> > QSVEncContext *q)
> >  if (ret < 0)
> >  return AVERROR_BUG;
> >
> > +if (sw_format == AV_PIX_FMT_X2RGB10 && q->low_power != 1) {
> 
> The SDK may choose a workable mode if low_power is set to auto.
> 
> Thanks
> Haihao

Thanks for your information. I will update patch.

> 
> > +av_log(avctx, AV_LOG_ERROR, "Only VDENC support encoding
> x2rgb10\n");
> > +return AVERROR(EINVAL);
> > +}
> > +
> >  q->param.mfx.FrameInfo.CropX  = 0;
> >  q->param.mfx.FrameInfo.CropY  = 0;
> >  q->param.mfx.FrameInfo.CropW  = avctx->width;
> > @@ -1616,6 +1621,14 @@ static int submit_frame(QSVEncContext *q,
> const AVFrame
> > *frame,
> >  qf->surface.Data.V = qf->surface.Data.UV + 2;
> >  break;
> >
> > +case AV_PIX_FMT_X2RGB10:
> > +case AV_PIX_FMT_BGRA:
> > +qf->surface.Data.B = qf->frame->data[0];
> > +qf->surface.Data.G = qf->frame->data[0] + 1;
> > +qf->surface.Data.R = qf->frame->data[0] + 2;
> > +qf->surface.Data.A = qf->frame->data[0] + 3;
> > +break;
> > +
> >  default:
> >  /* should not reach here */
> >  av_assert0(0);
> > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> > index 5cac141c4d..ade546d4ca 100644
> > --- a/libavcodec/qsvenc_hevc.c
> > +++ b/libavcodec/qsvenc_hevc.c
> > @@ -304,6 +304,12 @@ const AVCodec ff_hevc_qsv_encoder = {
> >  .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> >  AV_PIX_FMT_P010,
> >  AV_PIX_FMT_QSV,
> > +#if QSV_VERSION_ATLEAST(1, 17)
> > +AV_PIX_FMT_BGRA,
> > +#endif
> > +#if QSV_VERSION_ATLEAST(1, 9)
> > +AV_PIX_FMT_X2RGB10,
> > +#endif
> >  AV_PIX_FMT_NONE },
> >  .priv_class = ,
> >  .defaults   = qsv_enc_defaults,
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/3] configure: check avisynth header version

2022-02-17 Thread Stephen Hutchinson

On 2/17/22 5:19 PM, Helmut K. C. Tessarek wrote:


It's definitely not working, since I don't ship any dylibs. I always thought
3.5.1 li9nked a static lib, but I checked. It does not.

Even if I wanted to I couldn't ship any dylibs, since I can't build
AviSynthPlus on macOS 10.14.



It's really the same situation as Windows: users get the FFmpeg build 
from whoever builds it with AviSynth support enabled, and if they want 
to use that functionality, they can install the official release of 
AviSynth+ that we provide upstream.  The .dll situation on Windows is 
one of several reasons for the use of dlopen, as well.


That's why with 3.7.0 I started providing macOS builds in the releases 
in both installer .pkg and -filesonly tarball form, since I know some 
people prefer doing it that way.

___
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 3/3] configure: check avisynth header version

2022-02-17 Thread Helmut K. C. Tessarek
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512



On 2022-02-16 19:55, Stephen Hutchinson wrote:
> FFmpeg dlopens AviSynth, it only needs the headers and doesn't try to
> link it.  It has never linked to AviSynth.

This I find strange. dlopen is rather useless when you create static
binaries unless you want to ship X diffreent dylibs or SOs with the binary.

There's also no static version of frei0r. Very annoying.

> If 3.5.1 is working (and by that I assume you mean you're opening a
> Version() script in FFplay and it's showing you the video clip with the
> version and copyright information), then libavisynth.dylib is somewhere
> on your DYLD_LIBRARY_PATH, and you could just as easily set
> DYLD_LIBRARY_PATH to the /usr/lib directory in the -filesonly package and
> that Version() script will start reporting 3.7.1 instead.

It's definitely not working, since I don't ship any dylibs. I always thought
3.5.1 li9nked a static lib, but I checked. It does not.

Even if I wanted to I couldn't ship any dylibs, since I can't build
AviSynthPlus on macOS 10.14.

> At this point, just use latest git, since that's where the HEADERS_ONLY
> fix resides: And HEADERS_ONLY is exactly what it says on the tin: it only
> sets CMake to install the headers, and stops it from building the
> library, which wouldn't get linked to anyway.

Ok, this worked. I was able to compile ffmpeg again. At least now I know
that avisynth won't work with static banaries unless people install dylibs
themselves.

- -- 
regards Helmut K. C. Tessarek  KeyID 0x172380A011EF4944
Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944

/*
   Thou shalt not follow the NULL pointer for chaos and madness
   await thee at its end.
*/
-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEE191csiqpm8f5Ln9WvgmFNJ1E3QAFAmIOyeMACgkQvgmFNJ1E
3QDS7g//VMqsrxTK7uC/N65ydY4MvEOhqZJcAJqTtmyDStqWrgLOr1zeTutu359I
G3ah7M9/BYnZVwiVDypLgvRBNLR9F7bgv4CdG+VaV2M5Ljuv8yqiLG4ohbY6BcC3
6Da+CV2X7ylDunnGuI+jFQ2+E/DrP6lJRvMweotsLZvluTU3PCGNIpOHxt6SLq1S
eN9V9UluOZT/+YYk4XOWiWpYucDBvZbRUCfcZtckKESRwpRrZCMRO9ExJXdRvNRr
gyy0EIIDqAHhoEyP7RkadFuHOco4Beppalru4+UEvSwWae2B2pr8pwfFh8RUvXk6
75SNWOzfQoyndvEQR4jDv3PLFswWMv8upeGoGJHsb0NcOY31Uk0Y58kMzbzDC/eT
uK8Jp5+5Gx+uOG8k/dvKQK5TllnelApSFaVbyeuzrcRnphVi6ad6OtdSPBaWKjdD
BljKMkAr/plpCsfuJ9THdXIo3Q0qwoXC4l/fL8Q35uiqYcOOa8Ax/FePe/srMDnp
vxtDBBzo+8nA2305OUtErEAq0XhgCnSvOyfzoXx4fWxF39N15tU2VKTDoPAkjx9A
5dx/753wos5HewC5WeESzKCALXWu5l9r/sV/Jih8rf+8YXzJweMjso+Ca2B8e7bv
2nWvPMAcqtByklBnsVpkV3QTGDaxb2c1E4XhEoTchKjVKeFzrQo=
=5yaK
-END 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 1/3] avcodec/libaomenc: Add parameter for avif single image encoding

2022-02-17 Thread Vignesh Venkatasubramanian
On Thu, Feb 17, 2022 at 1:00 PM James Almer  wrote:
>
>
>
> On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote:
> > Add a parameter to libaom-av1 encoder to enforce some of the single
> > image constraints in the AV1 encoder. Setting this flag will limit
> > the encoder to producing exactly one frame and the sequence header
> > that is produced by the encoder will be conformant to the AVIF
> > specification [1].
> >
> > Part of Fixing Trac ticket #7621
> >
> > [1] https://aomediacodec.github.io/av1-avif
> >
> > Signed-off-by:: Vignesh Venkatasubramanian 
> > ---
> >   libavcodec/libaomenc.c | 14 ++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > index 963cc1bcbc..0398060a2f 100644
> > --- a/libavcodec/libaomenc.c
> > +++ b/libavcodec/libaomenc.c
> > @@ -99,6 +99,7 @@ typedef struct AOMEncoderContext {
> >   int enable_restoration;
> >   int usage;
> >   int tune;
> > +int is_avif;
> >   int enable_rect_partitions;
> >   int enable_1to4_partitions;
> >   int enable_ab_partitions;
> > @@ -746,6 +747,18 @@ static av_cold int aom_init(AVCodecContext *avctx,
> >   if (res < 0)
> >   return res;
> >
> > +if (ctx->is_avif) {
> > +// Set the maximum number of frames to 1. This will let libaom set
> > +// still_picture and reduced_still_picture_header to 1 in the 
> > Sequence
> > +// Header as required by AVIF still images.
> > +enccfg.g_limit = 1;
>
> How will libaom react if you feed it more than 1 frame? Will it reject
> the input and return an error?
>

Yes, trying to encode a second frame after setting g_limit to 1 will
result in aom_codec_encode() returning an error.

> > +// Reduce memory usage for still images.
> > +enccfg.g_lag_in_frames = 0;
> > +// All frames will be key frames.
> > +enccfg.kf_max_dist = 0;
> > +enccfg.kf_mode = AOM_KF_DISABLED;
> > +}
> > +
> >   /* Construct Encoder Context */
> >   res = aom_codec_enc_init(>encoder, iface, , flags);
> >   if (res != AOM_CODEC_OK) {
> > @@ -1290,6 +1303,7 @@ static const AVOption options[] = {
> >   { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> > AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
> >   { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> > AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
> >   FF_AV1_PROFILE_OPTS
> > +{ "avif-image", "Encode in single frame mode for still AVIF images.", 
> > OFFSET(is_avif), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },
>
> Judging by the above settings, this option should be called
> "still_picture". The description can mention it's required for AVIF output.
>

Renamed the variable and the option name to "still_picture".

> An alternative is to add new AVProfiles, giving them values outside the
> range that would be written into the sequence header. Like
> FF_PROFILE_AV1_MAIN_STILL_PICTURE with a value of 0x80,
> FF_PROFILE_AV1_HIGH_STILL_PICTURE with a value of 0x81, etc.
> Then you just look for avctx->profile & 0x80 to know it's a still picture.
>
> Of course considerations would need to be done to avoid problems, like
> the line "enccfg.g_profile = avctx->profile;" being changed to
> "enccfg.g_profile = avctx->profile & 0x3;" (We can define a constant for
> that 0x3 mask called profile_bits or whatever).
>
> >   { "enable-rect-partitions", "Enable rectangular partitions", 
> > OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> >   { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", 
> > OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> >   { "enable-ab-partitions",   "Enable ab shape partitions",
> > OFFSET(enable_ab_partitions),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> ___
> 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".



-- 
Vignesh
___
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/libaomenc: Add parameter for avif single image encoding

2022-02-17 Thread Vignesh Venkatasubramanian
Add a parameter to libaom-av1 encoder to enforce some of the single
image constraints in the AV1 encoder. Setting this flag will limit
the encoder to producing exactly one frame and the sequence header
that is produced by the encoder will be conformant to the AVIF
specification [1].

Part of Fixing Trac ticket #7621

[1] https://aomediacodec.github.io/av1-avif

Signed-off-by:: Vignesh Venkatasubramanian 
---
 libavcodec/libaomenc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 963cc1bcbc..638c1deca6 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -99,6 +99,7 @@ typedef struct AOMEncoderContext {
 int enable_restoration;
 int usage;
 int tune;
+int still_picture;
 int enable_rect_partitions;
 int enable_1to4_partitions;
 int enable_ab_partitions;
@@ -746,6 +747,18 @@ static av_cold int aom_init(AVCodecContext *avctx,
 if (res < 0)
 return res;
 
+if (ctx->still_picture) {
+// Set the maximum number of frames to 1. This will let libaom set
+// still_picture and reduced_still_picture_header to 1 in the Sequence
+// Header as required by AVIF still images.
+enccfg.g_limit = 1;
+// Reduce memory usage for still images.
+enccfg.g_lag_in_frames = 0;
+// All frames will be key frames.
+enccfg.kf_max_dist = 0;
+enccfg.kf_mode = AOM_KF_DISABLED;
+}
+
 /* Construct Encoder Context */
 res = aom_codec_enc_init(>encoder, iface, , flags);
 if (res != AOM_CODEC_OK) {
@@ -1290,6 +1303,7 @@ static const AVOption options[] = {
 { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
 { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
 FF_AV1_PROFILE_OPTS
+{ "still-picture", "Encode in single frame mode (typically used for still 
AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE 
},
 { "enable-rect-partitions", "Enable rectangular partitions", 
OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
 { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", 
OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
 { "enable-ab-partitions",   "Enable ab shape partitions",
OFFSET(enable_ab_partitions),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
-- 
2.35.1.265.g69c8d7142f-goog

___
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/libaomenc: Add parameter for avif single image encoding

2022-02-17 Thread James Almer




On 2/17/2022 2:51 AM, Vignesh Venkatasubramanian wrote:

Add a parameter to libaom-av1 encoder to enforce some of the single
image constraints in the AV1 encoder. Setting this flag will limit
the encoder to producing exactly one frame and the sequence header
that is produced by the encoder will be conformant to the AVIF
specification [1].

Part of Fixing Trac ticket #7621

[1] https://aomediacodec.github.io/av1-avif

Signed-off-by:: Vignesh Venkatasubramanian 
---
  libavcodec/libaomenc.c | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 963cc1bcbc..0398060a2f 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -99,6 +99,7 @@ typedef struct AOMEncoderContext {
  int enable_restoration;
  int usage;
  int tune;
+int is_avif;
  int enable_rect_partitions;
  int enable_1to4_partitions;
  int enable_ab_partitions;
@@ -746,6 +747,18 @@ static av_cold int aom_init(AVCodecContext *avctx,
  if (res < 0)
  return res;
  
+if (ctx->is_avif) {

+// Set the maximum number of frames to 1. This will let libaom set
+// still_picture and reduced_still_picture_header to 1 in the Sequence
+// Header as required by AVIF still images.
+enccfg.g_limit = 1;


How will libaom react if you feed it more than 1 frame? Will it reject 
the input and return an error?



+// Reduce memory usage for still images.
+enccfg.g_lag_in_frames = 0;
+// All frames will be key frames.
+enccfg.kf_max_dist = 0;
+enccfg.kf_mode = AOM_KF_DISABLED;
+}
+
  /* Construct Encoder Context */
  res = aom_codec_enc_init(>encoder, iface, , flags);
  if (res != AOM_CODEC_OK) {
@@ -1290,6 +1303,7 @@ static const AVOption options[] = {
  { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_PSNR}, 0, 
0, VE, "tune"},
  { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 
0, VE, "tune"},
  FF_AV1_PROFILE_OPTS
+{ "avif-image", "Encode in single frame mode for still AVIF images.", 
OFFSET(is_avif), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },


Judging by the above settings, this option should be called 
"still_picture". The description can mention it's required for AVIF output.


An alternative is to add new AVProfiles, giving them values outside the 
range that would be written into the sequence header. Like 
FF_PROFILE_AV1_MAIN_STILL_PICTURE with a value of 0x80, 
FF_PROFILE_AV1_HIGH_STILL_PICTURE with a value of 0x81, etc.

Then you just look for avctx->profile & 0x80 to know it's a still picture.

Of course considerations would need to be done to avoid problems, like 
the line "enccfg.g_profile = avctx->profile;" being changed to 
"enccfg.g_profile = avctx->profile & 0x3;" (We can define a constant for 
that 0x3 mask called profile_bits or whatever).



  { "enable-rect-partitions", "Enable rectangular partitions", 
OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
  { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", 
OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
  { "enable-ab-partitions",   "Enable ab shape partitions",
OFFSET(enable_ab_partitions),   AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},

___
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 5/5] fftools: Enable long path support on Windows (fixes #8885)

2022-02-17 Thread Marton Balint




On Wed, 16 Feb 2022, nihil-admirari wrote:


---
fftools/Makefile |  5 +
fftools/long_paths_utf8.manifest | 12 
fftools/long_paths_utf8.rc   |  3 +++
3 files changed, 20 insertions(+)
create mode 100644 fftools/long_paths_utf8.manifest
create mode 100644 fftools/long_paths_utf8.rc

diff --git a/fftools/Makefile b/fftools/Makefile
index da42078..53438b6 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -11,6 +11,11 @@ ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))

OBJS-ffmpeg+= fftools/ffmpeg_opt.o 
fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o

+# Windows resource files
+OBJS-ffmpeg-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o
+OBJS-ffplay-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o
+OBJS-ffprobe-$(HAVE_GNU_WINDRES) += fftools/long_paths_utf8.o
+
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
diff --git a/fftools/long_paths_utf8.manifest b/fftools/long_paths_utf8.manifest
new file mode 100644
index 000..d1ac1e4
--- /dev/null
+++ b/fftools/long_paths_utf8.manifest
@@ -0,0 +1,12 @@
+
+
+
+  
+  
+http://schemas.microsoft.com/SMI/2016/WindowsSettings;
+ 
xmlns:ws2019="http://schemas.microsoft.com/SMI/2019/WindowsSettings;>
+  true
+  UTF-8


Generally UTF-8 codepage should not be needed, because unicode windows 
functions should be used everywhere, right?


I'd perfer if you enable UTF8 codepage in a separate patch. And use simple 
fftools/fftools.manifest and fftools/manifest.rc as filenames, because 
later other things might be put there, not only utf8/longpath support.


Thanks,
Marton


+
+  
+
diff --git a/fftools/long_paths_utf8.rc b/fftools/long_paths_utf8.rc
new file mode 100644
index 000..f33de76
--- /dev/null
+++ b/fftools/long_paths_utf8.rc
@@ -0,0 +1,3 @@
+#include 
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "long_paths_utf8.manifest"
--
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 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/libaomenc: Add parameter for avif single image encoding

2022-02-17 Thread Vignesh Venkatasubramanian
On Thu, Feb 17, 2022 at 10:09 AM James Zern  wrote:
>
> On Wed, Feb 16, 2022 at 9:51 PM Vignesh Venkatasubramanian
>  wrote:
> >
> > Add a parameter to libaom-av1 encoder to enforce some of the single
> > image constraints in the AV1 encoder. Setting this flag will limit
> > the encoder to producing exactly one frame and the sequence header
> > that is produced by the encoder will be conformant to the AVIF
> > specification [1].
> >
> > Part of Fixing Trac ticket #7621
> >
> > [1] https://aomediacodec.github.io/av1-avif
> >
> > Signed-off-by:: Vignesh Venkatasubramanian 
> > ---
> >  libavcodec/libaomenc.c | 14 ++
> >  1 file changed, 14 insertions(+)
> >
> > [...]
> > @@ -1290,6 +1303,7 @@ static const AVOption options[] = {
> >  { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> > AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
> >  { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> > AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
> >  FF_AV1_PROFILE_OPTS
> > +{ "avif-image", "Encode in single frame mode for still AVIF images.", 
> > OFFSET(is_avif), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },
>
> Can this instead be mapped to something that can be sent via aom-params?


>From what i understand, aom-params can only be used to set key-value
pairs that are set using the aom_codec_set_option() function call. For
single image AVIF encodes, we are modifying some of the
aom_codec_enc_cfg entries. There is no way to do that in a generic way
other than to introduce a specific option like this.

-- 
Vignesh
___
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/libaomenc: Add parameter for avif single image encoding

2022-02-17 Thread James Zern
On Wed, Feb 16, 2022 at 9:51 PM Vignesh Venkatasubramanian
 wrote:
>
> Add a parameter to libaom-av1 encoder to enforce some of the single
> image constraints in the AV1 encoder. Setting this flag will limit
> the encoder to producing exactly one frame and the sequence header
> that is produced by the encoder will be conformant to the AVIF
> specification [1].
>
> Part of Fixing Trac ticket #7621
>
> [1] https://aomediacodec.github.io/av1-avif
>
> Signed-off-by:: Vignesh Venkatasubramanian 
> ---
>  libavcodec/libaomenc.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> [...]
> @@ -1290,6 +1303,7 @@ static const AVOption options[] = {
>  { "psnr",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> AOM_TUNE_PSNR}, 0, 0, VE, "tune"},
>  { "ssim",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
> AOM_TUNE_SSIM}, 0, 0, VE, "tune"},
>  FF_AV1_PROFILE_OPTS
> +{ "avif-image", "Encode in single frame mode for still AVIF images.", 
> OFFSET(is_avif), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE },

Can this instead be mapped to something that can be sent via aom-params?
___
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] lavfi/vf_libplacebo: support custom .cube LUTs

2022-02-17 Thread Niklas Haas
From: Niklas Haas 

Option boilerplate. Very soon we shall definitely need to add some sort
of generic forward-proof option parsing mechanism to libplacebo..
---
 libavfilter/vf_libplacebo.c | 78 +
 1 file changed, 78 insertions(+)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 31ae28ac38..0ee2db80ed 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -26,6 +26,14 @@
 #include 
 #include 
 
+struct custom_lut {
+const struct pl_custom_lut *lut;
+char *path;
+void *bin;
+int bin_len;
+int type;
+};
+
 typedef struct LibplaceboContext {
 /* lavfi vulkan*/
 FFVulkanContext vkctx;
@@ -115,6 +123,11 @@ typedef struct LibplaceboContext {
 int shader_bin_len;
 const struct pl_hook *hooks[2];
 int num_hooks;
+
+/* custom LUTs */
+struct custom_lut lut;
+struct custom_lut input_lut;
+struct custom_lut output_lut;
 } LibplaceboContext;
 
 static inline enum pl_log_level get_log_level(void)
@@ -202,6 +215,37 @@ static int libplacebo_init(AVFilterContext *avctx)
 return 0;
 }
 
+static int load_custom_lut(AVFilterContext *avctx, struct custom_lut *lut)
+{
+LibplaceboContext *s = avctx->priv;
+uint8_t *buf = NULL;
+size_t buf_len;
+int err;
+
+if (lut->bin_len) {
+// Binary specified
+buf = lut->bin;
+buf_len = lut->bin_len;
+} else if (lut->path) {
+// File path specified
+if ((err = av_file_map(lut->path, , _len, 0, s)))
+return err;
+} else {
+// No LUT specified
+return 0;
+}
+
+lut->lut = pl_lut_parse_cube(s->log, buf, buf_len);
+if (!lut->lut) {
+av_log(s, AV_LOG_ERROR, "Failed parsing custom .cube LUT!\n");
+if (buf && buf != lut->bin)
+av_file_unmap(buf, buf_len);
+return AVERROR_EXTERNAL;
+}
+
+return 0;
+}
+
 static int init_vulkan(AVFilterContext *avctx)
 {
 int err = 0;
@@ -254,6 +298,10 @@ static int init_vulkan(AVFilterContext *avctx)
 RET(parse_shader(avctx, buf, buf_len));
 }
 
+RET(load_custom_lut(avctx, >lut));
+RET(load_custom_lut(avctx, >input_lut));
+RET(load_custom_lut(avctx, >output_lut));
+
 /* fall through */
 fail:
 if (buf)
@@ -268,6 +316,9 @@ static void libplacebo_uninit(AVFilterContext *avctx)
 
 for (int i = 0; i < s->num_hooks; i++)
 pl_mpv_user_shader_destroy(>hooks[i]);
+pl_lut_free(>lut.lut);
+pl_lut_free(>input_lut.lut);
+pl_lut_free(>output_lut.lut);
 pl_renderer_destroy(>renderer);
 pl_vulkan_destroy(>vulkan);
 pl_log_destroy(>log);
@@ -305,6 +356,11 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 pl_rect2df_aspect_set(, aspect, s->pad_crop_ratio);
 }
 
+image.lut = s->input_lut.lut;
+image.lut_type = s->input_lut.type;
+target.lut = s->output_lut.lut;
+target.lut_type = s->output_lut.type;
+
 /* Update render params */
 params = (struct pl_render_params) {
 PL_RENDER_DEFAULTS
@@ -361,6 +417,8 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 
 .hooks = s->hooks,
 .num_hooks = s->num_hooks,
+.lut = s->lut.lut,
+.lut_type = s->lut.type,
 
 .skip_anti_aliasing = s->skip_aa,
 .polar_cutoff = s->polar_cutoff,
@@ -650,6 +708,26 @@ static const AVOption libplacebo_options[] = {
 { "custom_shader_path", "Path to custom user shader (mpv .hook format)", 
OFFSET(shader_path), AV_OPT_TYPE_STRING, .flags = STATIC },
 { "custom_shader_bin", "Custom user shader as binary (mpv .hook format)", 
OFFSET(shader_bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
 
+{ "lut_path", "Path to custom color LUT (.cube format)", OFFSET(lut.path), 
AV_OPT_TYPE_STRING, .flags = STATIC },
+{ "lut_bin", "Custom color LUT as binary (.cube format)", OFFSET(lut.bin), 
AV_OPT_TYPE_BINARY, .flags = STATIC },
+{ "lut_type", "Color LUT interpretation", OFFSET(lut.type), 
AV_OPT_TYPE_INT, {.i64 = PL_LUT_UNKNOWN}, 0, PL_LUT_CONVERSION, DYNAMIC, 
"lut_type" },
+{ "unknown", "Unknown LUT type", 0, AV_OPT_TYPE_CONST, {.i64 = 
PL_LUT_UNKNOWN}, 0, 0, STATIC, "lut_type" },
+{ "native", "Non-linear gamma RGB", 0, AV_OPT_TYPE_CONST, {.i64 = 
PL_LUT_NATIVE}, 0, 0, STATIC, "lut_type" },
+{ "normalized", "Normalized linear RGB (1.0 = SDR peak)", 0, 
AV_OPT_TYPE_CONST, {.i64 = PL_LUT_NORMALIZED}, 0, 0, STATIC, "lut_type" },
+{ "conversion", "LUT replaces tone mapping / gamut mapping", 0, 
AV_OPT_TYPE_CONST, {.i64 = PL_LUT_CONVERSION}, 0, 0, STATIC, "lut_type" },
+
+{ "input_lut_path", "Path to custom input LUT (.cube format)", 
OFFSET(input_lut.path), AV_OPT_TYPE_STRING, .flags = STATIC },
+{ "input_lut_bin", "Custom input LUT as binary (.cube format)", 
OFFSET(input_lut.bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
+{ "input_lut_type", "Input LUT 

Re: [FFmpeg-devel] [PATCH v3 4/5] fftools/cmdutils.c: Replace MAX_PATH-sized buffers with dynamically sized ones

2022-02-17 Thread nil-admirari
> if the path later is going to end up in a codepath that expects it to be UTF8 
> (please do check!), then we should go that way instead

I checked. datadir ends up in (cmdutils.c:2104)

base[2] = datadir;

and base[*] are later used in (cmdutils.c:2112 or 2116)

snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
 i != 1 ? "" : "/.ffmpeg", preset_name);
f = fopen(filename, "r");

On Windows fopen expects ANSI encoded strings, so we cannot change the encoding 
to UTF-8 without rewriting the rest of the function.



I've also overlooked something from your previous comment.

> unless passing them to an external API

Previous version of the manifest 
(https://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/293109.html) included

UTF-8

which makes CP_ACP the same as CP_UTF8. Unfortunately external APIs must also 
opt in for such a change, otherwise they won't be able to decode the strings 
FFmpeg sent them. A new version of the manifest without code page changes is at 
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/293168.html.



___
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 v4] fftools: Enable long path support on Windows (fixes #8885)

2022-02-17 Thread nihil-admirari
---
 fftools/Makefile|  5 +
 fftools/long_paths.manifest | 10 ++
 fftools/long_paths.rc   |  3 +++
 3 files changed, 18 insertions(+)
 create mode 100644 fftools/long_paths.manifest
 create mode 100644 fftools/long_paths.rc

diff --git a/fftools/Makefile b/fftools/Makefile
index da42078..37bdf38 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -11,6 +11,11 @@ ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
 
 OBJS-ffmpeg+= fftools/ffmpeg_opt.o 
fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o
 
+# Windows resource files
+OBJS-ffmpeg-$(HAVE_GNU_WINDRES) += fftools/long_paths.o
+OBJS-ffplay-$(HAVE_GNU_WINDRES) += fftools/long_paths.o
+OBJS-ffprobe-$(HAVE_GNU_WINDRES) += fftools/long_paths.o
+
 define DOFFTOOL
 OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
 $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
diff --git a/fftools/long_paths.manifest b/fftools/long_paths.manifest
new file mode 100644
index 000..30b7d8f
--- /dev/null
+++ b/fftools/long_paths.manifest
@@ -0,0 +1,10 @@
+
+
+
+  
+  
+http://schemas.microsoft.com/SMI/2016/WindowsSettings;>
+  true
+
+  
+
diff --git a/fftools/long_paths.rc b/fftools/long_paths.rc
new file mode 100644
index 000..689f8b2
--- /dev/null
+++ b/fftools/long_paths.rc
@@ -0,0 +1,3 @@
+#include 
+
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "long_paths.manifest"
-- 
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] [PATCH v2 3/5] libswscale: Avx2 hscale can process inputs of any size.

2022-02-17 Thread Michael Niedermayer
On Thu, Feb 17, 2022 at 11:04:04AM +0100, Alan Kelly wrote:
> The main loop processes blocks of 16 pixels. The tail processes blocks
> of size 4.
> ---
>  libswscale/x86/scale_avx2.asm | 48 +--
>  1 file changed, 46 insertions(+), 2 deletions(-)

ill wait a few days on this, there are people here who know avx2 better than i 
do
its a while since i wrote x86 SIMD.
but if noone else reviews this then ill do 

thx


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

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



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 v2 2/5] libswscale: Re-factor ff_shuffle_filter_coefficients.

2022-02-17 Thread Michael Niedermayer
On Thu, Feb 17, 2022 at 11:03:52AM +0100, Alan Kelly wrote:
> Make the code more readable and follow the style guide.
> ---
>  libswscale/utils.c | 66 +-
>  1 file changed, 36 insertions(+), 30 deletions(-)

will apply

thx

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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 v2 1/5] libswscale: Check and propagate memory allocation errors from ff_shuffle_filter_coefficients.

2022-02-17 Thread Michael Niedermayer
On Thu, Feb 17, 2022 at 11:03:21AM +0100, Alan Kelly wrote:
> ---
>  libswscale/swscale_internal.h |  2 +-
>  libswscale/utils.c| 11 ---
>  2 files changed, 9 insertions(+), 4 deletions(-)

will apply

thx

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

No great genius has ever existed without some touch of madness. -- Aristotle


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] avformat/riff: add more GeoVision FOURCC

2022-02-17 Thread Thomas Guillem
Hello,

Sorry, but I'm not allowed to share these cameras' footage.

I was able to test them, and it runs fine on last ffmpeg.

On Thu, Feb 17, 2022, at 15:32, Michael Niedermayer wrote:
> On Thu, Feb 17, 2022 at 11:01:38AM +0100, Thomas Guillem wrote:
>> ---
>>  libavformat/riff.c | 2 ++
>>  1 file changed, 2 insertions(+)
>
> please provide a link or sample file for these
>
> the change itself should be ok
>
> thx
>
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Awnsering whenever a program halts or runs forever is
> On a turing machine, in general impossible (turings halting problem).
> On any real computer, always possible as a real computer has a finite number
> of states N, and will either halt in less than N cycles or never halt.
>
> ___
> 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".
>
> Attachments:
> * signature.asc
___
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] avformat/nutdec: Add check for avformat_new_stream

2022-02-17 Thread Michael Niedermayer
On Wed, Feb 16, 2022 at 04:40:16PM +0800, Jiasheng Jiang wrote:
> As the potential failure of the memory allocation,
> the avformat_new_stream() could return NULL pointer.
> Therefore, it should be better to check it and return
> error if fails.
> Also, the caller, nut_read_header(), needs to deal with
> the return value of the decode_main_header() and return
> error if memory allocation fails.
> To avoid mishandling the invalid 'time_base_count', another
> check for the 'time_base_count' is needed and return different
> error if fails.
> 
> Fixes: 619d8e2e58 ("updating nut demuxer to latest spec no muxing yet no 
> index yet no seeking yet libnuts crcs dont match mine (didnt investigate yet) 
> samplerate is stored wrong by libnut (demuxer has a workaround) code is not 
> clean or beautifull yet, but i thought its better to commit early before 
> someone unneccesarily wastes his time duplicating the work demuxer split from 
> muxer")
> Signed-off-by: Jiasheng Jiang 
> ---
> Changelog:
> 
> v1 -> v2
> 
> * Change 1. Add the error handling for ENOMEM from decode_main_header()
> in nut_read_header().
> * Change 2. Check for the 'time_base_count'.
> ---
>  libavformat/nutdec.c | 21 +
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
> index 0a8a700acf..4cbccb20d9 100644
> --- a/libavformat/nutdec.c
> +++ b/libavformat/nutdec.c
> @@ -220,6 +220,10 @@ static int decode_main_header(NUTContext *nut)
>  }
>  
>  GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / 
> sizeof(AVRational) && tmp < length/2);
> +
> +if (nut->time_base_count > NUT_MAX_STREAMS)
> +return AVERROR_INVALIDDATA;

the code already checks against length/2. If you want to add to that
that should be done at the same level and
such a change should explain why the existing check is insufficent as
well as why the new is correct
and it should be in a patch seperate from other changes
also a file with NUT_MAX_STREAMS streams could use more timebases in principle
timebases need a lot less space than streams so they could have a slightly
higher limit


> +
>  nut->time_base = av_malloc_array(nut->time_base_count, 
> sizeof(AVRational));
>  if (!nut->time_base)
>  return AVERROR(ENOMEM);
> @@ -351,8 +355,13 @@ static int decode_main_header(NUTContext *nut)
>  ret = AVERROR(ENOMEM);
>  goto fail;
>  }
> -for (i = 0; i < stream_count; i++)
> -avformat_new_stream(s, NULL);
> +for (i = 0; i < stream_count; i++) {
> +if (!avformat_new_stream(s, NULL)) {
> +av_free(nut->stream);

freeing something and not clearing the pointer is a bad idea in general

thx

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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 v8 1/1] avformat: Add IPFS protocol support.

2022-02-17 Thread Mark Gaiser
On Thu, Feb 17, 2022 at 3:50 PM Mark Gaiser  wrote:

> This patch adds support for:
> - ffplay ipfs://
> - ffplay ipns://
>
> IPFS data can be played from so called "ipfs gateways".
> A gateway is essentially a webserver that gives access to the
> distributed IPFS network.
>
> This protocol support (ipfs and ipns) therefore translates
> ipfs:// and ipns:// to a http:// url. This resulting url is
> then handled by the http protocol. It could also be https
> depending on the gateway provided.
>
> To use this protocol, a gateway must be provided.
> If you do nothing it will try to find it in your
> $HOME/.ipfs/gateway file. The ways to set it manually are:
> 1. Define a -gateway  to the gateway.
> 2. Define $IPFS_GATEWAY with the full http link to the gateway.
> 3. Define $IPFS_PATH and point it to the IPFS data path.
> 4. Have IPFS running in your local user folder (under $HOME/.ipfs).
>
> Signed-off-by: Mark Gaiser 
> ---
>  configure |   2 +
>  doc/protocols.texi|  30 
>  libavformat/Makefile  |   2 +
>  libavformat/ipfsgateway.c | 309 ++
>  libavformat/protocols.c   |   2 +
>  5 files changed, 345 insertions(+)
>  create mode 100644 libavformat/ipfsgateway.c
>
> diff --git a/configure b/configure
> index 5b19a35f59..6ff09e7974 100755
> --- a/configure
> +++ b/configure
> @@ -3585,6 +3585,8 @@ udp_protocol_select="network"
>  udplite_protocol_select="network"
>  unix_protocol_deps="sys_un_h"
>  unix_protocol_select="network"
> +ipfs_protocol_select="https_protocol"
> +ipns_protocol_select="https_protocol"
>
>  # external library protocols
>  libamqp_protocol_deps="librabbitmq"
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index d207df0b52..7c9c0a4808 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -2025,5 +2025,35 @@ decoding errors.
>
>  @end table
>
> +@section ipfs
> +
> +InterPlanetary File System (IPFS) protocol support. One can access files
> stored
> +on the IPFS network through so called gateways. Those are http(s)
> endpoints.
> +This protocol wraps the IPFS native protocols (ipfs:// and ipns://) to be
> send
> +to such a gateway. Users can (and should) host their own node which means
> this
> +protocol will use your local machine gateway to access files on the IPFS
> network.
> +
> +If a user doesn't have a node of their own then the public gateway
> dweb.link is
> +used by default.
> +
> +You can use this protocol in 2 ways. Using IPFS:
> +@example
> +ffplay ipfs://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
> +@end example
> +
> +Or the IPNS protocol (IPNS is mutable IPFS):
> +@example
> +ffplay ipns://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
> +@end example
> +
> +You can also change the gateway to be used:
> +
> +@table @option
> +
> +@item gateway
> +Defines the gateway to use. When nothing is provided the protocol will
> first try
> +your local gateway. If that fails dweb.link will be used.
> +
> +@end table
>
>  @c man end PROTOCOLS
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 3dc6a479cc..4edce8420f 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -656,6 +656,8 @@ OBJS-$(CONFIG_SRTP_PROTOCOL) +=
> srtpproto.o srtp.o
>  OBJS-$(CONFIG_SUBFILE_PROTOCOL)  += subfile.o
>  OBJS-$(CONFIG_TEE_PROTOCOL)  += teeproto.o tee_common.o
>  OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
> +OBJS-$(CONFIG_IPFS_PROTOCOL) += ipfsgateway.o
> +OBJS-$(CONFIG_IPNS_PROTOCOL) += ipfsgateway.o
>  TLS-OBJS-$(CONFIG_GNUTLS)+= tls_gnutls.o
>  TLS-OBJS-$(CONFIG_LIBTLS)+= tls_libtls.o
>  TLS-OBJS-$(CONFIG_MBEDTLS)   += tls_mbedtls.o
> diff --git a/libavformat/ipfsgateway.c b/libavformat/ipfsgateway.c
> new file mode 100644
> index 00..7dfa56871d
> --- /dev/null
> +++ b/libavformat/ipfsgateway.c
> @@ -0,0 +1,309 @@
> +/*
> + * IPFS and IPNS protocol support through IPFS Gateway.
> + * Copyright (c) 2022 Mark Gaiser
> + *
> + * 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
> + */
> +
> +#include "avformat.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/avstring.h"
> +#include "libavutil/internal.h"
> +#include 

[FFmpeg-devel] [PATCH v8 1/1] avformat: Add IPFS protocol support.

2022-02-17 Thread Mark Gaiser
This patch adds support for:
- ffplay ipfs://
- ffplay ipns://

IPFS data can be played from so called "ipfs gateways".
A gateway is essentially a webserver that gives access to the
distributed IPFS network.

This protocol support (ipfs and ipns) therefore translates
ipfs:// and ipns:// to a http:// url. This resulting url is
then handled by the http protocol. It could also be https
depending on the gateway provided.

To use this protocol, a gateway must be provided.
If you do nothing it will try to find it in your
$HOME/.ipfs/gateway file. The ways to set it manually are:
1. Define a -gateway  to the gateway.
2. Define $IPFS_GATEWAY with the full http link to the gateway.
3. Define $IPFS_PATH and point it to the IPFS data path.
4. Have IPFS running in your local user folder (under $HOME/.ipfs).

Signed-off-by: Mark Gaiser 
---
 configure |   2 +
 doc/protocols.texi|  30 
 libavformat/Makefile  |   2 +
 libavformat/ipfsgateway.c | 309 ++
 libavformat/protocols.c   |   2 +
 5 files changed, 345 insertions(+)
 create mode 100644 libavformat/ipfsgateway.c

diff --git a/configure b/configure
index 5b19a35f59..6ff09e7974 100755
--- a/configure
+++ b/configure
@@ -3585,6 +3585,8 @@ udp_protocol_select="network"
 udplite_protocol_select="network"
 unix_protocol_deps="sys_un_h"
 unix_protocol_select="network"
+ipfs_protocol_select="https_protocol"
+ipns_protocol_select="https_protocol"
 
 # external library protocols
 libamqp_protocol_deps="librabbitmq"
diff --git a/doc/protocols.texi b/doc/protocols.texi
index d207df0b52..7c9c0a4808 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -2025,5 +2025,35 @@ decoding errors.
 
 @end table
 
+@section ipfs
+
+InterPlanetary File System (IPFS) protocol support. One can access files 
stored 
+on the IPFS network through so called gateways. Those are http(s) endpoints.
+This protocol wraps the IPFS native protocols (ipfs:// and ipns://) to be send 
+to such a gateway. Users can (and should) host their own node which means this 
+protocol will use your local machine gateway to access files on the IPFS 
network.
+
+If a user doesn't have a node of their own then the public gateway dweb.link 
is 
+used by default.
+
+You can use this protocol in 2 ways. Using IPFS:
+@example
+ffplay ipfs://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
+@end example
+
+Or the IPNS protocol (IPNS is mutable IPFS):
+@example
+ffplay ipns://QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T
+@end example
+
+You can also change the gateway to be used:
+
+@table @option
+
+@item gateway
+Defines the gateway to use. When nothing is provided the protocol will first 
try 
+your local gateway. If that fails dweb.link will be used.
+
+@end table
 
 @c man end PROTOCOLS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3dc6a479cc..4edce8420f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -656,6 +656,8 @@ OBJS-$(CONFIG_SRTP_PROTOCOL) += srtpproto.o 
srtp.o
 OBJS-$(CONFIG_SUBFILE_PROTOCOL)  += subfile.o
 OBJS-$(CONFIG_TEE_PROTOCOL)  += teeproto.o tee_common.o
 OBJS-$(CONFIG_TCP_PROTOCOL)  += tcp.o
+OBJS-$(CONFIG_IPFS_PROTOCOL) += ipfsgateway.o
+OBJS-$(CONFIG_IPNS_PROTOCOL) += ipfsgateway.o
 TLS-OBJS-$(CONFIG_GNUTLS)+= tls_gnutls.o
 TLS-OBJS-$(CONFIG_LIBTLS)+= tls_libtls.o
 TLS-OBJS-$(CONFIG_MBEDTLS)   += tls_mbedtls.o
diff --git a/libavformat/ipfsgateway.c b/libavformat/ipfsgateway.c
new file mode 100644
index 00..7dfa56871d
--- /dev/null
+++ b/libavformat/ipfsgateway.c
@@ -0,0 +1,309 @@
+/*
+ * IPFS and IPNS protocol support through IPFS Gateway.
+ * Copyright (c) 2022 Mark Gaiser
+ *
+ * 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
+ */
+
+#include "avformat.h"
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/tree.h"
+#include 
+#if HAVE_IO_H
+#include 
+#endif
+#if HAVE_UNISTD_H
+#include 
+#endif
+#include "os_support.h"
+#include "url.h"
+#include 
+#include 
+
+typedef struct IPFSGatewayContext {
+AVClass *class;
+URLContext *inner;
+// Is filled by the -gateway 

[FFmpeg-devel] [PATCH v8 0/1] Add IPFS protocol support.

2022-02-17 Thread Mark Gaiser
Hi,

This patch series adds support for IPFS.
V8:
- Removed unnecessary change to set the first gateway_buffer character to 0.
  It made no sense as the buffer is always overwritten in the function context.
- Change %li to %zu (it's intended to print the sizeof in all cases)
V7:
- Removed sanitize_ipfs_gateway. Only the http/https check stayed and that's
  now in translate_ipfs_to_http.
- Added a check for ipfs_cid. It's only to show an error is someone happens to
  profide `ffplay ipfs://` without a cid.
- All snprintf usages are now checked.
- Adding a / to a gateway if it didn't end with it is now done in the same line
  that composes the full resulting url.
- And a couple more minor things.
V6:
- Moved the gateway buffer (now called gateway_buffer) to IPFSGatewayContext
- Changed nearly all PATH_MAX uses to sizeof(...) uses for future flexibility
- The rest is relatively minor feedback changes
V5:
- "c->gateway" is now not modified anymore
- Moved most variables to the stack
- Even more strict checks with the auto detection logic
- Errors are now AVERROR :)
- Added more logging and changed some debug ones to info ones as they are 
  valuable to aid debugging as a user when something goes wrong.
V3 (V4):
- V4: title issue from V3..
- A lot of style changes
- Made url checks a lot more strict
- av_asprintf leak fixes
- So many changes that a diff to v2 is again not sensible.
V2:
- Squashed and changed so much that a diff to v1 was not sensible.

The following is a short summary. In the IPFS ecosystem you access it's content
by a "Content IDentifier" (CID). This CID is, in simplified terms, a hash of 
the content. IPFS itself is a distributed network where any user can run a node
to be part of the network and access files by their CID. If any reachable node 
within that network has the CID, you can get it.

IPFS (as a technology) has two protocols, ipfs and ipns.
The ipfs protocol is the immutable way to access content.
The ipns protocol is a mutable layer on top of it. It's essentially a new CID 
that points to a ipfs CID. This "pointer" if you will can be changed to point 
to something else.
Much more information on how this technology works can be found here [1].

This patch series allows to interact natively with IPFS. That means being able
to access files like:
- ffplay ipfs://
- ffplay ipns://

There are multiple ways to access files on the IPFS network. This patch series
uses the gateway driven way. An IPFS node - by default - exposes a local 
gateway (say http://localhost:8080) which is then used to get content from IPFS.
The gateway functionality on the IPFS side contains optimizations to
be as ideal to streaming data as it can be. Optimizations that the http protocol
in ffmpeg also has and are thus reused for free in this approach.

A note on other "more appropiate" ways, as I received some feedback on that.
For ffmpeg purposes the gateway approach is ideal! There is a "libipfs" but
that would spin up an ipfs node with the overhead of:
- bootstrapping
- connecting to nodes
- finding other nodes to connect too
- finally finding your file

This alternative approach could take minutes before a file is played. The
gateway approach immediately connects to an already running node thus gives
the file the fastest.

Much of the logic in this patch series is to find that gateway and essentially 
rewrite:

"ipfs://"

to:

"http://localhost:8080/ipfs/"

Once that's found it's forwared to the protocol handler where eventually the
http protocol is going to handle it. Note that it could also be https. There's 
enough flexibility in the implementation to allow the user to provide a 
gateway. There are also public https gateways which can be used just as well.

After this patch is accepted, I'll work on getting IPFS supported in:
- mpv (requires this ffmpeg patch)
- vlc (prefers this patch but can be made to work without this patch)
- kodi (requires this ffmpeg patch)

Best regards,
Mark Gaiser

[1] https://docs.ipfs.io/concepts/

Mark Gaiser (1):
  avformat: Add IPFS protocol support.

 configure |   2 +
 doc/protocols.texi|  30 
 libavformat/Makefile  |   2 +
 libavformat/ipfsgateway.c | 309 ++
 libavformat/protocols.c   |   2 +
 5 files changed, 345 insertions(+)
 create mode 100644 libavformat/ipfsgateway.c

-- 
2.35.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] Audacity Tenacity VLC FFMpeg Ardour and other open-source audio programs - you don't swing it like you're supposed to, man

2022-02-17 Thread Sergei Udris
Audacity Tenacity VLC FFMpeg Ardour and other open-source audio programs -
you don't swing it like you're supposed to, man
  be programming peer-to-peer programs including unseen competitive games

now it's time for me to take apart your aching parts
  selling out Isengard Tower and garden by letting
money-donate-ads-coins-sponsor-jobs disease in
Rey refuses to sell BB-8 for 60 portions in the desert - you do it from
comfy chairs in era of Internet
  siding with Chief Tui by doing servers and accepting island without
peer-to-peer github games twitch email
  caging programs under user namespaces - that makes L3 furious: why?!
because you are our organic overlords?!
  turning programs into projects like producers pushing Nick Lang to play
Joe Gunn when he wants Ray Casanov part
  targeting iOS or Android or just-this or just-that - even Hawkeye's
plunger arrow is not enough to get you on the leaving train
  nesting around one program and not programming games like proud Vulcan
Academy
yet having shiny webpages, chats, docs and lengthy maintainer
attribtions
no wonder Spock left for Starfleet
  thank you, ministers, for your consideration - live long and prosper

soak it in cause it's the last you'll ever see
  simple as Game Changers
  if Federer-Nadal-Djokovic instead of competing for grand-slams set up a
coin-collecting attribution-writing chat-booth in the middle of court
  if Linus - inner Jabba the Hutt stole name Freax - agreed to join Steve
Jobs and Apple of that meeting when first came to California
instead of keeping his word - free and open
  if torrent clients accepted Empire-server-networks-only galaxy instead of
being the Republic of data and generating most traffic
  if Jesus instead of feeding 5000 started a bread-breaking fundraiser
together with elders
  even i would invite them to Lalotai as guests of honor

now i eat you so prepare your final plea
  even dust of open-source audio programs we shake off of our
Seinfeld-Obama-Nike running shoes
  but be sure - peer-to-peer programs including new competitive games - are
climbing like Honnold on El Sendero Luminosa
  no projects no experiments no docs no
issue-discussions-scratching-on-top-of-our-heads
  no money-donate-sponsor-ads-coins-jobs lethal infection
  programs who are guests not workers
  alive and singing with their won voice like Dwayne TheRock Johnson
Franchise-Viagra
  better than what Borg of money-and-jobs can collective-gram
  are on their way along with Pat Brown and Impossible Foods mission
  both will be served in vegan jars of treasure-from-a-sunken-pirate-wreck
parens ( )

you wish you were nice and shin!


Mark Wahlberg: hey, Josh Brolin! how're you doing? you were in the Goonies
movie, right? i produce Entourage Josh: y Mark: say hi to your mother for me
___
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/riff: add more GeoVision FOURCC

2022-02-17 Thread Michael Niedermayer
On Thu, Feb 17, 2022 at 11:01:38AM +0100, Thomas Guillem wrote:
> ---
>  libavformat/riff.c | 2 ++
>  1 file changed, 2 insertions(+)

please provide a link or sample file for these

the change itself should be ok

thx

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 v7 1/1] avformat: Add IPFS protocol support.

2022-02-17 Thread Mark Gaiser
On Thu, Feb 17, 2022 at 2:57 PM Tomas Härdin  wrote:

> > +IPFSGatewayContext *c = h->priv_data;
> > +char ipfs_full_data_folder[PATH_MAX];
> > +char ipfs_gateway_file[PATH_MAX];
> > +struct stat st;
> > +int stat_ret = 0;
> > +int ret = AVERROR(EINVAL);
> > +FILE *gateway_file = NULL;
> > +
> > +// Set the first character of c->gateway_buffer to 0.
> > +c->gateway_buffer[0] = '\0';
>
> unnecessary
>

Hmm, interesting. I tried to be secure and not let any potential strlen
trip when there is garbage data in c->gateway_buffer.
Just to set it in a function that always overwrites it anyhow ;)
Aka, useless.

>
> > +
> > +// Test $IPFS_GATEWAY.
> > +if (getenv("IPFS_GATEWAY") != NULL) {
> > +if (snprintf(c->gateway_buffer, sizeof(c->gateway_buffer),
> > "%s",
> > + getenv("IPFS_GATEWAY")) >= sizeof(c-
> > >gateway_buffer)) {
> > +av_log(h, AV_LOG_ERROR, "The IPFS_GATEWAY environment
> > variable exceeds the maximum length. We allow a max of %li
> > characters\n", sizeof(c->gateway_buffer));
>
> nit: seems a bit weird to break the if but not the av_log()
> Also this should be %zu not %li
>

The compiler doesn't complain about this one.
How do you know %zu is right? I used this table and it knows nothing about
%z...
https://www.cplusplus.com/reference/cstdio/printf/

Anyhow, I'm certainly not doubting you so changing it (and all other %li
occurrences). Other sites seem to indicate it's for printing size_t .

So.. erm... the next version can finally be merged?


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

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


Re: [FFmpeg-devel] [PATCH v7 1/1] avformat: Add IPFS protocol support.

2022-02-17 Thread Tomas Härdin
> +    IPFSGatewayContext *c = h->priv_data;
> +    char ipfs_full_data_folder[PATH_MAX];
> +    char ipfs_gateway_file[PATH_MAX];
> +    struct stat st;
> +    int stat_ret = 0;
> +    int ret = AVERROR(EINVAL);
> +    FILE *gateway_file = NULL;
> +
> +    // Set the first character of c->gateway_buffer to 0.
> +    c->gateway_buffer[0] = '\0';

unnecessary

> +
> +    // Test $IPFS_GATEWAY.
> +    if (getenv("IPFS_GATEWAY") != NULL) {
> +    if (snprintf(c->gateway_buffer, sizeof(c->gateway_buffer),
> "%s",
> + getenv("IPFS_GATEWAY")) >= sizeof(c-
> >gateway_buffer)) {
> +    av_log(h, AV_LOG_ERROR, "The IPFS_GATEWAY environment
> variable exceeds the maximum length. We allow a max of %li
> characters\n", sizeof(c->gateway_buffer));

nit: seems a bit weird to break the if but not the av_log()
Also this should be %zu not %li

/Tomas

___
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] hevcdec: Correctly signal AVCOL_RANGE_UNSPECIFIED if nothing was set in the bitstream

2022-02-17 Thread Martin Storsjö

On Thu, 17 Feb 2022, Hendrik Leppkes wrote:


On Thu, Feb 17, 2022 at 1:54 PM Martin Storsjö  wrote:


This matches what the H264 decoder signals for such a case.

Signed-off-by: Martin Storsjö 
---
 libavcodec/hevcdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 8d7a4f7147..01d459984f 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -338,7 +338,7 @@ static void export_stream_params(HEVCContext *s, const 
HEVCSPS *sps)
 avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG
 : AVCOL_RANGE_MPEG;
 else
-avctx->color_range = AVCOL_RANGE_MPEG;
+avctx->color_range = AVCOL_RANGE_UNSPECIFIED;



The HEVC specification is pretty clear that when its not signalled, it
should be inferred as 0 (eg. mpeg)


When the video_full_range_flag syntax element is not present, the value of 
video_full_range_flag is inferred to be equal to 0


Hmm, I see. Ok, thanks - patch dropped then.

// 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] [PATCH] hevcdec: Correctly signal AVCOL_RANGE_UNSPECIFIED if nothing was set in the bitstream

2022-02-17 Thread Hendrik Leppkes
On Thu, Feb 17, 2022 at 1:54 PM Martin Storsjö  wrote:
>
> This matches what the H264 decoder signals for such a case.
>
> Signed-off-by: Martin Storsjö 
> ---
>  libavcodec/hevcdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index 8d7a4f7147..01d459984f 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -338,7 +338,7 @@ static void export_stream_params(HEVCContext *s, const 
> HEVCSPS *sps)
>  avctx->color_range = sps->vui.video_full_range_flag ? 
> AVCOL_RANGE_JPEG
>  : 
> AVCOL_RANGE_MPEG;
>  else
> -avctx->color_range = AVCOL_RANGE_MPEG;
> +avctx->color_range = AVCOL_RANGE_UNSPECIFIED;
>

The HEVC specification is pretty clear that when its not signalled, it
should be inferred as 0 (eg. mpeg)

> When the video_full_range_flag syntax element is not present, the value of 
> video_full_range_flag is inferred to be equal to 0

- Hendrik
___
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] hevcdec: Correctly signal AVCOL_RANGE_UNSPECIFIED if nothing was set in the bitstream

2022-02-17 Thread Martin Storsjö
This matches what the H264 decoder signals for such a case.

Signed-off-by: Martin Storsjö 
---
 libavcodec/hevcdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 8d7a4f7147..01d459984f 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -338,7 +338,7 @@ static void export_stream_params(HEVCContext *s, const 
HEVCSPS *sps)
 avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG
 : AVCOL_RANGE_MPEG;
 else
-avctx->color_range = AVCOL_RANGE_MPEG;
+avctx->color_range = AVCOL_RANGE_UNSPECIFIED;
 
 if (sps->vui.colour_description_present_flag) {
 avctx->color_primaries = sps->vui.colour_primaries;
-- 
2.32.0 (Apple Git-132)

___
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/2] lavc/dxva: properly namespace public symbols

2022-02-17 Thread Michael Niedermayer
On Thu, Feb 17, 2022 at 10:13:15AM +0100, Anton Khirnov wrote:
> ---
>  doc/APIchanges  |  6 ++
>  libavcodec/dxva2.c  |  4 ++--
>  libavcodec/dxva2.h  | 18 ++
>  libavcodec/dxva2_h264.c |  8 
>  libavcodec/dxva2_internal.h |  4 ++--
>  libavcodec/version.h|  3 ++-
>  6 files changed, 30 insertions(+), 13 deletions(-)

This doesnt build

CC  libavcodec/dxva2.o
In file included from src/libavcodec/dxva2_internal.h:34:0,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/dxva2.h:23:0: error: unterminated #ifndef
 #ifndef AVCODEC_DXVA2_H
 
In file included from src/libavcodec/dxva2_internal.h:35:0,
 from src/libavcodec/dxva2.c:33:
src/libavutil/hwcontext_dxva2.h:39:1: error: duplicate ‘typedef’
 typedef struct AVDXVA2DeviceContext {
 ^~~
src/libavutil/hwcontext_dxva2.h:39:9: error: two or more data types in 
declaration specifiers
 typedef struct AVDXVA2DeviceContext {
 ^~
In file included from src/libavcodec/dxva2_internal.h:38:0,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/d3d11va.h:48:0: warning: 
"FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG" redefined
 #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for 
Direct3D11 and old UVD/UVD+ ATI video cards
 
In file included from src/libavcodec/dxva2_internal.h:34:0,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/dxva2.h:52:0: note: this is the location of the previous 
definition
 #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 
AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG
 
In file included from src/libavcodec/dxva2_internal.h:38:0,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/d3d11va.h:49:0: warning: "FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO" 
redefined
 #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for 
Direct3D11 and old Intel GPUs with ClearVideo interface
 
In file included from src/libavcodec/dxva2_internal.h:34:0,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/dxva2.h:53:0: note: this is the location of the previous 
definition
 #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
 
In file included from src/libavcodec/dxva2.c:33:0:
src/libavcodec/dxva2_internal.h:63:5: error: unknown type name 
‘AVDXVA2DecodeContext’
 AVDXVA2DecodeContext dxva2;
 ^~~~
In file included from src/libavcodec/dxva2.h:39:0,
 from src/libavcodec/dxva2_internal.h:34,
 from src/libavcodec/dxva2.c:33:
src/libavcodec/dxva2.c: In function ‘dxva2_create_decoder’:
src/libavcodec/dxva2.c:359:63: error: dereferencing pointer to incomplete type 
‘AVDXVA2DeviceContext {aka struct dxva_context}’
 hr = IDirect3DDeviceManager9_OpenDeviceHandle(device_hwctx->devmgr,
   ^
src/libavcodec/dxva2.c: In function ‘ff_dxva2_decode_init’:
src/libavcodec/dxva2.c:707:9: error: unknown type name ‘AVDXVA2DecodeContext’; 
did you mean ‘AVDXVA2DeviceContext’?
 AVDXVA2DecodeContext *dxva_ctx = >ctx.dxva2;
 ^~~~
 AVDXVA2DeviceContext
src/libavcodec/dxva2.c:715:17: error: request for member ‘decoder’ in something 
not a structure or union
 dxva_ctx->decoder   = sctx->dxva2_decoder;
 ^~
src/libavcodec/dxva2.c:716:17: error: request for member ‘cfg’ in something not 
a structure or union
 dxva_ctx->cfg   = >dxva2_config;
 ^~
src/libavcodec/dxva2.c:717:17: error: request for member ‘surface’ in something 
not a structure or union
 dxva_ctx->surface   = frames_hwctx->surfaces;
 ^~
src/libavcodec/dxva2.c:718:17: error: request for member ‘surface_count’ in 
something not a structure or union
 dxva_ctx->surface_count = frames_hwctx->nb_surfaces;
 ^~
src/libavcodec/dxva2.c:719:17: error: request for member ‘workaround’ in 
something not a structure or union
 dxva_ctx->workaround= sctx->workaround;
 ^~
In file included from src/libavcodec/dxva2.c:33:0:
src/libavcodec/dxva2.c: In function ‘ff_dxva2_get_surface_index’:
src/libavcodec/dxva2_internal.h:106:116: error: request for member 
‘surface_count’ in something not a structure or union
 #define DXVA_CONTEXT_COUNT(avctx, ctx)  (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.surface_count : ctx->dxva2.surface_count)

^
src/libavcodec/dxva2.c:787:21: note: in expansion of macro ‘DXVA_CONTEXT_COUNT’
 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
 ^
src/libavcodec/dxva2.c:788:65: error: request for member ‘surface’ in something 
not a structure or union
 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == 
surface)
   

Re: [FFmpeg-devel] Optimize HEVC decoding for loongarch

2022-02-17 Thread 殷时友


> 2022年2月17日 下午7:11,Hao Chen  写道:
> 
> ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an
> before: 94fps
> after : 191fps
> 
> V2: Retrigger the patchwork.ffmpeg test.
> 
> [PATCH v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to
> [PATCH v2 2/5] avcodec: [loongarch] Optimize Hevcdsp with LSX.
> [PATCH v2 3/5] avcodec: [loongarch] Optimize Hevc_idct/lpf with LSX.
> [PATCH v2 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX.
> [PATCH v2 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX.
> 
LGTM

___
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 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX.

2022-02-17 Thread Hao Chen
From: Lu Wang 

ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an
before: 182fps
after : 191fps

Signed-off-by: Hao Chen 
---
 libavcodec/loongarch/Makefile |4 +-
 libavcodec/loongarch/hevc_mc_uni_lsx.c| 1423 +
 libavcodec/loongarch/hevc_mc_uniw_lsx.c   |  298 
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   30 +
 libavcodec/loongarch/hevcdsp_lsx.h|   59 +
 5 files changed, 1813 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/loongarch/hevc_mc_uni_lsx.c
 create mode 100644 libavcodec/loongarch/hevc_mc_uniw_lsx.c

diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile
index 620fba7192..c1b5de5c44 100644
--- a/libavcodec/loongarch/Makefile
+++ b/libavcodec/loongarch/Makefile
@@ -28,4 +28,6 @@ LSX-OBJS-$(CONFIG_VP9_DECODER)+= 
loongarch/vp9_mc_lsx.o \
 LSX-OBJS-$(CONFIG_HEVC_DECODER)   += loongarch/hevcdsp_lsx.o \
  loongarch/hevc_idct_lsx.o \
  loongarch/hevc_lpf_sao_lsx.o \
- loongarch/hevc_mc_bi_lsx.o
+ loongarch/hevc_mc_bi_lsx.o \
+ loongarch/hevc_mc_uni_lsx.o \
+ loongarch/hevc_mc_uniw_lsx.o
diff --git a/libavcodec/loongarch/hevc_mc_uni_lsx.c 
b/libavcodec/loongarch/hevc_mc_uni_lsx.c
new file mode 100644
index 00..a15c86268f
--- /dev/null
+++ b/libavcodec/loongarch/hevc_mc_uni_lsx.c
@@ -0,0 +1,1423 @@
+/*
+ * Copyright (c) 2022 Loongson Technology Corporation Limited
+ * Contributed by Lu Wang 
+ *Hao Chen 
+ *
+ * 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
+ */
+
+#include "libavutil/loongarch/loongson_intrinsics.h"
+#include "hevcdsp_lsx.h"
+
+static const uint8_t ff_hevc_mask_arr[16 * 3] __attribute__((aligned(0x40))) = 
{
+/* 8 width cases */
+0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
+/* 4 width cases */
+0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20,
+/* 4 width cases */
+8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28
+};
+
+static av_always_inline
+void common_hz_8t_64w_lsx(uint8_t *src, int32_t src_stride,
+  uint8_t *dst, int32_t dst_stride,
+  const int8_t *filter, int32_t height)
+{
+int32_t loop_cnt;
+__m128i mask0, mask1, mask2, mask3, out1, out2;
+__m128i src0, src1, src2, src3, src4, src5, src6, src7;
+__m128i vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
+__m128i filt0, filt1, filt2, filt3;
+__m128i res0, res1, res2, res3;
+
+mask0 = __lsx_vld(ff_hevc_mask_arr, 0);
+src -= 3;
+
+/* rearranging filter */
+DUP4_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filter, 4, filter, 6,
+  filt0, filt1, filt2, filt3);
+
+DUP2_ARG2(__lsx_vaddi_bu, mask0, 2, mask0, 4, mask1, mask2);
+mask3 = __lsx_vaddi_bu(mask0, 6);
+
+for (loop_cnt = height; loop_cnt--;) {
+DUP4_ARG2(__lsx_vld, src, 0, src, 8, src, 16, src, 24,
+  src0, src1, src2, src3);
+DUP4_ARG2(__lsx_vld, src, 32, src, 40, src, 48, src, 56,
+  src4, src5, src6, src7);
+src += src_stride;
+
+DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src1, src1, mask0,
+  vec0, vec1);
+DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask0, src3, src3, mask0,
+  vec2, vec3);
+DUP4_ARG2(__lsx_vdp2_h_bu_b, vec0, filt0, vec1, filt0, vec2, filt0,
+  vec3, filt0, res0, res1, res2, res3);
+DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask2, src1, src1, mask2,
+  vec0, vec1);
+DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask2, src3, src3, mask2,
+  vec2, vec3);
+DUP4_ARG3(__lsx_vdp2add_h_bu_b, res0, vec0, filt2, res1, vec1, filt2,
+  res2, vec2, filt2, res3, vec3, filt2, res0, res1, res2, 
res3);
+DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask1, src1, src1, mask1,
+  vec4, vec5);
+DUP2_ARG3(__lsx_vshuf_b, src2, src2, mask1, src3, src3, mask1,
+  vec6, vec7);
+DUP4_ARG3(__lsx_vdp2add_h_bu_b, 

[FFmpeg-devel] [PATCH v2 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX.

2022-02-17 Thread Hao Chen
ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an
before: 124fps
after : 182fps

Signed-off-by: Hao Chen 
---
 libavcodec/loongarch/Makefile |3 +-
 libavcodec/loongarch/hevc_mc_bi_lsx.c | 2289 +
 libavcodec/loongarch/hevcdsp_init_loongarch.c |   51 +
 libavcodec/loongarch/hevcdsp_lsx.h|   57 +
 4 files changed, 2399 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/loongarch/hevc_mc_bi_lsx.c

diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile
index cfc8e3aaff..620fba7192 100644
--- a/libavcodec/loongarch/Makefile
+++ b/libavcodec/loongarch/Makefile
@@ -27,4 +27,5 @@ LSX-OBJS-$(CONFIG_VP9_DECODER)+= 
loongarch/vp9_mc_lsx.o \
  loongarch/vp9_idct_lsx.o
 LSX-OBJS-$(CONFIG_HEVC_DECODER)   += loongarch/hevcdsp_lsx.o \
  loongarch/hevc_idct_lsx.o \
- loongarch/hevc_lpf_sao_lsx.o
+ loongarch/hevc_lpf_sao_lsx.o \
+ loongarch/hevc_mc_bi_lsx.o
diff --git a/libavcodec/loongarch/hevc_mc_bi_lsx.c 
b/libavcodec/loongarch/hevc_mc_bi_lsx.c
new file mode 100644
index 00..9092fdccb2
--- /dev/null
+++ b/libavcodec/loongarch/hevc_mc_bi_lsx.c
@@ -0,0 +1,2289 @@
+/*
+ * Copyright (c) 2022 Loongson Technology Corporation Limited
+ * Contributed by Lu Wang 
+ *Hao Chen 
+ *
+ * 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
+ */
+
+#include "libavutil/loongarch/loongson_intrinsics.h"
+#include "hevcdsp_lsx.h"
+
+static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = 
{
+/* 8 width cases */
+0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
+0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20
+};
+
+static av_always_inline __m128i
+hevc_bi_rnd_clip(__m128i in0, __m128i vec0, __m128i in1, __m128i vec1)
+{
+__m128i out;
+
+vec0 = __lsx_vsadd_h(in0, vec0);
+vec1 = __lsx_vsadd_h(in1, vec1);
+out  = __lsx_vssrarni_bu_h(vec1, vec0, 7);
+return out;
+}
+
+/* hevc_bi_copy: dst = av_clip_uint8((src0 << 6 + src1) >> 7) */
+static
+void hevc_bi_copy_4w_lsx(uint8_t *src0_ptr, int32_t src_stride,
+ int16_t *src1_ptr, int32_t src2_stride,
+ uint8_t *dst, int32_t dst_stride, int32_t height)
+{
+int32_t loop_cnt = height >> 3;
+int32_t res = (height & 0x07) >> 1;
+int32_t src_stride_2x = (src_stride << 1);
+int32_t dst_stride_2x = (dst_stride << 1);
+int32_t src_stride_4x = (src_stride << 2);
+int32_t dst_stride_4x = (dst_stride << 2);
+int32_t src2_stride_2x = (src2_stride << 1);
+int32_t src2_stride_4x = (src2_stride << 2);
+int32_t src_stride_3x = src_stride_2x + src_stride;
+int32_t dst_stride_3x = dst_stride_2x + dst_stride;
+int32_t src2_stride_3x = src2_stride_2x + src2_stride;
+__m128i src0, src1;
+__m128i zero = __lsx_vldi(0);
+__m128i in0, in1, in2, in3;
+__m128i tmp0, tmp1, tmp2, tmp3;
+__m128i reg0, reg1, reg2, reg3;
+__m128i dst0, dst1, dst2, dst3;
+
+for (;loop_cnt--;) {
+reg0 = __lsx_vldrepl_w(src0_ptr, 0);
+reg1 = __lsx_vldrepl_w(src0_ptr + src_stride, 0);
+reg2 = __lsx_vldrepl_w(src0_ptr + src_stride_2x, 0);
+reg3 = __lsx_vldrepl_w(src0_ptr + src_stride_3x, 0);
+src0_ptr += src_stride_4x;
+DUP2_ARG2(__lsx_vilvl_w, reg1, reg0, reg3, reg2, tmp0, tmp1);
+src0 = __lsx_vilvl_d(tmp1, tmp0);
+reg0 = __lsx_vldrepl_w(src0_ptr, 0);
+reg1 = __lsx_vldrepl_w(src0_ptr + src_stride, 0);
+reg2 = __lsx_vldrepl_w(src0_ptr + src_stride_2x, 0);
+reg3 = __lsx_vldrepl_w(src0_ptr + src_stride_3x, 0);
+DUP2_ARG2(__lsx_vilvl_w, reg1, reg0, reg3, reg2, tmp0, tmp1);
+src1 = __lsx_vilvl_d(tmp1, tmp0);
+src0_ptr += src_stride_4x;
+
+tmp0 = __lsx_vldrepl_d(src1_ptr, 0);
+tmp1 = __lsx_vldrepl_d(src1_ptr + src2_stride, 0);
+tmp2 = __lsx_vldrepl_d(src1_ptr + src2_stride_2x, 0);
+tmp3 = __lsx_vldrepl_d(src1_ptr + src2_stride_3x, 0);
+src1_ptr += src2_stride_4x;
+DUP2_ARG2(__lsx_vilvl_d, 

[FFmpeg-devel] [PATCH v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to v1.1.0

2022-02-17 Thread Hao Chen
The loongson_intrinsics.h file is updated from v1.0.3 version
to v1.1.0. Some spelling mistakes are fixed and new functions are added.

Signed-off-by: Hao Chen 
---
 libavutil/loongarch/loongson_intrinsics.h | 1697 +++--
 1 file changed, 884 insertions(+), 813 deletions(-)

diff --git a/libavutil/loongarch/loongson_intrinsics.h 
b/libavutil/loongarch/loongson_intrinsics.h
index 6e0439f829..eb256863c8 100644
--- a/libavutil/loongarch/loongson_intrinsics.h
+++ b/libavutil/loongarch/loongson_intrinsics.h
@@ -33,7 +33,7 @@
  *Xiwei Gu   
  *Lu Wang
  *
- * This file is a header file for loongarch builtin extention.
+ * This file is a header file for loongarch builtin extension.
  *
  */
 
@@ -42,50 +42,50 @@
 
 /**
  * MAJOR version: Macro usage changes.
- * MINOR version: Add new functions, or bug fix.
+ * MINOR version: Add new functions, or bug fixes.
  * MICRO version: Comment changes or implementation changes.
  */
 #define LSOM_VERSION_MAJOR 1
-#define LSOM_VERSION_MINOR 0
-#define LSOM_VERSION_MICRO 3
+#define LSOM_VERSION_MINOR 1
+#define LSOM_VERSION_MICRO 0
 
 #define DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1) \
-{ \
-_OUT0 = _INS(_IN0); \
-_OUT1 = _INS(_IN1); \
-}
+  {   \
+_OUT0 = _INS(_IN0);   \
+_OUT1 = _INS(_IN1);   \
+  }
 
 #define DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1) \
-{ \
-_OUT0 = _INS(_IN0, _IN1); \
-_OUT1 = _INS(_IN2, _IN3); \
-}
+  {   \
+_OUT0 = _INS(_IN0, _IN1); \
+_OUT1 = _INS(_IN2, _IN3); \
+  }
 
 #define DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _OUT0, _OUT1) \
-{ \
-_OUT0 = _INS(_IN0, _IN1, _IN2); \
-_OUT1 = _INS(_IN3, _IN4, _IN5); \
-}
+  {   \
+_OUT0 = _INS(_IN0, _IN1, _IN2);   \
+_OUT1 = _INS(_IN3, _IN4, _IN5);   \
+  }
 
 #define DUP4_ARG1(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1, _OUT2, _OUT3) \
-{ \
-DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1); \
-DUP2_ARG1(_INS, _IN2, _IN3, _OUT2, _OUT3); \
-}
-
-#define DUP4_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, \
-  _OUT0, _OUT1, _OUT2, _OUT3) \
-{ \
-DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1); \
-DUP2_ARG2(_INS, _IN4, _IN5, _IN6, _IN7, _OUT2, _OUT3); \
-}
-
-#define DUP4_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, \
-  _IN8, _IN9, _IN10, _IN11, _OUT0, _OUT1, _OUT2, _OUT3) \
-{ \
-DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4,  _IN5,  _OUT0, _OUT1); \
-DUP2_ARG3(_INS, _IN6, _IN7, _IN8, _IN9, _IN10, _IN11, _OUT2, _OUT3); \
-}
+  { \
+DUP2_ARG1(_INS, _IN0, _IN1, _OUT0, _OUT1);  \
+DUP2_ARG1(_INS, _IN2, _IN3, _OUT2, _OUT3);  \
+  }
+
+#define DUP4_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, _OUT0, 
\
+  _OUT1, _OUT2, _OUT3) 
\
+  {
\
+DUP2_ARG2(_INS, _IN0, _IN1, _IN2, _IN3, _OUT0, _OUT1); 
\
+DUP2_ARG2(_INS, _IN4, _IN5, _IN6, _IN7, _OUT2, _OUT3); 
\
+  }
+
+#define DUP4_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _IN6, _IN7, _IN8, \
+  _IN9, _IN10, _IN11, _OUT0, _OUT1, _OUT2, _OUT3) \
+  {   \
+DUP2_ARG3(_INS, _IN0, _IN1, _IN2, _IN3, _IN4, _IN5, _OUT0, _OUT1);\
+DUP2_ARG3(_INS, _IN6, _IN7, _IN8, _IN9, _IN10, _IN11, _OUT2, _OUT3);  \
+  }
 
 #ifdef __loongarch_sx
 #include 
@@ -94,11 +94,11 @@
  * Description : Dot product & addition of byte vector elements
  * Arguments   : Inputs  - in_c, in_h, in_l
  *   Outputs - out
- *   Retrun Type - halfword
+ *   Return Type - halfword
  * Details : Signed byte elements from in_h are multiplied by
  *   signed byte elements from in_l, and then added adjacent to
  *   each other to get results with the twice size of input.
- *   Then the results plus to signed half word elements from in_c.
+ *   Then the results plus to signed half-word elements from in_c.
  * Example : out = __lsx_vdp2add_h_b(in_c, in_h, in_l)
  *in_c : 1,2,3,4, 1,2,3,4
  *in_h : 1,2,3,4, 5,6,7,8, 1,2,3,4, 5,6,7,8
@@ -106,13 +106,13 @@
  * out : 23,40,41,26, 23,40,41,26
  * 
=
  */
-static inline __m128i __lsx_vdp2add_h_b(__m128i 

[FFmpeg-devel] Optimize HEVC decoding for loongarch

2022-02-17 Thread Hao Chen
ffmpeg -i 5_h265_1080p_60fps_3Mbps.mkv -f rawvideo -y /dev/null -an
before: 94fps
after : 191fps

V2: Retrigger the patchwork.ffmpeg test.

[PATCH v2 1/5] avutil: [loongarch] Update loongson_intrinsics.h to
[PATCH v2 2/5] avcodec: [loongarch] Optimize Hevcdsp with LSX.
[PATCH v2 3/5] avcodec: [loongarch] Optimize Hevc_idct/lpf with LSX.
[PATCH v2 4/5] avcodec: [loongarch] Optimize Hevc_mc_bi with LSX.
[PATCH v2 5/5] avcodec: [loongarch] Optimize Hevc_mc_uni/w with LSX.

___
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] Consulting Engagement Request

2022-02-17 Thread Linford Bacon
Hi All,

My name is Linford and I run a small startup based in the UK that is using 
machine vision to automate traffic surveys .

We are making extensive use of the ffmpeg library to consume and pre-process 
footage from network connected CCTV cameras.

I was wondering whether anyone would be interested in a consulting engagement 
to assist us with some development and/or debugging of the ffmpeg pipeline.

Initially, we are looking for some targeted support to optimise our use of the 
ffmpeg library but there could also be additional work to create custom 
components/filters and to improve the library integration into our pipeline.

Let me know if you would be interested in this and I can setup a call.

Best wishes,

Linford


Linford Bacon
CEO & Co-founder | ngenius.ai
Mob: (44) 7387 235 026
The Enterprise Centre, Norwich Research Park, UEA, Norwich, NR4 7TJ

___
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 5/5] checkasm/sw_scale: hscale does not requires cpuflag test.

2022-02-17 Thread Alan Kelly
This is done in ff_shuffle_filter_coefficients.
---
 tests/checkasm/sw_scale.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index 3c0a083b42..4c57b6a372 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -168,8 +168,6 @@ static void check_hscale(void)
   const uint8_t *src, const int16_t *filter,
   const int32_t *filterPos, int filterSize);
 
-int cpu_flags = av_get_cpu_flags();
-
 ctx = sws_alloc_context();
 if (sws_init_context(ctx, NULL, NULL) < 0)
 fail();
@@ -217,8 +215,7 @@ static void check_hscale(void)
 }
 ff_sws_init_scale(ctx);
 memcpy(filterAvx2, filter, sizeof(uint16_t) * (SRC_PIXELS * 
MAX_FILTER_WIDTH + MAX_FILTER_WIDTH));
-if ((cpu_flags & AV_CPU_FLAG_AVX2) && !(cpu_flags & 
AV_CPU_FLAG_SLOW_GATHER))
-ff_shuffle_filter_coefficients(ctx, filterPosAvx, width, 
filterAvx2, SRC_PIXELS);
+ff_shuffle_filter_coefficients(ctx, filterPosAvx, width, 
filterAvx2, SRC_PIXELS);
 
 if (check_func(ctx->hcScale, "hscale_%d_to_%d_width%d", 
ctx->srcBpc, ctx->dstBpc + 1, width)) {
 memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0]));
-- 
2.35.1.265.g69c8d7142f-goog

___
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/5] libswscale: Enable hscale_avx2 for all input sizes.

2022-02-17 Thread Alan Kelly
ff_shuffle_filter_coefficients shuffles the tail as required.
---
 libswscale/utils.c   | 19 ---
 libswscale/x86/swscale.c |  6 ++
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 7c8e1bbdde..d818c9ce55 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -285,8 +285,7 @@ int ff_shuffle_filter_coefficients(SwsContext *c, int 
*filterPos,
 #if ARCH_X86_64
 int i, j, k;
 int cpu_flags = av_get_cpu_flags();
-// avx2 hscale filter processes 16 pixel blocks.
-if (!filter || dstW % 16 != 0)
+if (!filter)
 return 0;
 if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & 
AV_CPU_FLAG_SLOW_GATHER)) {
 if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
@@ -298,9 +297,11 @@ int ff_shuffle_filter_coefficients(SwsContext *c, int 
*filterPos,
}
// Do not swap filterPos for pixels which won't be processed by
// the main loop.
-   for (i = 0; i + 8 <= dstW; i += 8) {
+   for (i = 0; i + 16 <= dstW; i += 16) {
FFSWAP(int, filterPos[i + 2], filterPos[i + 4]);
FFSWAP(int, filterPos[i + 3], filterPos[i + 5]);
+   FFSWAP(int, filterPos[i + 10], filterPos[i + 12]);
+   FFSWAP(int, filterPos[i + 11], filterPos[i + 13]);
}
if (filterSize > 4) {
// 16 pixels are processed at a time.
@@ -314,6 +315,18 @@ int ff_shuffle_filter_coefficients(SwsContext *c, int 
*filterPos,
}
}
}
+   // 4 pixels are processed at a time in the tail.
+   for (; i < dstW; i += 4) {
+   // 4 filter coeffs are processed at a time.
+   int rem = dstW - i >= 4 ? 4 : dstW - i;
+   for (k = 0; k + 4 <= filterSize; k += 4) {
+   for (j = 0; j < rem; ++j) {
+   int from = (i + j) * filterSize + k;
+   int to = i * filterSize + j * 4 + k * 4;
+   memcpy([to], [from], 4 * 
sizeof(int16_t));
+   }
+   }
+   }
}
av_free(filterCopy);
 }
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 73869355b8..76f5a70fc5 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -691,10 +691,8 @@ switch(c->dstBpc){ \
 
 if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & 
AV_CPU_FLAG_SLOW_GATHER)) {
 if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
-if (c->chrDstW % 16 == 0)
-ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
-if (c->dstW % 16 == 0)
-ASSIGN_AVX2_SCALE_FUNC(c->hyScale, c->hLumFilterSize);
+ASSIGN_AVX2_SCALE_FUNC(c->hcScale, c->hChrFilterSize);
+ASSIGN_AVX2_SCALE_FUNC(c->hyScale, c->hLumFilterSize);
 }
 }
 
-- 
2.35.1.265.g69c8d7142f-goog

___
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/5] libswscale: Avx2 hscale can process inputs of any size.

2022-02-17 Thread Alan Kelly
The main loop processes blocks of 16 pixels. The tail processes blocks
of size 4.
---
 libswscale/x86/scale_avx2.asm | 48 +--
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/libswscale/x86/scale_avx2.asm b/libswscale/x86/scale_avx2.asm
index 20acdbd633..dc42abb100 100644
--- a/libswscale/x86/scale_avx2.asm
+++ b/libswscale/x86/scale_avx2.asm
@@ -53,6 +53,9 @@ cglobal hscale8to15_%1, 7, 9, 16, pos0, dst, w, srcmem, 
filter, fltpos, fltsize,
 mova m14, [four]
 shr fltsized, 2
 %endif
+cmp wq, 16
+jl .tail_loop
+mov countq, 0x10
 .loop:
 movu m1, [fltposq]
 movu m2, [fltposq+32]
@@ -97,11 +100,52 @@ cglobal hscale8to15_%1, 7, 9, 16, pos0, dst, w, srcmem, 
filter, fltpos, fltsize,
 vpsrad  m6, 7
 vpackssdw m5, m5, m6
 vpermd m5, m15, m5
-vmovdqu [dstq + countq * 2], m5
+vmovdqu [dstq], m5
+add dstq, 0x20
 add fltposq, 0x40
 add countq, 0x10
 cmp countq, wq
-jl .loop
+jle .loop
+
+sub countq, 0x10
+cmp countq, wq
+jge .end
+
+.tail_loop:
+movu xm1, [fltposq]
+%ifidn %1, X4
+pxor xm9, xm9
+pxor xm10, xm10
+xor innerq, innerq
+.tail_innerloop:
+%endif
+vpcmpeqd  xm13, xm13
+vpgatherdd xm3,[srcmemq + xm1], xm13
+vpunpcklbw xm5, xm3, xm0
+vpunpckhbw xm6, xm3, xm0
+vpmaddwd xm5, xm5, [filterq]
+vpmaddwd xm6, xm6, [filterq + 16]
+add filterq, 0x20
+%ifidn %1, X4
+paddd xm9, xm5
+paddd xm10, xm6
+paddd xm1, xm14
+add innerq, 1
+cmp innerq, fltsizeq
+jl .tail_innerloop
+vphaddd xm5, xm9, xm10
+%else
+vphaddd xm5, xm5, xm6
+%endif
+vpsrad  xm5, 7
+vpackssdw xm5, xm5, xm5
+vmovq [dstq], xm5
+add dstq, 0x8
+add fltposq, 0x10
+add countq, 0x4
+cmp countq, wq
+jl .tail_loop
+.end:
 REP_RET
 %endmacro
 
-- 
2.35.1.265.g69c8d7142f-goog

___
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/5] libswscale: Re-factor ff_shuffle_filter_coefficients.

2022-02-17 Thread Alan Kelly
Make the code more readable and follow the style guide.
---
 libswscale/utils.c | 66 +-
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 344c87dfdf..7c8e1bbdde 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -278,42 +278,48 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_P416LE]  = { 1, 1 },
 };
 
-int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int 
filterSize, int16_t *filter, int dstW){
+int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
+   int filterSize, int16_t *filter,
+   int dstW)
+{
 #if ARCH_X86_64
-int i, j, k, l;
+int i, j, k;
 int cpu_flags = av_get_cpu_flags();
+// avx2 hscale filter processes 16 pixel blocks.
+if (!filter || dstW % 16 != 0)
+return 0;
 if (EXTERNAL_AVX2_FAST(cpu_flags) && !(cpu_flags & 
AV_CPU_FLAG_SLOW_GATHER)) {
-if ((c->srcBpc == 8) && (c->dstBpc <= 14)){
-if (dstW % 16 == 0){
-if (filter != NULL){
-for (i = 0; i < dstW; i += 8){
-FFSWAP(int, filterPos[i + 2], filterPos[i+4]);
-FFSWAP(int, filterPos[i + 3], filterPos[i+5]);
-}
-if (filterSize > 4){
-int16_t *tmp2 = av_malloc(dstW * filterSize * 2);
-if (!tmp2)
-return AVERROR(ENOMEM);
-memcpy(tmp2, filter, dstW * filterSize * 2);
-for (i = 0; i < dstW; i += 16){//pixel
-for (k = 0; k < filterSize / 4; ++k){//fcoeff
-for (j = 0; j < 16; ++j){//inner pixel
-for (l = 0; l < 4; ++l){//coeff
-int from = i * filterSize + j * 
filterSize + k * 4 + l;
-int to = (i) * filterSize + j * 4 + l 
+ k * 64;
-filter[to] = tmp2[from];
-}
-}
-}
-}
-av_free(tmp2);
-}
-}
-}
+if ((c->srcBpc == 8) && (c->dstBpc <= 14)) {
+   int16_t *filterCopy = NULL;
+   if (filterSize > 4) {
+   if (!FF_ALLOC_TYPED_ARRAY(filterCopy, dstW * filterSize))
+   return AVERROR(ENOMEM);
+   memcpy(filterCopy, filter, dstW * filterSize * sizeof(int16_t));
+   }
+   // Do not swap filterPos for pixels which won't be processed by
+   // the main loop.
+   for (i = 0; i + 8 <= dstW; i += 8) {
+   FFSWAP(int, filterPos[i + 2], filterPos[i + 4]);
+   FFSWAP(int, filterPos[i + 3], filterPos[i + 5]);
+   }
+   if (filterSize > 4) {
+   // 16 pixels are processed at a time.
+   for (i = 0; i + 16 <= dstW; i += 16) {
+   // 4 filter coeffs are processed at a time.
+   for (k = 0; k + 4 <= filterSize; k += 4) {
+   for (j = 0; j < 16; ++j) {
+   int from = (i + j) * filterSize + k;
+   int to = i * filterSize + j * 4 + k * 16;
+   memcpy([to], [from], 4 * 
sizeof(int16_t));
+   }
+   }
+   }
+   }
+   av_free(filterCopy);
 }
 }
-return 0;
 #endif
+return 0;
 }
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
2.35.1.265.g69c8d7142f-goog

___
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/5] libswscale: Check and propagate memory allocation errors from ff_shuffle_filter_coefficients.

2022-02-17 Thread Alan Kelly
---
 libswscale/swscale_internal.h |  2 +-
 libswscale/utils.c| 11 ---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 3a78d95ba6..26d28d42e6 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -1144,5 +1144,5 @@ void ff_sws_slice_worker(void *priv, int jobnr, int 
threadnr,
 #define MAX_LINES_AHEAD 4
 
 //shuffle filter and filterPos for hyScale and hcScale filters in avx2
-void ff_shuffle_filter_coefficients(SwsContext *c, int* filterPos, int 
filterSize, int16_t *filter, int dstW);
+int ff_shuffle_filter_coefficients(SwsContext *c, int* filterPos, int 
filterSize, int16_t *filter, int dstW);
 #endif /* SWSCALE_SWSCALE_INTERNAL_H */
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c5ea8853d5..344c87dfdf 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -278,7 +278,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_P416LE]  = { 1, 1 },
 };
 
-void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int 
filterSize, int16_t *filter, int dstW){
+int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int 
filterSize, int16_t *filter, int dstW){
 #if ARCH_X86_64
 int i, j, k, l;
 int cpu_flags = av_get_cpu_flags();
@@ -292,6 +292,8 @@ void ff_shuffle_filter_coefficients(SwsContext *c, int 
*filterPos, int filterSiz
 }
 if (filterSize > 4){
 int16_t *tmp2 = av_malloc(dstW * filterSize * 2);
+if (!tmp2)
+return AVERROR(ENOMEM);
 memcpy(tmp2, filter, dstW * filterSize * 2);
 for (i = 0; i < dstW; i += 16){//pixel
 for (k = 0; k < filterSize / 4; ++k){//fcoeff
@@ -310,6 +312,7 @@ void ff_shuffle_filter_coefficients(SwsContext *c, int 
*filterPos, int filterSiz
 }
 }
 }
+return 0;
 #endif
 }
 
@@ -1836,7 +1839,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
get_local_pos(c, 0, 0, 0),
get_local_pos(c, 0, 0, 0))) < 0)
 goto fail;
-ff_shuffle_filter_coefficients(c, c->hLumFilterPos, 
c->hLumFilterSize, c->hLumFilter, dstW);
+if (ff_shuffle_filter_coefficients(c, c->hLumFilterPos, 
c->hLumFilterSize, c->hLumFilter, dstW) < 0)
+goto nomem;
 if ((ret = initFilter(>hChrFilter, >hChrFilterPos,
>hChrFilterSize, c->chrXInc,
c->chrSrcW, c->chrDstW, filterAlign, 1 << 14,
@@ -1846,7 +1850,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter 
*srcFilter,
get_local_pos(c, c->chrSrcHSubSample, 
c->src_h_chr_pos, 0),
get_local_pos(c, c->chrDstHSubSample, 
c->dst_h_chr_pos, 0))) < 0)
 goto fail;
-ff_shuffle_filter_coefficients(c, c->hChrFilterPos, 
c->hChrFilterSize, c->hChrFilter, c->chrDstW);
+if (ff_shuffle_filter_coefficients(c, c->hChrFilterPos, 
c->hChrFilterSize, c->hChrFilter, c->chrDstW) < 0)
+goto nomem;
 }
 } // initialize horizontal stuff
 
-- 
2.35.1.265.g69c8d7142f-goog

___
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] avformat/riff: add more GeoVision FOURCC

2022-02-17 Thread Thomas Guillem
---
 libavformat/riff.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/riff.c b/libavformat/riff.c
index 27a9706510..23e6306b66 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -32,6 +32,7 @@
  * files use it as well.
  */
 const AVCodecTag ff_codec_bmp_tags[] = {
+{ AV_CODEC_ID_H265, MKTAG('G', 'H', 'E', 'C') }, /* GeoVision 
camera */
 { AV_CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
 { AV_CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
 { AV_CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
@@ -115,6 +116,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
 { AV_CODEC_ID_MPEG4,MKTAG('P', 'L', 'V', '1') }, /* Pelco DVR 
MPEG-4 */
 { AV_CODEC_ID_MPEG4,MKTAG('G', 'L', 'V', '4') },
 { AV_CODEC_ID_MPEG4,MKTAG('G', 'M', 'P', '4') }, /* GeoVision 
camera */
+{ AV_CODEC_ID_MPEG4,MKTAG('G', 'M', '4', '0') }, /* GeoVision 
camera */
 { AV_CODEC_ID_MPEG4,MKTAG('M', 'N', 'M', '4') }, /* March Networks 
DVR */
 { AV_CODEC_ID_MPEG4,MKTAG('G', 'T', 'M', '4') }, /* Telefactor */
 { AV_CODEC_ID_MSMPEG4V3,MKTAG('M', 'P', '4', '3') },
-- 
2.30.2

___
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/2] lavc/dxva: properly namespace public symbols

2022-02-17 Thread Hendrik Leppkes
On Thu, Feb 17, 2022 at 10:13 AM Anton Khirnov  wrote:
>
> ---
>  doc/APIchanges  |  6 ++
>  libavcodec/dxva2.c  |  4 ++--
>  libavcodec/dxva2.h  | 18 ++
>  libavcodec/dxva2_h264.c |  8 
>  libavcodec/dxva2_internal.h |  4 ++--
>  libavcodec/version.h|  3 ++-
>  6 files changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ea402f6118..3447872752 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,12 @@ libavutil: 2021-04-27
>
>  API changes, most recent first:
>
> +2022-02-xx - xx - lavc 59.22.100 - dxva2.h
> +  Rename struct dxva_context to (typedeffed) AVDXVA2DecodeContext.
> +  Rename FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG and 
> FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
> +  to AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG and 
> AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO,
> +  respectively. The previous names are now deprecated.
> +
>  2022-02-07 - xx - lavu 57.21.100 - fifo.h
>Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(),
>av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(),
> diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
> index c31a71ba3b..ab6995940b 100644
> --- a/libavcodec/dxva2.c
> +++ b/libavcodec/dxva2.c
> @@ -299,7 +299,7 @@ static int dxva_get_decoder_guid(AVCodecContext *avctx, 
> void *service, void *sur
>  }
>
>  if (IsEqualGUID(decoder_guid, _DXVADDI_Intel_ModeH264_E))
> -sctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
> +sctx->workaround |= AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
>
>  return 0;
>  }
> @@ -704,7 +704,7 @@ int ff_dxva2_decode_init(AVCodecContext *avctx)
>  #if CONFIG_DXVA2
>  if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
>  AVDXVA2FramesContext *frames_hwctx = frames_ctx->hwctx;
> -struct dxva_context *dxva_ctx = >ctx.dxva2;
> +AVDXVA2DecodeContext *dxva_ctx = >ctx.dxva2;
>
>  ff_dxva2_lock(avctx);
>  ret = dxva2_create_decoder(avctx);
> diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h
> index 22c93992f2..7892da693c 100644
> --- a/libavcodec/dxva2.h
> +++ b/libavcodec/dxva2.h
> @@ -45,8 +45,13 @@
>   * @{
>   */
>
> -#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 
> and old UVD/UVD+ ATI video cards
> -#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for DXVA2 
> and old Intel GPUs with ClearVideo interface
> +#define AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 
> and old UVD/UVD+ ATI video cards
> +#define AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for DXVA2 
> and old Intel GPUs with ClearVideo interface
> +
> +#if FF_API_DXVA_NAMING
> +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 
> AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG
> +#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
> AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
> +#endif

Why not rename the constants in d3d11va.h at the same time? they are
the same afterall.

This header likely needs to include version.h now to ensure the
FF_API_ macros are available.

>
>  /**
>   * This structure is used to provides the necessary configurations and data
> @@ -54,7 +59,12 @@
>   *
>   * The application must make it available as AVCodecContext.hwaccel_context.
>   */
> -struct dxva_context {
> +typedef struct
> +#if FF_API_DXVA_NAMING
> +dxva_context
> +#else
> +AVDXVA2DecodeContext

#endif missing here

> +{
>  /**
>   * DXVA2 decoder object
>   */
> @@ -84,7 +94,7 @@ struct dxva_context {
>   * Private to the FFmpeg AVHWAccel implementation
>   */
>  unsigned report_id;
> -};
> +} AVDXVA2DecodeContext;
>
>  /**
>   * @}
> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
> index 489b9bb0f5..f4d6098e0e 100644
> --- a/libavcodec/dxva2_h264.c
> +++ b/libavcodec/dxva2_h264.c
> @@ -119,9 +119,9 @@ static void fill_picture_parameters(const AVCodecContext 
> *avctx, DXVAContext *ct
>
>  pp->bit_depth_luma_minus8 = sps->bit_depth_luma - 8;
>  pp->bit_depth_chroma_minus8   = sps->bit_depth_chroma - 8;
> -if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
> FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG)
> +if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
> AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG)
>  pp->Reserved16Bits= 0;
> -else if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
> FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
> +else if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
> AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
>  pp->Reserved16Bits= 0x34c;
>  else
>  pp->Reserved16Bits= 3; /* FIXME is there a way to detect 
> the right mode ? */
> @@ -166,7 +166,7 @@ static void fill_scaling_lists(const AVCodecContext 
> *avctx, DXVAContext *ctx, co
>  const PPS *pps = h->ps.pps;
>  unsigned i, j;
>  memset(qm, 0, sizeof(*qm));
> -if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
> 

[FFmpeg-devel] [PATCH 2/2] lavc/dxva: properly namespace public symbols

2022-02-17 Thread Anton Khirnov
---
 doc/APIchanges  |  6 ++
 libavcodec/dxva2.c  |  4 ++--
 libavcodec/dxva2.h  | 18 ++
 libavcodec/dxva2_h264.c |  8 
 libavcodec/dxva2_internal.h |  4 ++--
 libavcodec/version.h|  3 ++-
 6 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ea402f6118..3447872752 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,12 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-02-xx - xx - lavc 59.22.100 - dxva2.h
+  Rename struct dxva_context to (typedeffed) AVDXVA2DecodeContext.
+  Rename FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG and 
FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
+  to AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG and 
AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO,
+  respectively. The previous names are now deprecated.
+
 2022-02-07 - xx - lavu 57.21.100 - fifo.h
   Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(),
   av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(),
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index c31a71ba3b..ab6995940b 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -299,7 +299,7 @@ static int dxva_get_decoder_guid(AVCodecContext *avctx, 
void *service, void *sur
 }
 
 if (IsEqualGUID(decoder_guid, _DXVADDI_Intel_ModeH264_E))
-sctx->workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
+sctx->workaround |= AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
 
 return 0;
 }
@@ -704,7 +704,7 @@ int ff_dxva2_decode_init(AVCodecContext *avctx)
 #if CONFIG_DXVA2
 if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
 AVDXVA2FramesContext *frames_hwctx = frames_ctx->hwctx;
-struct dxva_context *dxva_ctx = >ctx.dxva2;
+AVDXVA2DecodeContext *dxva_ctx = >ctx.dxva2;
 
 ff_dxva2_lock(avctx);
 ret = dxva2_create_decoder(avctx);
diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h
index 22c93992f2..7892da693c 100644
--- a/libavcodec/dxva2.h
+++ b/libavcodec/dxva2.h
@@ -45,8 +45,13 @@
  * @{
  */
 
-#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 
and old UVD/UVD+ ATI video cards
-#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for DXVA2 
and old Intel GPUs with ClearVideo interface
+#define AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 
and old UVD/UVD+ ATI video cards
+#define AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for DXVA2 
and old Intel GPUs with ClearVideo interface
+
+#if FF_API_DXVA_NAMING
+#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 
AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG
+#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO
+#endif
 
 /**
  * This structure is used to provides the necessary configurations and data
@@ -54,7 +59,12 @@
  *
  * The application must make it available as AVCodecContext.hwaccel_context.
  */
-struct dxva_context {
+typedef struct
+#if FF_API_DXVA_NAMING
+dxva_context
+#else
+AVDXVA2DecodeContext
+{
 /**
  * DXVA2 decoder object
  */
@@ -84,7 +94,7 @@ struct dxva_context {
  * Private to the FFmpeg AVHWAccel implementation
  */
 unsigned report_id;
-};
+} AVDXVA2DecodeContext;
 
 /**
  * @}
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 489b9bb0f5..f4d6098e0e 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -119,9 +119,9 @@ static void fill_picture_parameters(const AVCodecContext 
*avctx, DXVAContext *ct
 
 pp->bit_depth_luma_minus8 = sps->bit_depth_luma - 8;
 pp->bit_depth_chroma_minus8   = sps->bit_depth_chroma - 8;
-if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG)
+if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG)
 pp->Reserved16Bits= 0;
-else if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
+else if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
AV_DXVA2_WORKAROUND_INTEL_CLEARVIDEO)
 pp->Reserved16Bits= 0x34c;
 else
 pp->Reserved16Bits= 3; /* FIXME is there a way to detect 
the right mode ? */
@@ -166,7 +166,7 @@ static void fill_scaling_lists(const AVCodecContext *avctx, 
DXVAContext *ctx, co
 const PPS *pps = h->ps.pps;
 unsigned i, j;
 memset(qm, 0, sizeof(*qm));
-if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) {
+if (DXVA_CONTEXT_WORKAROUND(avctx, ctx) & 
AV_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG) {
 for (i = 0; i < 6; i++)
 for (j = 0; j < 16; j++)
 qm->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j];
@@ -249,7 +249,7 @@ static void fill_slice_long(AVCodecContext *avctx, 
DXVA_Slice_H264_Long *slice,
 const H264Picture *r = sl->ref_list[list][i].parent;
 unsigned plane;
 

[FFmpeg-devel] [PATCH 1/2] lavc/dxva2: rename drop AV prefix from AVDXVAContext

2022-02-17 Thread Anton Khirnov
It is not public.
---
 libavcodec/dxva2.c  | 10 +-
 libavcodec/dxva2_av1.c  |  6 +++---
 libavcodec/dxva2_h264.c | 14 +++---
 libavcodec/dxva2_hevc.c |  8 
 libavcodec/dxva2_internal.h | 10 +-
 libavcodec/dxva2_mpeg2.c|  8 
 libavcodec/dxva2_vc1.c  |  6 +++---
 libavcodec/dxva2_vp9.c  |  6 +++---
 8 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 568d686f39..c31a71ba3b 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -562,7 +562,7 @@ static void ff_dxva2_lock(AVCodecContext *avctx)
 #if CONFIG_D3D11VA
 if (ff_dxva2_is_d3d11(avctx)) {
 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
-AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
+DXVAContext *ctx = DXVA_CONTEXT(avctx);
 if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
 WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, 
INFINITE, FALSE);
 if (sctx->device_ctx) {
@@ -578,7 +578,7 @@ static void ff_dxva2_unlock(AVCodecContext *avctx)
 #if CONFIG_D3D11VA
 if (ff_dxva2_is_d3d11(avctx)) {
 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
-AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
+DXVAContext *ctx = DXVA_CONTEXT(avctx);
 if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
 if (sctx->device_ctx) {
@@ -768,7 +768,7 @@ static void *get_surface(const AVCodecContext *avctx, const 
AVFrame *frame)
 }
 
 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
-const AVDXVAContext *ctx,
+const DXVAContext *ctx,
 const AVFrame *frame)
 {
 void *surface = get_surface(avctx, frame);
@@ -795,7 +795,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext 
*avctx,
 }
 
 int ff_dxva2_commit_buffer(AVCodecContext *avctx,
-   AVDXVAContext *ctx,
+   DXVAContext *ctx,
DECODER_BUFFER_DESC *dsc,
unsigned type, const void *data, unsigned size,
unsigned mb_count)
@@ -890,7 +890,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, 
AVFrame *frame,
   DECODER_BUFFER_DESC *bs,
   DECODER_BUFFER_DESC *slice))
 {
-AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
+DXVAContext *ctx = DXVA_CONTEXT(avctx);
 unsigned   buffer_count = 0;
 #if CONFIG_D3D11VA
 D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c
index 7b4483f855..66a4594550 100644
--- a/libavcodec/dxva2_av1.c
+++ b/libavcodec/dxva2_av1.c
@@ -53,7 +53,7 @@ static int get_bit_depth_from_seq(const AV1RawSequenceHeader 
*seq)
 return 8;
 }
 
-static int fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext 
*ctx, const AV1DecContext *h,
+static int fill_picture_parameters(const AVCodecContext *avctx, DXVAContext 
*ctx, const AV1DecContext *h,
 DXVA_PicParams_AV1 *pp)
 {
 int i,j, uses_lr;
@@ -270,7 +270,7 @@ static int dxva2_av1_start_frame(AVCodecContext *avctx,
  av_unused uint32_t size)
 {
 const AV1DecContext *h = avctx->priv_data;
-AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
+DXVAContext *ctx = DXVA_CONTEXT(avctx);
 struct av1_dxva2_picture_context *ctx_pic = 
h->cur_frame.hwaccel_picture_private;
 
 if (!DXVA_CONTEXT_VALID(avctx, ctx))
@@ -346,7 +346,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext 
*avctx,
  DECODER_BUFFER_DESC *sc)
 {
 const AV1DecContext *h = avctx->priv_data;
-AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
+DXVAContext *ctx = DXVA_CONTEXT(avctx);
 struct av1_dxva2_picture_context *ctx_pic = 
h->cur_frame.hwaccel_picture_private;
 void *dxva_data_ptr;
 uint8_t  *dxva_data;
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 5b23b28f12..489b9bb0f5 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -45,7 +45,7 @@ static void fill_picture_entry(DXVA_PicEntry_H264 *pic,
 pic->bPicEntry = index | (flag << 7);
 }
 
-static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext 
*ctx, const H264Context *h,
+static void fill_picture_parameters(const AVCodecContext *avctx, DXVAContext 
*ctx, const H264Context *h,
 DXVA_PicParams_H264 *pp)
 {
 const H264Picture *current_picture = h->cur_pic_ptr;
@@ -161,7 +161,7 @@ static void fill_picture_parameters(const AVCodecContext 
*avctx, AVDXVAContext *
 //pp->SliceGroupMap[810];   /* XXX not