[FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available

2024-01-16 Thread Xiang, Haihao
From: Haihao Xiang 

This makes '-init_hw_device opencl' work in a multiple-device system.

Signed-off-by: Haihao Xiang 
---
 doc/ffmpeg.texi  | 5 +
 libavutil/hwcontext_opencl.c | 9 -
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 7246a46d2f..edda0d5d9b 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1424,6 +1424,8 @@ Choose the GPU subdevice with type @samp{dxva2} and 
create QSV device with @samp
 The set of devices can also be filtered using the key-value pairs to find only
 devices matching particular platform or device strings.
 
+If more than one matching device found, choose the first one from the set of 
devices.
+
 The strings usable as filters are:
 @table @option
 @item platform_profile
@@ -1444,6 +1446,9 @@ The indices and filters must together uniquely select a 
device.
 
 Examples:
 @table @emph
+@item -init_hw_device opencl
+Choose the first device on the first platform.
+
 @item -init_hw_device opencl:0.1
 Choose the second device on the first platform.
 
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 247834aaf6..98e35919bf 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -515,7 +515,7 @@ static int opencl_device_create_internal(AVHWDeviceContext 
*hwdev,
 return err;
 
 found = 0;
-for (p = 0; p < nb_platforms; p++) {
+for (p = nb_platforms - 1; p >= 0; p--) {
 const char *platform_name;
 
 if (selector->platform_index >= 0 &&
@@ -546,7 +546,7 @@ static int opencl_device_create_internal(AVHWDeviceContext 
*hwdev,
 if (err < 0)
 continue;
 
-for (d = 0; d < nb_devices; d++) {
+for (d = nb_devices - 1; d >= 0; d--) {
 const char *device_name;
 
 if (selector->device_index >= 0 &&
@@ -588,9 +588,8 @@ static int opencl_device_create_internal(AVHWDeviceContext 
*hwdev,
 goto fail;
 }
 if (found > 1) {
-av_log(hwdev, AV_LOG_ERROR, "More than one matching device found.\n");
-err = AVERROR(ENODEV);
-goto fail;
+av_log(hwdev, AV_LOG_VERBOSE,
+   "More than one matching device found, choose the first 
device.\n");
 }
 
 if (!props) {
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 3/3] libavfilter/vf_dnn_detect: Use class confidence to filt boxes

2024-01-16 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Use class confidence instead of box_score to filt boxes, which is more
accurate. Class confidence is obtained by multiplying class probability
distribution and box_score.

Signed-off-by: Wenbin Chen 
---
 libavfilter/vf_dnn_detect.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index caccbf7a12..2bf5ed7476 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -236,9 +236,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 conf = post_process_raw_data(
 detection_boxes_data[cy * cell_w + cx + 4 * 
cell_w * cell_h]);
 }
-if (conf < conf_threshold) {
-continue;
-}
 
 if (is_NHWC) {
 x = post_process_raw_data(detection_boxes_data[0]);
@@ -257,6 +254,9 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, 
DNNData *output, int out
 conf = conf * post_process_raw_data(
 detection_boxes_data[cy * cell_w + cx + 
(label_id + 5) * cell_w * cell_h]);
 }
+if (conf < conf_threshold) {
+continue;
+}
 
 bbox = av_mallocz(sizeof(*bbox));
 if (!bbox)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/3] libavfilter/dnn_interface: use dims to represent shapes

2024-01-16 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

For detect and classify output, width and height make no sence, so
change width, height to dims to represent the shape of tensor. Use
layout and dims to get width, height and channel.

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_openvino.c | 80 ++
 libavfilter/dnn/dnn_backend_tf.c   | 32 +++
 libavfilter/dnn/dnn_io_proc.c  | 30 +++---
 libavfilter/dnn_interface.h| 17 +-
 libavfilter/vf_dnn_classify.c  |  6 +-
 libavfilter/vf_dnn_detect.c| 50 
 libavfilter/vf_dnn_processing.c| 21 ---
 7 files changed, 146 insertions(+), 90 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 590ddd586c..73b42c32b1 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -253,9 +253,9 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 ov_shape_free(_shape);
 return ov2_map_error(status, NULL);
 }
-input.height = dims[1];
-input.width = dims[2];
-input.channels = dims[3];
+for (int i = 0; i < input_shape.rank; i++)
+input.dims[i] = dims[i];
+input.layout = DL_NHWC;
 input.dt = precision_to_datatype(precision);
 #else
 status = ie_infer_request_get_blob(request->infer_request, 
task->input_name, _blob);
@@ -278,9 +278,9 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 av_log(ctx, AV_LOG_ERROR, "Failed to get input blob buffer\n");
 return DNN_GENERIC_ERROR;
 }
-input.height = dims.dims[2];
-input.width = dims.dims[3];
-input.channels = dims.dims[1];
+for (int i = 0; i < input_shape.rank; i++)
+input.dims[i] = dims[i];
+input.layout = DL_NCHW;
 input.data = blob_buffer.buffer;
 input.dt = precision_to_datatype(precision);
 #endif
@@ -339,8 +339,8 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 av_assert0(!"should not reach here");
 break;
 }
-input.data = (uint8_t *)input.data
- + input.width * input.height * input.channels * 
get_datatype_size(input.dt);
+input.data = (uint8_t *)input.data +
+input.dims[1] * input.dims[2] * input.dims[3] * 
get_datatype_size(input.dt);
 }
 #if HAVE_OPENVINO2
 ov_tensor_free(tensor);
@@ -403,10 +403,11 @@ static void infer_completion_callback(void *args)
 goto end;
 }
 outputs[i].dt   = precision_to_datatype(precision);
-
-outputs[i].channels = output_shape.rank > 2 ? dims[output_shape.rank - 
3] : 1;
-outputs[i].height   = output_shape.rank > 1 ? dims[output_shape.rank - 
2] : 1;
-outputs[i].width= output_shape.rank > 0 ? dims[output_shape.rank - 
1] : 1;
+outputs[i].layout   = DL_NCHW;
+outputs[i].dims[0]  = 1;
+outputs[i].dims[1]  = output_shape.rank > 2 ? dims[output_shape.rank - 
3] : 1;
+outputs[i].dims[2]  = output_shape.rank > 1 ? dims[output_shape.rank - 
2] : 1;
+outputs[i].dims[3]  = output_shape.rank > 0 ? dims[output_shape.rank - 
1] : 1;
 av_assert0(request->lltask_count <= dims[0]);
 outputs[i].layout   = ctx->options.layout;
 outputs[i].scale= ctx->options.scale;
@@ -445,9 +446,9 @@ static void infer_completion_callback(void *args)
 return;
 }
 output.data = blob_buffer.buffer;
-output.channels = dims.dims[1];
-output.height   = dims.dims[2];
-output.width= dims.dims[3];
+output.layout   = DL_NCHW;
+for (int i = 0; i < 4; i++)
+output.dims[i] = dims.dims[i];
 av_assert0(request->lltask_count <= dims.dims[0]);
 output.dt   = precision_to_datatype(precision);
 output.layout   = ctx->options.layout;
@@ -469,8 +470,10 @@ static void infer_completion_callback(void *args)
 ff_proc_from_dnn_to_frame(task->out_frame, outputs, ctx);
 }
 } else {
-task->out_frame->width = outputs[0].width;
-task->out_frame->height = outputs[0].height;
+task->out_frame->width =
+
outputs[0].dims[dnn_get_width_idx_by_layout(outputs[0].layout)];
+task->out_frame->height =
+
outputs[0].dims[dnn_get_height_idx_by_layout(outputs[0].layout)];
 }
 break;
 case DFT_ANALYTICS_DETECT:
@@ -501,7 +504,8 @@ static void infer_completion_callback(void *args)
 av_freep(>lltasks[i]);
 for (int i = 0; i < ov_model->nb_outputs; i++)
 outputs[i].data = (uint8_t *)outputs[i].data +
-outputs[i].width * outputs[i].height * outputs[i].channels * 
get_datatype_size(outputs[i].dt);
+outputs[i].dims[1] * outputs[i].dims[2] * outputs[i].dims[3] *
+

[FFmpeg-devel] [PATCH 1/3] libavfilter/dnn_bakcend_openvino: Add automatic input/output detection

2024-01-16 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Now when using openvino backend, user doesn't need to set input/output
names in command line. Model ports will be automatically detected.

For example:
ffmpeg -i input.png -vf \
dnn_detect=dnn_backend=openvino:model=model.xml:input=image:\
output=detection_out -y output.png

can be simplified to:
ffmpeg -i input.png -vf dnn_detect=dnn_backend=openvino:model=model.xml\
 -y output.png

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_openvino.c | 64 ++
 libavfilter/dnn_filter_common.c| 21 +
 2 files changed, 67 insertions(+), 18 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index e207d44584..590ddd586c 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -205,6 +205,7 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 ov_tensor_t* tensor = NULL;
 ov_shape_t input_shape = {0};
 ov_element_type_e precision;
+char *port_name;
 #else
 dimensions_t dims;
 precision_e precision;
@@ -223,11 +224,23 @@ static int fill_model_input_ov(OVModel *ov_model, 
OVRequestItem *request)
 ov_output_const_port_free(ov_model->input_port);
 ov_model->input_port = NULL;
 }
-status = ov_model_const_input_by_name(ov_model->ov_model, 
task->input_name, _model->input_port);
+if (task->input_name)
+status = ov_model_const_input_by_name(ov_model->ov_model, 
task->input_name, _model->input_port);
+else
+status = ov_model_const_input(ov_model->ov_model, 
_model->input_port);
 if (status != OK) {
 av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
 return ov2_map_error(status, NULL);
 }
