[FFmpeg-devel] [PATCH WIP v2 6/9] avfilter/dnn_backend_tf: Simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_tf.c | 33 +--- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 3b4de6d13f..c7716e696d 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -37,8 +37,8 @@ #include typedef struct TFModel { +DNNModel model; DnnContext *ctx; -DNNModel *model; TF_Graph *graph; TF_Session *session; TF_Status *status; @@ -518,7 +518,7 @@ static void dnn_free_model_tf(DNNModel **model) TF_DeleteStatus(tf_model->status); } av_freep(&tf_model); -av_freep(&model); +*model = NULL; } static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx) @@ -526,18 +526,11 @@ static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, A DNNModel *model = NULL; TFModel *tf_model = NULL; -model = av_mallocz(sizeof(DNNModel)); -if (!model){ -return NULL; -} - tf_model = av_mallocz(sizeof(TFModel)); -if (!tf_model){ -av_freep(&model); +if (!tf_model) return NULL; -} +model = &tf_model->model; model->model = tf_model; -tf_model->model = model; tf_model->ctx = ctx; if (load_tf_model(tf_model, ctx->model_filename) != 0){ @@ -650,11 +643,11 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) { } input.data = (float *)TF_TensorData(infer_request->input_tensor); -switch (tf_model->model->func_type) { +switch (tf_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (tf_model->model->frame_pre_proc != NULL) { -tf_model->model->frame_pre_proc(task->in_frame, &input, tf_model->model->filter_ctx); +if (tf_model->model.frame_pre_proc != NULL) { +tf_model->model.frame_pre_proc(task->in_frame, &input, tf_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } @@ -664,7 +657,7 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) { ff_frame_to_dnn_detect(task->in_frame, &input, ctx); break; default: -avpriv_report_missing_feature(ctx, "model function type %d", tf_model->model->func_type); +avpriv_report_missing_feature(ctx, "model function type %d", tf_model->model.func_type); break; } @@ -724,12 +717,12 @@ static void infer_completion_callback(void *args) { outputs[i].data = TF_TensorData(infer_request->output_tensors[i]); outputs[i].dt = (DNNDataType)TF_TensorType(infer_request->output_tensors[i]); } -switch (tf_model->model->func_type) { +switch (tf_model->model.func_type) { case DFT_PROCESS_FRAME: //it only support 1 output if it's frame in & frame out if (task->do_ioproc) { -if (tf_model->model->frame_post_proc != NULL) { -tf_model->model->frame_post_proc(task->out_frame, outputs, tf_model->model->filter_ctx); +if (tf_model->model.frame_post_proc != NULL) { +tf_model->model.frame_post_proc(task->out_frame, outputs, tf_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, outputs, ctx); } @@ -741,11 +734,11 @@ static void infer_completion_callback(void *args) { } break; case DFT_ANALYTICS_DETECT: -if (!tf_model->model->detect_post_proc) { +if (!tf_model->model.detect_post_proc) { av_log(ctx, AV_LOG_ERROR, "Detect filter needs provide post proc\n"); return; } -tf_model->model->detect_post_proc(task->in_frame, outputs, task->nb_output, tf_model->model->filter_ctx); +tf_model->model.detect_post_proc(task->in_frame, outputs, task->nb_output, tf_model->model.filter_ctx); break; default: av_log(ctx, AV_LOG_ERROR, "Tensorflow backend does not support this kind of dnn filter now\n"); -- 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 WIP v2 5/9] avfilter/dnn_backend_tf: Fix free context at random place
From: Zhao Zhili It will be freed again by ff_dnn_uninit. --- libavfilter/dnn/dnn_backend_tf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 60f9e57fb7..3b4de6d13f 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -804,7 +804,7 @@ err: if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) { destroy_request_item(&request); } -dnn_free_model_tf(&tf_model->model); + return ret; } -- 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 WIP v2 1/9] avfilter/dnn: Refactor DNN parameter configuration system
From: Zhao Zhili This patch trying to resolve mulitiple issues related to parameter configuration: Firstly, each DNN filters duplicate DNN_COMMON_OPTIONS, which should be the common options of backend. Secondly, backend options are hidden behind the scene. It's a AV_OPT_TYPE_STRING backend_configs for user, and parsed by each backend. We don't know each backend support what kind of options from the help message. Third, DNN backends duplicate DNN_BACKEND_COMMON_OPTIONS. Last but not the least, pass backend options via AV_OPT_TYPE_STRING makes it hard to pass AV_OPT_TYPE_BINARY to backend, if not impossible. This patch puts backend common options and each backend options inside DnnContext to reduce code duplication, make options user friendly, and easy to extend for future usecase. There is a known issue that, for a filter which only support one or two of the backends, the help message still show the option of all three backends. Each DNN filter should be able to run on any backend. Current issue is mostly due to incomplete implementation (e.g., libtorch only support DFT_PROCESS_FRAME), and lack of maintenance on the filters. For example, ./ffmpeg -h filter=dnn_processing dnn_processing AVOptions: dnn_backend ..FV... DNN backend (from INT_MIN to INT_MAX) (default tensorflow) tensorflow 1..FV... tensorflow backend flag openvino2..FV... openvino backend flag torch 3..FV... torch backend flag dnn_base AVOptions: model ..F path to model file input ..F input name of the model output ..F output name of the model backend_configs..F...P backend configs (deprecated) options..F...P backend configs (deprecated) nireq ..F number of request (from 0 to INT_MAX) (default 0) async ..F use DNN async inference (default true) device ..F device to run model dnn_tensorflow AVOptions: sess_config..F config for SessionOptions dnn_openvino AVOptions: batch_size..F batch size per request (from 1 to 1000) (default 1) input_resizable ..F can input be resizable or not (default false) layout..F input layout of model (from 0 to 2) (default none) none0..F none nchw1..F nchw nhwc2..F nhwc scale ..F Add scale preprocess operation. Divide each element of input by specified value. (from INT_MIN to INT_MAX) (default 0) mean..F Add mean preprocess operation. Subtract specified value from each element of input. (from INT_MIN to INT_MAX) (default 0) dnn_th AVOptions: optimize ..F turn on graph executor optimization (from 0 to 1) (default 0) --- libavfilter/dnn/dnn_backend_common.h | 13 ++- libavfilter/dnn/dnn_backend_openvino.c | 146 ++--- libavfilter/dnn/dnn_backend_tf.c | 82 +- libavfilter/dnn/dnn_backend_torch.cpp | 67 libavfilter/dnn/dnn_interface.c| 81 ++ libavfilter/dnn_filter_common.c| 32 +- libavfilter/dnn_filter_common.h| 37 +++ libavfilter/dnn_interface.h| 66 ++- libavfilter/vf_derain.c| 5 +- libavfilter/vf_dnn_classify.c | 3 +- libavfilter/vf_dnn_detect.c| 3 +- libavfilter/vf_dnn_processing.c| 3 +- libavfilter/vf_sr.c| 5 +- 13 files changed, 314 insertions(+), 229 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h index 42c67c7040..9f5d37b3e0 100644 --- a/libavfilter/dnn/dnn_backend_common.h +++ b/libavfilter/dnn/dnn_backend_common.h @@ -28,9 +28,16 @@ #include "../dnn_interface.h" #include "libavutil/thread.h" -#define DNN_BACKEND_COMMON_OPTIONS \ -{ "nireq", "number of request", OFFSET(options.nireq), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS }, \ -{ "async", "use DNN async inference", OFFSET(options.async), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, +#define DNN_DEFINE_CLASS_EXT(name, desc, options) \ +{ \ +.class_name = desc, \ +.item_name = av_default_item_name, \ +.option = options, \ +.version= LIBAVUTIL_VERSION_INT,\ +.category = AV_CLASS_CATEGORY_FILTER, \ +} +#define DNN_DEFINE_CLASS(fname) \ +DNN_DEFINE_CLASS_EXT(fname, #fname, fname##_options) // one task for one function call from dnn
[FFmpeg-devel] [PATCH WIP v2 2/9] avfilter/dnn_backend_openvino: Fix free context at random place
From: Zhao Zhili It will be freed again by ff_dnn_uninit. --- libavfilter/dnn/dnn_backend_openvino.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index c4b0682f11..769ba0a54b 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -959,7 +959,6 @@ err: if (input_model_info) ov_preprocess_input_model_info_free(input_model_info); #endif -dnn_free_model_ov(&ov_model->model); return ret; } -- 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 WIP v2 9/9] avfilter/dnn: Use dnn_backend_info_list to search for dnn module
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_openvino.c | 1 + libavfilter/dnn/dnn_backend_tf.c | 1 + libavfilter/dnn/dnn_backend_torch.cpp | 1 + libavfilter/dnn/dnn_interface.c| 26 -- libavfilter/dnn_interface.h| 1 + 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index d8a6820dc2..9c699cdc8c 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -1613,6 +1613,7 @@ static int dnn_flush_ov(const DNNModel *model) const DNNModule ff_dnn_backend_openvino = { .clazz = DNN_DEFINE_CLASS(dnn_openvino), +.type = DNN_OV, .load_model = dnn_load_model_ov, .execute_model = dnn_execute_model_ov, .get_result = dnn_get_result_ov, diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 06ea6cbb8c..6afefe8115 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -886,6 +886,7 @@ static int dnn_flush_tf(const DNNModel *model) const DNNModule ff_dnn_backend_tf = { .clazz = DNN_DEFINE_CLASS(dnn_tensorflow), +.type = DNN_TF, .load_model = dnn_load_model_tf, .execute_model = dnn_execute_model_tf, .get_result = dnn_get_result_tf, diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp index 24e9f2c8e2..2557264713 100644 --- a/libavfilter/dnn/dnn_backend_torch.cpp +++ b/libavfilter/dnn/dnn_backend_torch.cpp @@ -561,6 +561,7 @@ static int dnn_flush_th(const DNNModel *model) extern const DNNModule ff_dnn_backend_torch = { .clazz = DNN_DEFINE_CLASS(dnn_th), +.type = DNN_TH, .load_model = dnn_load_model_th, .execute_model = dnn_execute_model_th, .get_result = dnn_get_result_th, diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c index ebd308cd84..cce3c45856 100644 --- a/libavfilter/dnn/dnn_interface.c +++ b/libavfilter/dnn/dnn_interface.c @@ -80,25 +80,15 @@ static const DnnBackendInfo dnn_backend_info_list[] = { const DNNModule *ff_get_dnn_module(DNNBackendType backend_type, void *log_ctx) { -switch(backend_type){ -#if (CONFIG_LIBTENSORFLOW == 1) -case DNN_TF: -return &ff_dnn_backend_tf; -#endif -#if (CONFIG_LIBOPENVINO == 1) -case DNN_OV: -return &ff_dnn_backend_openvino; -#endif -#if (CONFIG_LIBTORCH == 1) -case DNN_TH: -return &ff_dnn_backend_torch; -#endif -default: -av_log(log_ctx, AV_LOG_ERROR, -"Module backend_type %d is not supported or enabled.\n", -backend_type); -return NULL; +for (int i = 1; i < FF_ARRAY_ELEMS(dnn_backend_info_list); i++) { +if (dnn_backend_info_list[i].module->type == backend_type) +return dnn_backend_info_list[i].module; } + +av_log(log_ctx, AV_LOG_ERROR, +"Module backend_type %d is not supported or enabled.\n", +backend_type); +return NULL; } void *ff_dnn_child_next(DnnContext *obj, void *prev) { diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index 4e14a42d00..4b25ac2b84 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -170,6 +170,7 @@ typedef struct DnnContext { // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends. struct DNNModule { const AVClass clazz; +DNNBackendType type; // Loads model and parameters from given file. Returns NULL if it is not possible. DNNModel *(*load_model)(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx); // Executes model with specified input and output. Returns the error code otherwise. -- 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 WIP v2 4/9] avfilter/dnn_backend_tf: Remove one level of indentation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_tf.c | 63 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index d24591b90b..60f9e57fb7 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -483,41 +483,42 @@ static void dnn_free_model_tf(DNNModel **model) { TFModel *tf_model; -if (*model){ -tf_model = (*model)->model; -while (ff_safe_queue_size(tf_model->request_queue) != 0) { -TFRequestItem *item = ff_safe_queue_pop_front(tf_model->request_queue); -destroy_request_item(&item); -} -ff_safe_queue_destroy(tf_model->request_queue); +if (!model || !*model) +return; -while (ff_queue_size(tf_model->lltask_queue) != 0) { -LastLevelTaskItem *item = ff_queue_pop_front(tf_model->lltask_queue); -av_freep(&item); -} -ff_queue_destroy(tf_model->lltask_queue); +tf_model = (*model)->model; +while (ff_safe_queue_size(tf_model->request_queue) != 0) { +TFRequestItem *item = ff_safe_queue_pop_front(tf_model->request_queue); +destroy_request_item(&item); +} +ff_safe_queue_destroy(tf_model->request_queue); -while (ff_queue_size(tf_model->task_queue) != 0) { -TaskItem *item = ff_queue_pop_front(tf_model->task_queue); -av_frame_free(&item->in_frame); -av_frame_free(&item->out_frame); -av_freep(&item); -} -ff_queue_destroy(tf_model->task_queue); +while (ff_queue_size(tf_model->lltask_queue) != 0) { +LastLevelTaskItem *item = ff_queue_pop_front(tf_model->lltask_queue); +av_freep(&item); +} +ff_queue_destroy(tf_model->lltask_queue); -if (tf_model->graph){ -TF_DeleteGraph(tf_model->graph); -} -if (tf_model->session){ -TF_CloseSession(tf_model->session, tf_model->status); -TF_DeleteSession(tf_model->session, tf_model->status); -} -if (tf_model->status){ -TF_DeleteStatus(tf_model->status); -} -av_freep(&tf_model); -av_freep(&model); +while (ff_queue_size(tf_model->task_queue) != 0) { +TaskItem *item = ff_queue_pop_front(tf_model->task_queue); +av_frame_free(&item->in_frame); +av_frame_free(&item->out_frame); +av_freep(&item); +} +ff_queue_destroy(tf_model->task_queue); + +if (tf_model->graph){ +TF_DeleteGraph(tf_model->graph); +} +if (tf_model->session){ +TF_CloseSession(tf_model->session, tf_model->status); +TF_DeleteSession(tf_model->session, tf_model->status); +} +if (tf_model->status){ +TF_DeleteStatus(tf_model->status); } +av_freep(&tf_model); +av_freep(&model); } static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx) -- 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 WIP v2 3/9] avfilter/dnn_backend_openvino: simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_openvino.c | 47 +++--- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 769ba0a54b..1acc54b791 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -41,8 +41,8 @@ #include "dnn_backend_common.h" typedef struct OVModel{ +DNNModel model; DnnContext *ctx; -DNNModel *model; #if HAVE_OPENVINO2 ov_core_t *core; ov_model_t *ov_model; @@ -300,11 +300,11 @@ static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request) return ov2_map_error(status, NULL); } #endif -switch (ov_model->model->func_type) { +switch (ov_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (ov_model->model->frame_pre_proc != NULL) { -ov_model->model->frame_pre_proc(task->in_frame, &input, ov_model->model->filter_ctx); +if (ov_model->model.frame_pre_proc != NULL) { +ov_model->model.frame_pre_proc(task->in_frame, &input, ov_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } @@ -442,11 +442,11 @@ static void infer_completion_callback(void *args) for (int i = 0; i < request->lltask_count; ++i) { task = request->lltasks[i]->task; -switch (ov_model->model->func_type) { +switch (ov_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (ov_model->model->frame_post_proc != NULL) { -ov_model->model->frame_post_proc(task->out_frame, outputs, ov_model->model->filter_ctx); +if (ov_model->model.frame_post_proc != NULL) { +ov_model->model.frame_post_proc(task->out_frame, outputs, ov_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, outputs, ctx); } @@ -458,23 +458,23 @@ static void infer_completion_callback(void *args) } break; case DFT_ANALYTICS_DETECT: -if (!ov_model->model->detect_post_proc) { +if (!ov_model->model.detect_post_proc) { av_log(ctx, AV_LOG_ERROR, "detect filter needs to provide post proc\n"); goto end; } -ov_model->model->detect_post_proc(task->in_frame, outputs, +ov_model->model.detect_post_proc(task->in_frame, outputs, ov_model->nb_outputs, - ov_model->model->filter_ctx); + ov_model->model.filter_ctx); break; case DFT_ANALYTICS_CLASSIFY: -if (!ov_model->model->classify_post_proc) { +if (!ov_model->model.classify_post_proc) { av_log(ctx, AV_LOG_ERROR, "classify filter needs to provide post proc\n"); goto end; } for (int output_i = 0; output_i < ov_model->nb_outputs; output_i++) -ov_model->model->classify_post_proc(task->in_frame, outputs, +ov_model->model.classify_post_proc(task->in_frame, outputs, request->lltasks[i]->bbox_index, - ov_model->model->filter_ctx); + ov_model->model.filter_ctx); break; default: av_assert0(!"should not reach here"); @@ -571,7 +571,7 @@ static void dnn_free_model_ov(DNNModel **model) av_free(ov_model->all_input_names); #endif av_freep(&ov_model); -av_freep(model); +*model = NULL; } @@ -598,7 +598,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * #endif // We scale pixel by default when do frame processing. if (fabsf(ctx->ov_option.scale) < 1e-6f) -ctx->ov_option.scale = ov_model->model->func_type == DFT_PROCESS_FRAME ? 255 : 1; +ctx->ov_option.scale = ov_model->model.func_type == DFT_PROCESS_FRAME ? 255 : 1; // batch size if (ctx->ov_option.batch_size <= 0) { ctx->ov_option.batch_size = 1; @@ -702,7 +702,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * ret = ov2_map_error(status, NULL); goto err; } -if (ov_model->model->func_type != DFT_PROCESS_FRAME) +if (ov_model->model.func_type != DFT_PROCESS_FRAME) status |= ov_preprocess_output_set_element_type(output_tensor_info, F32); else if (fabsf(ctx->ov_option.scale - 1) > 1e-6f || fabsf(ctx->ov_option.mean) > 1e-6f)
[FFmpeg-devel] [PATCH WIP v2 7/9] avfilter/dnn_backend_torch: Simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_torch.cpp | 31 +++ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp index abdef1f178..818ec5b713 100644 --- a/libavfilter/dnn/dnn_backend_torch.cpp +++ b/libavfilter/dnn/dnn_backend_torch.cpp @@ -37,8 +37,8 @@ extern "C" { } typedef struct THModel { +DNNModel model; DnnContext *ctx; -DNNModel *model; torch::jit::Module *jit_model; SafeQueue *request_queue; Queue *task_queue; @@ -141,7 +141,7 @@ static void dnn_free_model_th(DNNModel **model) ff_queue_destroy(th_model->task_queue); delete th_model->jit_model; av_freep(&th_model); -av_freep(model); +*model = NULL; } static int get_input_th(void *model, DNNData *input, const char *input_name) @@ -195,19 +195,19 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request) infer_request->input_tensor = new torch::Tensor(); infer_request->output = new torch::Tensor(); -switch (th_model->model->func_type) { +switch (th_model->model.func_type) { case DFT_PROCESS_FRAME: input.scale = 255; if (task->do_ioproc) { -if (th_model->model->frame_pre_proc != NULL) { -th_model->model->frame_pre_proc(task->in_frame, &input, th_model->model->filter_ctx); +if (th_model->model.frame_pre_proc != NULL) { +th_model->model.frame_pre_proc(task->in_frame, &input, th_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } } break; default: -avpriv_report_missing_feature(NULL, "model function type %d", th_model->model->func_type); +avpriv_report_missing_feature(NULL, "model function type %d", th_model->model.func_type); break; } *infer_request->input_tensor = torch::from_blob(input.data, @@ -282,13 +282,13 @@ static void infer_completion_callback(void *args) { goto err; } -switch (th_model->model->func_type) { +switch (th_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { outputs.scale = 255; outputs.data = output->data_ptr(); -if (th_model->model->frame_post_proc != NULL) { -th_model->model->frame_post_proc(task->out_frame, &outputs, th_model->model->filter_ctx); +if (th_model->model.frame_post_proc != NULL) { +th_model->model.frame_post_proc(task->out_frame, &outputs, th_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, &outputs, th_model->ctx); } @@ -298,7 +298,7 @@ static void infer_completion_callback(void *args) { } break; default: -avpriv_report_missing_feature(th_model->ctx, "model function type %d", th_model->model->func_type); +avpriv_report_missing_feature(th_model->ctx, "model function type %d", th_model->model.func_type); goto err; } task->inference_done++; @@ -417,17 +417,10 @@ static DNNModel *dnn_load_model_th(DnnContext *ctx, DNNFunctionType func_type, A THRequestItem *item = NULL; const char *device_name = ctx->device ? ctx->device : "cpu"; -model = (DNNModel *)av_mallocz(sizeof(DNNModel)); -if (!model) { -return NULL; -} - th_model = (THModel *)av_mallocz(sizeof(THModel)); -if (!th_model) { -av_freep(&model); +if (!th_model) return NULL; -} -th_model->model = model; +model = &th_model->model; model->model = th_model; th_model->ctx = ctx; -- 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 WIP v2 8/9] avfilter/dnn: Remove a level of dereference
From: Zhao Zhili For code such as 'model->model = ov_model' is confusing. We can just drop the member variable and use cast to get the subclass. --- libavfilter/dnn/dnn_backend_openvino.c | 17 - libavfilter/dnn/dnn_backend_tf.c | 19 +-- libavfilter/dnn/dnn_backend_torch.cpp | 15 +++ libavfilter/dnn_filter_common.c| 6 +++--- libavfilter/dnn_interface.h| 6 ++ 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 1acc54b791..d8a6820dc2 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -517,7 +517,7 @@ static void dnn_free_model_ov(DNNModel **model) if (!model || !*model) return; -ov_model = (*model)->model; +ov_model = (OVModel *)(*model); while (ff_safe_queue_size(ov_model->request_queue) != 0) { OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue); if (item && item->infer_request) { @@ -1059,9 +1059,9 @@ err: return ret; } -static int get_input_ov(void *model, DNNData *input, const char *input_name) +static int get_input_ov(DNNModel *model, DNNData *input, const char *input_name) { -OVModel *ov_model = model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; int input_resizable = ctx->ov_option.input_resizable; @@ -1255,7 +1255,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q } } -static int get_output_ov(void *model, const char *input_name, int input_width, int input_height, +static int get_output_ov(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height) { #if HAVE_OPENVINO2 @@ -1268,7 +1268,7 @@ static int get_output_ov(void *model, const char *input_name, int input_width, i input_shapes_t input_shapes; #endif int ret; -OVModel *ov_model = model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; TaskItem task; OVRequestItem *request; @@ -1383,7 +1383,6 @@ static DNNModel *dnn_load_model_ov(DnnContext *ctx, DNNFunctionType func_type, A return NULL; ov_model->ctx = ctx; model = &ov_model->model; -model->model = ov_model; #if HAVE_OPENVINO2 status = ov_core_create(&core); @@ -1470,7 +1469,7 @@ err: static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_params) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; OVRequestItem *request; TaskItem *task; @@ -1558,13 +1557,13 @@ static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_p static DNNAsyncStatusType dnn_get_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; return ff_dnn_get_result_common(ov_model->task_queue, in, out); } static int dnn_flush_ov(const DNNModel *model) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; OVRequestItem *request; #if HAVE_OPENVINO2 diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index c7716e696d..06ea6cbb8c 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -262,9 +262,9 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input) input_dims[1] * input_dims[2] * input_dims[3] * size); } -static int get_input_tf(void *model, DNNData *input, const char *input_name) +static int get_input_tf(DNNModel *model, DNNData *input, const char *input_name) { -TFModel *tf_model = model; +TFModel *tf_model = (TFModel *)model; DnnContext *ctx = tf_model->ctx; TF_Status *status; TF_DataType dt; @@ -310,11 +310,11 @@ static int get_input_tf(void *model, DNNData *input, const char *input_name) return 0; } -static int get_output_tf(void *model, const char *input_name, int input_width, int input_height, +static int get_output_tf(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height) { int ret; -TFModel *tf_model = model; +TFModel *tf_model = (TFModel *)model; DnnContext *ctx = tf_model->ctx; TaskItem task; TFRequestItem *request; @@ -486,7 +486,7 @@ static void dnn_free_model_tf(DNNModel **model) if (!model || !*model) return; -tf_model = (*model)->model; +tf_model = (TFModel *)(*model); while (ff_safe_queue_size(tf_model->request_queue) != 0) { TFRequestItem *item = ff_safe_queue_pop_front(tf_model->re
Re: [FFmpeg-devel] [PATCH] avformat/framecrcenc: compute the checksum for side data
On 4/27/2024 9:07 AM, Michael Niedermayer wrote: On Sat, Apr 27, 2024 at 12:44:18PM +0200, Andreas Rheinhardt wrote: Michael Niedermayer: This allows detecting issues in side data related code, same as what framecrc does for before already for packet data itself. Signed-off-by: Michael Niedermayer --- libavformat/framecrcenc.c | 76 +- tests/ref/fate/autorotate |2 +- tests/ref/fate/cover-art-mp3-id3v2-remux|2 +- tests/ref/fate/ffmpeg-bsf-input | 10 +- tests/ref/fate/force_key_frames-source | 784 ++-- tests/ref/fate/force_key_frames-source-drop | 34 +- tests/ref/fate/force_key_frames-source-dup | 1224 +-- tests/ref/fate/gapless-mp3 |6 +- tests/ref/fate/h264_redundant_pps-side_data |2 +- tests/ref/fate/iamf-5_1-copy| 208 ++-- tests/ref/fate/iamf-5_1-demux | 208 ++-- tests/ref/fate/id3v2-priv-remux |2 +- tests/ref/fate/matroska-hdr10-plus-remux|2 +- tests/ref/fate/matroska-ogg-opus-remux |2 +- tests/ref/fate/matroska-opus-remux |2 +- tests/ref/fate/matroska-vp8-alpha-remux | 14 +- tests/ref/fate/mov-cover-image |2 +- tests/ref/fate/segment-mp4-to-ts| 250 ++-- tests/ref/fate/shortest | 100 +- tests/ref/fate/webm-hdr10-plus-remux|2 +- tests/ref/fate/webm-webvtt-remux| 24 +- 21 files changed, 1513 insertions(+), 1443 deletions(-) diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c index ce306a6c498..e71bfbd8777 100644 --- a/libavformat/framecrcenc.c +++ b/libavformat/framecrcenc.c @@ -21,8 +21,10 @@ #include +#include "config.h" #include "libavutil/adler32.h" #include "libavutil/avstring.h" +#include "libavutil/intreadwrite.h" #include "libavcodec/codec_id.h" #include "libavcodec/codec_par.h" @@ -48,6 +50,17 @@ static int framecrc_write_header(struct AVFormatContext *s) return ff_framehash_write_header(s); } +static av_unused void inline bswap(char *buf, int offset, int size) +{ +if (size == 8) { +uint64_t val = AV_RN64(buf + offset); +AV_WN64(buf + offset, av_bswap64(val)); +} else if (size == 4) { +uint32_t val = AV_RN32(buf + offset); +AV_WN32(buf + offset, av_bswap32(val)); +} +} + static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) { uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); @@ -58,11 +71,68 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) if (pkt->flags != AV_PKT_FLAG_KEY) av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags); if (pkt->side_data_elems) { +int i; This change is wrong. av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems); -for (int i = 0; i < pkt->side_data_elems; i++) { -av_strlcatf(buf, sizeof(buf), ", %8"SIZE_SPECIFIER, -pkt->side_data[i].size); +for (i=0; iside_data_elems; i++) { +const AVPacketSideData *const sd = &pkt->side_data[i]; +const uint8_t *data = sd->data; +uint32_t side_data_crc = 0; + +switch (sd->type) { +#if HAVE_BIGENDIAN +uint8_t bswap_buf[FFMAX(sizeof(AVCPBProperties), +sizeof(AVProducerReferenceTime))]; +case AV_PKT_DATA_PALETTE: +case AV_PKT_DATA_REPLAYGAIN: +case AV_PKT_DATA_DISPLAYMATRIX: +case AV_PKT_DATA_STEREO3D: +case AV_PKT_DATA_AUDIO_SERVICE_TYPE: +case AV_PKT_DATA_FALLBACK_TRACK: +case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: +case AV_PKT_DATA_SPHERICAL: +case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: +case AV_PKT_DATA_S12M_TIMECODE: +for (size_t j = 0; j < sd->size / 4; j++) { +uint8_t buf[4]; +AV_WL32(buf, AV_RB32(sd->data + 4 * j)); +side_data_crc = av_adler32_update(side_data_crc, buf, 4); +} +break; +case AV_PKT_DATA_CPB_PROPERTIES: +#define BSWAP(struct, field) bswap(bswap_buf, offsetof(struct, field), sizeof(((struct){0}).field)) +if (sd->size == sizeof(AVCPBProperties)) { +memcpy(bswap_buf, sd->data, sizeof(AVCPBProperties)); +data = bswap_buf; +BSWAP(AVCPBProperties, max_bitrate); +BSWAP(AVCPBProperties, min_bitrate); +BSWAP(AVCPBProperties, avg_bitrate); +BSWAP(AVCPBProperties, buffer_size); +BSWAP(AVCPBProperties, vbv_delay); +} +goto pod; +case AV_PKT_DATA_PRFT: +if (sd->size == sizeof(AVProducerReferen
Re: [FFmpeg-devel] [PATCH] lavfi/qsv: Copy metadata fields from the given input
On Do, 2024-04-25 at 13:18 +0800, Xiang, Haihao wrote: > From: Haihao Xiang > > Currently it always copies the metadata fields from the last input when > there are multiple inputs for the filter. For example, the metadata > fields from input1 are copied to the output for overlay_qsv filter, > however for regular overlay filters, the metadata fields from input0 are > copied to the output. With this fix, we may copy the metadata fields > from input0 to the ouput as well. > > Signed-off-by: Haihao Xiang > --- > libavfilter/qsvvpp.c | 29 +++-- > libavfilter/qsvvpp.h | 2 +- > libavfilter/vf_overlay_qsv.c | 9 ++--- > libavfilter/vf_stack_qsv.c | 9 ++--- > libavfilter/vf_vpp_qsv.c | 2 +- > 5 files changed, 25 insertions(+), 26 deletions(-) > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c > index 8c92fec0c1..10d970652e 100644 > --- a/libavfilter/qsvvpp.c > +++ b/libavfilter/qsvvpp.c > @@ -441,11 +441,6 @@ static QSVFrame *submit_frame(QSVVPPContext *s, > AVFilterLink *inlink, AVFrame *p > av_frame_free(&qsv_frame->frame); > return NULL; > } > - > - if (av_frame_copy_props(qsv_frame->frame, picref) < 0) { > - av_frame_free(&qsv_frame->frame); > - return NULL; > - } > } else > qsv_frame->frame = av_frame_clone(picref); > > @@ -494,12 +489,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, > AVFilterLink *outlink, const AVFr > if (!out_frame->frame) > return NULL; > > - ret = av_frame_copy_props(out_frame->frame, in); > - if (ret < 0) { > - av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from > src to dst.\n"); > - return NULL; > - } > - > ret = av_hwframe_get_buffer(outlink->hw_frames_ctx, out_frame->frame, > 0); > if (ret < 0) { > av_log(ctx, AV_LOG_ERROR, "Can't allocate a surface.\n"); > @@ -516,12 +505,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, > AVFilterLink *outlink, const AVFr > if (!out_frame->frame) > return NULL; > > - ret = av_frame_copy_props(out_frame->frame, in); > - if (ret < 0) { > - av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from > src to dst.\n"); > - return NULL; > - } > - > ret = map_frame_to_surface(out_frame->frame, > &out_frame->surface); > if (ret < 0) > @@ -958,7 +941,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx) > return 0; > } > > -int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame > *picref) > +int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame > *picref, AVFrame *propref) > { > AVFilterContext *ctx = inlink->dst; > AVFilterLink *outlink = ctx->outputs[0]; > @@ -1015,6 +998,16 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, > AVFilterLink *inlink, AVFrame *picr > return AVERROR(EAGAIN); > break; > } > + > + if (propref) { > + ret1 = av_frame_copy_props(out_frame->frame, propref); > + if (ret1 < 0) { > + av_frame_free(&out_frame->frame); > + av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields > from src to dst.\n"); > + return ret1; > + } > + } > + > out_frame->frame->pts = av_rescale_q(out_frame- > >surface.Data.TimeStamp, > default_tb, outlink->time_base); > > diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h > index 4eea7a46c7..3b9192b62e 100644 > --- a/libavfilter/qsvvpp.h > +++ b/libavfilter/qsvvpp.h > @@ -131,7 +131,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam > *param); > int ff_qsvvpp_close(AVFilterContext *avctx); > > /* vpp filter frame and call the cb if needed */ > -int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame > *frame); > +int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame > *frame, AVFrame *propref); > > int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, > const char *extra_string); > diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c > index 0f52c93245..059602fe03 100644 > --- a/libavfilter/vf_overlay_qsv.c > +++ b/libavfilter/vf_overlay_qsv.c > @@ -228,13 +228,16 @@ static int process_frame(FFFrameSync *fs) > { > AVFilterContext *ctx = fs->parent; > QSVVPPContext *qsv = fs->opaque; > - AVFrame *frame = NULL; > + AVFrame *frame = NULL, *propref = NULL; > int ret = 0, i; > > for (i = 0; i < ctx->nb_inputs; i++) { > ret = ff_framesync_get_frame(fs, i, &frame, 0); > - if (ret == 0) > - ret = ff_qsvvpp_filter_frame(qsv, ctx->
Re: [FFmpeg-devel] [PATCH v4] lavu/hwcontext_vaapi: Use vaMapBuffer2 for mapping image buffers
On Do, 2024-04-25 at 09:33 +0200, David Rosca wrote: > On Fri, Nov 24, 2023 at 8:27 AM Xiang, Haihao wrote: > > > > On Vr, 2023-10-27 at 22:25 +0200, David Rosca wrote: > > > This allows some optimizations in driver, such as not having to read > > > back the data if write-only mapping is requested. > > > --- > > > v4: overwrite + note about vaMapBuffer libva fallback > > > > > > libavutil/hwcontext_vaapi.c | 12 > > > 1 file changed, 12 insertions(+) > > > > > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > > > index 558fed94c6..435f10a7f3 100644 > > > --- a/libavutil/hwcontext_vaapi.c > > > +++ b/libavutil/hwcontext_vaapi.c > > > @@ -799,6 +799,9 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, > > > VAStatus vas; > > > void *address = NULL; > > > int err, i; > > > +#if VA_CHECK_VERSION(1, 21, 0) > > > + uint32_t vaflags = 0; > > > +#endif > > > > > > surface_id = (VASurfaceID)(uintptr_t)src->data[3]; > > > av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id); > > > @@ -882,7 +885,16 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, > > > } > > > } > > > > > > +#if VA_CHECK_VERSION(1, 21, 0) > > > + if (flags & AV_HWFRAME_MAP_READ) > > > + vaflags |= VA_MAPBUFFER_FLAG_READ; > > > + if (flags & AV_HWFRAME_MAP_WRITE) > > > + vaflags |= VA_MAPBUFFER_FLAG_WRITE; > > > + // On drivers not implementing vaMapBuffer2 libva calls vaMapBuffer > > > instead. > > > + vas = vaMapBuffer2(hwctx->display, map->image.buf, &address, > > > vaflags); > > > +#else > > > vas = vaMapBuffer(hwctx->display, map->image.buf, &address); > > > +#endif > > > if (vas != VA_STATUS_SUCCESS) { > > > av_log(hwfc, AV_LOG_ERROR, "Failed to map image from surface " > > > "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas)); > > > > LGTM, and will apply it when the official libva 2.21 is released. > > Ping, libva 2.21 has now been released. Thanks for reminding me, will apply. -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] avformat/iamfdec: check nb_streams in header read
On 4/27/2024 3:51 PM, Michael Niedermayer wrote: Fixes: Assertion pkt->stream_index < (unsigned)s->nb_streams && "Invalid stream index.\n" failed at libavformat/demux.c:572 Fixes: 67890/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5166340789829632.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/iamfdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c index e34d13e74c5..ce6d4aa0647 100644 --- a/libavformat/iamfdec.c +++ b/libavformat/iamfdec.c @@ -154,6 +154,9 @@ static int iamf_read_header(AVFormatContext *s) } } +if (!s->nb_streams) +return AVERROR_INVALIDDATA; + return 0; } Should be ok. ___ 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 10/10] fftools/ffplay: Check vulkan_params
Fixes: CID1550133 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffplay.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 63a9806fb80..cc00e209d52 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3839,8 +3839,13 @@ int main(int argc, char **argv) if (vk_renderer) { AVDictionary *dict = NULL; -if (vulkan_params) -av_dict_parse_string(&dict, vulkan_params, "=", ":", 0); +if (vulkan_params) { +int ret = av_dict_parse_string(&dict, vulkan_params, "=", ":", 0); +if (ret < 0) { +av_log(NULL, AV_LOG_FATAL, "Failed to parse, %s\n", vulkan_params); +do_exit(NULL); +} +} ret = vk_renderer_create(vk_renderer, window, dict); av_dict_free(&dict); if (ret < 0) { -- 2.43.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".
[FFmpeg-devel] [PATCH 09/10] fftools/ffplay: Check return of swr_alloc_set_opts2()
This probably makes no difference but its more correct Fixes: CID1503080 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffplay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index d4300d5d46e..63a9806fb80 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2392,11 +2392,11 @@ static int audio_decode_frame(VideoState *is) af->frame->sample_rate != is->audio_src.freq || (wanted_nb_samples != af->frame->nb_samples && !is->swr_ctx)) { swr_free(&is->swr_ctx); -swr_alloc_set_opts2(&is->swr_ctx, +int ret = swr_alloc_set_opts2(&is->swr_ctx, &is->audio_tgt.ch_layout, is->audio_tgt.fmt, is->audio_tgt.freq, &af->frame->ch_layout, af->frame->format, af->frame->sample_rate, 0, NULL); -if (!is->swr_ctx || swr_init(is->swr_ctx) < 0) { +if (ret < 0 || swr_init(is->swr_ctx) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n", af->frame->sample_rate, av_get_sample_fmt_name(af->frame->format), af->frame->ch_layout.nb_channels, -- 2.43.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".
[FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_sched: Remove dead assignments in sch_dec_send()
Fixes: CID1592383 Unused value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_sched.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index e58b00ea97b..cff824340b7 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -2174,7 +2174,7 @@ finish: int sch_dec_send(Scheduler *sch, unsigned dec_idx, AVFrame *frame) { SchDec *dec; -int ret = 0; +int ret; unsigned nb_done = 0; av_assert0(dec_idx < sch->nb_dec); @@ -2201,7 +2201,6 @@ int sch_dec_send(Scheduler *sch, unsigned dec_idx, AVFrame *frame) av_frame_unref(to_send); if (ret == AVERROR_EOF) { nb_done++; -ret = 0; continue; } return ret; -- 2.43.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".
[FFmpeg-devel] [PATCH 07/10] fftools/cmdutils: Add protective () to FLAGS
issue found while reviewing CID1452612 Free of array-typed value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index a8f5c6d89b4..d28f5f3a8bd 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -578,7 +578,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, return o; } -#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 +#define FLAGS ((o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0) int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; -- 2.43.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".
[FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_mux_init: Cleanup on error return in set_dispositions()
Fixes: CID1539099 Resource leak Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg.h | 9 +++-- fftools/ffmpeg_mux_init.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 885a7c0c102..7fd6c57d50f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -868,7 +868,7 @@ void update_benchmark(const char *fmt, ...); namestr, st->index, o->optname.opt_canon->name, spec[0] ? ":" : "", spec, so->u.type);\ } -#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ +#define MATCH_PER_STREAM_OPT_CLEAN(name, type, outvar, fmtctx, st, clean)\ {\ int _ret, _matches = 0, _match_idx;\ for (int _i = 0; _i < o->name.nb_opt; _i++) {\ @@ -878,12 +878,17 @@ void update_benchmark(const char *fmt, ...); _match_idx = _i;\ _matches++;\ } else if (_ret < 0)\ -return _ret;\ +clean;\ }\ if (_matches > 1 && o->name.opt_canon)\ WARN_MULTIPLE_OPT_USAGE(name, type, _match_idx, st);\ } +#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ +{\ +MATCH_PER_STREAM_OPT_CLEAN(name, type, outvar, fmtctx, st, return _ret)\ +} + const char *opt_match_per_type_str(const SpecifierOptList *sol, char mediatype); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index b1cb6cf7bd7..1262630b24e 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2933,7 +2933,7 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) nb_streams[ost->type + 1]++; -MATCH_PER_STREAM_OPT(disposition, str, dispositions[i], ctx, ost->st); +MATCH_PER_STREAM_OPT_CLEAN(disposition, str, dispositions[i], ctx, ost->st, goto finish); have_manual |= !!dispositions[i]; -- 2.43.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".
[FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_mux_init: Free pts on error
Fixes: CID1538863 Resource leak Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_mux_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 8797265145c..b1cb6cf7bd7 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -3025,7 +3025,7 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf, if (nb_ch > INT_MAX - size || !(pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts -return AVERROR(ENOMEM); +goto fail; if (p[8]) { ret = av_parse_time(&t, p + 8, 1); -- 2.43.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".
[FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_enc: simplify opaque_ref check
Found-while-revieweing: CID1520670 Dereference after null check Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 618ba193ff5..863d1a43edd 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -476,7 +476,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, const FrameData *fd; -if ((frame && frame->opaque_ref) || (pkt && pkt->opaque_ref)) { +if (frame ? frame->opaque_ref : pkt->opaque_ref) { fd = (const FrameData*)(frame ? frame->opaque_ref->data : pkt->opaque_ref->data); tbi = fd->dec.tb; ptsi = fd->dec.pts; -- 2.43.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".
[FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_mux: Remove unneeded initialization
Not sure this change makes sense, the code is more robust with ret set Fixes: CID1559178 Unused value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_mux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index a1583edd618..4306067eca2 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -290,7 +290,7 @@ static int mux_packet_filter(Muxer *mux, MuxThreadContext *mt, { MuxStream *ms = ms_from_ost(ost); const char *err_msg; -int ret = 0; +int ret; if (pkt && !ost->enc) { ret = of_streamcopy(&mux->of, ost, pkt); @@ -299,7 +299,6 @@ static int mux_packet_filter(Muxer *mux, MuxThreadContext *mt, else if (ret == AVERROR_EOF) { av_packet_unref(pkt); pkt = NULL; -ret = 0; *stream_eof = 1; } else if (ret < 0) goto fail; -- 2.43.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".
[FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_enc: Initialize Decoder
Fixes: CID1591439 Uninitialized pointer read Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 0b3f3f101a2..928114c20ff 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -168,7 +168,7 @@ int enc_open(void *opaque, const AVFrame *frame) InputStream *ist = ost->ist; Encoder *e = ost->enc; AVCodecContext *enc_ctx = ost->enc_ctx; -Decoder*dec; +Decoder*dec = NULL; const AVCodec *enc = enc_ctx->codec; OutputFile *of = ost->file; FrameData *fd; -- 2.43.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".
[FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_enc: Initialize fd
Fixes: CID1520677 Uninitialized pointer read Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- fftools/ffmpeg_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 863d1a43edd..0b3f3f101a2 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -474,7 +474,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, AVRational tbi = (AVRational){ 0, 1}; int64_tptsi = INT64_MAX; -const FrameData *fd; +const FrameData *fd = NULL; if (frame ? frame->opaque_ref : pkt->opaque_ref) { fd = (const FrameData*)(frame ? frame->opaque_ref->data : pkt->opaque_ref->data); -- 2.43.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 5/5] avformat/mov: Check if heif item name is already allocated
On 4/26/2024 9:23 PM, James Almer wrote: On 4/26/2024 9:03 PM, Michael Niedermayer wrote: On Fri, Apr 26, 2024 at 08:57:02PM -0300, James Almer wrote: On 4/26/2024 8:52 PM, Michael Niedermayer wrote: Fixes: memleak Fixes: 68212/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4963488540721152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 97a24e6737e..5b8278f736e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8136,6 +8136,9 @@ static int mov_read_infe(MOVContext *c, AVIOContext *pb, MOVAtom atom, int idx) avio_rb24(pb); // flags. size -= 4; + if (c->heif_item[idx].name) + return AVERROR_INVALIDDATA; I prefer to free the old one before the av_bprint_finalize() call instead of aborting. does the format allow this to be changing ? This code is not supposed to be invoked twice if an iinf box is correctly parsed. It can only happen if a second iinf box shows up after the first and demuxing wasn't aborted, either because the error was ignored, or an infe box within was version < 2. because security wise, allowing an attacker to change things is worse than allowing her to just set it once. A second iinf box could show up after the first was not finished parsing, and as long as it has no names for the items, it would still finish parsing even after this patch. So better just clean old values and keep parsing. Further sanity checks will happen when all the items are turned into something meant to be exported. and heif seems to have a rather high density of issues already, judging from how many of the recent mov issues where in heif code thx Can you test https://ffmpeg.org//pipermail/ffmpeg-devel/2024-April/326317.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 v2] avformat/mov: free the infe allocated item data on failure
Signed-off-by: James Almer --- libavformat/mov.c | 30 -- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ede25d3342..9e95c6fcc0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -84,6 +84,7 @@ typedef struct MOVParseTableEntry { static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom); static int mov_read_mfra(MOVContext *c, AVIOContext *f); +static void mov_free_stream_context(AVFormatContext *s, AVStream *st); static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size, int count, int duration); @@ -8181,7 +8182,7 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, MOVAtom atom) { HEIFItem *heif_item; int entry_count; -int version, ret; +int version, got_stream = 0, ret, i; if (c->found_iinf) { av_log(c->fc, AV_LOG_WARNING, "Duplicate iinf box found\n"); @@ -8201,20 +8202,33 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, MOVAtom atom) sizeof(*c->heif_item) * (entry_count - c->nb_heif_item)); c->nb_heif_item = FFMAX(c->nb_heif_item, entry_count); -for (int i = 0; i < entry_count; i++) { +for (i = 0; i < entry_count; i++) { MOVAtom infe; infe.size = avio_rb32(pb) - 8; infe.type = avio_rl32(pb); ret = mov_read_infe(c, pb, infe, i); if (ret < 0) -return ret; -if (ret) -return 0; +goto fail; +if (!ret) +got_stream = 1; } -c->found_iinf = 1; +c->found_iinf = got_stream; return 0; +fail: +for (; i >= 0; i--) { +HEIFItem *item = &c->heif_item[i]; + +av_freep(&item->name); +if (!item->st) +continue; + +mov_free_stream_context(c->fc, item->st); +ff_remove_stream(c->fc, item->st); +item->st = NULL; +} +return ret; } static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version) @@ -9561,6 +9575,10 @@ static int mov_read_header(AVFormatContext *s) return err; } } +// prevent iloc and iinf boxes from being parsed while reading packets. +// this is needed because an iinf box may have been parsed but ignored +// for having old infe boxes which create no streams. +mov->found_iloc = mov->found_iinf = 1; if (pb->seekable & AVIO_SEEKABLE_NORMAL) { if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters) -- 2.44.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, v2] libavcodec/amfenc: Update AMF encoder options
Encoder options have been updated to the current version of the AMF. Signed-off-by: Araz Iusubov --- libavcodec/amfenc_av1.c | 108 +++-- libavcodec/amfenc_h264.c | 146 +-- libavcodec/amfenc_hevc.c | 143 +- 3 files changed, 259 insertions(+), 138 deletions(-) diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index 9f18aac648..d40c71cb33 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -25,15 +25,16 @@ #define OFFSET(x) offsetof(AmfContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{ "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING }, AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING, AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY, VE, .unit = "usage" }, -{ "transcoding","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING }, 0, 0, VE, .unit = "usage" }, -{ "lowlatency", "", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY }, 0, 0, VE, .unit = "usage" }, -{ "profile","Set the profile (default main)", OFFSET(profile),AV_OPT_TYPE_INT,{.i64 = AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN }, AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, VE, .unit = "profile" }, +{ "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY, VE, .unit = "usage" }, +{ "transcoding","Generic Transcoding", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING }, 0, 0, VE, .unit = "usage" }, +{ "lowlatency", "Low latency usecase", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY }, 0, 0, VE, .unit = "usage" }, + +{ "profile","Set the profile", OFFSET(profile), AV_OPT_TYPE_INT,{.i64 = -1 }, -1, AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN, VE, .unit = "profile" }, { "main", "", 0, AV_OPT_TYPE_CONST,{.i64 = AMF_VIDEO_ENCODER_AV1_PROFILE_MAIN }, 0, 0, VE, .unit = "profile" }, -{ "level", "Set the encoding level (default auto)", OFFSET(level), AV_OPT_TYPE_INT,{.i64 = 0 }, 0, AMF_VIDEO_ENCODER_AV1_LEVEL_7_3, VE, .unit = "level" }, -{ "auto", "", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, VE, .unit = "level" }, +{ "level", "Set the encoding level (default auto)", OFFSET(level), AV_OPT_TYPE_INT,{.i64 = -1 }, -1, AMF_VIDEO_ENCODER_AV1_LEVEL_7_3, VE, .unit = "level" }, +{ "auto", "", 0, AV_OPT_TYPE_CONST, {.i64 = -1 }, 0, 0, VE, .unit = "level" }, { "2.0","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_LEVEL_2_0 }, 0, 0, VE, .unit = "level" }, { "2.1","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_LEVEL_2_1 }, 0, 0, VE, .unit = "level" }, { "2.2","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_LEVEL_2_2 }, 0, 0, VE, .unit = "level" }, @@ -59,11 +60,12 @@ static const AVOption options[] = { { "7.2","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_LEVEL_7_2 }, 0, 0, VE, .unit = "level" }, { "7.3","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_LEVEL_7_3 }, 0, 0, VE, .unit = "level" }, -{ "quality","Set the encoding quality", OFFSET(quality),AV_OPT_TYPE_INT, {.i64 = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED }, AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY, AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" }, +{ "quality","Set the encoding quality preset", OFFSET(quality), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" }, +{ "preset", "Set the encoding quality preset", OFFSET(quality), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED, VE, .unit = "quality" }, +{ "high_quality", "", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY }, 0, 0, VE, .unit = "quality" }, +{ "quality","", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_QUALITY }, 0, 0, VE, .unit = "quality" }, { "balanced", "", 0, AV_OPT_TYPE_CONST, {.i64 = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_BALANCED
Re: [FFmpeg-devel] [PATCH] fate: allow https for git URLs
On 24.04.2024 22:01, Timo Rothenpieler wrote: --- tests/fate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fate.sh b/tests/fate.sh index c5ee18de80..4081e865ae 100755 --- a/tests/fate.sh +++ b/tests/fate.sh @@ -30,14 +30,14 @@ lock(){ checkout(){ case "$repo" in file:*|/*) src="${repo#file:}" ;; -git:*) git clone --quiet --branch "$branch" "$repo" "$src" ;; +git:*|https:*) git clone --quiet --branch "$branch" "$repo" "$src" ;; esac } update()( cd ${src} || return case "$repo" in -git:*) git fetch --quiet --force && git reset --quiet --hard "origin/$branch" ;; +git:*|https:*) git fetch --quiet --force && git reset --quiet --hard "origin/$branch" ;; esac ) applied ___ 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] configure: support msvc build inside WSL
On 27.04.2024 22:21, Sean McGovern wrote: Aside: We are now that much closer to summoning a demon inside 'configure' *laughs*. The reasoning behind this complexification in v2 is that v1 put the string returned by cl.exe into a shell, allowing potential injection vectors. Granted, the injection would come from inside ffmpeg code, so probably all would be lost at that point anyway, but at the very least, this approach avoids spawning a bunch of subshells we don't need, though is quite a bit uglier. ___ 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] configure: support msvc build inside WSL
On Sat, Apr 27, 2024, 16:15 Timo Rothenpieler wrote: > --- > configure | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/configure b/configure > index 8101b4fce6..89af5f75e7 100755 > --- a/configure > +++ b/configure > @@ -5036,7 +5036,12 @@ probe_cc(){ > else > _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r') > fi > -_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | > awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if > (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' > +if [ -x "$(command -v wslpath)" ]; then > +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 > | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { > print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf > "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' > > $(@:.o=.d)' > + > +else > +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 > | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if > (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' > +fi > _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' > _cflags_speed="-O2" > _cflags_size="-O1" > -- > 2.43.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". > Aside: We are now that much closer to summoning a demon inside 'configure' *laughs*. -- Sean McGovern > ___ 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] configure: support msvc build inside WSL
--- configure | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 8101b4fce6..89af5f75e7 100755 --- a/configure +++ b/configure @@ -5036,7 +5036,12 @@ probe_cc(){ else _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r') fi -_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' +if [ -x "$(command -v wslpath)" ]; then +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' > $(@:.o=.d)' + +else +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' +fi _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" -- 2.43.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] [RFC] 5 year plan & Inovation
On Sat Apr 27, 2024 at 12:24 PM CEST, Michael Niedermayer wrote: > A phone originally was a tool to call and talk to someone, to be reachable by > voice communication. > Its not a tool to write letters, until it was > Its not a tool to browse the internet until it was > Its not an assitent you could ask something until it was > ... > > A internet browser originally was a tool to display static text and images > maybe some ftp and gopher sprinkled into it. > its not a tool to do video chat with , until it was > its not a tool to write mails in, until it was > its not a tool to submit your patches to git, until it was, ohh wait, i have > a deja vue feeling here And arguably both of them are terrible at these additional tasks. I will take my terminal-based email client over a web browser any day, thank you. To quote Doug McIlroy: > Write programs that do one thing and do it well. ___ 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/iamfdec: check nb_streams in header read
Fixes: Assertion pkt->stream_index < (unsigned)s->nb_streams && "Invalid stream index.\n" failed at libavformat/demux.c:572 Fixes: 67890/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5166340789829632.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/iamfdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c index e34d13e74c5..ce6d4aa0647 100644 --- a/libavformat/iamfdec.c +++ b/libavformat/iamfdec.c @@ -154,6 +154,9 @@ static int iamf_read_header(AVFormatContext *s) } } +if (!s->nb_streams) +return AVERROR_INVALIDDATA; + return 0; } -- 2.43.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 4/5] avcodec/hevcdec: Check ref frame
On Sat, Apr 27, 2024 at 12:14:18PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: NULL pointer dereferences > > Fixes: > > 68197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6382538823106560 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/hevcdec.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > > index fcfb275f63a..92b0e45eee0 100644 > > --- a/libavcodec/hevcdec.c > > +++ b/libavcodec/hevcdec.c > > @@ -1969,13 +1969,13 @@ static void hls_prediction_unit(HEVCLocalContext > > *lc, int x0, int y0, > > > > if (current_mv.pred_flag & PF_L0) { > > ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; > > -if (!ref0 || !ref0->frame->data[0]) > > +if (!ref0 || !ref0->frame || !ref0->frame->data[0]) > > return; > > hevc_await_progress(s, ref0, ¤t_mv.mv[0], y0, nPbH); > > } > > if (current_mv.pred_flag & PF_L1) { > > ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; > > -if (!ref1 || !ref1->frame->data[0]) > > +if (!ref1 || !ref1->frame || !ref1->frame->data[0]) > > return; > > hevc_await_progress(s, ref1, ¤t_mv.mv[1], y0, nPbH); > > } > > Same as with 1/5: Checking for !ref0->frame is enough as HEVCFrame.f is > set if and only if the HEVCFrame.f->data[0] is set (with the possible will apply with this simplification thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad 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 2/5] avcodec/vp3: Call ff_progress_frame_unref() before ff_progress_frame_get_buffer()
Hi On Sat, Apr 27, 2024 at 11:47:32AM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: Assertion !f->f && !f->progress failed at libavcodec/decode.c:1688 > > Fixes: > > 68190/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5942090287611904 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/vp3.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c > > index 2a5f68dfa8e..09527607767 100644 > > --- a/libavcodec/vp3.c > > +++ b/libavcodec/vp3.c > > @@ -2651,6 +2651,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, > > AVFrame *frame, > > if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe) > > return buf_size; > > > > +ff_progress_frame_unref(&s->current_frame); > > ret = ff_progress_frame_get_buffer(avctx, &s->current_frame, > > AV_GET_BUFFER_FLAG_REF); > > if (ret < 0) { > > LGTM. will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator 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 1/5] avcodec/pngdec: Check last AVFrame before deref
On Sat, Apr 27, 2024 at 11:36:30AM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: NULL pointer dereference > > Fixes: > > 68184/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-4926478069334016 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/pngdec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c > > index f7751223b81..b24bfa248dc 100644 > > --- a/libavcodec/pngdec.c > > +++ b/libavcodec/pngdec.c > > @@ -1218,7 +1218,7 @@ static int decode_fctl_chunk(AVCodecContext *avctx, > > PNGDecContext *s, > > return AVERROR_INVALIDDATA; > > } > > > > -if ((sequence_number == 0 || !s->last_picture.f->data[0]) && > > +if ((sequence_number == 0 || !s->last_picture.f || > > !s->last_picture.f->data[0]) && > > dispose_op == APNG_DISPOSE_OP_PREVIOUS) { > > // No previous frame to revert to for the first frame > > // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND > > Just checking for !s->last_picture.f is enough -- s->last_picture.f is > set if and only if s->last_picture.f->data[0] is set. ok will apply with that simplified thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is a danger to trust the dream we wish for rather than the science we have, -- Dr. Kenneth Brown 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 1/6] avformat/mov: Check tile_item_list
On Fri, Apr 26, 2024 at 09:30:50AM -0300, James Almer wrote: > On 4/26/2024 12:08 AM, Michael Niedermayer wrote: > > Fixes: Null pointer dereference > > Fixes: > > 67861/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5352628142800896 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/mov.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index ecd29a7d08b..97a24e6737e 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -9289,6 +9289,9 @@ static int read_image_grid(AVFormatContext *s, const > > HEIFGrid *grid, > > if (tile_grid->nb_tiles != size) > > return AVERROR_INVALIDDATA; > > +for (int i = 0; i < size; i++) > > +if (!grid->tile_item_list[i]) > > +return AVERROR_INVALIDDATA; > > for (int i = 0; i < tile_cols; i++) > > tile_grid->coded_width += grid->tile_item_list[i]->width; > > for (int i = 0; i < size; i += tile_cols) > > We shouldn't get this far if that's NULL. Does the following also work? > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index ecd29a7d08..b21c4b6f3c 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -9440,7 +9440,7 @@ static int mov_parse_tiles(AVFormatContext *s) > > break; > > } > > > > -if (k == grid->nb_tiles) { > > +if (k == mov->nb_heif_item) { works, please apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. 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] [RFC] 5 year plan & Inovation
lör 2024-04-27 klockan 12:53 +0200 skrev Michael Niedermayer: > On Thu, Apr 25, 2024 at 12:26:00PM +0200, Tomas Härdin wrote: > > tor 2024-04-25 klockan 02:07 +0200 skrev Michael Niedermayer: > > > On Thu, Apr 25, 2024 at 12:50:02AM +0200, Tomas Härdin wrote: > > > > ons 2024-04-17 klockan 15:58 +0200 skrev Michael Niedermayer: > > > > > > > > > * ffchat > > > > > (expand into realtime chat / zoom) this would > > > > > bring in more users and developers, and we basically have > > > > > almost > > > > > all parts for it already but some people where against it > > > > > > > > You mean inventing a new chat protocol? If so then please > > > > don't. We > > > > > > If theres an existing protocol that serves the purpose then > > > theres no > > > need to invent a new one > > > > > > I think at a minimum it should have "secure and private by > > > default > > > and always" > > > (there are many solutions already when one is willing to give up > > > security/privacy) > > > > "Security" and "privacy" are relative terms. > > yes, more security and privacy is better Not always. More security is typically more work. For example TOFU (trust on first use) is easy but you should really compare fingerprints. The latter is more work however. I've worked with helping people who have a need or even a legal obligation to secure their chats, such as journalists. This is non- trivial. Have you done the necessary research on this? > > If you want end-to-end encryption in a federated system then > > XMPP+OMEMO > > is the way to go. Or Matrix I guess, but it isn't standardized last > > time I checked. > > > > If you want metadata resistance then Briar is the way to go. It's a > > peer-to-peer store-and-forward network that tunnels all its > > internet > > traffic through Tor, and also supports synchronizing messages over > > WiFi > > Direct and Bluetooth. > > > > There's also GNUnet and its associated protocols like psyc. > > > > Short of using some complicated thing involving data diodes you're > > not > > likely to do better than what's already out there. And nothing > > beats > > not using computers at all. > > sure, i agree, we should use existing protocols whenever one exists > for a purpose already ... > > libavformat supports, RTP, RTSP, MMS, HLS, RTMP and probably more > we support audio, video, data and text packets/streams > > So adding support for some more secure/private protocols is > within the scope of libavformat. I'm curious what protocols you have in mind, assuming we're still talking multimedia. Taking XMPP as an example, multimedia attachments are handled via HTTP upload, meaning playback only depends on HTTP(S) support. I expect most XMPP clients already leverage libav* for playback > And it would allow all multimedia players to use these more secure > means of communicating. Why do media players need chat functionality? Should we implement email while we're at it? > As well as writing dedicated secure chat applications on > top of libavformat. I can imagine many things more pleasant than writing a chat system on top of lavf, such as eating sand. Or even worse, having to take such systems into consideration when attempting to refactor lavf.. > This would bring in more users and developers Outreach would likely be more effective, and far less work /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] [PATCH WIP 9/9] avfilter/dnn: Use dnn_backend_info_list to search for dnn module
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_openvino.c | 1 + libavfilter/dnn/dnn_backend_tf.c | 1 + libavfilter/dnn/dnn_backend_torch.cpp | 1 + libavfilter/dnn/dnn_interface.c| 26 -- libavfilter/dnn_interface.h| 1 + 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index d8a6820dc2..9c699cdc8c 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -1613,6 +1613,7 @@ static int dnn_flush_ov(const DNNModel *model) const DNNModule ff_dnn_backend_openvino = { .clazz = DNN_DEFINE_CLASS(dnn_openvino), +.type = DNN_OV, .load_model = dnn_load_model_ov, .execute_model = dnn_execute_model_ov, .get_result = dnn_get_result_ov, diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 06ea6cbb8c..6afefe8115 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -886,6 +886,7 @@ static int dnn_flush_tf(const DNNModel *model) const DNNModule ff_dnn_backend_tf = { .clazz = DNN_DEFINE_CLASS(dnn_tensorflow), +.type = DNN_TF, .load_model = dnn_load_model_tf, .execute_model = dnn_execute_model_tf, .get_result = dnn_get_result_tf, diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp index 24e9f2c8e2..2557264713 100644 --- a/libavfilter/dnn/dnn_backend_torch.cpp +++ b/libavfilter/dnn/dnn_backend_torch.cpp @@ -561,6 +561,7 @@ static int dnn_flush_th(const DNNModel *model) extern const DNNModule ff_dnn_backend_torch = { .clazz = DNN_DEFINE_CLASS(dnn_th), +.type = DNN_TH, .load_model = dnn_load_model_th, .execute_model = dnn_execute_model_th, .get_result = dnn_get_result_th, diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c index 245fe5f759..76fe364a47 100644 --- a/libavfilter/dnn/dnn_interface.c +++ b/libavfilter/dnn/dnn_interface.c @@ -80,25 +80,15 @@ static const DnnBackendInfo dnn_backend_info_list[] = { const DNNModule *ff_get_dnn_module(DNNBackendType backend_type, void *log_ctx) { -switch(backend_type){ -#if (CONFIG_LIBTENSORFLOW == 1) -case DNN_TF: -return &ff_dnn_backend_tf; -#endif -#if (CONFIG_LIBOPENVINO == 1) -case DNN_OV: -return &ff_dnn_backend_openvino; -#endif -#if (CONFIG_LIBTORCH == 1) -case DNN_TH: -return &ff_dnn_backend_torch; -#endif -default: -av_log(log_ctx, AV_LOG_ERROR, -"Module backend_type %d is not supported or enabled.\n", -backend_type); -return NULL; +for (int i = 1; i < FF_ARRAY_ELEMS(dnn_backend_info_list); i++) { +if (dnn_backend_info_list[i].module->type == backend_type) +return dnn_backend_info_list[i].module; } + +av_log(log_ctx, AV_LOG_ERROR, +"Module backend_type %d is not supported or enabled.\n", +backend_type); +return NULL; } void *ff_dnn_child_next(DnnContext *obj, void *prev) { diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index 2b35c9c9fb..3fe88d4029 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -170,6 +170,7 @@ typedef struct DnnContext { // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends. struct DNNModule { const AVClass clazz; +DNNBackendType type; // Loads model and parameters from given file. Returns NULL if it is not possible. DNNModel *(*load_model)(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx); // Executes model with specified input and output. Returns the error code otherwise. -- 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 WIP 7/9] avfilter/dnn_backend_torch: Simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_torch.cpp | 31 +++ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp index abdef1f178..818ec5b713 100644 --- a/libavfilter/dnn/dnn_backend_torch.cpp +++ b/libavfilter/dnn/dnn_backend_torch.cpp @@ -37,8 +37,8 @@ extern "C" { } typedef struct THModel { +DNNModel model; DnnContext *ctx; -DNNModel *model; torch::jit::Module *jit_model; SafeQueue *request_queue; Queue *task_queue; @@ -141,7 +141,7 @@ static void dnn_free_model_th(DNNModel **model) ff_queue_destroy(th_model->task_queue); delete th_model->jit_model; av_freep(&th_model); -av_freep(model); +*model = NULL; } static int get_input_th(void *model, DNNData *input, const char *input_name) @@ -195,19 +195,19 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request) infer_request->input_tensor = new torch::Tensor(); infer_request->output = new torch::Tensor(); -switch (th_model->model->func_type) { +switch (th_model->model.func_type) { case DFT_PROCESS_FRAME: input.scale = 255; if (task->do_ioproc) { -if (th_model->model->frame_pre_proc != NULL) { -th_model->model->frame_pre_proc(task->in_frame, &input, th_model->model->filter_ctx); +if (th_model->model.frame_pre_proc != NULL) { +th_model->model.frame_pre_proc(task->in_frame, &input, th_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } } break; default: -avpriv_report_missing_feature(NULL, "model function type %d", th_model->model->func_type); +avpriv_report_missing_feature(NULL, "model function type %d", th_model->model.func_type); break; } *infer_request->input_tensor = torch::from_blob(input.data, @@ -282,13 +282,13 @@ static void infer_completion_callback(void *args) { goto err; } -switch (th_model->model->func_type) { +switch (th_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { outputs.scale = 255; outputs.data = output->data_ptr(); -if (th_model->model->frame_post_proc != NULL) { -th_model->model->frame_post_proc(task->out_frame, &outputs, th_model->model->filter_ctx); +if (th_model->model.frame_post_proc != NULL) { +th_model->model.frame_post_proc(task->out_frame, &outputs, th_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, &outputs, th_model->ctx); } @@ -298,7 +298,7 @@ static void infer_completion_callback(void *args) { } break; default: -avpriv_report_missing_feature(th_model->ctx, "model function type %d", th_model->model->func_type); +avpriv_report_missing_feature(th_model->ctx, "model function type %d", th_model->model.func_type); goto err; } task->inference_done++; @@ -417,17 +417,10 @@ static DNNModel *dnn_load_model_th(DnnContext *ctx, DNNFunctionType func_type, A THRequestItem *item = NULL; const char *device_name = ctx->device ? ctx->device : "cpu"; -model = (DNNModel *)av_mallocz(sizeof(DNNModel)); -if (!model) { -return NULL; -} - th_model = (THModel *)av_mallocz(sizeof(THModel)); -if (!th_model) { -av_freep(&model); +if (!th_model) return NULL; -} -th_model->model = model; +model = &th_model->model; model->model = th_model; th_model->ctx = ctx; -- 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 WIP 8/9] avfilter/dnn: Remove a level of dereference
From: Zhao Zhili For code such as 'model->model = ov_model' is confusing. We can just drop the member variable and use cast to get the subclass. --- libavfilter/dnn/dnn_backend_openvino.c | 17 - libavfilter/dnn/dnn_backend_tf.c | 19 +-- libavfilter/dnn/dnn_backend_torch.cpp | 15 +++ libavfilter/dnn_filter_common.c| 6 +++--- libavfilter/dnn_interface.h| 6 ++ 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 1acc54b791..d8a6820dc2 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -517,7 +517,7 @@ static void dnn_free_model_ov(DNNModel **model) if (!model || !*model) return; -ov_model = (*model)->model; +ov_model = (OVModel *)(*model); while (ff_safe_queue_size(ov_model->request_queue) != 0) { OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue); if (item && item->infer_request) { @@ -1059,9 +1059,9 @@ err: return ret; } -static int get_input_ov(void *model, DNNData *input, const char *input_name) +static int get_input_ov(DNNModel *model, DNNData *input, const char *input_name) { -OVModel *ov_model = model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; int input_resizable = ctx->ov_option.input_resizable; @@ -1255,7 +1255,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q } } -static int get_output_ov(void *model, const char *input_name, int input_width, int input_height, +static int get_output_ov(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height) { #if HAVE_OPENVINO2 @@ -1268,7 +1268,7 @@ static int get_output_ov(void *model, const char *input_name, int input_width, i input_shapes_t input_shapes; #endif int ret; -OVModel *ov_model = model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; TaskItem task; OVRequestItem *request; @@ -1383,7 +1383,6 @@ static DNNModel *dnn_load_model_ov(DnnContext *ctx, DNNFunctionType func_type, A return NULL; ov_model->ctx = ctx; model = &ov_model->model; -model->model = ov_model; #if HAVE_OPENVINO2 status = ov_core_create(&core); @@ -1470,7 +1469,7 @@ err: static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_params) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; OVRequestItem *request; TaskItem *task; @@ -1558,13 +1557,13 @@ static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_p static DNNAsyncStatusType dnn_get_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; return ff_dnn_get_result_common(ov_model->task_queue, in, out); } static int dnn_flush_ov(const DNNModel *model) { -OVModel *ov_model = model->model; +OVModel *ov_model = (OVModel *)model; DnnContext *ctx = ov_model->ctx; OVRequestItem *request; #if HAVE_OPENVINO2 diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index c7716e696d..06ea6cbb8c 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -262,9 +262,9 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input) input_dims[1] * input_dims[2] * input_dims[3] * size); } -static int get_input_tf(void *model, DNNData *input, const char *input_name) +static int get_input_tf(DNNModel *model, DNNData *input, const char *input_name) { -TFModel *tf_model = model; +TFModel *tf_model = (TFModel *)model; DnnContext *ctx = tf_model->ctx; TF_Status *status; TF_DataType dt; @@ -310,11 +310,11 @@ static int get_input_tf(void *model, DNNData *input, const char *input_name) return 0; } -static int get_output_tf(void *model, const char *input_name, int input_width, int input_height, +static int get_output_tf(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height) { int ret; -TFModel *tf_model = model; +TFModel *tf_model = (TFModel *)model; DnnContext *ctx = tf_model->ctx; TaskItem task; TFRequestItem *request; @@ -486,7 +486,7 @@ static void dnn_free_model_tf(DNNModel **model) if (!model || !*model) return; -tf_model = (*model)->model; +tf_model = (TFModel *)(*model); while (ff_safe_queue_size(tf_model->request_queue) != 0) { TFRequestItem *item = ff_safe_queue_pop_front(tf_model->re
[FFmpeg-devel] [PATCH WIP 4/9] avfilter/dnn_backend_tf: Remove one level of indentation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_tf.c | 63 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index d24591b90b..60f9e57fb7 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -483,41 +483,42 @@ static void dnn_free_model_tf(DNNModel **model) { TFModel *tf_model; -if (*model){ -tf_model = (*model)->model; -while (ff_safe_queue_size(tf_model->request_queue) != 0) { -TFRequestItem *item = ff_safe_queue_pop_front(tf_model->request_queue); -destroy_request_item(&item); -} -ff_safe_queue_destroy(tf_model->request_queue); +if (!model || !*model) +return; -while (ff_queue_size(tf_model->lltask_queue) != 0) { -LastLevelTaskItem *item = ff_queue_pop_front(tf_model->lltask_queue); -av_freep(&item); -} -ff_queue_destroy(tf_model->lltask_queue); +tf_model = (*model)->model; +while (ff_safe_queue_size(tf_model->request_queue) != 0) { +TFRequestItem *item = ff_safe_queue_pop_front(tf_model->request_queue); +destroy_request_item(&item); +} +ff_safe_queue_destroy(tf_model->request_queue); -while (ff_queue_size(tf_model->task_queue) != 0) { -TaskItem *item = ff_queue_pop_front(tf_model->task_queue); -av_frame_free(&item->in_frame); -av_frame_free(&item->out_frame); -av_freep(&item); -} -ff_queue_destroy(tf_model->task_queue); +while (ff_queue_size(tf_model->lltask_queue) != 0) { +LastLevelTaskItem *item = ff_queue_pop_front(tf_model->lltask_queue); +av_freep(&item); +} +ff_queue_destroy(tf_model->lltask_queue); -if (tf_model->graph){ -TF_DeleteGraph(tf_model->graph); -} -if (tf_model->session){ -TF_CloseSession(tf_model->session, tf_model->status); -TF_DeleteSession(tf_model->session, tf_model->status); -} -if (tf_model->status){ -TF_DeleteStatus(tf_model->status); -} -av_freep(&tf_model); -av_freep(&model); +while (ff_queue_size(tf_model->task_queue) != 0) { +TaskItem *item = ff_queue_pop_front(tf_model->task_queue); +av_frame_free(&item->in_frame); +av_frame_free(&item->out_frame); +av_freep(&item); +} +ff_queue_destroy(tf_model->task_queue); + +if (tf_model->graph){ +TF_DeleteGraph(tf_model->graph); +} +if (tf_model->session){ +TF_CloseSession(tf_model->session, tf_model->status); +TF_DeleteSession(tf_model->session, tf_model->status); +} +if (tf_model->status){ +TF_DeleteStatus(tf_model->status); } +av_freep(&tf_model); +av_freep(&model); } static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx) -- 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 WIP 5/9] avfilter/dnn_backend_tf: Fix free context at random place
From: Zhao Zhili It will be freed again by ff_dnn_uninit. --- libavfilter/dnn/dnn_backend_tf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 60f9e57fb7..3b4de6d13f 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -804,7 +804,7 @@ err: if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) { destroy_request_item(&request); } -dnn_free_model_tf(&tf_model->model); + return ret; } -- 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 WIP 3/9] avfilter/dnn_backend_openvino: simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_openvino.c | 47 +++--- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 769ba0a54b..1acc54b791 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -41,8 +41,8 @@ #include "dnn_backend_common.h" typedef struct OVModel{ +DNNModel model; DnnContext *ctx; -DNNModel *model; #if HAVE_OPENVINO2 ov_core_t *core; ov_model_t *ov_model; @@ -300,11 +300,11 @@ static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request) return ov2_map_error(status, NULL); } #endif -switch (ov_model->model->func_type) { +switch (ov_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (ov_model->model->frame_pre_proc != NULL) { -ov_model->model->frame_pre_proc(task->in_frame, &input, ov_model->model->filter_ctx); +if (ov_model->model.frame_pre_proc != NULL) { +ov_model->model.frame_pre_proc(task->in_frame, &input, ov_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } @@ -442,11 +442,11 @@ static void infer_completion_callback(void *args) for (int i = 0; i < request->lltask_count; ++i) { task = request->lltasks[i]->task; -switch (ov_model->model->func_type) { +switch (ov_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (ov_model->model->frame_post_proc != NULL) { -ov_model->model->frame_post_proc(task->out_frame, outputs, ov_model->model->filter_ctx); +if (ov_model->model.frame_post_proc != NULL) { +ov_model->model.frame_post_proc(task->out_frame, outputs, ov_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, outputs, ctx); } @@ -458,23 +458,23 @@ static void infer_completion_callback(void *args) } break; case DFT_ANALYTICS_DETECT: -if (!ov_model->model->detect_post_proc) { +if (!ov_model->model.detect_post_proc) { av_log(ctx, AV_LOG_ERROR, "detect filter needs to provide post proc\n"); goto end; } -ov_model->model->detect_post_proc(task->in_frame, outputs, +ov_model->model.detect_post_proc(task->in_frame, outputs, ov_model->nb_outputs, - ov_model->model->filter_ctx); + ov_model->model.filter_ctx); break; case DFT_ANALYTICS_CLASSIFY: -if (!ov_model->model->classify_post_proc) { +if (!ov_model->model.classify_post_proc) { av_log(ctx, AV_LOG_ERROR, "classify filter needs to provide post proc\n"); goto end; } for (int output_i = 0; output_i < ov_model->nb_outputs; output_i++) -ov_model->model->classify_post_proc(task->in_frame, outputs, +ov_model->model.classify_post_proc(task->in_frame, outputs, request->lltasks[i]->bbox_index, - ov_model->model->filter_ctx); + ov_model->model.filter_ctx); break; default: av_assert0(!"should not reach here"); @@ -571,7 +571,7 @@ static void dnn_free_model_ov(DNNModel **model) av_free(ov_model->all_input_names); #endif av_freep(&ov_model); -av_freep(model); +*model = NULL; } @@ -598,7 +598,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * #endif // We scale pixel by default when do frame processing. if (fabsf(ctx->ov_option.scale) < 1e-6f) -ctx->ov_option.scale = ov_model->model->func_type == DFT_PROCESS_FRAME ? 255 : 1; +ctx->ov_option.scale = ov_model->model.func_type == DFT_PROCESS_FRAME ? 255 : 1; // batch size if (ctx->ov_option.batch_size <= 0) { ctx->ov_option.batch_size = 1; @@ -702,7 +702,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char * ret = ov2_map_error(status, NULL); goto err; } -if (ov_model->model->func_type != DFT_PROCESS_FRAME) +if (ov_model->model.func_type != DFT_PROCESS_FRAME) status |= ov_preprocess_output_set_element_type(output_tensor_info, F32); else if (fabsf(ctx->ov_option.scale - 1) > 1e-6f || fabsf(ctx->ov_option.mean) > 1e-6f)
[FFmpeg-devel] [PATCH WIP 6/9] avfilter/dnn_backend_tf: Simplify memory allocation
From: Zhao Zhili --- libavfilter/dnn/dnn_backend_tf.c | 33 +--- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 3b4de6d13f..c7716e696d 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -37,8 +37,8 @@ #include typedef struct TFModel { +DNNModel model; DnnContext *ctx; -DNNModel *model; TF_Graph *graph; TF_Session *session; TF_Status *status; @@ -518,7 +518,7 @@ static void dnn_free_model_tf(DNNModel **model) TF_DeleteStatus(tf_model->status); } av_freep(&tf_model); -av_freep(&model); +*model = NULL; } static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx) @@ -526,18 +526,11 @@ static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, A DNNModel *model = NULL; TFModel *tf_model = NULL; -model = av_mallocz(sizeof(DNNModel)); -if (!model){ -return NULL; -} - tf_model = av_mallocz(sizeof(TFModel)); -if (!tf_model){ -av_freep(&model); +if (!tf_model) return NULL; -} +model = &tf_model->model; model->model = tf_model; -tf_model->model = model; tf_model->ctx = ctx; if (load_tf_model(tf_model, ctx->model_filename) != 0){ @@ -650,11 +643,11 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) { } input.data = (float *)TF_TensorData(infer_request->input_tensor); -switch (tf_model->model->func_type) { +switch (tf_model->model.func_type) { case DFT_PROCESS_FRAME: if (task->do_ioproc) { -if (tf_model->model->frame_pre_proc != NULL) { -tf_model->model->frame_pre_proc(task->in_frame, &input, tf_model->model->filter_ctx); +if (tf_model->model.frame_pre_proc != NULL) { +tf_model->model.frame_pre_proc(task->in_frame, &input, tf_model->model.filter_ctx); } else { ff_proc_from_frame_to_dnn(task->in_frame, &input, ctx); } @@ -664,7 +657,7 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) { ff_frame_to_dnn_detect(task->in_frame, &input, ctx); break; default: -avpriv_report_missing_feature(ctx, "model function type %d", tf_model->model->func_type); +avpriv_report_missing_feature(ctx, "model function type %d", tf_model->model.func_type); break; } @@ -724,12 +717,12 @@ static void infer_completion_callback(void *args) { outputs[i].data = TF_TensorData(infer_request->output_tensors[i]); outputs[i].dt = (DNNDataType)TF_TensorType(infer_request->output_tensors[i]); } -switch (tf_model->model->func_type) { +switch (tf_model->model.func_type) { case DFT_PROCESS_FRAME: //it only support 1 output if it's frame in & frame out if (task->do_ioproc) { -if (tf_model->model->frame_post_proc != NULL) { -tf_model->model->frame_post_proc(task->out_frame, outputs, tf_model->model->filter_ctx); +if (tf_model->model.frame_post_proc != NULL) { +tf_model->model.frame_post_proc(task->out_frame, outputs, tf_model->model.filter_ctx); } else { ff_proc_from_dnn_to_frame(task->out_frame, outputs, ctx); } @@ -741,11 +734,11 @@ static void infer_completion_callback(void *args) { } break; case DFT_ANALYTICS_DETECT: -if (!tf_model->model->detect_post_proc) { +if (!tf_model->model.detect_post_proc) { av_log(ctx, AV_LOG_ERROR, "Detect filter needs provide post proc\n"); return; } -tf_model->model->detect_post_proc(task->in_frame, outputs, task->nb_output, tf_model->model->filter_ctx); +tf_model->model.detect_post_proc(task->in_frame, outputs, task->nb_output, tf_model->model.filter_ctx); break; default: av_log(ctx, AV_LOG_ERROR, "Tensorflow backend does not support this kind of dnn filter now\n"); -- 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 WIP 1/9] avfilter/dnn: Refactor DNN parameter configuration system
From: Zhao Zhili This patch trying to resolve mulitiple issues related to parameter configuration: Firstly, each DNN filters duplicate DNN_COMMON_OPTIONS, which should be the common options of backend. Secondly, backend options are hidden behind the scene. It's a AV_OPT_TYPE_STRING backend_configs for user, and parsed by each backend. We don't know each backend support what kind of options from the help message. Third, DNN backends duplicate DNN_BACKEND_COMMON_OPTIONS. Last but not the least, pass backend options via AV_OPT_TYPE_STRING makes it hard to pass AV_OPT_TYPE_BINARY to backend, if not impossible. This patch puts backend common options and each backend options inside DnnContext to reduce code duplication, make options user friendly, and easy to extend for future usecase. There is a known issue that, for a filter which only support one or two of the backends, the help message still show the option of all three backend. Each DNN filter should be able to run on any backend. Current issue is mostly due to incomplete implementation of backend (e.g., only support DFT_PROCESS_FRAME with libtorch backedn), and lack of maintenance on the filters. For example, ./ffmpeg -h filter=dnn_processing dnn_processing AVOptions: dnn_backend ..FV... DNN backend (from INT_MIN to INT_MAX) (default tensorflow) tensorflow 1..FV... tensorflow backend flag openvino2..FV... openvino backend flag torch 3..FV... torch backend flag dnn_base AVOptions: model ..F path to model file input ..F input name of the model output ..F output name of the model backend_configs..F...P backend configs (deprecated) options..F...P backend configs (deprecated) async ..F use DNN async inference (ignored, use backend_configs='async=1') (default true) nireq ..F number of request (from 0 to INT_MAX) (default 0) async ..F use DNN async inference (default true) device ..F device to run model dnn_tensorflow AVOptions: sess_config..F config for SessionOptions dnn_openvino AVOptions: batch_size..F batch size per request (from 1 to 1000) (default 1) input_resizable ..F can input be resizable or not (default false) layout..F input layout of model (from 0 to 2) (default none) none0..F none nchw1..F nchw nhwc2..F nhwc scale ..F Add scale preprocess operation. Divide each element of input by specified value. (from INT_MIN to INT_MAX) (default 0) mean..F Add mean preprocess operation. Subtract specified value from each element of input. (from INT_MIN to INT_MAX) (default 0) dnn_th AVOptions: optimize ..F turn on graph executor optimization (from 0 to 1) (default 0) --- libavfilter/dnn/dnn_backend_common.h | 13 ++- libavfilter/dnn/dnn_backend_openvino.c | 146 ++--- libavfilter/dnn/dnn_backend_tf.c | 82 +- libavfilter/dnn/dnn_backend_torch.cpp | 67 libavfilter/dnn/dnn_interface.c| 81 ++ libavfilter/dnn_filter_common.c| 32 +- libavfilter/dnn_filter_common.h| 37 +++ libavfilter/dnn_interface.h| 66 ++- libavfilter/vf_derain.c| 5 +- libavfilter/vf_dnn_classify.c | 3 +- libavfilter/vf_dnn_detect.c| 3 +- libavfilter/vf_dnn_processing.c| 3 +- libavfilter/vf_sr.c| 5 +- 13 files changed, 314 insertions(+), 229 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h index 42c67c7040..9f5d37b3e0 100644 --- a/libavfilter/dnn/dnn_backend_common.h +++ b/libavfilter/dnn/dnn_backend_common.h @@ -28,9 +28,16 @@ #include "../dnn_interface.h" #include "libavutil/thread.h" -#define DNN_BACKEND_COMMON_OPTIONS \ -{ "nireq", "number of request", OFFSET(options.nireq), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, FLAGS }, \ -{ "async", "use DNN async inference", OFFSET(options.async), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, +#define DNN_DEFINE_CLASS_EXT(name, desc, options) \ +{ \ +.class_name = desc, \ +.item_name = av_default_item_name, \ +.option = options, \ +.version= LIBAVUTIL_VERSION_INT,\ +.category = AV_CLASS_CATEGORY_FILTER, \ +
[FFmpeg-devel] [PATCH WIP 2/9] avfilter/dnn_backend_openvino: Fix free context at random place
From: Zhao Zhili It will be freed again by ff_dnn_uninit. --- libavfilter/dnn/dnn_backend_openvino.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index c4b0682f11..769ba0a54b 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -959,7 +959,6 @@ err: if (input_model_info) ov_preprocess_input_model_info_free(input_model_info); #endif -dnn_free_model_ov(&ov_model->model); return ret; } -- 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 WIP 0/9] Refactor DNN
From: Zhao Zhili During the refactor progress, I have found some serious issues, which is not resolved by the patchset: 1. Tensorflow backend is broken. I think it doesn't work since 2021 at least. For example, it destroy a thread and create a new thread for each frame, and it destroy an invalid thread at the first frame: pthread_join(async_module->thread_id, &status); if (status == DNN_ASYNC_FAIL) { av_log(ctx, AV_LOG_ERROR, "Unable to start inference as previous inference failed.\n"); return DNN_GENERIC_ERROR; } ret = pthread_create(&async_module->thread_id, NULL, async_thread_routine, async_module); 2. Openvino V1 doesn't compile. It doesn't compile and no one complains, I think it's a hint to just keep the code for V2. 3. Error handling. It's easy to crash with incorrect command line arguments. I don't have enough test case. Please share your test case and help on test. Zhao Zhili (9): avfilter/dnn: Refactor DNN parameter configuration system avfilter/dnn_backend_openvino: Fix free context at random place avfilter/dnn_backend_openvino: simplify memory allocation avfilter/dnn_backend_tf: Remove one level of indentation avfilter/dnn_backend_tf: Fix free context at random place avfilter/dnn_backend_tf: Simplify memory allocation avfilter/dnn_backend_torch: Simplify memory allocation avfilter/dnn: Remove a level of dereference avfilter/dnn: Use dnn_backend_info_list to search for dnn module libavfilter/dnn/dnn_backend_common.h | 13 +- libavfilter/dnn/dnn_backend_openvino.c | 210 ++--- libavfilter/dnn/dnn_backend_tf.c | 194 ++- libavfilter/dnn/dnn_backend_torch.cpp | 112 + libavfilter/dnn/dnn_interface.c| 107 ++--- libavfilter/dnn_filter_common.c| 38 - libavfilter/dnn_filter_common.h| 37 ++--- libavfilter/dnn_interface.h| 73 +++-- libavfilter/vf_derain.c| 5 +- libavfilter/vf_dnn_classify.c | 3 +- libavfilter/vf_dnn_detect.c| 3 +- libavfilter/vf_dnn_processing.c| 3 +- libavfilter/vf_sr.c| 5 +- 13 files changed, 428 insertions(+), 375 deletions(-) -- 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".
Re: [FFmpeg-devel] [RFC] 5 year plan & Inovation
On Sat, Apr 27, 2024 at 6:24 AM Michael Niedermayer wrote: > On Thu, Apr 25, 2024 at 08:15:27AM -0700, Vittorio Giovara wrote: > > On Wed, Apr 24, 2024 at 3:00 PM Michael Niedermayer < > mich...@niedermayer.cc> > > wrote: > > > > > > Microsoft expanded into new fields with Xbox and Azure, yes. But > Windows > > > is still an OS, and Office is still a (un)productivity suite. > > > > > > > > Accordingly, maybe you can innovate with a new project within the > same > > > legal entity as FFmpeg (be it SPI, FFlabs or whatever). > > > > > > > > But FFmpeg as a software project is not a suitable venue for radical > new > > > innovation. > > > > > > Microsofts OS does not limit what can be installed to whats in MS main > > > repository, FFmpeg does > > > > > > Microsoft windows from a user POV includes internet explorer IIRC. Its > not > > > a seperate > > > product from just the legal entity. It was not in the first OS from > > > microsoft > > > > > > microsofts first OS MS-DOS 1.0 ? looks slightly different than the > current > > > latest OS. > > > There was radical innovation, if one likes MS or hate them. > > > > > > > > > > > > > > >You can do the same with apple, google, or others. > > > > > > > > Sure but you can't do the same with iPhone or Google Search. > > > > > > of course you can, googles search inovated. Theres a image search a > audio > > > search > > > news, travel, shoping. > > > These did not exist in the initial google search. And while i dont > know, i > > > suspect > > > google search is very good at finding google products. > > > Google didnt became that big by simply "not being evil" > > > > > > But lets not assume, lets try, if i search for maps i get > > > Google Maps as first entry. > > > > > > or finance, 2nd entry is https://www.google.com/finance/ > > > > > > > > > And the iphone uses apples operating system and their app store, with > > > many apple apps. Check the first iphone and compare it to the latest > > > there is huge inovation with what you can do with all the software > > > that comes preinstalled and also what you can install later. > > > Thats in stark contrast to > > > "FFmpeg as a software project is not a suitable venue for radical new > > > innovation" > > > when did you last use siri with your iphone ? siri was added in > > > iphone 4s IIUC. Thats a big change. > > > > > > I can ultimately only repeat my oppinion. FFmpeg will innovate or > FFmpeg > > > will stagnate and eventually be replaced by some other project that > doesnt > > > have an opposition to innovation. > > > > > > IMHO we need to find out what direction (of innovation or lack thereof) > > > people want. This RFC thread is kind of the first step. > > > 2nd step would be a vote. > > > > > > You are kinda comparing apples and oranges, a platform like an OS or a > > The examples i showed cover a wide range of software (An OS, A office > suite, > A web browser, an AI assitent, a search engine, web apps, and more) > and hardware like a phone, services like cloud > > For all of them its true that radical innovation was essential for success. > > our multimedia framework is not a special case relative to above > > > > network or a crypto exchange or a browser based on ffmpeg.exe, and not > > because it's impossible but > > These sound like really bad ideas unrealated to innovation. > > > > because it's the wrong tool for the job - > > IMHO, this is missing the point a bit > > A phone originally was a tool to call and talk to someone, to be reachable > by > voice communication. > Its not a tool to write letters, until it was > Its not a tool to browse the internet until it was > Its not an assitent you could ask something until it was > ... > > A internet browser originally was a tool to display static text and images > maybe some ftp and gopher sprinkled into it. > its not a tool to do video chat with , until it was > its not a tool to write mails in, until it was > its not a tool to submit your patches to git, until it was, ohh wait, i > have a deja vue feeling here > > (and you can continue this list with software, hardware and services from > other > successfull companies, there is radical innovation everywhere) > > our repository is also not just the ffmpeg tool, there are libraries and > theres > ffmpeg, ffprobe, ffplay > > FFmpeg is a whole multimedia framework and there are many things we could > innovate > on. > > Also, i agree its important to listen to what the users want. But often > what they > ask for and what actually would help them most, can be different. > This is many words to say that you're missing the point. Let me try in social media format You👏can't👏compare👏ffmpeg👏to👏the👏many👏projects👏you👏mentioned. And please address the main innovation points that we need, reiterated here - switching to a more user friendly patch system - have stronger meaningful actions from the CC - secure funding for larger projects These are all hard to do, even more so when the leadership stalls any action ou
[FFmpeg-devel] [PATCH 6/6] vulkan_av1: Fix force_integer_mv value
--- libavcodec/vulkan_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 25ab4ecc70..a550215e32 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, .render_and_frame_size_different = frame_header->render_and_frame_size_different, .allow_screen_content_tools = frame_header->allow_screen_content_tools, .is_filter_switchable = frame_header->is_filter_switchable, -.force_integer_mv = frame_header->force_integer_mv, +.force_integer_mv = pic->force_integer_mv, .frame_size_override_flag = frame_header->frame_size_override_flag, .buffer_removal_time_present_flag = frame_header->buffer_removal_time_present_flag, .allow_intrabc = frame_header->allow_intrabc, -- 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 5/6] vaapi_av1: Fix force_integer_mv value
--- libavcodec/vaapi_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 1f563483b9..f61bf63098 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -220,7 +220,7 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, .error_resilient_mode = frame_header->error_resilient_mode, .disable_cdf_update = frame_header->disable_cdf_update, .allow_screen_content_tools = frame_header->allow_screen_content_tools, -.force_integer_mv = frame_header->force_integer_mv, +.force_integer_mv = s->cur_frame.force_integer_mv, .allow_intrabc= frame_header->allow_intrabc, .use_superres = frame_header->use_superres, .allow_high_precision_mv = frame_header->allow_high_precision_mv, -- 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 4/6] nvdec_av1: Use av1dec force_integer_mv value
--- libavcodec/nvdec_av1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c index 4efa420e66..8a46db1ed5 100644 --- a/libavcodec/nvdec_av1.c +++ b/libavcodec/nvdec_av1.c @@ -106,9 +106,7 @@ static int nvdec_av1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u .show_frame = frame_header->show_frame, .disable_cdf_update = frame_header->disable_cdf_update, .allow_screen_content_tools = frame_header->allow_screen_content_tools, -.force_integer_mv = frame_header->force_integer_mv || -frame_header->frame_type == AV1_FRAME_INTRA_ONLY || -frame_header->frame_type == AV1_FRAME_KEY, +.force_integer_mv = s->cur_frame.force_integer_mv; .coded_denom = frame_header->coded_denom, .allow_intrabc= frame_header->allow_intrabc, .allow_high_precision_mv = frame_header->allow_high_precision_mv, -- 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 3/6] vdpau_av1: Use av1dec force_integer_mv value
--- libavcodec/vdpau_av1.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/vdpau_av1.c b/libavcodec/vdpau_av1.c index b74ea6aa0c..a1aff79bb7 100644 --- a/libavcodec/vdpau_av1.c +++ b/libavcodec/vdpau_av1.c @@ -91,9 +91,7 @@ static int vdpau_av1_start_frame(AVCodecContext *avctx, info->show_frame = frame_header->show_frame; info->disable_cdf_update = frame_header->disable_cdf_update; info->allow_screen_content_tools = frame_header->allow_screen_content_tools; -info->force_integer_mv = frame_header->force_integer_mv || -frame_header->frame_type == AV1_FRAME_INTRA_ONLY || -frame_header->frame_type == AV1_FRAME_KEY; +info->force_integer_mv = s->cur_frame.force_integer_mv; info->coded_denom = frame_header->coded_denom; info->allow_intrabc= frame_header->allow_intrabc; info->allow_high_precision_mv = frame_header->allow_high_precision_mv; -- 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/6] dxva2_av1: Use av1dec force_integer_mv value
--- libavcodec/dxva2_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c index 5b95f99c9b..1b55510659 100644 --- a/libavcodec/dxva2_av1.c +++ b/libavcodec/dxva2_av1.c @@ -101,7 +101,7 @@ int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACont pp->coding.dual_filter = seq->enable_dual_filter; pp->coding.jnt_comp = seq->enable_jnt_comp; pp->coding.screen_content_tools = frame_header->allow_screen_content_tools; -pp->coding.integer_mv = frame_header->force_integer_mv || !(frame_header->frame_type & 1); +pp->coding.integer_mv = h->cur_frame.force_integer_mv; pp->coding.cdef = seq->enable_cdef; pp->coding.restoration = seq->enable_restoration; pp->coding.film_grain = seq->film_grain_params_present && !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN); -- 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/6] av1dec: Add force_integer_mv derived field for decoder use
This is not the same as the syntax element value in the frame header because the specification parsing tables override the value on intra frames. --- On 27/04/2024 15:58, Lynne wrote: > This looks better to me. HYG. Of these, only VAAPI tested. (And probably it never did anything anyway.) libavcodec/av1dec.c | 7 +++ libavcodec/av1dec.h | 6 ++ 2 files changed, 13 insertions(+) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 79a30a114d..601e3f05e1 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -725,6 +725,8 @@ static void av1_frame_replace(AV1Frame *dst, const AV1Frame *src) sizeof(dst->ref_frame_sign_bias)); memcpy(dst->order_hints, src->order_hints, sizeof(dst->order_hints)); + +dst->force_integer_mv = src->force_integer_mv; } static av_cold int av1_decode_free(AVCodecContext *avctx) @@ -1255,6 +1257,11 @@ static int get_current_frame(AVCodecContext *avctx) order_hint_info(s); load_grain_params(s); +s->cur_frame.force_integer_mv = +s->raw_frame_header->force_integer_mv || +s->raw_frame_header->frame_type == AV1_FRAME_KEY || +s->raw_frame_header->frame_type == AV1_FRAME_INTRA_ONLY; + return ret; } diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 66a732d781..8b2a7b0896 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -67,6 +67,12 @@ typedef struct AV1Frame { // OrderHints[] when this is the current frame, otherwise // SavedOrderHints[s][] when is the reference frame in slot s. uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME]; + +// force_integer_mv value at the end of the frame header parsing. +// This is not the same as the syntax element value in +// raw_frame_header because the specification parsing tables +// override the value on intra frames. +uint8_t force_integer_mv; } AV1Frame; typedef struct TileGroupInfo { -- 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".
Re: [FFmpeg-devel] [PATCH] vulkan_av1: Set force_integer_mv on intra frames
Apr 27, 2024, 16:07 by s...@jkqxz.net: > On 27/04/2024 14:58, Mark Thompson wrote: > >> On 27/04/2024 14:47, Ronald S. Bultje wrote: >> >>> Hi, >>> >>> On Sat, Apr 27, 2024 at 9:40 AM Mark Thompson wrote: >>> The flag in CBS is the value read from the bitstream (as required for passthrough), but the specification overrides that by setting it immediately after reading if the frame is intra. --- This is already done for DXVA and VDPAU. Also wondering whether this should be done for VAAPI? libavcodec/vulkan_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 25ab4ecc70..694e643954 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, .render_and_frame_size_different = frame_header->render_and_frame_size_different, .allow_screen_content_tools = frame_header->allow_screen_content_tools, .is_filter_switchable = frame_header->is_filter_switchable, -.force_integer_mv = frame_header->force_integer_mv, +.force_integer_mv = frame_header->force_integer_mv || !(frame_header->frame_type & 1), .frame_size_override_flag = frame_header->frame_size_override_flag, .buffer_removal_time_present_flag = frame_header->buffer_removal_time_present_flag, .allow_intrabc = frame_header->allow_intrabc, -- 2.43.0 >>> >>> Wouldn't it be better to adjust the CBS reader then? Prevents us from >>> having to re-do this in every hw wrapper. >>> >> >> How would you suggest doing this? >> >> We could add a derived field force_integer_mv somewhere else (av1dec?) but >> that doesn't seem obviously better for use in the "copy stuff from frame >> header" function. >> > > Something like this. Unsure whether this is more or less confusing! > > libavcodec/av1dec.c | 7 +++ > libavcodec/av1dec.h | 3 +++ > libavcodec/vulkan_av1.c | 2 +- > 3 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c > index 79a30a114d..601e3f05e1 100644 > --- a/libavcodec/av1dec.c > +++ b/libavcodec/av1dec.c > @@ -725,6 +725,8 @@ static void av1_frame_replace(AV1Frame *dst, const > AV1Frame *src) > sizeof(dst->ref_frame_sign_bias)); > memcpy(dst->order_hints, src->order_hints, > sizeof(dst->order_hints)); > + > +dst->force_integer_mv = src->force_integer_mv; > } > > static av_cold int av1_decode_free(AVCodecContext *avctx) > @@ -1255,6 +1257,11 @@ static int get_current_frame(AVCodecContext *avctx) > order_hint_info(s); > load_grain_params(s); > > +s->cur_frame.force_integer_mv = > +s->raw_frame_header->force_integer_mv || > +s->raw_frame_header->frame_type == AV1_FRAME_KEY || > +s->raw_frame_header->frame_type == AV1_FRAME_INTRA_ONLY; > + > return ret; > } > > diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h > index 66a732d781..e3016b82a3 100644 > --- a/libavcodec/av1dec.h > +++ b/libavcodec/av1dec.h > @@ -67,6 +67,9 @@ typedef struct AV1Frame { > // OrderHints[] when this is the current frame, otherwise > // SavedOrderHints[s][] when is the reference frame in slot s. > uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME]; > + > +// force_integer_mv value at the end of the frame header parsing. > +uint8_t force_integer_mv; > } AV1Frame; > > typedef struct TileGroupInfo { > diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c > index 25ab4ecc70..a550215e32 100644 > --- a/libavcodec/vulkan_av1.c > +++ b/libavcodec/vulkan_av1.c > @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext > *avctx, > .render_and_frame_size_different = > frame_header->render_and_frame_size_different, > .allow_screen_content_tools = frame_header->allow_screen_content_tools, > .is_filter_switchable = frame_header->is_filter_switchable, > -.force_integer_mv = frame_header->force_integer_mv, > +.force_integer_mv = pic->force_integer_mv, > .frame_size_override_flag = frame_header->frame_size_override_flag, > .buffer_removal_time_present_flag = > frame_header->buffer_removal_time_present_flag, > .allow_intrabc = frame_header->allow_intrabc, > This looks better to 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] fftools/ffmpeg_filter: Fix check
Andreas Rheinhardt: > Fixes Coverity issues #1596529, #1596531. > Introduced in 8e35e33d42efb89ff7e3da92b841a3b43a5a95bc. > > Signed-off-by: Andreas Rheinhardt > --- > fftools/ffmpeg_filter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c > index f108f8daf9..382d0f75b1 100644 > --- a/fftools/ffmpeg_filter.c > +++ b/fftools/ffmpeg_filter.c > @@ -862,7 +862,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream > *ost, > ofp->fps.vsync_method= opts->vsync_method; > ofp->fps.framerate = ost->frame_rate; > ofp->fps.framerate_max = ost->max_frame_rate; > -ofp->fps.framerate_supported = ost->force_fps && opts->enc ? > +ofp->fps.framerate_supported = ost->force_fps || !opts->enc ? > NULL : > opts->enc->supported_framerates; > > // reduce frame rate for mpeg4 to be within the spec limits Will apply. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] vulkan_av1: Set force_integer_mv on intra frames
On 27/04/2024 14:58, Mark Thompson wrote: > On 27/04/2024 14:47, Ronald S. Bultje wrote: >> Hi, >> >> On Sat, Apr 27, 2024 at 9:40 AM Mark Thompson wrote: >> >>> The flag in CBS is the value read from the bitstream (as required for >>> passthrough), but the specification overrides that by setting it >>> immediately after reading if the frame is intra. >>> --- >>> This is already done for DXVA and VDPAU. Also wondering whether this >>> should be done for VAAPI? >>> >>> libavcodec/vulkan_av1.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c >>> index 25ab4ecc70..694e643954 100644 >>> --- a/libavcodec/vulkan_av1.c >>> +++ b/libavcodec/vulkan_av1.c >>> @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext >>> *avctx, >>> .render_and_frame_size_different = >>> frame_header->render_and_frame_size_different, >>> .allow_screen_content_tools = >>> frame_header->allow_screen_content_tools, >>> .is_filter_switchable = frame_header->is_filter_switchable, >>> -.force_integer_mv = frame_header->force_integer_mv, >>> +.force_integer_mv = frame_header->force_integer_mv || >>> !(frame_header->frame_type & 1), >>> .frame_size_override_flag = >>> frame_header->frame_size_override_flag, >>> .buffer_removal_time_present_flag = >>> frame_header->buffer_removal_time_present_flag, >>> .allow_intrabc = frame_header->allow_intrabc, >>> -- >>> 2.43.0 >>> >> >> Wouldn't it be better to adjust the CBS reader then? Prevents us from >> having to re-do this in every hw wrapper. > > How would you suggest doing this? > > We could add a derived field force_integer_mv somewhere else (av1dec?) but > that doesn't seem obviously better for use in the "copy stuff from frame > header" function. Something like this. Unsure whether this is more or less confusing! libavcodec/av1dec.c | 7 +++ libavcodec/av1dec.h | 3 +++ libavcodec/vulkan_av1.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 79a30a114d..601e3f05e1 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -725,6 +725,8 @@ static void av1_frame_replace(AV1Frame *dst, const AV1Frame *src) sizeof(dst->ref_frame_sign_bias)); memcpy(dst->order_hints, src->order_hints, sizeof(dst->order_hints)); + +dst->force_integer_mv = src->force_integer_mv; } static av_cold int av1_decode_free(AVCodecContext *avctx) @@ -1255,6 +1257,11 @@ static int get_current_frame(AVCodecContext *avctx) order_hint_info(s); load_grain_params(s); +s->cur_frame.force_integer_mv = +s->raw_frame_header->force_integer_mv || +s->raw_frame_header->frame_type == AV1_FRAME_KEY || +s->raw_frame_header->frame_type == AV1_FRAME_INTRA_ONLY; + return ret; } diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index 66a732d781..e3016b82a3 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -67,6 +67,9 @@ typedef struct AV1Frame { // OrderHints[] when this is the current frame, otherwise // SavedOrderHints[s][] when is the reference frame in slot s. uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME]; + +// force_integer_mv value at the end of the frame header parsing. +uint8_t force_integer_mv; } AV1Frame; typedef struct TileGroupInfo { diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 25ab4ecc70..a550215e32 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, .render_and_frame_size_different = frame_header->render_and_frame_size_different, .allow_screen_content_tools = frame_header->allow_screen_content_tools, .is_filter_switchable = frame_header->is_filter_switchable, -.force_integer_mv = frame_header->force_integer_mv, +.force_integer_mv = pic->force_integer_mv, .frame_size_override_flag = frame_header->frame_size_override_flag, .buffer_removal_time_present_flag = frame_header->buffer_removal_time_present_flag, .allow_intrabc = frame_header->allow_intrabc, -- 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".
Re: [FFmpeg-devel] [PATCH] vulkan_av1: Set force_integer_mv on intra frames
On 27/04/2024 14:47, Ronald S. Bultje wrote: > Hi, > > On Sat, Apr 27, 2024 at 9:40 AM Mark Thompson wrote: > >> The flag in CBS is the value read from the bitstream (as required for >> passthrough), but the specification overrides that by setting it >> immediately after reading if the frame is intra. >> --- >> This is already done for DXVA and VDPAU. Also wondering whether this >> should be done for VAAPI? >> >> libavcodec/vulkan_av1.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c >> index 25ab4ecc70..694e643954 100644 >> --- a/libavcodec/vulkan_av1.c >> +++ b/libavcodec/vulkan_av1.c >> @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext >> *avctx, >> .render_and_frame_size_different = >> frame_header->render_and_frame_size_different, >> .allow_screen_content_tools = >> frame_header->allow_screen_content_tools, >> .is_filter_switchable = frame_header->is_filter_switchable, >> -.force_integer_mv = frame_header->force_integer_mv, >> +.force_integer_mv = frame_header->force_integer_mv || >> !(frame_header->frame_type & 1), >> .frame_size_override_flag = >> frame_header->frame_size_override_flag, >> .buffer_removal_time_present_flag = >> frame_header->buffer_removal_time_present_flag, >> .allow_intrabc = frame_header->allow_intrabc, >> -- >> 2.43.0 >> > > Wouldn't it be better to adjust the CBS reader then? Prevents us from > having to re-do this in every hw wrapper. How would you suggest doing this? We could add a derived field force_integer_mv somewhere else (av1dec?) but that doesn't seem obviously better for use in the "copy stuff from frame header" function. - Mark ___ 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] configure: support msvc build inside WSL
--- configure | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 8101b4fce6..b872c37933 100755 --- a/configure +++ b/configure @@ -5036,7 +5036,11 @@ probe_cc(){ else _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r') fi -_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' +if [ -x "$(command -v wslpath)" ]; then +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { cmd = "wslpath -u '\'\\\'\''" $$0 "'\'\\\'\''"; cmd | getline; close(cmd); print "$@:", $$0 } }'\'' > $(@:.o=.d)' +else +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' +fi _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" -- 2.43.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] vulkan_av1: Set force_integer_mv on intra frames
Hi, On Sat, Apr 27, 2024 at 9:40 AM Mark Thompson wrote: > The flag in CBS is the value read from the bitstream (as required for > passthrough), but the specification overrides that by setting it > immediately after reading if the frame is intra. > --- > This is already done for DXVA and VDPAU. Also wondering whether this > should be done for VAAPI? > > libavcodec/vulkan_av1.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c > index 25ab4ecc70..694e643954 100644 > --- a/libavcodec/vulkan_av1.c > +++ b/libavcodec/vulkan_av1.c > @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext > *avctx, > .render_and_frame_size_different = > frame_header->render_and_frame_size_different, > .allow_screen_content_tools = > frame_header->allow_screen_content_tools, > .is_filter_switchable = frame_header->is_filter_switchable, > -.force_integer_mv = frame_header->force_integer_mv, > +.force_integer_mv = frame_header->force_integer_mv || > !(frame_header->frame_type & 1), > .frame_size_override_flag = > frame_header->frame_size_override_flag, > .buffer_removal_time_present_flag = > frame_header->buffer_removal_time_present_flag, > .allow_intrabc = frame_header->allow_intrabc, > -- > 2.43.0 > Wouldn't it be better to adjust the CBS reader then? Prevents us from having to re-do this in every hw wrapper. Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/vp8: Return error on error
Hi, On Sat, Apr 27, 2024 at 7:47 AM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > Regression since e1ba00ac8f755f37ebc8448d3dbea906d7b79da2. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/vp8.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c > index f37938ad27..19f32b3400 100644 > --- a/libavcodec/vp8.c > +++ b/libavcodec/vp8.c > @@ -107,8 +107,11 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame > *f, int ref) > ref ? AV_GET_BUFFER_FLAG_REF : > 0); > if (ret < 0) > return ret; > -if (!(f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height))) > +f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height); > +if (!f->seg_map) { > +ret = AVERROR(ENOMEM); > goto fail; > +} > ret = ff_hwaccel_frame_priv_alloc(s->avctx, > &f->hwaccel_picture_private); > if (ret < 0) > goto fail; > -- > 2.40.1 > OK. Ronald ___ 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] vulkan_av1: Set force_integer_mv on intra frames
The flag in CBS is the value read from the bitstream (as required for passthrough), but the specification overrides that by setting it immediately after reading if the frame is intra. --- This is already done for DXVA and VDPAU. Also wondering whether this should be done for VAAPI? libavcodec/vulkan_av1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 25ab4ecc70..694e643954 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -435,7 +435,7 @@ static int vk_av1_start_frame(AVCodecContext *avctx, .render_and_frame_size_different = frame_header->render_and_frame_size_different, .allow_screen_content_tools = frame_header->allow_screen_content_tools, .is_filter_switchable = frame_header->is_filter_switchable, -.force_integer_mv = frame_header->force_integer_mv, +.force_integer_mv = frame_header->force_integer_mv || !(frame_header->frame_type & 1), .frame_size_override_flag = frame_header->frame_size_override_flag, .buffer_removal_time_present_flag = frame_header->buffer_removal_time_present_flag, .allow_intrabc = frame_header->allow_intrabc, -- 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] [REFUND-REQUEST] Vulkan F2F travel
Hi, I'm requesting a reimbursement for attending the Khronos F2F event in Brussels on 2024-04-26, where I gave a talk about the current status of Vulkan Video integration into FFmpeg: - Currently implemented decoding features - What we would like to be improved (stability, speed and testing from all vendors) - Currently implemented WIP encoding features - What we would need to implement in order to match nvenc in terms of quality on most vendors Also, I collaborated on future extensions to the standard, and discussed AV1 issues recently found in the specifications and how we could fix them. 95 GBP: Eurostar to Bruxelle-Midi 95 GBP: Eurostar from Bruxelle-Midi Total: 190 GBP ___ 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/framecrcenc: compute the checksum for side data
On Sat, Apr 27, 2024 at 12:44:18PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > This allows detecting issues in side data related code, same as what > > framecrc does for before already for packet data itself. > > > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/framecrcenc.c | 76 +- > > tests/ref/fate/autorotate |2 +- > > tests/ref/fate/cover-art-mp3-id3v2-remux|2 +- > > tests/ref/fate/ffmpeg-bsf-input | 10 +- > > tests/ref/fate/force_key_frames-source | 784 ++-- > > tests/ref/fate/force_key_frames-source-drop | 34 +- > > tests/ref/fate/force_key_frames-source-dup | 1224 +-- > > tests/ref/fate/gapless-mp3 |6 +- > > tests/ref/fate/h264_redundant_pps-side_data |2 +- > > tests/ref/fate/iamf-5_1-copy| 208 ++-- > > tests/ref/fate/iamf-5_1-demux | 208 ++-- > > tests/ref/fate/id3v2-priv-remux |2 +- > > tests/ref/fate/matroska-hdr10-plus-remux|2 +- > > tests/ref/fate/matroska-ogg-opus-remux |2 +- > > tests/ref/fate/matroska-opus-remux |2 +- > > tests/ref/fate/matroska-vp8-alpha-remux | 14 +- > > tests/ref/fate/mov-cover-image |2 +- > > tests/ref/fate/segment-mp4-to-ts| 250 ++-- > > tests/ref/fate/shortest | 100 +- > > tests/ref/fate/webm-hdr10-plus-remux|2 +- > > tests/ref/fate/webm-webvtt-remux| 24 +- > > 21 files changed, 1513 insertions(+), 1443 deletions(-) > > > > diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c > > index ce306a6c498..e71bfbd8777 100644 > > --- a/libavformat/framecrcenc.c > > +++ b/libavformat/framecrcenc.c > > @@ -21,8 +21,10 @@ > > > > #include > > > > +#include "config.h" > > #include "libavutil/adler32.h" > > #include "libavutil/avstring.h" > > +#include "libavutil/intreadwrite.h" > > > > #include "libavcodec/codec_id.h" > > #include "libavcodec/codec_par.h" > > @@ -48,6 +50,17 @@ static int framecrc_write_header(struct AVFormatContext > > *s) > > return ff_framehash_write_header(s); > > } > > > > +static av_unused void inline bswap(char *buf, int offset, int size) > > +{ > > +if (size == 8) { > > +uint64_t val = AV_RN64(buf + offset); > > +AV_WN64(buf + offset, av_bswap64(val)); > > +} else if (size == 4) { > > +uint32_t val = AV_RN32(buf + offset); > > +AV_WN32(buf + offset, av_bswap32(val)); > > +} > > +} > > + > > static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) > > { > > uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); > > @@ -58,11 +71,68 @@ static int framecrc_write_packet(struct AVFormatContext > > *s, AVPacket *pkt) > > if (pkt->flags != AV_PKT_FLAG_KEY) > > av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags); > > if (pkt->side_data_elems) { > > +int i; > > This change is wrong. > > > av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems); > > > > -for (int i = 0; i < pkt->side_data_elems; i++) { > > -av_strlcatf(buf, sizeof(buf), ", %8"SIZE_SPECIFIER, > > -pkt->side_data[i].size); > > +for (i=0; iside_data_elems; i++) { > > +const AVPacketSideData *const sd = &pkt->side_data[i]; > > +const uint8_t *data = sd->data; > > +uint32_t side_data_crc = 0; > > + > > +switch (sd->type) { > > +#if HAVE_BIGENDIAN > > +uint8_t bswap_buf[FFMAX(sizeof(AVCPBProperties), > > +sizeof(AVProducerReferenceTime))]; > > +case AV_PKT_DATA_PALETTE: > > +case AV_PKT_DATA_REPLAYGAIN: > > +case AV_PKT_DATA_DISPLAYMATRIX: > > +case AV_PKT_DATA_STEREO3D: > > +case AV_PKT_DATA_AUDIO_SERVICE_TYPE: > > +case AV_PKT_DATA_FALLBACK_TRACK: > > +case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: > > +case AV_PKT_DATA_SPHERICAL: > > +case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: > > +case AV_PKT_DATA_S12M_TIMECODE: > > +for (size_t j = 0; j < sd->size / 4; j++) { > > +uint8_t buf[4]; > > +AV_WL32(buf, AV_RB32(sd->data + 4 * j)); > > +side_data_crc = av_adler32_update(side_data_crc, buf, > > 4); > > +} > > +break; > > +case AV_PKT_DATA_CPB_PROPERTIES: > > +#define BSWAP(struct, field) bswap(bswap_buf, offsetof(struct, field), > > sizeof(((struct){0}).field)) > > +if (sd->size == sizeof(AVCPBProperties)) { > > +memcpy(bswap_buf, sd->data, sizeof(AVCPBProperties)); > > +data = bswap_buf; > > +BSWAP(AVCPBProperties, max_bitrate); > > +BSWAP(AVCP
[FFmpeg-devel] [PATCH] avcodec/vp8: Return error on error
Regression since e1ba00ac8f755f37ebc8448d3dbea906d7b79da2. Signed-off-by: Andreas Rheinhardt --- libavcodec/vp8.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index f37938ad27..19f32b3400 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -107,8 +107,11 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref) ref ? AV_GET_BUFFER_FLAG_REF : 0); if (ret < 0) return ret; -if (!(f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height))) +f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height); +if (!f->seg_map) { +ret = AVERROR(ENOMEM); goto fail; +} ret = ff_hwaccel_frame_priv_alloc(s->avctx, &f->hwaccel_picture_private); if (ret < 0) goto fail; -- 2.40.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 3/5] avcodec/decode: Check progress before dereferencing
Michael Niedermayer: > Fixes: NULL pointer dereference > Fixes: > 68192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP8_fuzzer-6180311026171904 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/decode.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index d031b1ca176..a6131941f43 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1744,6 +1744,8 @@ void ff_progress_frame_report(ProgressFrame *f, int n) > > void ff_progress_frame_await(const ProgressFrame *f, int n) > { > +if (!f->progress) > +return; > ff_thread_progress_await(&f->progress->progress, n); > } > Can I get the sample? I see two places in VP8 where the VP8Frame pointers are set before the actual frame inside it is properly allocated. (Actually, it was intended for this API to not support waiting on non-existent frames (i.e. let the caller check for this; in most instances, it is already guaranteed that the frame one waits one exists, so this is unnecessary for them).) - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] 5 year plan & Inovation
On Thu, Apr 25, 2024 at 12:26:00PM +0200, Tomas Härdin wrote: > tor 2024-04-25 klockan 02:07 +0200 skrev Michael Niedermayer: > > On Thu, Apr 25, 2024 at 12:50:02AM +0200, Tomas Härdin wrote: > > > ons 2024-04-17 klockan 15:58 +0200 skrev Michael Niedermayer: > > > > > > > * ffchat > > > > (expand into realtime chat / zoom) this would > > > > bring in more users and developers, and we basically have > > > > almost > > > > all parts for it already but some people where against it > > > > > > You mean inventing a new chat protocol? If so then please don't. We > > > > If theres an existing protocol that serves the purpose then theres no > > need to invent a new one > > > > I think at a minimum it should have "secure and private by default > > and always" > > (there are many solutions already when one is willing to give up > > security/privacy) > > "Security" and "privacy" are relative terms. yes, more security and privacy is better > > If you want end-to-end encryption in a federated system then XMPP+OMEMO > is the way to go. Or Matrix I guess, but it isn't standardized last > time I checked. > > If you want metadata resistance then Briar is the way to go. It's a > peer-to-peer store-and-forward network that tunnels all its internet > traffic through Tor, and also supports synchronizing messages over WiFi > Direct and Bluetooth. > > There's also GNUnet and its associated protocols like psyc. > > Short of using some complicated thing involving data diodes you're not > likely to do better than what's already out there. And nothing beats > not using computers at all. sure, i agree, we should use existing protocols whenever one exists for a purpose already ... libavformat supports, RTP, RTSP, MMS, HLS, RTMP and probably more we support audio, video, data and text packets/streams So adding support for some more secure/private protocols is within the scope of libavformat. And it would allow all multimedia players to use these more secure means of communicating. As well as writing dedicated secure chat applications on top of libavformat. This would bring in more users and developers thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/framecrcenc: compute the checksum for side data
Michael Niedermayer: > This allows detecting issues in side data related code, same as what > framecrc does for before already for packet data itself. > > Signed-off-by: Michael Niedermayer > --- > libavformat/framecrcenc.c | 76 +- > tests/ref/fate/autorotate |2 +- > tests/ref/fate/cover-art-mp3-id3v2-remux|2 +- > tests/ref/fate/ffmpeg-bsf-input | 10 +- > tests/ref/fate/force_key_frames-source | 784 ++-- > tests/ref/fate/force_key_frames-source-drop | 34 +- > tests/ref/fate/force_key_frames-source-dup | 1224 +-- > tests/ref/fate/gapless-mp3 |6 +- > tests/ref/fate/h264_redundant_pps-side_data |2 +- > tests/ref/fate/iamf-5_1-copy| 208 ++-- > tests/ref/fate/iamf-5_1-demux | 208 ++-- > tests/ref/fate/id3v2-priv-remux |2 +- > tests/ref/fate/matroska-hdr10-plus-remux|2 +- > tests/ref/fate/matroska-ogg-opus-remux |2 +- > tests/ref/fate/matroska-opus-remux |2 +- > tests/ref/fate/matroska-vp8-alpha-remux | 14 +- > tests/ref/fate/mov-cover-image |2 +- > tests/ref/fate/segment-mp4-to-ts| 250 ++-- > tests/ref/fate/shortest | 100 +- > tests/ref/fate/webm-hdr10-plus-remux|2 +- > tests/ref/fate/webm-webvtt-remux| 24 +- > 21 files changed, 1513 insertions(+), 1443 deletions(-) > > diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c > index ce306a6c498..e71bfbd8777 100644 > --- a/libavformat/framecrcenc.c > +++ b/libavformat/framecrcenc.c > @@ -21,8 +21,10 @@ > > #include > > +#include "config.h" > #include "libavutil/adler32.h" > #include "libavutil/avstring.h" > +#include "libavutil/intreadwrite.h" > > #include "libavcodec/codec_id.h" > #include "libavcodec/codec_par.h" > @@ -48,6 +50,17 @@ static int framecrc_write_header(struct AVFormatContext *s) > return ff_framehash_write_header(s); > } > > +static av_unused void inline bswap(char *buf, int offset, int size) > +{ > +if (size == 8) { > +uint64_t val = AV_RN64(buf + offset); > +AV_WN64(buf + offset, av_bswap64(val)); > +} else if (size == 4) { > +uint32_t val = AV_RN32(buf + offset); > +AV_WN32(buf + offset, av_bswap32(val)); > +} > +} > + > static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) > { > uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); > @@ -58,11 +71,68 @@ static int framecrc_write_packet(struct AVFormatContext > *s, AVPacket *pkt) > if (pkt->flags != AV_PKT_FLAG_KEY) > av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags); > if (pkt->side_data_elems) { > +int i; This change is wrong. > av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems); > > -for (int i = 0; i < pkt->side_data_elems; i++) { > -av_strlcatf(buf, sizeof(buf), ", %8"SIZE_SPECIFIER, > -pkt->side_data[i].size); > +for (i=0; iside_data_elems; i++) { > +const AVPacketSideData *const sd = &pkt->side_data[i]; > +const uint8_t *data = sd->data; > +uint32_t side_data_crc = 0; > + > +switch (sd->type) { > +#if HAVE_BIGENDIAN > +uint8_t bswap_buf[FFMAX(sizeof(AVCPBProperties), > +sizeof(AVProducerReferenceTime))]; > +case AV_PKT_DATA_PALETTE: > +case AV_PKT_DATA_REPLAYGAIN: > +case AV_PKT_DATA_DISPLAYMATRIX: > +case AV_PKT_DATA_STEREO3D: > +case AV_PKT_DATA_AUDIO_SERVICE_TYPE: > +case AV_PKT_DATA_FALLBACK_TRACK: > +case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: > +case AV_PKT_DATA_SPHERICAL: > +case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: > +case AV_PKT_DATA_S12M_TIMECODE: > +for (size_t j = 0; j < sd->size / 4; j++) { > +uint8_t buf[4]; > +AV_WL32(buf, AV_RB32(sd->data + 4 * j)); > +side_data_crc = av_adler32_update(side_data_crc, buf, 4); > +} > +break; > +case AV_PKT_DATA_CPB_PROPERTIES: > +#define BSWAP(struct, field) bswap(bswap_buf, offsetof(struct, field), > sizeof(((struct){0}).field)) > +if (sd->size == sizeof(AVCPBProperties)) { > +memcpy(bswap_buf, sd->data, sizeof(AVCPBProperties)); > +data = bswap_buf; > +BSWAP(AVCPBProperties, max_bitrate); > +BSWAP(AVCPBProperties, min_bitrate); > +BSWAP(AVCPBProperties, avg_bitrate); > +BSWAP(AVCPBProperties, buffer_size); > +BSWAP(AVCPBProperties, vbv_delay); > +} > +goto pod; > +case AV_PKT_DATA_PRFT: > +
Re: [FFmpeg-devel] [RFC] 5 year plan & Inovation
On Thu, Apr 25, 2024 at 08:15:27AM -0700, Vittorio Giovara wrote: > On Wed, Apr 24, 2024 at 3:00 PM Michael Niedermayer > wrote: > > > > Microsoft expanded into new fields with Xbox and Azure, yes. But Windows > > is still an OS, and Office is still a (un)productivity suite. > > > > > > Accordingly, maybe you can innovate with a new project within the same > > legal entity as FFmpeg (be it SPI, FFlabs or whatever). > > > > > > But FFmpeg as a software project is not a suitable venue for radical new > > innovation. > > > > Microsofts OS does not limit what can be installed to whats in MS main > > repository, FFmpeg does > > > > Microsoft windows from a user POV includes internet explorer IIRC. Its not > > a seperate > > product from just the legal entity. It was not in the first OS from > > microsoft > > > > microsofts first OS MS-DOS 1.0 ? looks slightly different than the current > > latest OS. > > There was radical innovation, if one likes MS or hate them. > > > > > > > > > > >You can do the same with apple, google, or others. > > > > > > Sure but you can't do the same with iPhone or Google Search. > > > > of course you can, googles search inovated. Theres a image search a audio > > search > > news, travel, shoping. > > These did not exist in the initial google search. And while i dont know, i > > suspect > > google search is very good at finding google products. > > Google didnt became that big by simply "not being evil" > > > > But lets not assume, lets try, if i search for maps i get > > Google Maps as first entry. > > > > or finance, 2nd entry is https://www.google.com/finance/ > > > > > > And the iphone uses apples operating system and their app store, with > > many apple apps. Check the first iphone and compare it to the latest > > there is huge inovation with what you can do with all the software > > that comes preinstalled and also what you can install later. > > Thats in stark contrast to > > "FFmpeg as a software project is not a suitable venue for radical new > > innovation" > > when did you last use siri with your iphone ? siri was added in > > iphone 4s IIUC. Thats a big change. > > > > I can ultimately only repeat my oppinion. FFmpeg will innovate or FFmpeg > > will stagnate and eventually be replaced by some other project that doesnt > > have an opposition to innovation. > > > > IMHO we need to find out what direction (of innovation or lack thereof) > > people want. This RFC thread is kind of the first step. > > 2nd step would be a vote. > > > You are kinda comparing apples and oranges, a platform like an OS or a The examples i showed cover a wide range of software (An OS, A office suite, A web browser, an AI assitent, a search engine, web apps, and more) and hardware like a phone, services like cloud For all of them its true that radical innovation was essential for success. our multimedia framework is not a special case relative to above > network or a crypto exchange or a browser based on ffmpeg.exe, and not > because it's impossible but These sound like really bad ideas unrealated to innovation. > because it's the wrong tool for the job - IMHO, this is missing the point a bit A phone originally was a tool to call and talk to someone, to be reachable by voice communication. Its not a tool to write letters, until it was Its not a tool to browse the internet until it was Its not an assitent you could ask something until it was ... A internet browser originally was a tool to display static text and images maybe some ftp and gopher sprinkled into it. its not a tool to do video chat with , until it was its not a tool to write mails in, until it was its not a tool to submit your patches to git, until it was, ohh wait, i have a deja vue feeling here (and you can continue this list with software, hardware and services from other successfull companies, there is radical innovation everywhere) our repository is also not just the ffmpeg tool, there are libraries and theres ffmpeg, ffprobe, ffplay FFmpeg is a whole multimedia framework and there are many things we could innovate on. Also, i agree its important to listen to what the users want. But often what they ask for and what actually would help them most, can be different. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you fake or manipulate statistics in a paper in physics you will never get a job again. If you fake or manipulate statistics in a paper in medicin you will get a job for life at the pharma industry. 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 4/5] avcodec/hevcdec: Check ref frame
Michael Niedermayer: > Fixes: NULL pointer dereferences > Fixes: > 68197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6382538823106560 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/hevcdec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > index fcfb275f63a..92b0e45eee0 100644 > --- a/libavcodec/hevcdec.c > +++ b/libavcodec/hevcdec.c > @@ -1969,13 +1969,13 @@ static void hls_prediction_unit(HEVCLocalContext *lc, > int x0, int y0, > > if (current_mv.pred_flag & PF_L0) { > ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; > -if (!ref0 || !ref0->frame->data[0]) > +if (!ref0 || !ref0->frame || !ref0->frame->data[0]) > return; > hevc_await_progress(s, ref0, ¤t_mv.mv[0], y0, nPbH); > } > if (current_mv.pred_flag & PF_L1) { > ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; > -if (!ref1 || !ref1->frame->data[0]) > +if (!ref1 || !ref1->frame || !ref1->frame->data[0]) > return; > hevc_await_progress(s, ref1, ¤t_mv.mv[1], y0, nPbH); > } Same as with 1/5: Checking for !ref0->frame is enough as HEVCFrame.f is set if and only if the HEVCFrame.f->data[0] is set (with the possible exception of hw-accelerated pixel formats that don't use AVFrame.data at all (I don't know whether they exist); in any case, HEVCFrame.f is set if and only if HEVCFrame.f->buf[0] is set). Actually, I checked all the decoder that I ported to ProgressFrames for this pattern, but apparently I overlooked way too much (maybe I only checked for the ->buf[0] pattern?). Sorry for that. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] avcodec/vp3: Call ff_progress_frame_unref() before ff_progress_frame_get_buffer()
Michael Niedermayer: > Fixes: Assertion !f->f && !f->progress failed at libavcodec/decode.c:1688 > Fixes: > 68190/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5942090287611904 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/vp3.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c > index 2a5f68dfa8e..09527607767 100644 > --- a/libavcodec/vp3.c > +++ b/libavcodec/vp3.c > @@ -2651,6 +2651,7 @@ static int vp3_decode_frame(AVCodecContext *avctx, > AVFrame *frame, > if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe) > return buf_size; > > +ff_progress_frame_unref(&s->current_frame); > ret = ff_progress_frame_get_buffer(avctx, &s->current_frame, > AV_GET_BUFFER_FLAG_REF); > if (ret < 0) { LGTM. (If I am not mistaken, this would have triggered the av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n") codepath before switching to ProgressFrames, i.e. using an assert instead of erroring out uncovered a bug. Maybe we should use an assert in ff_get_buffer(), too?) - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/5] avcodec/pngdec: Check last AVFrame before deref
Michael Niedermayer: > Fixes: NULL pointer dereference > Fixes: > 68184/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-4926478069334016 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/pngdec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c > index f7751223b81..b24bfa248dc 100644 > --- a/libavcodec/pngdec.c > +++ b/libavcodec/pngdec.c > @@ -1218,7 +1218,7 @@ static int decode_fctl_chunk(AVCodecContext *avctx, > PNGDecContext *s, > return AVERROR_INVALIDDATA; > } > > -if ((sequence_number == 0 || !s->last_picture.f->data[0]) && > +if ((sequence_number == 0 || !s->last_picture.f || > !s->last_picture.f->data[0]) && > dispose_op == APNG_DISPOSE_OP_PREVIOUS) { > // No previous frame to revert to for the first frame > // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND Just checking for !s->last_picture.f is enough -- s->last_picture.f is set if and only if s->last_picture.f->data[0] is set. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/3] avformat/network: add ff_neterrno2() for cases where we already have an errno
On Sat, Apr 20, 2024 at 02:24:59PM +0100, Andrew Sayers wrote: > For example, WSAStartup()'s documentation says: > > "A call to the WSAGetLastError function is not needed and should not be > used" > --- > libavformat/network.c | 5 - > libavformat/network.h | 2 ++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/libavformat/network.c b/libavformat/network.c > index f752efc411..f295957aa5 100644 > --- a/libavformat/network.c > +++ b/libavformat/network.c > @@ -123,7 +123,10 @@ void ff_network_close(void) > #if HAVE_WINSOCK2_H > int ff_neterrno(void) > { > -int err = WSAGetLastError(); > +return ff_neterrno2(WSAGetLastError()); > +} > +int ff_neterrno2(int err) > +{ > switch (err) { > case WSAEWOULDBLOCK: > return AVERROR(EAGAIN); > diff --git a/libavformat/network.h b/libavformat/network.h > index ca214087fc..84348f52a4 100644 > --- a/libavformat/network.h > +++ b/libavformat/network.h > @@ -58,6 +58,7 @@ > #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) > > int ff_neterrno(void); > +int ff_neterrno2(int err); > #else > #include > #include > @@ -66,6 +67,7 @@ int ff_neterrno(void); > #include > > #define ff_neterrno() AVERROR(errno) > +#define ff_neterrno2(ERRNO) AVERROR(ERRNO) > #endif /* HAVE_WINSOCK2_H */ > > #if HAVE_ARPA_INET_H Ping? Still applies, and I'm not aware of any further changes needed. ___ 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".