+status = ov_port_get_any_name(ov_model->input_port, _name);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get input port name.\n");
+return ov2_map_error(status, NULL);
+}
+av_log(ctx, AV_LOG_VERBOSE, "OpenVINO model input: %s\n", port_name);
+ov_free(port_name);
+port_name = NULL;
+
 status = ov_const_port_get_shape(ov_model->input_port, _shape);
 if (status != OK) {
 av_log(ctx, AV_LOG_ERROR, "Failed to get input port shape.\n");
@@ -620,7 +633,10 @@ static int init_model_ov(OVModel *ov_model, const char 
*input_name, const char *
 goto err;
 }
 
-status = 
ov_preprocess_prepostprocessor_get_input_info_by_name(ov_model->preprocess, 
input_name, _model->input_info);
+if (input_name)
+status = 
ov_preprocess_prepostprocessor_get_input_info_by_name(ov_model->preprocess, 
input_name, _model->input_info);
+else
+status = 
ov_preprocess_prepostprocessor_get_input_info(ov_model->preprocess, 
_model->input_info);
 if (status != OK) {
 av_log(ctx, AV_LOG_ERROR, "Failed to get input info from 
preprocess.\n");
 ret = ov2_map_error(status, NULL);
@@ -673,10 +689,24 @@ static int init_model_ov(OVModel *ov_model, const char 
*input_name, const char *
 goto err;
 }
 
+if (!nb_outputs) {
+size_t output_size;
+status = ov_model_outputs_size(ov_model->ov_model, _size);
+if (status != OK) {
+av_log(ctx, AV_LOG_ERROR, "Failed to get output size.\n");
+ret = ov2_map_error(status, NULL);
+goto err;
+}
+nb_outputs = output_size;
+}
 ov_model->nb_outputs = nb_outputs;
 for (int i = 0; i < nb_outputs; i++) {
-status = ov_preprocess_prepostprocessor_get_output_info_by_name(
-ov_model->preprocess, output_names[i], _model->output_info);
+if (output_names)
+status = ov_preprocess_prepostprocessor_get_output_info_by_name(
+ov_model->preprocess, output_names[i], 
_model->output_info);
+else
+status = ov_preprocess_prepostprocessor_get_output_info_by_index(
+ov_model->preprocess, i, _model->output_info);
 if (status != OK) {
 av_log(ctx, AV_LOG_ERROR, "Failed to get output info from 
preprocess.\n");
 ret = ov2_map_error(status, NULL);
@@ -758,12 +788,25 @@ static int init_model_ov(OVModel *ov_model, const char 
*input_name, const char *
 }
 
 for (int i = 0; i < nb_outputs; i++) {
-status = ov_model_const_output_by_name(ov_model->ov_model, 
output_names[i],
-   _model->output_ports[i]);
+char *port_name;
+if (output_names)
+status = ov_model_const_output_by_name(ov_model->ov_model, 
output_names[i],
+_model->output_ports[i]);
+else
+status = ov_model_const_output_by_index(ov_model->ov_model, i,
+_model->output_ports[i]);
 if (status != OK) {
 av_log(ctx, AV_LOG_ERROR, "Failed to get output port 

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index

2024-01-16 Thread Xiang, Haihao
On Do, 2024-01-11 at 14:31 +0800, tong1.wu-at-intel@ffmpeg.org wrote:
> From: Tong Wu 
> 
> Fixes #10759.
> 
> It can happen in H.264, MPEG2, VC1 that the current frame resource
> memory is already in ref_resource. For example, for a interlaced frame,
> the same curr memory is passed twice. For the second time it could possibly
> reference itself. When this happens the curr is already given an index and
> in ref_resources. When the reference frame index is required, we should check
> the existance in the ref_resources first before assigning a new index for it.
> 
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/d3d12va_decode.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
> index c5c599675e..a6f40236d1 100644
> --- a/libavcodec/d3d12va_decode.c
> +++ b/libavcodec/d3d12va_decode.c
> @@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext
> *avctx,
>  if (!res)
>  goto fail;
>  
> -    if (!curr) {
> -    for (i = 0; i < ctx->max_num_ref; i++) {
> -    if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> -    ctx->used_mask |= 1 << i;
> -    return i;
> -    }
> +    for (i = 0; i < ctx->max_num_ref; i++) {
> +    if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> +    ctx->used_mask |= 1 << i;
> +    return i;
>  }
> -    } else {
> +    }
> +
> +    if (curr) {
>  for (i = 0; i < ctx->max_num_ref; i++) {
>  if (!((ctx->used_mask >> i) & 0x1)) {
>  ctx->ref_resources[i] = res;

Patchset LGTM, 

BRs
Haihao


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

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


Re: [FFmpeg-devel] [PATCH v2 1/2] lavc/d3d12va: remove unused variables

2024-01-16 Thread Xiang, Haihao
On Ma, 2024-01-15 at 10:34 +0800, tong1.wu-at-intel@ffmpeg.org wrote:
> From: Tong Wu 
> 
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/d3d12va_av1.c    | 18 +-
>  libavcodec/d3d12va_decode.c |  9 ++---
>  libavcodec/d3d12va_h264.c   |  4 
>  libavcodec/d3d12va_hevc.c   |  5 -
>  libavcodec/d3d12va_vc1.c    |  3 ---
>  libavcodec/d3d12va_vp9.c    |  4 
>  6 files changed, 7 insertions(+), 36 deletions(-)
> 
> diff --git a/libavcodec/d3d12va_av1.c b/libavcodec/d3d12va_av1.c
> index 6a3543353f..5f96f7da04 100644
> --- a/libavcodec/d3d12va_av1.c
> +++ b/libavcodec/d3d12va_av1.c
> @@ -108,11 +108,8 @@ static int d3d12va_av1_decode_slice(AVCodecContext
> *avctx,
>  
>  static int update_input_arguments(AVCodecContext *avctx,
> D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer)
>  {
> -    D3D12VADecodeContext    *ctx  = D3D12VA_DECODE_CONTEXT(avctx);
> -    AVHWFramesContext   *frames_ctx   = D3D12VA_FRAMES_CONTEXT(avctx);
> -    AVD3D12VAFramesContext  *frames_hwctx = frames_ctx->hwctx;
> -    const AV1DecContext *h    = avctx->priv_data;
> -    AV1DecodePictureContext *ctx_pic  = h-
> >cur_frame.hwaccel_picture_private;
> +    const AV1DecContext *h   = avctx->priv_data;
> +    AV1DecodePictureContext *ctx_pic = h->cur_frame.hwaccel_picture_private;
>  uint8_t *mapped_data;
>  
>  D3D12_VIDEO_DECODE_FRAME_ARGUMENT *args = _args-
> >FrameArguments[input_args->NumFrameArguments++];
> @@ -142,7 +139,6 @@ static int d3d12va_av1_end_frame(AVCodecContext *avctx)
>  {
>  int ret;
>  const AV1DecContext *h   = avctx->priv_data;
> -    D3D12VADecodeContext    *ctx = D3D12VA_DECODE_CONTEXT(avctx);
>  AV1DecodePictureContext *ctx_pic = h->cur_frame.hwaccel_picture_private;
>  
>  if (ctx_pic->tiles <= 0 || ctx_pic->bitstream_size <= 0)
> @@ -156,10 +152,8 @@ static int d3d12va_av1_end_frame(AVCodecContext *avctx)
>  
>  static int d3d12va_av1_decode_init(AVCodecContext *avctx)
>  {
> -    const AV1DecContext *h   = avctx->priv_data;
> -    D3D12VADecodeContext    *ctx = D3D12VA_DECODE_CONTEXT(avctx);
> -    D3D12AV1DecodeContext   *av1_ctx = D3D12_AV1_DECODE_CONTEXT(avctx);
> -    AV1DecodePictureContext *ctx_pic = h->cur_frame.hwaccel_picture_private;
> +    D3D12VADecodeContext  *ctx = D3D12VA_DECODE_CONTEXT(avctx);
> +    D3D12AV1DecodeContext *av1_ctx = D3D12_AV1_DECODE_CONTEXT(avctx);
>  DXVA_PicParams_AV1 pp;
>  
>  int ret;
> @@ -186,9 +180,7 @@ static int d3d12va_av1_decode_init(AVCodecContext *avctx)
>  
>  static int d3d12va_av1_decode_uninit(AVCodecContext *avctx)
>  {
> -    const AV1DecContext *h   = avctx->priv_data;
> -    D3D12AV1DecodeContext   *ctx = D3D12_AV1_DECODE_CONTEXT(avctx);
> -    AV1DecodePictureContext *ctx_pic = h->cur_frame.hwaccel_picture_private;
> +    D3D12AV1DecodeContext *ctx = D3D12_AV1_DECODE_CONTEXT(avctx);
>  
>  if (ctx->bitstream_buffer)
>  av_freep(>bitstream_buffer);
> diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
> index c5c599675e..ae2f577e25 100644
> --- a/libavcodec/d3d12va_decode.c
> +++ b/libavcodec/d3d12va_decode.c
> @@ -265,8 +265,7 @@ fail:
>  
>  int ff_d3d12va_common_frame_params(AVCodecContext *avctx, AVBufferRef
> *hw_frames_ctx)
>  {
> -    AVHWFramesContext  *frames_ctx   = (AVHWFramesContext
> *)hw_frames_ctx->data;
> -    AVHWDeviceContext  *device_ctx   = frames_ctx->device_ctx;
> +    AVHWFramesContext *frames_ctx = (AVHWFramesContext *)hw_frames_ctx->data;
>  
>  frames_ctx->format    = AV_PIX_FMT_D3D12;
>  frames_ctx->sw_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
> AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
> @@ -407,9 +406,7 @@ int ff_d3d12va_decode_uninit(AVCodecContext *avctx)
>  static inline int d3d12va_update_reference_frames_state(AVCodecContext
> *avctx, D3D12_RESOURCE_BARRIER *barriers,
>  ID3D12Resource
> *current_resource, int state_before, int state_end)
>  {
> -    D3D12VADecodeContext   *ctx  = D3D12VA_DECODE_CONTEXT(avctx);
> -    AVHWFramesContext  *frames_ctx   = D3D12VA_FRAMES_CONTEXT(avctx);
> -    AVD3D12VAFramesContext *frames_hwctx = frames_ctx->hwctx;
> +    D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx);
>  
>  int num_barrier = 0;
>  for (int i = 0; i < ctx->max_num_ref; i++) {
> @@ -436,8 +433,6 @@ int ff_d3d12va_common_end_frame(AVCodecContext *avctx,
> AVFrame *frame,
>  {
>  int ret;
>  D3D12VADecodeContext   *ctx   =
> D3D12VA_DECODE_CONTEXT(avctx);
> -    AVHWFramesContext  *frames_ctx    =
> D3D12VA_FRAMES_CONTEXT(avctx);
> -    AVD3D12VAFramesContext *frames_hwctx  = frames_ctx->hwctx;
>  ID3D12Resource *buffer    = NULL;
>  ID3D12CommandAllocator *command_allocator = NULL;
>  AVD3D12VAFrame *f = (AVD3D12VAFrame *)frame-
> 

[FFmpeg-devel] [PATCH v2 0/2] avcodec/vvcdec: fix valgrind issue for deblock

2024-01-16 Thread Nuo Mi
change since v1:
Rebased on top of master.

Nuo Mi (2):
  avcodec/vvcdec: deblock, fix uninitialized values
  avcodec/vvcdec: misc, constify hor_ctu_edge

 libavcodec/vvc/vvc_filter_template.c | 242 ++-
 1 file changed, 122 insertions(+), 120 deletions(-)

--
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".


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/vvcdec: deblock, fix uninitialized values

2024-01-16 Thread Nuo Mi
On Tue, Jan 16, 2024 at 10:38 PM James Almer  wrote:

> On 1/8/2024 10:00 PM, Nuo Mi wrote:
> >
> >
> > On Sun, Jan 7, 2024 at 12:43 PM Nuo Mi  > > wrote:
> >
> > see
> >
> https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind=20240105201935
> <
> https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind=20240105201935
> >
> >
> > If tc is zero, the max_len_q, max_len_p are uninitialized.
> >
> > Reported-by: James Almer  jamr...@gmail.com>>
> >
> > Hi James,
> > Could you help try and review this?
>
> The patch doesn't seem to apply.
>
Sorry, the master changed.
Please use the v2.
Thank you

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

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


[FFmpeg-devel] [PATCH v2 1/2] avcodec/vvcdec: deblock, fix uninitialized values

2024-01-16 Thread Nuo Mi
see 
https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind=20240105201935
If tc is zero, the max_len_q, max_len_p are uninitialized.

Reported-by: James Almer 
---
 libavcodec/vvc/vvc_filter_template.c | 236 ++-
 1 file changed, 119 insertions(+), 117 deletions(-)

diff --git a/libavcodec/vvc/vvc_filter_template.c 
b/libavcodec/vvc/vvc_filter_template.c
index 671ed7de4e..845c8a4181 100644
--- a/libavcodec/vvc/vvc_filter_template.c
+++ b/libavcodec/vvc/vvc_filter_template.c
@@ -551,81 +551,80 @@ static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, 
ptrdiff_t _xstride, ptrdif
 const ptrdiff_t ystride = _ystride / sizeof(pixel);
 
 for (int i = 0; i < 2; i++) {
-pixel* pix  = (pixel*)_pix + i * 4 * ystride;
-const int dp0   = abs(P2 - 2 * P1 + P0);
-const int dq0   = abs(Q2 - 2 * Q1 + Q0);
-const int dp3   = abs(TP2 - 2 * TP1 + TP0);
-const int dq3   = abs(TQ2 - 2 * TQ1 + TQ0);
-const int d0= dp0 + dq0;
-const int d3= dp3 + dq3;
 #if BIT_DEPTH < 10
 const int tc= (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - 
BIT_DEPTH);
 #else
 const int tc= _tc[i] << (BIT_DEPTH - 10);
 #endif
-const int tc25  = ((tc * 5 + 1) >> 1);
-
-const int no_p  = _no_p[i];
-const int no_q  = _no_q[i];
-
-int max_len_p   = _max_len_p[i];
-int max_len_q   = _max_len_q[i];
-
-const int large_p = (max_len_p > 3 && !hor_ctu_edge);
-const int large_q = max_len_q > 3;
-const int beta = _beta[i] << BIT_DEPTH - 8;
-
-const int beta_3 = beta >> 3;
-const int beta_2 = beta >> 2;
-
-if (!tc)
-continue;
-
-if (large_p || large_q) {
-const int dp0l = large_p ? ((dp0 + abs(P5 - 2 * P4 + P3) + 1) >> 
1) : dp0;
-const int dq0l = large_q ? ((dq0 + abs(Q5 - 2 * Q4 + Q3) + 1) >> 
1) : dq0;
-const int dp3l = large_p ? ((dp3 + abs(TP5 - 2 * TP4 + TP3) + 1) 
>> 1) : dp3;
-const int dq3l = large_q ? ((dq3 + abs(TQ5 - 2 * TQ4 + TQ3) + 1) 
>> 1) : dq3;
-const int d0l = dp0l + dq0l;
-const int d3l = dp3l + dq3l;
-const int beta53 = beta * 3 >> 5;
-const int beta_4 = beta >> 4;
-max_len_p = large_p ? max_len_p : 3;
-max_len_q = large_q ? max_len_q : 3;
-
-if (d0l + d3l < beta) {
-const int sp0l = abs(P3 - P0) + (max_len_p == 7 ? abs(P7 - P6 
- P5 + P4) : 0);
-const int sq0l = abs(Q0 - Q3) + (max_len_q == 7 ? abs(Q4 - Q5 
- Q6 + Q7) : 0);
-const int sp3l = abs(TP3 - TP0) + (max_len_p == 7 ? abs(TP7 - 
TP6 - TP5 + TP4) : 0);
-const int sq3l = abs(TQ0 - TQ3) + (max_len_q == 7 ? abs(TQ4 - 
TQ5 - TQ6 + TQ7) : 0);
-const int sp0 = large_p ? ((sp0l + abs(P3 -   P(max_len_p)) + 
1) >> 1) : sp0l;
-const int sp3 = large_p ? ((sp3l + abs(TP3 - TP(max_len_p)) + 
1) >> 1) : sp3l;
-const int sq0 = large_q ? ((sq0l + abs(Q3 -   Q(max_len_q)) + 
1) >> 1) : sq0l;
-const int sq3 = large_q ? ((sq3l + abs(TQ3 - TQ(max_len_q)) + 
1) >> 1) : sq3l;
-if (sp0 + sq0 < beta53 && abs(P0 - Q0) < tc25 &&
-sp3 + sq3 < beta53 && abs(TP0 - TQ0) < tc25 &&
-(d0l << 1) < beta_4 && (d3l << 1) < beta_4) {
-FUNC(loop_filter_luma_large)(pix, xstride, ystride, tc, 
no_p, no_q, max_len_p, max_len_q);
-continue;
+if (tc) {
+pixel* pix = (pixel*)_pix + i * 4 * ystride;
+const int dp0  = abs(P2 - 2 * P1 + P0);
+const int dq0  = abs(Q2 - 2 * Q1 + Q0);
+const int dp3  = abs(TP2 - 2 * TP1 + TP0);
+const int dq3  = abs(TQ2 - 2 * TQ1 + TQ0);
+const int d0   = dp0 + dq0;
+const int d3   = dp3 + dq3;
+const int tc25 = ((tc * 5 + 1) >> 1);
+
+const int no_p = _no_p[i];
+const int no_q = _no_q[i];
+
+int max_len_p  = _max_len_p[i];
+int max_len_q  = _max_len_q[i];
+
+const int large_p = (max_len_p > 3 && !hor_ctu_edge);
+const int large_q = max_len_q > 3;
+
+const int beta= _beta[i] << BIT_DEPTH - 8;
+const int beta_3  = beta >> 3;
+const int beta_2  = beta >> 2;
+
+if (large_p || large_q) {
+const int dp0l = large_p ? ((dp0 + abs(P5 - 2 * P4 + P3) + 1) 
>> 1) : dp0;
+const int dq0l = large_q ? ((dq0 + abs(Q5 - 2 * Q4 + Q3) + 1) 
>> 1) : dq0;
+const int dp3l = large_p ? ((dp3 + abs(TP5 - 2 * TP4 + TP3) + 
1) >> 1) : dp3;
+const int dq3l = large_q ? ((dq3 + abs(TQ5 - 2 * TQ4 + TQ3) + 
1) >> 1) : dq3;
+const int d0l = dp0l + dq0l;
+const int d3l = dp3l + dq3l;
+const int beta53 = beta * 3 

[FFmpeg-devel] [PATCH v2 2/2] avcodec/vvcdec: misc, constify hor_ctu_edge

2024-01-16 Thread Nuo Mi
---
 libavcodec/vvc/vvc_filter_template.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vvc/vvc_filter_template.c 
b/libavcodec/vvc/vvc_filter_template.c
index 845c8a4181..b7eaef5125 100644
--- a/libavcodec/vvc/vvc_filter_template.c
+++ b/libavcodec/vvc/vvc_filter_template.c
@@ -545,7 +545,7 @@ static void FUNC(loop_filter_luma_large)(pixel *pix, const 
ptrdiff_t xstride, co
 
 static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, 
ptrdiff_t _ystride,
 const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const 
uint8_t *_no_q,
-const uint8_t *_max_len_p, const uint8_t *_max_len_q, int hor_ctu_edge)
+const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int 
hor_ctu_edge)
 {
 const ptrdiff_t xstride = _xstride / sizeof(pixel);
 const ptrdiff_t ystride = _ystride / sizeof(pixel);
@@ -771,7 +771,7 @@ static void FUNC(vvc_v_loop_filter_chroma)(uint8_t *pix, 
ptrdiff_t stride,
 
 static void FUNC(vvc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t 
*no_q,
-const uint8_t *max_len_p, const uint8_t *max_len_q, int hor_ctu_edge)
+const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
 {
 FUNC(vvc_loop_filter_luma)(pix, stride, sizeof(pixel), beta, tc,
 no_p, no_q, max_len_p, max_len_q, hor_ctu_edge);
@@ -779,7 +779,7 @@ static void FUNC(vvc_h_loop_filter_luma)(uint8_t *pix, 
ptrdiff_t stride,
 
 static void FUNC(vvc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t 
*no_q,
-const uint8_t *max_len_p, const uint8_t *max_len_q, int hor_ctu_edge)
+const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
 {
 FUNC(vvc_loop_filter_luma)(pix, sizeof(pixel), stride, beta, tc,
 no_p, no_q, max_len_p, max_len_q, hor_ctu_edge);
-- 
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] avfilter/vf_xfade: Update to support transition between two points in single video stream.

2024-01-16 Thread Aidan O Connor
This patch replaces my previous patch from Jan. 4 2024, which had bugs.


Signed-off-by: Aidan O'Connor 
---
 libavfilter/vf_xfade.c | 260 -
 1 file changed, 207 insertions(+), 53 deletions(-)

diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index 890995a608..f50ae1ada1 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -93,11 +93,18 @@ enum XFadeTransitions {
 typedef struct XFadeContext {
 const AVClass *class;

+// Number of inputs. May be 1 for transition within stream or 2 for 
cross-fade between streams.
+int nb_inputs;
+
 int transition;
 int64_t duration;
 int64_t offset;
 char   *custom_str;

+// Start & end time user options (single input only)
+int64_t start;
+int64_t end;
+
 int nb_planes;
 int depth;
 int is_rgb;
@@ -105,12 +112,18 @@ typedef struct XFadeContext {
 // PTS when the fade should start (in first inputs timebase)
 int64_t start_pts;

+// PTS when the fade should end (single input only)
+int64_t end_pts;
+
 // PTS offset between first and second input
 int64_t inputs_offset_pts;

 // Duration of the transition
 int64_t duration_pts;

+// Frame duration (single input only)
+int64_t frame_duration;
+
 // Current PTS of the first input
 int64_t pts;

@@ -118,6 +131,12 @@ typedef struct XFadeContext {
 // like before and after the actual transition.
 int passthrough;

+// Copy of transition start frame (single input only)
+AVFrame *start_frame;
+
+// Number of input frames discarded that are to be regenerated for the 
transition (single input only)
+int nb_frames;
+
 int status[2];
 AVFrame *xf[2];
 int max_value;
@@ -169,6 +188,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)

 static const AVOption xfade_options[] = {
+{ "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, { 
.i64 = 2 }, 1, 2, FLAGS },
 { "transition", "set cross fade transition", OFFSET(transition), 
AV_OPT_TYPE_INT, {.i64=FADE}, -1, NB_TRANSITIONS-1, FLAGS, "transition" },
 {   "custom","custom transition", 0, AV_OPT_TYPE_CONST, 
{.i64=CUSTOM},0, 0, FLAGS, "transition" },
 {   "fade",  "fade transition",   0, AV_OPT_TYPE_CONST, 
{.i64=FADE},  0, 0, FLAGS, "transition" },
@@ -231,6 +251,8 @@ static const AVOption xfade_options[] = {
 {   "revealdown", "reveal down transition", 0, AV_OPT_TYPE_CONST, 
{.i64=REVEALDOWN}, 0, 0, FLAGS, "transition" },
 { "duration", "set cross fade duration", OFFSET(duration), 
AV_OPT_TYPE_DURATION, {.i64=100}, 0, 6000, FLAGS },
 { "offset",   "set cross fade start relative to first input stream", 
OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
+{ "start", "set fade start time (single input only)", OFFSET(start), 
AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
+{ "end", "set fade end time (single input only)", OFFSET(end), 
AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
 { "expr",   "set expression for custom transition", OFFSET(custom_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
 { NULL }
 };
@@ -2039,44 +2061,53 @@ static double b3(void *priv, double x, double y) { 
return getpix(priv, x, y, 3,
 static int config_output(AVFilterLink *outlink)
 {
 AVFilterContext *ctx = outlink->src;
-AVFilterLink *inlink0 = ctx->inputs[0];
-AVFilterLink *inlink1 = ctx->inputs[1];
 XFadeContext *s = ctx->priv;
+unsigned nb_inputs = s->nb_inputs;
+AVFilterLink *inlink0 = ctx->inputs[0];
+AVFilterLink *inlink1 = nb_inputs > 1 ? ctx->inputs[1] : NULL;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink0->format);

-if (inlink0->w != inlink1->w || inlink0->h != inlink1->h) {
-av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
-   "(size %dx%d) do not match the corresponding "
-   "second input link %s parameters (size %dx%d)\n",
-   ctx->input_pads[0].name, inlink0->w, inlink0->h,
-   ctx->input_pads[1].name, inlink1->w, inlink1->h);
-return AVERROR(EINVAL);
-}
+if (nb_inputs == 1) {
+if (!inlink0->frame_rate.num || !inlink0->frame_rate.den) {
+av_log(ctx, AV_LOG_ERROR, "The input needs to be a constant frame 
rate; "
+"current rate of %d/%d is invalid\n", inlink0->frame_rate.num, 
inlink0->frame_rate.den);
+return AVERROR(EINVAL);
+}
+} else if (nb_inputs == 2) {
+if (inlink0->w != inlink1->w || inlink0->h != inlink1->h) {
+av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
+"(size %dx%d) do not match the corresponding "
+"second input link %s parameters (size %dx%d)\n",
+ctx->input_pads[0].name, 

Re: [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg_demux: set options on codec parameters rather than decoder

2024-01-16 Thread James Almer

On 1/16/2024 4:49 PM, Anton Khirnov wrote:

Quoting James Almer (2024-01-06 15:22:10)

This does not fix the issue of the guessed channel layout not being
present on the output stream,


Well, it wasn't supposed to fix anything. This patch exists as a
prerequisite for the next one.


I know, hence the "but might be a change in the right direction." part 
followed by the changed output you removed from the quote :p

___
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/avcodec: Add DTS-UHD demuxer and parser, movenc support.

2024-01-16 Thread Roy Funderburk

Updated to latest master changes.--- Begin Message ---
Signed-off-by: Roy Funderburk 
---
 Changelog |   1 +
 configure |   1 +
 doc/general_contents.texi |   1 +
 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/dtshddec.c|   2 +-
 libavformat/dtsuhddec.c   | 216 ++
 libavformat/movenc.c  |  32 ++
 libavformat/version.h |   2 +-
 9 files changed, 255 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/dtsuhddec.c

diff --git a/Changelog b/Changelog
index 4e7c1ce2c1..d1f19d7047 100644
--- a/Changelog
+++ b/Changelog
@@ -19,6 +19,7 @@ version :
 - VVC decoder
 - fsync filter
 - Raw Captions with Time (RCWT) closed caption muxer
+- DTS-UHD demuxer
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index c8ae0a061d..70f511827e 100755
--- a/configure
+++ b/configure
@@ -3517,6 +3517,7 @@ dash_demuxer_deps="libxml2"
 dirac_demuxer_select="dirac_parser"
 dts_demuxer_select="dca_parser"
 dtshd_demuxer_select="dca_parser"
+dtsuhd_demuxer_select="dtsuhd_parser"
 dv_demuxer_select="dvprofile"
 dv_muxer_select="dvprofile"
 dxa_demuxer_select="riffdec"
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 8b48fed060..2c6d008039 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -613,6 +613,7 @@ library:
 @item raw DNxHD @tab X @tab X
 @item raw DTS   @tab X @tab X
 @item raw DTS-HD@tab   @tab X
+@item raw DTS-UHD   @tab   @tab
 @item raw E-AC-3@tab X @tab X
 @item raw EVC   @tab X @tab X
 @item raw FLAC  @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index dcc99eeac4..f98f157ab0 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -188,6 +188,7 @@ OBJS-$(CONFIG_DSICIN_DEMUXER)+= dsicin.o
 OBJS-$(CONFIG_DSS_DEMUXER)   += dss.o
 OBJS-$(CONFIG_DTSHD_DEMUXER) += dtshddec.o
 OBJS-$(CONFIG_DTS_DEMUXER)   += dtsdec.o rawdec.o
+OBJS-$(CONFIG_DTSUHD_DEMUXER)+= dtsuhddec.o
 OBJS-$(CONFIG_DTS_MUXER) += rawenc.o
 OBJS-$(CONFIG_DV_MUXER)  += dvenc.o
 OBJS-$(CONFIG_DVBSUB_DEMUXER)+= dvbsub.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index b04b43cab3..5e0608de7f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -146,6 +146,7 @@ extern const AVInputFormat  ff_dss_demuxer;
 extern const AVInputFormat  ff_dts_demuxer;
 extern const FFOutputFormat ff_dts_muxer;
 extern const AVInputFormat  ff_dtshd_demuxer;
+extern const AVInputFormat  ff_dtsuhd_demuxer;
 extern const AVInputFormat  ff_dv_demuxer;
 extern const FFOutputFormat ff_dv_muxer;
 extern const AVInputFormat  ff_dvbsub_demuxer;
diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index a3dea0668f..6e9e78a335 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -46,7 +46,7 @@ typedef struct DTSHDDemuxContext {
 static int dtshd_probe(const AVProbeData *p)
 {
 if (AV_RB64(p->buf) == DTSHDHDR)
-return AVPROBE_SCORE_MAX;
+return AVPROBE_SCORE_MAX - 4; // DTSUHD (.dtsx) files also have this 
signature.
 return 0;
 }
 
diff --git a/libavformat/dtsuhddec.c b/libavformat/dtsuhddec.c
new file mode 100644
index 00..d840c0a033
--- /dev/null
+++ b/libavformat/dtsuhddec.c
@@ -0,0 +1,216 @@
+/*
+ * DTS-UHD audio demuxer
+ * Copyright (c) 2023 Xperi Corporation / DTS, Inc.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Report DTS-UHD audio stream configuration and extract raw packet data.
+ */
+
+#include "internal.h"
+#include "libavcodec/dtsuhd_common.h"
+#include "libavcodec/put_bits.h"
+#include "libavutil/intreadwrite.h"
+
+#define DTSUHD_BUFFER_SIZE (1024 * 1024)
+
+typedef struct DTSUHDDemuxContext {
+size_t data_end;
+struct DTSUHD *dtsuhd;
+uint8_t *buf;
+} DTSUHDDemuxContext;
+
+static int probe(const AVProbeData *p)
+{
+int offset = av_dtsuhd_strmdata_payload(p->buf, p->buf_size, NULL);
+int score = 0;
+struct DTSUHD *h = av_dtsuhd_create();
+
+if (h && offset >= 0) {
+ 

Re: [FFmpeg-devel] [PATCH 6/8] fftools/ffmpeg_demux: add demuxing thread private data

2024-01-16 Thread Anton Khirnov
Quoting Stefano Sabatini (2024-01-06 12:44:27)
> On date Friday 2024-01-05 17:42:49 +0100, Anton Khirnov wrote:
> > To be used for data that never needs to be visible outside of the
> > demuxer thread, similarly as was previously done for other components.
> > ---
> >  fftools/ffmpeg_demux.c | 67 --
> >  1 file changed, 45 insertions(+), 22 deletions(-)
> > 
> > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
> > index c51140b1c5..eae1f0bde5 100644
> > --- a/fftools/ffmpeg_demux.c
> > +++ b/fftools/ffmpeg_demux.c
> > @@ -115,6 +115,11 @@ typedef struct Demuxer {
> >  int   nb_streams_finished;
> >  } Demuxer;
> >  
> 
> > +typedef struct DemuxThreadContext {
> > +// packet used for reading from the demuxer
> 
> > +AVPacket *pkt_demux;
> 
> nit: you might drop the _demux suffix since this is already clear from
> the context and it's adding no information

I'm adding the suffix because a following commit adds another packet to
the struct, so I prefer to make it clear what each one's role is.

> >  static void *input_thread(void *arg)
> >  {
> >  Demuxer   *d = arg;
> >  InputFile *f = >f;
> > -AVPacket *pkt;
> > +
> > +DemuxThreadContext dt;
> > +
> 
> nit++: weird style, you might drop the empty lines around the
> declaration

I prefer it this way.

-- 
Anton Khirnov
___
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 5/8] fftools/ffmpeg_demux: only allocate the decoder when actually decoding

2024-01-16 Thread Anton Khirnov
Quoting Stefano Sabatini (2024-01-06 12:34:53)
> On date Friday 2024-01-05 17:42:48 +0100, Anton Khirnov wrote:
> > It is not needed otherwise.
> > ---
> >  fftools/ffmpeg_demux.c | 24 
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> > 
> > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
> > index 892094c512..c51140b1c5 100644
> > --- a/fftools/ffmpeg_demux.c
> > +++ b/fftools/ffmpeg_demux.c
> > @@ -782,6 +782,16 @@ static int ist_use(InputStream *ist, int 
> > decoding_needed)
> >  if (decoding_needed && ds->sch_idx_dec < 0) {
> >  int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
> >  
> > +ist->dec_ctx = avcodec_alloc_context3(ist->dec);
> > +if (!ist->dec_ctx)
> > +return AVERROR(ENOMEM);
> > +
> > +ret = avcodec_parameters_to_context(ist->dec_ctx, ist->par);
> > +if (ret < 0) {
> 
> > +av_log(ist, AV_LOG_ERROR, "Error initializing the decoder 
> > context.\n");
> 
> unrelated, here and below: might be useful to notify the failing
> stream identifier, assuming it is not already shown in the log

It is, logging to ist prints something like
[aist#0:0/pcm_s16le @ 0x563a40304b40] 

-- 
Anton Khirnov
___
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 4/8] fftools/ffmpeg_demux: set options on codec parameters rather than decoder

2024-01-16 Thread Anton Khirnov
Quoting James Almer (2024-01-06 15:22:10)
> This does not fix the issue of the guessed channel layout not being 
> present on the output stream,

Well, it wasn't supposed to fix anything. This patch exists as a
prerequisite for the next one.

-- 
Anton Khirnov
___
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] lavc/svq1enc: R-V V ssd_int8_vs_int16

2024-01-16 Thread flow gg
Okay, I updated it in the reply

Rémi Denis-Courmont  于2024年1月17日周三 02:04写道:

> +vsetvli  t0, a2, e8, m2, tu, ma
> +vle8.v   v0, (a0)
> +sub  a2, a2, t0
> +vsetvli  zero, t0, e16, m4, tu, ma
> +vle16.v  v8, (a1)
> +vsetvli  zero, t0, e8, m2, tu, ma
> +vwsub.wv v16, v8, v0
> +vsetvli  zero, t0, e16, m4, tu, ma
>
> It looks to me like the second vsetvli is unnecessary, and consequently
> the
> third as well. As for the later ones, please use `vsetvli zero, zero` if
> you
> intend to change SEW while preserving VL and the LMUL:SEW ratio.
>
> --
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
>
>
>
> ___
> 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".
>
From b3c3187bebfc3ccf180e840dafe4a0486ce5d429 Mon Sep 17 00:00:00 2001
From: sunyuechi 
Date: Fri, 29 Dec 2023 13:27:31 +0800
Subject: [PATCH] lavc/svq1enc: R-V V ssd_int8_vs_int16

C908
ssd_int8_vs_int16_c: 207.7
ssd_int8_vs_int16_rvv_i32: 14.2
---
 libavcodec/riscv/Makefile  |  2 ++
 libavcodec/riscv/svqenc_init.c | 41 
 libavcodec/riscv/svqenc_rvv.S  | 43 ++
 libavcodec/svq1enc.c   |  2 ++
 libavcodec/svq1encdsp.h|  1 +
 5 files changed, 89 insertions(+)
 create mode 100644 libavcodec/riscv/svqenc_init.c
 create mode 100644 libavcodec/riscv/svqenc_rvv.S

diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 4c587ce4e0..1996f6bf37 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -48,6 +48,8 @@ RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o
 OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o
 RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o
 RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o
+OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_init.o
+RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_rvv.o
 OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o
 RVV-OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_rvv.o
 OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_init.o
diff --git a/libavcodec/riscv/svqenc_init.c b/libavcodec/riscv/svqenc_init.c
new file mode 100644
index 00..f4c398960c
--- /dev/null
+++ b/libavcodec/riscv/svqenc_init.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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 "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavcodec/svq1encdsp.h"
+
+int ff_ssd_int8_vs_int16_rvv(const int8_t *pix1, const int16_t *pix2,
+  intptr_t size);
+
+av_cold void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c)
+{
+#if HAVE_RVV
+int flags = av_get_cpu_flags();
+
+if (flags & AV_CPU_FLAG_RVV_I32) {
+if (flags & AV_CPU_FLAG_RVB_ADDR) {
+c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_rvv;
+}
+}
+#endif
+}
diff --git a/libavcodec/riscv/svqenc_rvv.S b/libavcodec/riscv/svqenc_rvv.S
new file mode 100644
index 00..cfc27154dd
--- /dev/null
+++ b/libavcodec/riscv/svqenc_rvv.S
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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/riscv/asm.S"
+
+func 

[FFmpeg-devel] [PATCH] libavformat/libgme: avoid infinite reads of looping files

2024-01-16 Thread Bex Kelly
From: Rebecca Kelly 

This fixes an issue where certain VGM/VGZ files (and possibly other formats
handled by libgme) will report a duration of "N/A" when ffprobed, and will
produce an infinite-length audio file when converted with ffmpeg. The behaviour
here follows the recommendations in the libgme documentation¹: use total
duration if available, otherwise use intro length + two loops, otherwise pretend
the file is 2.5 minutes long.

It uses gme_set_fade() to implement this, which will cause libgme to insert a
clean fade-out and then report end of file at the specified time.

Patch released under the LGPL 2.1 license (or any later version).

———
¹ https://github.com/mcfiredrill/libgme/blob/master/gme.txt

Signed-off-by: Rebecca Kelly 
---
 libavformat/libgme.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavformat/libgme.c b/libavformat/libgme.c
index 4d04537339..b2635fc89f 100644
--- a/libavformat/libgme.c
+++ b/libavformat/libgme.c
@@ -63,7 +63,26 @@ static int load_metadata(AVFormatContext *s, int64_t 
*duration)
 if (gme_track_info(gme->music_emu, , gme->track_index))
 return AVERROR_STREAM_NOT_FOUND;
 
-*duration = info->length;
+// Some formats support looped audio. In these cases, length will be -1, 
and
+// the track length needs to be determined from intro_length and 
loop_length
+// instead. Furthermore, some formats have no length data at all, in which
+// case all of these fields will be -1.
+// When reading these formats, GME will return audio frames forever if you
+// ask for them; it's up to the caller to decide when to stop, either by
+// closing the file after a certain point or by calling gme_set_fade()
+// before starting playback, which will cause GME to simulate a fadeout and
+// end of file at that point.
+// The GME documentation recommends a default behaviour of playing the 
intro
+// followed by two loops, for looped audio, or playing 2.5 minutes and then
+// fading out, for audio of indeterminate length.
+if (info->length > 0) {
+*duration = info->length;
+} else if (info->intro_length > 0 || info->loop_length > 0) {
+*duration = info->intro_length + info->loop_length * 2;
+} else {
+*duration = 15; // 2.5 minutes in milliseconds
+}
+
 add_meta(s, "system",   info->system);
 add_meta(s, "game", info->game);
 add_meta(s, "song", info->song);
@@ -138,8 +157,10 @@ static int read_header_gme(AVFormatContext *s)
 if (!st)
 return AVERROR(ENOMEM);
 avpriv_set_pts_info(st, 64, 1, 1000);
-if (duration > 0)
+if (duration > 0) {
 st->duration = duration;
+gme_set_fade(gme->music_emu, duration); // Avoid infinite playback
+}
 st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
 st->codecpar->codec_id= AV_NE(AV_CODEC_ID_PCM_S16BE, 
AV_CODEC_ID_PCM_S16LE);
 st->codecpar->ch_layout.nb_channels = 2;
-- 
2.42.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 3/3] lavc/svq1enc: R-V V ssd_int8_vs_int16

2024-01-16 Thread Rémi Denis-Courmont
Le sunnuntaina 7. tammikuuta 2024, 10.36.23 EET flow gg a écrit :
> Alright, I learned a bit more, so should we not consider the internal
> implementation?

You asked what the reason was for your counter-intuitive observations, and I 
provided a plausible hypothesis. Nothing more ,nothing less.

Of course we should take performance characteristics of real hardware into 
account, as is done on all other ISAs. The flip side however is that we might 
have to make tradeoffs when design from other vendors come out exhibiting 
different characteristics.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



___
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] lavc/svq1enc: R-V V ssd_int8_vs_int16

2024-01-16 Thread Rémi Denis-Courmont
+vsetvli  t0, a2, e8, m2, tu, ma
+vle8.v   v0, (a0)
+sub  a2, a2, t0
+vsetvli  zero, t0, e16, m4, tu, ma
+vle16.v  v8, (a1)
+vsetvli  zero, t0, e8, m2, tu, ma
+vwsub.wv v16, v8, v0
+vsetvli  zero, t0, e16, m4, tu, ma

It looks to me like the second vsetvli is unnecessary, and consequently the 
third as well. As for the later ones, please use `vsetvli zero, zero` if you 
intend to change SEW while preserving VL and the LMUL:SEW ratio.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



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

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


[FFmpeg-devel] [PATCH 3/3] lavc/h264pred: R-V V pred16x16_dc_8

2024-01-16 Thread flow gg

From 8c5fdbfea42e9ad6ba6e1df5e4ea3c583d59537a Mon Sep 17 00:00:00 2001
From: sunyuechi 
Date: Tue, 16 Jan 2024 23:57:53 +0800
Subject: [PATCH 3/3] lavc/h264pred: R-V V pred16x16_dc_8

C908
pred16x16_dc_8_c: 2.5
pred16x16_dc_8_rvv_i32: 1.7
---
 libavcodec/riscv/h264pred_init.c |  2 ++
 libavcodec/riscv/h264pred_rvv.S  | 28 
 2 files changed, 30 insertions(+)

diff --git a/libavcodec/riscv/h264pred_init.c b/libavcodec/riscv/h264pred_init.c
index 8665bc729e..e8d5b7dd8f 100644
--- a/libavcodec/riscv/h264pred_init.c
+++ b/libavcodec/riscv/h264pred_init.c
@@ -26,6 +26,7 @@
 
 void ff_pred16x16_vertical_8_rvv(uint8_t *src, ptrdiff_t stride);
 void ff_pred16x16_horizontal_8_rvv(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_dc_8_rvv(uint8_t *src, ptrdiff_t stride);
 
 av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
const int bit_depth,
@@ -38,6 +39,7 @@ av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
 if (flags & AV_CPU_FLAG_RVV_I32) {
 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv;
 h->pred16x16[HOR_PRED8x8] = ff_pred16x16_horizontal_8_rvv;
+h->pred16x16[DC_PRED8x8] = ff_pred16x16_dc_8_rvv;
 }
 #endif
 }
diff --git a/libavcodec/riscv/h264pred_rvv.S b/libavcodec/riscv/h264pred_rvv.S
index ba1e9045e1..1492991ef4 100644
--- a/libavcodec/riscv/h264pred_rvv.S
+++ b/libavcodec/riscv/h264pred_rvv.S
@@ -48,3 +48,31 @@ func ff_pred16x16_horizontal_8_rvv, zve32x
 
 ret
 endfunc
+
+func ff_pred16x16_dc_8_rvv, zve32x
+vsetivli zero, 1, e16, m1, ta, ma
+vmv.v.x  v16, zero
+
+vsetivli zero, 16, e8, m1, ta, ma
+sub  t2, a0, a1
+vle8.v   v8, (t2)
+vwredsumu.vs v16, v8, v16
+addi t2, a0, -1
+vlse8.v  v8, (t2), a1
+vwredsumu.vs v16, v8, v16
+vsetivli zero, 1, e16, m1, ta, ma
+vmv.x.s  t1, v16
+addi t1, t1, 16
+srai t1, t1, 5
+vsetivli zero, 16, e8, m1, ta, ma
+vmv.v.x  v0, t1
+vsetivli zero, 4, e8, mf4, ta, ma
+li   t0, 16
+1:
+vse32.v  v0, (a0)
+addi t0, t0, -1
+add  a0, a0, a1
+bnez t0, 1b
+
+ret
+endfunc
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH 2/3] lavc/h264pred: R-V V pred16x16_horizontal_8

2024-01-16 Thread flow gg

From 806f84ea5557c4652e48451decc4c679c9485472 Mon Sep 17 00:00:00 2001
From: sunyuechi 
Date: Tue, 16 Jan 2024 23:56:33 +0800
Subject: [PATCH 2/3] lavc/h264pred: R-V V pred16x16_horizontal_8

C908
pred16x16_horizontal_8_c: 3.0
pred16x16_horizontal_8_rvv_i32: 2.5
---
 libavcodec/riscv/h264pred_init.c |  2 ++
 libavcodec/riscv/h264pred_rvv.S  | 15 +++
 2 files changed, 17 insertions(+)

diff --git a/libavcodec/riscv/h264pred_init.c b/libavcodec/riscv/h264pred_init.c
index 179bd8c8a5..8665bc729e 100644
--- a/libavcodec/riscv/h264pred_init.c
+++ b/libavcodec/riscv/h264pred_init.c
@@ -25,6 +25,7 @@
 #include "libavcodec/h264pred.h"
 
 void ff_pred16x16_vertical_8_rvv(uint8_t *src, ptrdiff_t stride);
+void ff_pred16x16_horizontal_8_rvv(uint8_t *src, ptrdiff_t stride);
 
 av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
const int bit_depth,
@@ -36,6 +37,7 @@ av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
 
 if (flags & AV_CPU_FLAG_RVV_I32) {
 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv;
+h->pred16x16[HOR_PRED8x8] = ff_pred16x16_horizontal_8_rvv;
 }
 #endif
 }
diff --git a/libavcodec/riscv/h264pred_rvv.S b/libavcodec/riscv/h264pred_rvv.S
index 0e48662922..ba1e9045e1 100644
--- a/libavcodec/riscv/h264pred_rvv.S
+++ b/libavcodec/riscv/h264pred_rvv.S
@@ -33,3 +33,18 @@ func ff_pred16x16_vertical_8_rvv, zve32x
 
 ret
 endfunc
+
+func ff_pred16x16_horizontal_8_rvv, zve32x
+lit0, 16
+1:
+lbu   t1, -1(a0)
+vsetivli  zero, 16, e8, m1, ta, ma
+vmv.v.x   v0, t1
+vsetivli  zero, 4, e8, mf4, ta, ma
+addi  t0, t0, -1
+vse32.v   v0, (a0)
+add   a0, a0, a1
+bnez  t0, 1b
+
+ret
+endfunc
-- 
2.43.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 1/3] lavc/h264pred: R-V V pred16x16_vertical_8

2024-01-16 Thread flow gg

From eaac50d41b3398ef39d1026a7d84480860a1c41e Mon Sep 17 00:00:00 2001
From: sunyuechi 
Date: Tue, 16 Jan 2024 23:55:33 +0800
Subject: [PATCH 1/3] lavc/h264pred: R-V V pred16x16_vertical_8

C908
pred16x16_vertical_8_c: 1.5
pred16x16_vertical_8_rvv_i32: 1.0
---
 libavcodec/h264pred.c|  2 ++
 libavcodec/h264pred.h|  2 ++
 libavcodec/riscv/Makefile|  2 ++
 libavcodec/riscv/h264pred_init.c | 42 
 libavcodec/riscv/h264pred_rvv.S  | 35 ++
 5 files changed, 83 insertions(+)
 create mode 100644 libavcodec/riscv/h264pred_init.c
 create mode 100644 libavcodec/riscv/h264pred_rvv.S

diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c
index 25f9995a0b..bd45da2fde 100644
--- a/libavcodec/h264pred.c
+++ b/libavcodec/h264pred.c
@@ -592,6 +592,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
 ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc);
 #elif ARCH_ARM
 ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
+#elif ARCH_RISCV
+ff_h264_pred_init_riscv(h, codec_id, bit_depth, chroma_format_idc);
 #elif ARCH_X86
 ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
 #elif ARCH_MIPS
diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h
index cb008548fc..44dc1637c5 100644
--- a/libavcodec/h264pred.h
+++ b/libavcodec/h264pred.h
@@ -120,6 +120,8 @@ void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id,
const int chroma_format_idc);
 void ff_h264_pred_init_arm(H264PredContext *h, int codec_id,
const int bit_depth, const int chroma_format_idc);
+void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
+   const int bit_depth, const int chroma_format_idc);
 void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
const int bit_depth, const int chroma_format_idc);
 void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index aa758eba1c..3232b16b97 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -22,6 +22,8 @@ RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o
 OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o
 RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o
 OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_init.o
+RVV-OBJS-$(CONFIG_H264PRED) += riscv/h264pred_rvv.o
+OBJS-$(CONFIG_H264PRED) += riscv/h264pred_init.o
 RVV-OBJS-$(CONFIG_JPEG2000_DECODER) += riscv/jpeg2000dsp_rvv.o
 OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o
 RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o
diff --git a/libavcodec/riscv/h264pred_init.c b/libavcodec/riscv/h264pred_init.c
new file mode 100644
index 00..179bd8c8a5
--- /dev/null
+++ b/libavcodec/riscv/h264pred_init.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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 "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavcodec/h264pred.h"
+
+void ff_pred16x16_vertical_8_rvv(uint8_t *src, ptrdiff_t stride);
+
+av_cold void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id,
+   const int bit_depth,
+   const int chroma_format_idc)
+{
+if (bit_depth == 8) {
+#if HAVE_RVV
+int flags = av_get_cpu_flags();
+
+if (flags & AV_CPU_FLAG_RVV_I32) {
+h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv;
+}
+#endif
+}
+}
diff --git a/libavcodec/riscv/h264pred_rvv.S b/libavcodec/riscv/h264pred_rvv.S
new file mode 100644
index 00..0e48662922
--- /dev/null
+++ b/libavcodec/riscv/h264pred_rvv.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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 

Re: [FFmpeg-devel] Hardware purchase request: AVX512-capable laptop

2024-01-16 Thread Lynne
Jan 16, 2024, 11:06 by kier...@obe.tv:

>>
>> A ticket doesn't have durability.
>>
>
> A Ryzen 5 vs Ryzen 7 in the same laptop chassis doesn't change its
> durability, it only doubles the laptop's price.
>

It doubles the number of registers and expands the number
of instructions available. The price isn't doubled.
___
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/4] avcodec/mdec: DC reading for STRv1 is like STRv2

2024-01-16 Thread aybe aybe
These email issues made me forgot to tell an important thing...

That new FPS patch is meant to be applied right after this:

avformat/psxstr: fix unknown sector type 00/80
a96d556baaf7cb71babad96238eadb532d02f3a6

i.e. not over the previous FPS patch attempt:

avformat/psxstr: basic FPS detection instead of fixed value
464243adac7abfa9b926a1faf6f59515661efa7f

I think we're good now :)

-- Original Message --
>From "aybe aybe" 
To "FFmpeg development discussions and patches"

Date 1/16/2024 3:39:09 PM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for
STRv1 is like STRv2

>Lol, I told you I was struggling with emClient, it decided to send .eml as 
>.url...
>
>Here are the patches, hopefully!
>
>[FFmpeg-devel] [PATCH 1/2] avformat/psxstr: infer video FPS using sector LBA
>https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/319701.html
>
>[FFmpeg-devel] [PATCH 2/2] avformat/psxstr: update fate checksums
>https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/319702.html
>
>-- Original Message --
>From "aybe" mailto:aybe@hotmail.com>>
>To "FFmpeg development discussions and patches" 
>mailto:ffmpeg-devel@ffmpeg.org>>
>Date 1/16/2024 3:32:36 PM
>Subject Re[2]: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 
>is like STRv2
>
>Modern email clients like to do stuff they're told not to...
>
>The link I meant previously: https://github.com/aybe/FFmpeg-PSX-STR-tests
>
>
>-- Original Message --
>From "aybe aybe" 
>mailto:aybe.one-at-hotmail@ffmpeg.org>>
>To "FFmpeg development discussions and patches" 
>mailto:ffmpeg-devel@ffmpeg.org>>
>Date 1/16/2024 3:27:16 PM
>Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
>like STRv2
>
>The new patch appears to work, stuff is synchronized, except:
>- 30 FPS video still seen as 150FPS by VLC
>- 15 FPS video emits tons of "[vost#0:0/rawvideo @ 0269b580] Clipping 
>frame in rate conversion by 0.199989"
>
>As for the corrupt samples, been able to find the original sources:
>
>- the first is good old Descent
>- was cut at exactly 2MB
>- works in FFmpeg
>- the second is Ridge Racer Type 4
>- bad/incomplete extract with a tool that added "RIFFCDXA" header for 
>whatever reason
>- does NOT work in FFmpeg, comprised of 38 audio streams + 2 video streams 
>(only decodes some audio then aborts)
>- but if I extract the relevant section from it, then works in FFmpeg
>
>New videos, samples, logs:
>https://github.com/aybe/FFmpeg-PSX-STR-tests
>
>-- Original Message --
>From "Michael Niedermayer" 
>mailto:mich...@niedermayer.cc>>
>To "FFmpeg development discussions and patches" 
>mailto:ffmpeg-devel@ffmpeg.org>>
>Date 1/16/2024 12:42:49 AM
>Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
>like STRv2
>
>On Mon, Jan 15, 2024 at 04:14:46PM +, aybe aybe wrote:
>Hi!
>
>I just tried what you've suggested, using 150 and setting AVPacket->pts using 
>sector MSF as LBA.
>
>The results are somewhat mixed:
>
>- NTSC video: A/V synchronized but is now seen as 120 FPS by VLC
>- PAL video: A/V not synchronized anymore but still seen as 25 FPS by VLC
>
>can you send the patch for this plus links to one sample for both cases ?
>
>id like to take a look
>
>thx
>
>[...]
>--
>Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
>The greatest way to live with honor in this world is to be what we pretend
>to be. -- Socrates
>___
>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/4] avcodec/mdec: DC reading for STRv1 is like STRv2

2024-01-16 Thread aybe aybe
Lol, I told you I was struggling with emClient, it decided to send .eml as 
.url...

Here are the patches, hopefully!

[FFmpeg-devel] [PATCH 1/2] avformat/psxstr: infer video FPS using sector LBA
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/319701.html

[FFmpeg-devel] [PATCH 2/2] avformat/psxstr: update fate checksums
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/319702.html

-- Original Message --
>From "aybe" mailto:aybe@hotmail.com>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 3:32:36 PM
Subject Re[2]: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

Modern email clients like to do stuff they're told not to...

The link I meant previously: https://github.com/aybe/FFmpeg-PSX-STR-tests


-- Original Message --
>From "aybe aybe" 
>mailto:aybe.one-at-hotmail@ffmpeg.org>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 3:27:16 PM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

The new patch appears to work, stuff is synchronized, except:
- 30 FPS video still seen as 150FPS by VLC
- 15 FPS video emits tons of "[vost#0:0/rawvideo @ 0269b580] Clipping 
frame in rate conversion by 0.199989"

As for the corrupt samples, been able to find the original sources:

- the first is good old Descent
- was cut at exactly 2MB
- works in FFmpeg
- the second is Ridge Racer Type 4
- bad/incomplete extract with a tool that added "RIFFCDXA" header for 
whatever reason
- does NOT work in FFmpeg, comprised of 38 audio streams + 2 video streams 
(only decodes some audio then aborts)
- but if I extract the relevant section from it, then works in FFmpeg

New videos, samples, logs:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faybe%2FFFmpeg-PSX-STR-tests=05%7C02%7C%7Cc7debed92bce42a5bcd908dc169f43bd%7C84df9e7fe9f640afb435%7C1%7C0%7C638410120640174537%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=%2Faq1Hcn5X%2FVCvtVi5GO6Jes7mrPUCeZyrIZvDiAj6lw%3D=0

-- Original Message --
>From "Michael Niedermayer" 
>mailto:mich...@niedermayer.cc>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 12:42:49 AM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

On Mon, Jan 15, 2024 at 04:14:46PM +, aybe aybe wrote:
Hi!

I just tried what you've suggested, using 150 and setting AVPacket->pts using 
sector MSF as LBA.

The results are somewhat mixed:

- NTSC video: A/V synchronized but is now seen as 120 FPS by VLC
- PAL video: A/V not synchronized anymore but still seen as 25 FPS by VLC

can you send the patch for this plus links to one sample for both cases ?

id like to take a look

thx

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
___
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/2] avcodec/vvcdec: deblock, fix uninitialized values

2024-01-16 Thread James Almer

On 1/8/2024 10:00 PM, Nuo Mi wrote:



On Sun, Jan 7, 2024 at 12:43 PM Nuo Mi > wrote:


see

https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind=20240105201935 


If tc is zero, the max_len_q, max_len_p are uninitialized.

Reported-by: James Almer mailto:jamr...@gmail.com>>

Hi James,
Could you help try and review this?


The patch doesn't seem to apply.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] avformat/psxstr: update fate checksums

2024-01-16 Thread aybe aybe
Signed-off-by: aybe 
---
  tests/ref/fate/psx-str-demux | 178 +--
  1 file changed, 89 insertions(+), 89 deletions(-)

diff --git a/tests/ref/fate/psx-str-demux b/tests/ref/fate/psx-str-demux
index 18a21b0bb6..0a31c44323 100644
--- a/tests/ref/fate/psx-str-demux
+++ b/tests/ref/fate/psx-str-demux
@@ -1,4 +1,4 @@
-#tb 0: 1/15
+#tb 0: 1/150
  #media_type 0: video
  #codec_id 0: mdec
  #dimensions 0: 320x240
@@ -11,200 +11,200 @@
  0,  0,  0,1, 8832, 0x01ad3eeb
  1,  0,  0,1, 2304, 0xf0ad1000
  1,  1,  1,1, 2304, 0x69269ce6
-0,  1,  1,1, 8968, 0xe0033799
+0, 10, 10,1, 8968, 0xe0033799
  1,  2,  2,1, 2304, 0x124a995d
-0,  2,  2,1, 9036, 0xd6189ab7
+0, 20, 20,1, 9036, 0xd6189ab7
  1,  3,  3,1, 2304, 0x3fc0ca07
-0,  3,  3,1, 9192, 0xb44b9ffa
+0, 30, 30,1, 9192, 0xb44b9ffa
  1,  4,  4,1, 2304, 0x40a1b447
-0,  4,  4,1, 9404, 0xe94dfd40
+0, 40, 40,1, 9404, 0xe94dfd40
  1,  5,  5,1, 2304, 0x150dae9f
  1,  6,  6,1, 2304, 0xad16bc63
-0,  5,  5,1, 9492, 0xf73f2541
+0, 50, 50,1, 9492, 0xf73f2541
  1,  7,  7,1, 2304, 0xe989b175
-0,  6,  6,1, 9652, 0x243d53f8
+0, 60, 60,1, 9652, 0x243d53f8
  1,  8,  8,1, 2304, 0x3c77cd39
-0,  7,  7,1, 9872, 0x83f3ea7a
+0, 70, 70,1, 9872, 0x83f3ea7a
  1,  9,  9,1, 2304, 0x93f0c2ba
-0,  8,  8,1,10052, 0x7604247a
+0, 80, 80,1,10052, 0x7604247a
  1, 10, 10,1, 2304, 0x6e2ad2d0
  1, 11, 11,1, 2304, 0xf8eab90a
-0,  9,  9,1,10100, 0x077107fd
+0, 90, 90,1,10100, 0x077107fd
  1, 12, 12,1, 2304, 0xc039bf0d
-0, 10, 10,1,10264, 0xae675eb6
+0,100,100,1,10264, 0xae675eb6
  1, 13, 13,1, 2304, 0x0900c7e8
-0, 11, 11,1,10464, 0x428f83ae
+0,110,110,1,10464, 0x428f83ae
  1, 14, 14,1, 2304, 0x9722d580
-0, 12, 12,1,10580, 0x1bdcd71b
+0,120,120,1,10580, 0x1bdcd71b
  1, 15, 15,1, 2304, 0x02eec8de
  1, 16, 16,1, 2304, 0x4807a2b3
-0, 13, 13,1,10800, 0xde75213a
+0,130,130,1,10800, 0xde75213a
  1, 17, 17,1, 2304, 0x4643be06
-0, 14, 14,1,11236, 0x9387cc8e
+0,140,140,1,11236, 0x9387cc8e
  1, 18, 18,1, 2304, 0x5bd9d249
-0, 15, 15,1,11420, 0x3a7d321b
+0,150,150,1,11420, 0x3a7d321b
  1, 19, 19,1, 2304, 0x4e33c2bc
-0, 16, 16,1,11632, 0x7edc9cdf
+0,160,160,1,11632, 0x7edc9cdf
  1, 20, 20,1, 2304, 0x085ca51d
  1, 21, 21,1, 2304, 0xa205b202
-0, 17, 17,1,11936, 0xf0521017
+0,170,170,1,11936, 0xf0521017
  1, 22, 22,1, 2304, 0x71b9bcca
-0, 18, 18,1,11804, 0x53b22066
+0,180,180,1,11804, 0x53b22066
  1, 23, 23,1, 2304, 0xcb769e5f
-0, 19, 19,1,11852, 0x9425fb21
+0,190,190,1,11852, 0x9425fb21
  1, 24, 24,1, 2304, 0x9322d85a
-0, 20, 20,1,12108, 0xc386941d
+0,200,200,1,12108, 0xc386941d
  1, 25, 25,1, 2304, 0x7f13bf6e
  1, 26, 26,1, 2304, 0xd302a5cd
-0, 21, 21,1,12796, 0x8b7e5dab
+0,210,210,1,12796, 0x8b7e5dab
  1, 27, 27,1, 2304, 0x7a7a9e30
-0, 22, 22,1,13316, 0x81235102
+0,220,220,1,13316, 0x81235102
  1, 28, 28,1, 2304, 0x6ffccfdd
-0, 23, 23,1,13724, 0xe5fc2bca
+0,230,230,1,13724, 0xe5fc2bca
  1, 29,  

[FFmpeg-devel] [PATCH 1/2] avformat/psxstr: infer video FPS using sector LBA

2024-01-16 Thread aybe aybe
Signed-off-by: aybe 
---
  libavformat/psxstr.c | 44 ++--
  1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c
index 306a690f52..c718fb6daf 100644
--- a/libavformat/psxstr.c
+++ b/libavformat/psxstr.c
@@ -65,6 +65,9 @@ typedef struct StrDemuxContext {

  /* a STR file can contain up to 32 channels of data */
  StrChannel channels[32];
+
+/* the index for the first frame (sector, LBA units)*/
+int64_t first_frame_index;
  } StrDemuxContext;

  static const uint8_t sync_header[12] = 
{0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00};
@@ -150,18 +153,51 @@ static int str_read_header(AVFormatContext *s)
  str->channels[i].audio_stream_index= -1;
  }

+str->first_frame_index = 0;
+
  s->ctx_flags |= AVFMTCTX_NOHEADER;

  return 0;
  }

+static uint8_t bcd_to_dec(uint8_t bcd)
+{
+uint8_t dec = (bcd & 0xF) + (((bcd >> 4) & 0xF) * 10);
+
+return dec;
+}
+
+static int32_t msf_to_lba(uint8_t m, uint8_t s, uint8_t f)
+{
+int32_t lba = 0; /* int because it can be negative! */
+
+m = bcd_to_dec(m);
+s = bcd_to_dec(s);
+f = bcd_to_dec(f);
+
+lba = (((m * 60 + s) * 75) + f) - 150;
+
+return lba;
+}
+
+static int32_t str_get_frame_lba(uint8_t sector[2352])
+{
+uint8_t m = sector[0xC];
+uint8_t s = sector[0xD];
+uint8_t f = sector[0xE];
+
+int32_t lba = msf_to_lba(m, s, f);
+
+return lba;
+}
+
  static int str_read_packet(AVFormatContext *s,
 AVPacket *ret_pkt)
  {
  AVIOContext *pb = s->pb;
  StrDemuxContext *str = s->priv_data;
  unsigned char sector[RAW_CD_SECTOR_SIZE];
-int channel, ret;
+int channel, ret, frame_lba;
  AVPacket *pkt;
  AVStream *st;

@@ -200,10 +236,12 @@ static int str_read_packet(AVFormatContext *s,
  st = avformat_new_stream(s, NULL);
  if (!st)
  return AVERROR(ENOMEM);
-avpriv_set_pts_info(st, 64, 1, 15);
+avpriv_set_pts_info(st, 64, 1, 150); /* 150 sectors at 2x 
speed */

  str->channels[channel].video_stream_index = st->index;

+str->first_frame_index = str_get_frame_lba(sector);
+
  st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
  st->codecpar->codec_id   = AV_CODEC_ID_MDEC;
  st->codecpar->codec_tag  = 0;  /* no fourcc */
@@ -223,6 +261,8 @@ static int str_read_packet(AVFormatContext *s,
  return ret;
  memset(pkt->data, 0, sector_count*VIDEO_DATA_CHUNK_SIZE);

+frame_lba = str_get_frame_lba(sector);
+pkt->pts = frame_lba - str->first_frame_index;
  pkt->pos= avio_tell(pb) - RAW_CD_SECTOR_SIZE;
  pkt->stream_index =
  str->channels[channel].video_stream_index;
--
2.41.0.windows.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is like STRv2

2024-01-16 Thread aybe aybe
Modern email clients like to do stuff they're told not to...

The link I meant previously: https://github.com/aybe/FFmpeg-PSX-STR-tests


-- Original Message --
>From "aybe aybe" 
>mailto:aybe.one-at-hotmail@ffmpeg.org>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 3:27:16 PM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

The new patch appears to work, stuff is synchronized, except:
- 30 FPS video still seen as 150FPS by VLC
- 15 FPS video emits tons of "[vost#0:0/rawvideo @ 0269b580] Clipping 
frame in rate conversion by 0.199989"

As for the corrupt samples, been able to find the original sources:

- the first is good old Descent
- was cut at exactly 2MB
- works in FFmpeg
- the second is Ridge Racer Type 4
- bad/incomplete extract with a tool that added "RIFFCDXA" header for 
whatever reason
- does NOT work in FFmpeg, comprised of 38 audio streams + 2 video streams 
(only decodes some audio then aborts)
- but if I extract the relevant section from it, then works in FFmpeg

New videos, samples, logs:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faybe%2FFFmpeg-PSX-STR-tests=05%7C02%7C%7Cc7debed92bce42a5bcd908dc169f43bd%7C84df9e7fe9f640afb435%7C1%7C0%7C638410120640174537%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=%2Faq1Hcn5X%2FVCvtVi5GO6Jes7mrPUCeZyrIZvDiAj6lw%3D=0

-- Original Message --
>From "Michael Niedermayer" 
>mailto:mich...@niedermayer.cc>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 12:42:49 AM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

On Mon, Jan 15, 2024 at 04:14:46PM +, aybe aybe wrote:
Hi!

I just tried what you've suggested, using 150 and setting AVPacket->pts using 
sector MSF as LBA.

The results are somewhat mixed:

- NTSC video: A/V synchronized but is now seen as 120 FPS by VLC
- PAL video: A/V not synchronized anymore but still seen as 25 FPS by VLC

can you send the patch for this plus links to one sample for both cases ?

id like to take a look

thx

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
___
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/4] avcodec/mdec: DC reading for STRv1 is like STRv2

2024-01-16 Thread aybe aybe
The new patch appears to work, stuff is synchronized, except:
- 30 FPS video still seen as 150FPS by VLC
- 15 FPS video emits tons of "[vost#0:0/rawvideo @ 0269b580] Clipping 
frame in rate conversion by 0.199989"

As for the corrupt samples, been able to find the original sources:

- the first is good old Descent
- was cut at exactly 2MB
- works in FFmpeg
- the second is Ridge Racer Type 4
- bad/incomplete extract with a tool that added "RIFFCDXA" header for 
whatever reason
- does NOT work in FFmpeg, comprised of 38 audio streams + 2 video streams 
(only decodes some audio then aborts)
- but if I extract the relevant section from it, then works in FFmpeg

New videos, samples, logs:
https://github.com/aybe/FFmpeg-PSX-STR-tests

-- Original Message --
From "Michael Niedermayer" 
mailto:mich...@niedermayer.cc>>
To "FFmpeg development discussions and patches" 
mailto:ffmpeg-devel@ffmpeg.org>>
Date 1/16/2024 12:42:49 AM
Subject Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mdec: DC reading for STRv1 is 
like STRv2

On Mon, Jan 15, 2024 at 04:14:46PM +, aybe aybe wrote:
Hi!

I just tried what you've suggested, using 150 and setting AVPacket->pts using 
sector MSF as LBA.

The results are somewhat mixed:

- NTSC video: A/V synchronized but is now seen as 120 FPS by VLC
- PAL video: A/V not synchronized anymore but still seen as 25 FPS by VLC

can you send the patch for this plus links to one sample for both cases ?

id like to take a look

thx

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


0001-avformat-psxstr-infer-video-FPS-using-sector-LBA.eml.url
Description: 0001-avformat-psxstr-infer-video-FPS-using-sector-LBA.eml.url


0002-avformat-psxstr-update-fate-checksums.eml.url
Description: 0002-avformat-psxstr-update-fate-checksums.eml.url
___
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] fate: Add tests for aoverlay filter

2024-01-16 Thread Harshit Karwal
---
 tests/fate/filter-audio.mak|  22 ++
 tests/ref/fate/filter-aoverlay-crossfade-d | 224 ++
 tests/ref/fate/filter-aoverlay-crossfade-t | 202 
 tests/ref/fate/filter-aoverlay-default | 259 +
 tests/ref/fate/filter-aoverlay-timeline| 254 
 5 files changed, 961 insertions(+)
 create mode 100644 tests/ref/fate/filter-aoverlay-crossfade-d
 create mode 100644 tests/ref/fate/filter-aoverlay-crossfade-t
 create mode 100644 tests/ref/fate/filter-aoverlay-default
 create mode 100644 tests/ref/fate/filter-aoverlay-timeline

diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index adf61cf074..718558636b 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -73,6 +73,28 @@ fate-filter-amerge: tests/data/asynth-44100-1.wav
 fate-filter-amerge: SRC = $(TARGET_PATH)/tests/data/asynth-44100-1.wav
 fate-filter-amerge: CMD = framecrc -i $(SRC) -i $(SRC) -filter_complex 
"[0:a][1:a]amerge=inputs=2[aout]" -map "[aout]"
 
+FATE_AFILTER_AOVERLAY += fate-filter-aoverlay-timeline
+fate-filter-aoverlay-timeline: tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-timeline: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-timeline: CMD = framecrc -i $(SRC) -i $(SRC) 
-auto_conversion_filters -filter_complex 
"aoverlay=enable='\''between\(t,2,3\)'\''"
+
+FATE_AFILTER_AOVERLAY += fate-filter-aoverlay-default
+fate-filter-aoverlay-default: tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-default: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-default: CMD = framecrc -i $(SRC) -i $(SRC) 
-auto_conversion_filters -filter_complex 
"[0]aselect='\''not\(between\(t,2,3\)\)'\''[temp];[temp][1]aoverlay[out]" -map 
"[out]"
+
+FATE_AFILTER_AOVERLAY += fate-filter-aoverlay-crossfade-t
+fate-filter-aoverlay-crossfade-t: tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-crossfade-t: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-crossfade-t: CMD = framecrc -i $(SRC) -i $(SRC) 
-auto_conversion_filters -filter_complex 
"aoverlay=cf_duration=0.5:enable='\''between\(t,2,3\)'\''"
+
+FATE_AFILTER_AOVERLAY += fate-filter-aoverlay-crossfade-d
+fate-filter-aoverlay-crossfade-d: tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-crossfade-d: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav
+fate-filter-aoverlay-crossfade-d: CMD = framecrc -i $(SRC) -i $(SRC) 
-auto_conversion_filters -filter_complex 
"[0]aselect='\''not\(between\(t,2,3\)\)'\''[temp];[temp][1]aoverlay=cf_duration=0.5[out]"
 -map "[out]"
+
+FATE_AFILTER-$(call FILTERDEMDECENCMUX, AOVERLAY, WAV, PCM_S16LE, PCM_S16LE, 
WAV) += $(FATE_AFILTER_AOVERLAY)
+
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, APAD, WAV, PCM_S16LE, PCM_S16LE, WAV) 
+= fate-filter-apad
 fate-filter-apad: tests/data/asynth-44100-2.wav
 fate-filter-apad: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
diff --git a/tests/ref/fate/filter-aoverlay-crossfade-d 
b/tests/ref/fate/filter-aoverlay-crossfade-d
new file mode 100644
index 00..b3975bde2f
--- /dev/null
+++ b/tests/ref/fate/filter-aoverlay-crossfade-d
@@ -0,0 +1,224 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+0,  0,  0, 1024, 2048, 0x490ff760
+0,   1024,   1024, 1024, 2048, 0xc8a405cb
+0,   2048,   2048, 1024, 2048, 0xeed6fd45
+0,   3072,   3072, 1024, 2048, 0x8cabf8a0
+0,   4096,   4096, 1024, 2048, 0x4707f6c1
+0,   5120,   5120, 1024, 2048, 0xc1a50038
+0,   6144,   6144, 1024, 2048, 0x3e75fa60
+0,   7168,   7168, 1024, 2048, 0x988ffec2
+0,   8192,   8192, 1024, 2048, 0x0537f926
+0,   9216,   9216, 1024, 2048, 0x6919fd71
+0,  10240,  10240, 1024, 2048, 0xeef4f7d0
+0,  11264,  11264, 1024, 2048, 0xcf7a01c8
+0,  12288,  12288, 1024, 2048, 0x2cf70048
+0,  13312,  13312, 1024, 2048, 0x8a51fba6
+0,  14336,  14336, 1024, 2048, 0x311af181
+0,  15360,  15360, 1024, 2048, 0x8248009c
+0,  16384,  16384, 1024, 2048, 0x9aa4010b
+0,  17408,  17408, 1024, 2048, 0x1a2df2a0
+0,  18432,  18432, 1024, 2048, 0xf6e2fb18
+0,  19456,  19456, 1024, 2048, 0x548effbc
+0,  20480,  20480, 1024, 2048, 0x965a01a9
+0,  21504,  21504, 1024, 2048, 0x2554f834
+0,  22528,  22528, 1024, 2048, 0xa390fdfc
+0,  23552,  23552, 1024, 2048, 0x51d8f99b
+0,  24576,  24576, 1024, 2048, 0xed47fd39
+0,  25600,  25600, 1024, 2048, 0x79b8faeb
+0,  26624,  26624, 1024, 2048, 0xf6da009c
+0,  27648,  27648, 1024, 2048, 0x0ffbf6a2
+0,  28672,  28672, 1024,  

[FFmpeg-devel] [PATCH v4 1/2] avfilter: add audio overlay filter

2024-01-16 Thread Harshit Karwal
Co-authored-by: Paul B Mahol 
Signed-off-by: Harshit Karwal 
---
 doc/filters.texi  |  40 +++
 libavfilter/Makefile  |   1 +
 libavfilter/af_aoverlay.c | 538 ++
 libavfilter/allfilters.c  |   1 +
 4 files changed, 580 insertions(+)
 create mode 100644 libavfilter/af_aoverlay.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 20c91bab3a..79eb600ae3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2779,6 +2779,46 @@ This filter supports the same commands as options, 
excluding option @code{order}
 
 Pass the audio source unchanged to the output.
 
+@section aoverlay
+
+Replace a specified section of an audio stream with another input audio stream.
+
+In case no enable option for timeline editing is specified, the second audio 
stream will
+be output at sections of the first stream which have a gap in PTS 
(Presentation TimeStamp) values
+such that the output stream's PTS values are monotonous.
+
+This filter also supports linear cross fading when transitioning from one
+input stream to another.
+
+The filter accepts the following option:
+
+@table @option
+@item cf_duration
+Set duration (in seconds) for cross fade between the inputs. Default value is 
@code{100} milliseconds.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Replace the first stream with the second stream from @code{t=10} seconds to 
@code{t=20} seconds:
+@example
+ffmpeg -i first.wav -i second.wav -filter_complex 
"aoverlay=enable='between(t,10,20)'" output.wav
+@end example
+
+@item
+Do the same as above, but with crossfading for @code{2} seconds between the 
streams:
+@example
+ffmpeg -i first.wav -i second.wav -filter_complex 
"aoverlay=cf_duration=2:enable='between(t,10,20)'" output.wav
+@end example
+
+@item
+Introduce a PTS gap from @code{t=4} seconds to @code{t=8} seconds in the first 
stream and output the second stream during this gap:
+@example
+ffmpeg -i first.wav -i second.wav -filter_complex 
"[0]aselect='not(between(t,4,8))'[temp];[temp][1]aoverlay[out]" -map "[out]" 
output.wav
+@end example
+@end itemize
+
 @section apad
 
 Pad the end of an audio stream with silence.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index bba0219876..0f2b403441 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -81,6 +81,7 @@ OBJS-$(CONFIG_ANLMDN_FILTER) += af_anlmdn.o
 OBJS-$(CONFIG_ANLMF_FILTER)  += af_anlms.o
 OBJS-$(CONFIG_ANLMS_FILTER)  += af_anlms.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
+OBJS-$(CONFIG_AOVERLAY_FILTER)   += af_aoverlay.o
 OBJS-$(CONFIG_APAD_FILTER)   += af_apad.o
 OBJS-$(CONFIG_APERMS_FILTER) += f_perms.o
 OBJS-$(CONFIG_APHASER_FILTER)+= af_aphaser.o 
generate_wave_table.o
diff --git a/libavfilter/af_aoverlay.c b/libavfilter/af_aoverlay.c
new file mode 100644
index 00..f7ac00dda1
--- /dev/null
+++ b/libavfilter/af_aoverlay.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright (c) 2023 Harshit Karwal
+ *
+ * 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/opt.h"
+#include "libavutil/audio_fifo.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "filters.h"
+#include "internal.h"
+
+typedef struct AOverlayContext {
+const AVClass *class;
+AVFrame *main_input;
+AVFrame *overlay_input;
+int64_t pts;
+int main_eof;
+int overlay_eof;
+
+int default_mode;
+int previous_samples;
+int64_t pts_gap;
+int64_t previous_pts;
+int64_t pts_gap_start;
+int64_t pts_gap_end;
+
+int is_disabled;
+int nb_channels;
+int crossfade_ready;
+AVAudioFifo *main_sample_buffers;
+AVAudioFifo *overlay_sample_buffers;
+int64_t cf_duration;
+int64_t cf_samples;
+void (*crossfade_samples)(uint8_t **dst, uint8_t * const *cf0,
+  uint8_t * const *cf1,
+  int nb_samples, int channels);
+
+int64_t transition_pts;
+int64_t transition_pts2;
+
+uint8_t **cf0;
+uint8_t **cf1;
+} AOverlayContext;
+
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_FLTP,
+AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P,
+AV_SAMPLE_FMT_NONE
+};

[FFmpeg-devel] [PATCH v4 0/2] GSoC 2023: Add Audio Overlay Filter

2024-01-16 Thread Harshit Karwal
Includes some fixes authored by Paul over the v3 patch I sent earlier, and FATE 
tests for the filter. 

Harshit Karwal (2):
  avfilter: add audio overlay filter
  fate: Add tests for aoverlay filter

 doc/filters.texi   |  40 ++
 libavfilter/Makefile   |   1 +
 libavfilter/af_aoverlay.c  | 538 +
 libavfilter/allfilters.c   |   1 +
 tests/fate/filter-audio.mak|  22 +
 tests/ref/fate/filter-aoverlay-crossfade-d | 224 +
 tests/ref/fate/filter-aoverlay-crossfade-t | 202 
 tests/ref/fate/filter-aoverlay-default | 259 ++
 tests/ref/fate/filter-aoverlay-timeline| 254 ++
 9 files changed, 1541 insertions(+)
 create mode 100644 libavfilter/af_aoverlay.c
 create mode 100644 tests/ref/fate/filter-aoverlay-crossfade-d
 create mode 100644 tests/ref/fate/filter-aoverlay-crossfade-t
 create mode 100644 tests/ref/fate/filter-aoverlay-default
 create mode 100644 tests/ref/fate/filter-aoverlay-timeline

-- 
2.39.3 (Apple Git-145)

___
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] Hardware purchase request: AVX512-capable laptop

2024-01-16 Thread Kieran Kunhya
On Tue, 16 Jan 2024, 11:50 Paul B Mahol,  wrote:

> On Tue, Jan 16, 2024 at 11:06 AM Kieran Kunhya  wrote:
>
> > >
> > > A ticket doesn't have durability.
> > >
> >
> > A Ryzen 5 vs Ryzen 7 in the same laptop chassis doesn't change its
> > durability, it only doubles the laptop's price.
> >
>
> Are you CEO of FFmpeg or FFlabs now?
>

I'm CEO of librempeg and librempeglabs.

Kieran

>
___
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] Hardware purchase request: AVX512-capable laptop

2024-01-16 Thread Paul B Mahol
On Tue, Jan 16, 2024 at 11:06 AM Kieran Kunhya  wrote:

> >
> > A ticket doesn't have durability.
> >
>
> A Ryzen 5 vs Ryzen 7 in the same laptop chassis doesn't change its
> durability, it only doubles the laptop's price.
>

Are you CEO of FFmpeg or FFlabs now?


>
> Kieran
> ___
> 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] Hardware purchase request: AVX512-capable laptop

2024-01-16 Thread Kieran Kunhya
>
> A ticket doesn't have durability.
>

A Ryzen 5 vs Ryzen 7 in the same laptop chassis doesn't change its
durability, it only doubles the laptop's price.

Kieran
___
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".