* [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType @ 2022-06-30 2:45 Tong Wu 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format Tong Wu ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Tong Wu @ 2022-06-30 2:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Tong Wu Add a function to get the corresponding AVHWDeviceType from a given hardware pixel format. Signed-off-by: Tong Wu <tong1.wu@intel.com> --- libavutil/hwcontext.c | 12 ++++++++++++ libavutil/hwcontext.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index ab9ad3703e..3521ed34f4 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) +{ + int i, j; + for (i = 0; hw_table[i]; i++) { + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { + if (hw_table[i]->pix_fmts[j] == fmt) + return hw_table[i]->type; + } + } + return AV_HWDEVICE_TYPE_NONE; +} + enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) { int type; diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index c18b7e1e8b..97f94403e2 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { int width, height; } AVHWFramesContext; +/** + * Get the device type by a given pixel format. + * + * @param fmt Pixel format from enum AVPixelFormat. + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if + * not found. + */ +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); + /** * Look up an AVHWDeviceType by name. * -- 2.35.1.windows.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-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format 2022-06-30 2:45 [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Tong Wu @ 2022-06-30 2:45 ` Tong Wu 2022-06-30 11:49 ` Paul B Mahol 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/avfiltergraph: add an auto hwmap filter Tong Wu 2022-06-30 8:43 ` [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Anton Khirnov 2 siblings, 1 reply; 13+ messages in thread From: Tong Wu @ 2022-06-30 2:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Tong Wu When a derive_device_type is not specified, the hwmap filter should be able to retrieve AVHWDeviceType from outlink->format and create corresponding hwdevice context. Signed-off-by: Tong Wu <tong1.wu@intel.com> --- libavfilter/vf_hwmap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 2e03dfc1fe..136980c982 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -70,23 +70,32 @@ static int hwmap_config_output(AVFilterLink *outlink) device_is_derived = 0; if (inlink->hw_frames_ctx) { + enum AVHWDeviceType type; hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; if (ctx->derive_device_type) { - enum AVHWDeviceType type; - type = av_hwdevice_find_type_by_name(ctx->derive_device_type); if (type == AV_HWDEVICE_TYPE_NONE) { av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); err = AVERROR(EINVAL); goto fail; } + } else { + type = av_hwdevice_get_type_by_pix_fmt(outlink->format); + if (type == AV_HWDEVICE_TYPE_NONE) { + av_log(avctx, AV_LOG_ERROR, "Could not get device type from " + "format %s.\n", av_get_pix_fmt_name(outlink->format)); + err = AVERROR(EINVAL); + goto fail; + } + } + if (!device || ctx->derive_device_type) { err = av_hwdevice_ctx_create_derived(&device, type, - hwfc->device_ref, 0); + hwfc->device_ref, 0); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to created derived " - "device context: %d.\n", err); + "device context: %d.\n", err); goto fail; } device_is_derived = 1; -- 2.35.1.windows.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-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format Tong Wu @ 2022-06-30 11:49 ` Paul B Mahol 2022-07-01 2:11 ` Wu, Tong1 0 siblings, 1 reply; 13+ messages in thread From: Paul B Mahol @ 2022-06-30 11:49 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Tong Wu On Thu, Jun 30, 2022 at 4:47 AM Tong Wu <tong1.wu-at-intel.com@ffmpeg.org> wrote: > When a derive_device_type is not specified, the hwmap filter should be > able to retrieve AVHWDeviceType from outlink->format and create > corresponding hwdevice context. > > Signed-off-by: Tong Wu <tong1.wu@intel.com> > --- > libavfilter/vf_hwmap.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c > index 2e03dfc1fe..136980c982 100644 > --- a/libavfilter/vf_hwmap.c > +++ b/libavfilter/vf_hwmap.c > @@ -70,23 +70,32 @@ static int hwmap_config_output(AVFilterLink *outlink) > device_is_derived = 0; > > if (inlink->hw_frames_ctx) { > + enum AVHWDeviceType type; > hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; > > if (ctx->derive_device_type) { > - enum AVHWDeviceType type; > - > type = av_hwdevice_find_type_by_name(ctx->derive_device_type); > if (type == AV_HWDEVICE_TYPE_NONE) { > av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); > err = AVERROR(EINVAL); > goto fail; > } > + } else { > + type = av_hwdevice_get_type_by_pix_fmt(outlink->format); > + if (type == AV_HWDEVICE_TYPE_NONE) { > + av_log(avctx, AV_LOG_ERROR, "Could not get device type > from " > + "format %s.\n", > av_get_pix_fmt_name(outlink->format)); > + err = AVERROR(EINVAL); > + goto fail; > + } > + } > > + if (!device || ctx->derive_device_type) { > err = av_hwdevice_ctx_create_derived(&device, type, > - hwfc->device_ref, 0); > + hwfc->device_ref, 0); > if (err < 0) { > av_log(avctx, AV_LOG_ERROR, "Failed to created derived " > - "device context: %d.\n", err); > + "device context: %d.\n", err); > Looks like mixed re-indentation and functional changes in same commit. > goto fail; > } > device_is_derived = 1; > -- > 2.35.1.windows.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-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format 2022-06-30 11:49 ` Paul B Mahol @ 2022-07-01 2:11 ` Wu, Tong1 0 siblings, 0 replies; 13+ messages in thread From: Wu, Tong1 @ 2022-07-01 2:11 UTC (permalink / raw) To: Paul B Mahol, FFmpeg development discussions and patches On Thu, Jun 30, 2022 at 4:47 AM Tong Wu <tong1.wu-at-intel.com@ffmpeg.org<mailto:tong1.wu-at-intel.com@ffmpeg.org>> wrote: When a derive_device_type is not specified, the hwmap filter should be able to retrieve AVHWDeviceType from outlink->format and create corresponding hwdevice context. Signed-off-by: Tong Wu <tong1.wu@intel.com<mailto:tong1.wu@intel.com>> --- libavfilter/vf_hwmap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 2e03dfc1fe..136980c982 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -70,23 +70,32 @@ static int hwmap_config_output(AVFilterLink *outlink) device_is_derived = 0; if (inlink->hw_frames_ctx) { + enum AVHWDeviceType type; hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; if (ctx->derive_device_type) { - enum AVHWDeviceType type; - type = av_hwdevice_find_type_by_name(ctx->derive_device_type); if (type == AV_HWDEVICE_TYPE_NONE) { av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); err = AVERROR(EINVAL); goto fail; } + } else { + type = av_hwdevice_get_type_by_pix_fmt(outlink->format); + if (type == AV_HWDEVICE_TYPE_NONE) { + av_log(avctx, AV_LOG_ERROR, "Could not get device type from " + "format %s.\n", av_get_pix_fmt_name(outlink->format)); + err = AVERROR(EINVAL); + goto fail; + } + } + if (!device || ctx->derive_device_type) { err = av_hwdevice_ctx_create_derived(&device, type, - hwfc->device_ref, 0); + hwfc->device_ref, 0); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to created derived " - "device context: %d.\n", err); + "device context: %d.\n", err); Looks like mixed re-indentation and functional changes in same commit. Yes this should not be re-indented, will update later. Thanks, Tong goto fail; } device_is_derived = 1; -- 2.35.1.windows.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org<mailto:ffmpeg-devel@ffmpeg.org> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org<mailto:ffmpeg-devel-request@ffmpeg.org> with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/3] avfilter/avfiltergraph: add an auto hwmap filter 2022-06-30 2:45 [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Tong Wu 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format Tong Wu @ 2022-06-30 2:45 ` Tong Wu 2022-06-30 8:43 ` [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Anton Khirnov 2 siblings, 0 replies; 13+ messages in thread From: Tong Wu @ 2022-06-30 2:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Tong Wu When two formats lists cannot be merged, a scale filter is auto-inserted. However, when it comes to hardware map, we have to manually add a hwmap filter to do the conversion. This patch introduces an auto hwmap filter to do the hwmap conversion automatically and modifies the negotiation structures, making it extensible for more auto filters. Signed-off-by: Tong Wu <tong1.wu@intel.com> --- libavfilter/avfiltergraph.c | 183 ++++++++++++++++++++++++------------ libavfilter/formats.c | 26 ++++- libavfilter/formats.h | 9 +- 3 files changed, 150 insertions(+), 68 deletions(-) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index b7dbfc063b..0f12f2d802 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -393,6 +393,83 @@ static int formats_declared(AVFilterContext *f) return 1; } +static int insert_auto_filter(AVFilterContext **convert, AVFilterGraph *graph, + AVFilterLink *link, const AVFilterNegotiation *neg, + unsigned conv_step, int *converter_count, void *log_ctx) +{ + int ret; + const AVFilter *filter; + AVFilterContext *ctx; + AVFilterLink *inlink, *outlink; + char inst_name[30]; + const char *opts = neg->conversion_filters[conv_step].conversion_opts_offset == 0 ? NULL : + FF_FIELD_AT(char *, neg->conversion_filters[conv_step].conversion_opts_offset, *graph); + const char *name = neg->conversion_filters[conv_step].conversion_filter; + + if (graph->disable_auto_convert) { + av_log(log_ctx, AV_LOG_ERROR, + "The filters '%s' and '%s' do not have a common format " + "and automatic conversion is disabled.\n", + link->src->name, link->dst->name); + return AVERROR(EINVAL); + } + + if (!(filter = avfilter_get_by_name(name))) { + av_log(log_ctx, AV_LOG_ERROR, + "'%s' filter not present, cannot convert formats.\n", + name); + return AVERROR(EINVAL); + } + snprintf(inst_name, sizeof(inst_name), "auto_%s_%d", + name, (*converter_count)++); + ret = avfilter_graph_create_filter(&ctx, filter, inst_name, opts, NULL, graph); + if (ret < 0) + return ret; + + if ((ret = avfilter_insert_filter(link, ctx, 0, 0)) < 0) + return ret; + + if ((ret = filter_query_formats(ctx)) < 0) + return ret; + + inlink = ctx->inputs[0]; + outlink = ctx->outputs[0]; + av_assert0( inlink->incfg.formats->refcount > 0); + av_assert0( inlink->outcfg.formats->refcount > 0); + av_assert0(outlink->incfg.formats->refcount > 0); + av_assert0(outlink->outcfg.formats->refcount > 0); + if (outlink->type == AVMEDIA_TYPE_AUDIO) { + av_assert0( inlink-> incfg.samplerates->refcount > 0); + av_assert0( inlink->outcfg.samplerates->refcount > 0); + av_assert0(outlink-> incfg.samplerates->refcount > 0); + av_assert0(outlink->outcfg.samplerates->refcount > 0); + av_assert0( inlink-> incfg.channel_layouts->refcount > 0); + av_assert0( inlink->outcfg.channel_layouts->refcount > 0); + av_assert0(outlink-> incfg.channel_layouts->refcount > 0); + av_assert0(outlink->outcfg.channel_layouts->refcount > 0); + } + + *convert = ctx; + return 0; +} + +static int merge_auto_filter(AVFilterContext *convert, const AVFilterNegotiation *neg) +{ + int neg_step, ret; + AVFilterLink *inlink = convert->inputs[0]; + AVFilterLink *outlink = convert->outputs[0]; +#define MERGE(merger, link) \ + ((merger)->merge(FF_FIELD_AT(void *, (merger)->offset, (link)->incfg), \ + FF_FIELD_AT(void *, (merger)->offset, (link)->outcfg))) + for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) { + const AVFilterFormatsMerger *m = &neg->mergers[neg_step]; + if ((ret = MERGE(m, inlink)) <= 0 || + (ret = MERGE(m, outlink)) <= 0) + break; + } + return ret; +} + /** * Perform one round of query_formats() and merging formats lists on the * filter graph. @@ -433,7 +510,7 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx) for (j = 0; j < filter->nb_inputs; j++) { AVFilterLink *link = filter->inputs[j]; const AVFilterNegotiation *neg; - unsigned neg_step; + unsigned neg_step, conv_step; int convert_needed = 0; if (!link) @@ -469,68 +546,50 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx) } if (convert_needed) { - AVFilterContext *convert; - const AVFilter *filter; - AVFilterLink *inlink, *outlink; - char inst_name[30]; - const char *opts; - - if (graph->disable_auto_convert) { - av_log(log_ctx, AV_LOG_ERROR, - "The filters '%s' and '%s' do not have a common format " - "and automatic conversion is disabled.\n", - link->src->name, link->dst->name); - return AVERROR(EINVAL); - } - - /* couldn't merge format lists. auto-insert conversion filter */ - if (!(filter = avfilter_get_by_name(neg->conversion_filter))) { - av_log(log_ctx, AV_LOG_ERROR, - "'%s' filter not present, cannot convert formats.\n", - neg->conversion_filter); - return AVERROR(EINVAL); - } - snprintf(inst_name, sizeof(inst_name), "auto_%s_%d", - neg->conversion_filter, converter_count++); - opts = FF_FIELD_AT(char *, neg->conversion_opts_offset, *graph); - ret = avfilter_graph_create_filter(&convert, filter, inst_name, opts, NULL, graph); - if (ret < 0) - return ret; - if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0) - return ret; - - if ((ret = filter_query_formats(convert)) < 0) - return ret; + for (conv_step = 0; conv_step < neg->nb_conversion_filters; conv_step++) { + AVFilterContext *convert; + ret = insert_auto_filter(&convert, graph, link, neg, + conv_step, &converter_count, log_ctx); + if (ret < 0) { + av_log(log_ctx, AV_LOG_ERROR, "Failed to insert an auto filter.\n"); + return ret; + } - inlink = convert->inputs[0]; - outlink = convert->outputs[0]; - av_assert0( inlink->incfg.formats->refcount > 0); - av_assert0( inlink->outcfg.formats->refcount > 0); - av_assert0(outlink->incfg.formats->refcount > 0); - av_assert0(outlink->outcfg.formats->refcount > 0); - if (outlink->type == AVMEDIA_TYPE_AUDIO) { - av_assert0( inlink-> incfg.samplerates->refcount > 0); - av_assert0( inlink->outcfg.samplerates->refcount > 0); - av_assert0(outlink-> incfg.samplerates->refcount > 0); - av_assert0(outlink->outcfg.samplerates->refcount > 0); - av_assert0( inlink-> incfg.channel_layouts->refcount > 0); - av_assert0( inlink->outcfg.channel_layouts->refcount > 0); - av_assert0(outlink-> incfg.channel_layouts->refcount > 0); - av_assert0(outlink->outcfg.channel_layouts->refcount > 0); - } -#define MERGE(merger, link) \ - ((merger)->merge(FF_FIELD_AT(void *, (merger)->offset, (link)->incfg), \ - FF_FIELD_AT(void *, (merger)->offset, (link)->outcfg))) - for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) { - const AVFilterFormatsMerger *m = &neg->mergers[neg_step]; - if ((ret = MERGE(m, inlink)) <= 0 || - (ret = MERGE(m, outlink)) <= 0) { - if (ret < 0) - return ret; - av_log(log_ctx, AV_LOG_ERROR, - "Impossible to convert between the formats supported by the filter " - "'%s' and the filter '%s'\n", link->src->name, link->dst->name); - return AVERROR(ENOSYS); + ret = merge_auto_filter(convert, neg); + if (ret < 0) + return ret; + else if (ret > 0) + break; + else if (conv_step < neg->nb_conversion_filters - 1) { + AVFilterLink *inlink = convert->inputs[0]; + AVFilterLink *outlink = convert->outputs[0]; + av_log(log_ctx, AV_LOG_VERBOSE, + "Impossible to convert between the formats supported by the filter " + "'%s' and the filter '%s', try another conversion filter.\n", + link->src->name, link->dst->name); + unsigned dstpad_idx = outlink->dstpad - outlink->dst->input_pads; + converter_count--; + /* re-hookup the link */ + inlink->dst = outlink->dst; + inlink->dstpad = &outlink->dst->input_pads[dstpad_idx]; + outlink->dst->inputs[dstpad_idx] = inlink; + if (outlink->outcfg.formats) + ff_formats_changeref(&outlink->outcfg.formats, + &inlink->outcfg.formats); + if (outlink->outcfg.samplerates) + ff_formats_changeref(&outlink->outcfg.samplerates, + &inlink->outcfg.samplerates); + if (outlink->outcfg.channel_layouts) + ff_channel_layouts_changeref(&outlink->outcfg.channel_layouts, + &inlink->outcfg.channel_layouts); + /* remove the previous auto filter */ + convert->inputs[0] = NULL; + convert->outputs[0]->dst = NULL; + avfilter_free(convert); + } else { + av_log(log_ctx, AV_LOG_ERROR, + "Impossible to convert between the formats supported by the filter " + "'%s' and the filter '%s'\n", link->src->name, link->dst->name); } } } diff --git a/libavfilter/formats.c b/libavfilter/formats.c index e8c2888c0c..fee10fa0ee 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -326,18 +326,36 @@ static const AVFilterFormatsMerger mergers_audio[] = { }, }; +static const AVFilterFormatsFilter filters_video[] = { + { + .conversion_filter = "scale", + .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts), + }, + { + .conversion_filter = "hwmap", + .conversion_opts_offset = 0, + } +}; + +static const AVFilterFormatsFilter filters_audio[] = { + { + .conversion_filter = "aresample", + .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts), + } +}; + static const AVFilterNegotiation negotiate_video = { .nb_mergers = FF_ARRAY_ELEMS(mergers_video), .mergers = mergers_video, - .conversion_filter = "scale", - .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts), + .nb_conversion_filters = FF_ARRAY_ELEMS(filters_video), + .conversion_filters = filters_video, }; static const AVFilterNegotiation negotiate_audio = { .nb_mergers = FF_ARRAY_ELEMS(mergers_audio), .mergers = mergers_audio, - .conversion_filter = "aresample", - .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts), + .nb_conversion_filters = FF_ARRAY_ELEMS(filters_audio), + .conversion_filters = filters_audio, }; const AVFilterNegotiation *ff_filter_get_negotiation(AVFilterLink *link) diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 22224dce2d..9943fb8aa3 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -330,6 +330,11 @@ typedef struct AVFilterFormatMerger { int (*can_merge)(const void *a, const void *b); } AVFilterFormatsMerger; +typedef struct AVFilterFormatFilter { + const char *conversion_filter; + unsigned conversion_opts_offset; +} AVFilterFormatsFilter; + /** * Callbacks and properties to describe the steps of a format negotiation. * @@ -418,8 +423,8 @@ typedef struct AVFilterFormatMerger { typedef struct AVFilterNegotiation { unsigned nb_mergers; const AVFilterFormatsMerger *mergers; - const char *conversion_filter; - unsigned conversion_opts_offset; + unsigned nb_conversion_filters; + const AVFilterFormatsFilter *conversion_filters; } AVFilterNegotiation; const AVFilterNegotiation *ff_filter_get_negotiation(AVFilterLink *link); -- 2.35.1.windows.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-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 2:45 [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Tong Wu 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format Tong Wu 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/avfiltergraph: add an auto hwmap filter Tong Wu @ 2022-06-30 8:43 ` Anton Khirnov 2022-06-30 11:52 ` "zhilizhao(赵志立)" 2 siblings, 1 reply; 13+ messages in thread From: Anton Khirnov @ 2022-06-30 8:43 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Tong Wu Quoting Tong Wu (2022-06-30 04:45:56) > Add a function to get the corresponding AVHWDeviceType from a given > hardware pixel format. > > Signed-off-by: Tong Wu <tong1.wu@intel.com> > --- > libavutil/hwcontext.c | 12 ++++++++++++ > libavutil/hwcontext.h | 9 +++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c > index ab9ad3703e..3521ed34f4 100644 > --- a/libavutil/hwcontext.c > +++ b/libavutil/hwcontext.c > @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { > [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", > }; > > +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) > +{ > + int i, j; Nit: you can and should declare loop indices in the loop statement itself > + for (i = 0; hw_table[i]; i++) { > + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { > + if (hw_table[i]->pix_fmts[j] == fmt) > + return hw_table[i]->type; > + } > + } > + return AV_HWDEVICE_TYPE_NONE; > +} > + > enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) > { > int type; > diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h > index c18b7e1e8b..97f94403e2 100644 > --- a/libavutil/hwcontext.h > +++ b/libavutil/hwcontext.h > @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { > int width, height; > } AVHWFramesContext; > > +/** > + * Get the device type by a given pixel format. > + * > + * @param fmt Pixel format from enum AVPixelFormat. > + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if > + * not found. > + */ > +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); I wonder if we should consider the possibility of a format being supported by more than one device type. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 8:43 ` [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Anton Khirnov @ 2022-06-30 11:52 ` "zhilizhao(赵志立)" 2022-06-30 11:56 ` Andreas Rheinhardt 0 siblings, 1 reply; 13+ messages in thread From: "zhilizhao(赵志立)" @ 2022-06-30 11:52 UTC (permalink / raw) To: FFmpeg development discussions and patches > On Jun 30, 2022, at 4:43 PM, Anton Khirnov <anton@khirnov.net> wrote: > > Quoting Tong Wu (2022-06-30 04:45:56) >> Add a function to get the corresponding AVHWDeviceType from a given >> hardware pixel format. >> >> Signed-off-by: Tong Wu <tong1.wu@intel.com> >> --- >> libavutil/hwcontext.c | 12 ++++++++++++ >> libavutil/hwcontext.h | 9 +++++++++ >> 2 files changed, 21 insertions(+) >> >> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c >> index ab9ad3703e..3521ed34f4 100644 >> --- a/libavutil/hwcontext.c >> +++ b/libavutil/hwcontext.c >> @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { >> [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", >> }; >> >> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) >> +{ >> + int i, j; > > Nit: you can and should declare loop indices in the loop statement > itself > >> + for (i = 0; hw_table[i]; i++) { >> + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { >> + if (hw_table[i]->pix_fmts[j] == fmt) >> + return hw_table[i]->type; >> + } >> + } >> + return AV_HWDEVICE_TYPE_NONE; >> +} >> + >> enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) >> { >> int type; >> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h >> index c18b7e1e8b..97f94403e2 100644 >> --- a/libavutil/hwcontext.h >> +++ b/libavutil/hwcontext.h >> @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { >> int width, height; >> } AVHWFramesContext; >> >> +/** >> + * Get the device type by a given pixel format. >> + * >> + * @param fmt Pixel format from enum AVPixelFormat. >> + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if >> + * not found. >> + */ >> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); > > I wonder if we should consider the possibility of a format being > supported by more than one device type. For future proof, we can make it clear that there is no guarantee that the device type is unique, e.g., "Get any device type which support the given pixel format” > > -- > Anton Khirnov > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 11:52 ` "zhilizhao(赵志立)" @ 2022-06-30 11:56 ` Andreas Rheinhardt 2022-06-30 12:12 ` "zhilizhao(赵志立)" 0 siblings, 1 reply; 13+ messages in thread From: Andreas Rheinhardt @ 2022-06-30 11:56 UTC (permalink / raw) To: ffmpeg-devel "zhilizhao(赵志立)": > > >> On Jun 30, 2022, at 4:43 PM, Anton Khirnov <anton@khirnov.net> wrote: >> >> Quoting Tong Wu (2022-06-30 04:45:56) >>> Add a function to get the corresponding AVHWDeviceType from a given >>> hardware pixel format. >>> >>> Signed-off-by: Tong Wu <tong1.wu@intel.com> >>> --- >>> libavutil/hwcontext.c | 12 ++++++++++++ >>> libavutil/hwcontext.h | 9 +++++++++ >>> 2 files changed, 21 insertions(+) >>> >>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c >>> index ab9ad3703e..3521ed34f4 100644 >>> --- a/libavutil/hwcontext.c >>> +++ b/libavutil/hwcontext.c >>> @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { >>> [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", >>> }; >>> >>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) >>> +{ >>> + int i, j; >> >> Nit: you can and should declare loop indices in the loop statement >> itself >> >>> + for (i = 0; hw_table[i]; i++) { >>> + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { >>> + if (hw_table[i]->pix_fmts[j] == fmt) >>> + return hw_table[i]->type; >>> + } >>> + } >>> + return AV_HWDEVICE_TYPE_NONE; >>> +} >>> + >>> enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) >>> { >>> int type; >>> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h >>> index c18b7e1e8b..97f94403e2 100644 >>> --- a/libavutil/hwcontext.h >>> +++ b/libavutil/hwcontext.h >>> @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { >>> int width, height; >>> } AVHWFramesContext; >>> >>> +/** >>> + * Get the device type by a given pixel format. >>> + * >>> + * @param fmt Pixel format from enum AVPixelFormat. >>> + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if >>> + * not found. >>> + */ >>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); >> >> I wonder if we should consider the possibility of a format being >> supported by more than one device type. > > For future proof, we can make it clear that there is no guarantee > that the device type is unique, e.g., > > "Get any device type which support the given pixel format” > Then you'd need to return a list or modify the user accept an iterator. - 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-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 11:56 ` Andreas Rheinhardt @ 2022-06-30 12:12 ` "zhilizhao(赵志立)" 2022-07-01 2:37 ` Wu, Tong1 2022-07-02 8:50 ` Anton Khirnov 0 siblings, 2 replies; 13+ messages in thread From: "zhilizhao(赵志立)" @ 2022-06-30 12:12 UTC (permalink / raw) To: FFmpeg development discussions and patches > On Jun 30, 2022, at 7:56 PM, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote: > > "zhilizhao(赵志立)": >> >> >>> On Jun 30, 2022, at 4:43 PM, Anton Khirnov <anton@khirnov.net> wrote: >>> >>> Quoting Tong Wu (2022-06-30 04:45:56) >>>> Add a function to get the corresponding AVHWDeviceType from a given >>>> hardware pixel format. >>>> >>>> Signed-off-by: Tong Wu <tong1.wu@intel.com> >>>> --- >>>> libavutil/hwcontext.c | 12 ++++++++++++ >>>> libavutil/hwcontext.h | 9 +++++++++ >>>> 2 files changed, 21 insertions(+) >>>> >>>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c >>>> index ab9ad3703e..3521ed34f4 100644 >>>> --- a/libavutil/hwcontext.c >>>> +++ b/libavutil/hwcontext.c >>>> @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { >>>> [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", >>>> }; >>>> >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) >>>> +{ >>>> + int i, j; >>> >>> Nit: you can and should declare loop indices in the loop statement >>> itself >>> >>>> + for (i = 0; hw_table[i]; i++) { >>>> + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { >>>> + if (hw_table[i]->pix_fmts[j] == fmt) >>>> + return hw_table[i]->type; >>>> + } >>>> + } >>>> + return AV_HWDEVICE_TYPE_NONE; >>>> +} >>>> + >>>> enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) >>>> { >>>> int type; >>>> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h >>>> index c18b7e1e8b..97f94403e2 100644 >>>> --- a/libavutil/hwcontext.h >>>> +++ b/libavutil/hwcontext.h >>>> @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { >>>> int width, height; >>>> } AVHWFramesContext; >>>> >>>> +/** >>>> + * Get the device type by a given pixel format. >>>> + * >>>> + * @param fmt Pixel format from enum AVPixelFormat. >>>> + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if >>>> + * not found. >>>> + */ >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); >>> >>> I wonder if we should consider the possibility of a format being >>> supported by more than one device type. >> >> For future proof, we can make it clear that there is no guarantee >> that the device type is unique, e.g., >> >> "Get any device type which support the given pixel format” >> > > Then you'd need to return a list or modify the user accept an iterator. Iterator should be fine. However, the use case is unclear: since we only return an AVHWDeviceType without description like av_pix_fmt_desc_get(), user has little information to skip to the next one, unless user only wants to get all of the device types which support a pixel format. > > - 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-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 12:12 ` "zhilizhao(赵志立)" @ 2022-07-01 2:37 ` Wu, Tong1 2022-07-01 6:51 ` Wu, Tong1 2022-07-02 8:50 ` Anton Khirnov 1 sibling, 1 reply; 13+ messages in thread From: Wu, Tong1 @ 2022-07-01 2:37 UTC (permalink / raw) To: FFmpeg development discussions and patches > > On Jun 30, 2022, at 7:56 PM, Andreas Rheinhardt > <andreas.rheinhardt@outlook.com> wrote: > > > > "zhilizhao(赵志立)": > >> > >> > >>> On Jun 30, 2022, at 4:43 PM, Anton Khirnov <anton@khirnov.net> wrote: > >>> > >>> Quoting Tong Wu (2022-06-30 04:45:56) > >>>> Add a function to get the corresponding AVHWDeviceType from a given > >>>> hardware pixel format. > >>>> > >>>> Signed-off-by: Tong Wu <tong1.wu@intel.com> > >>>> --- > >>>> libavutil/hwcontext.c | 12 ++++++++++++ libavutil/hwcontext.h | 9 > >>>> +++++++++ > >>>> 2 files changed, 21 insertions(+) > >>>> > >>>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index > >>>> ab9ad3703e..3521ed34f4 100644 > >>>> --- a/libavutil/hwcontext.c > >>>> +++ b/libavutil/hwcontext.c > >>>> @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { > >>>> [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; > >>>> > >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum > >>>> +AVPixelFormat fmt) { > >>>> + int i, j; > >>> > >>> Nit: you can and should declare loop indices in the loop statement > >>> itself Sure, will modify them in v3. > >>> > >>>> + for (i = 0; hw_table[i]; i++) { > >>>> + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { > >>>> + if (hw_table[i]->pix_fmts[j] == fmt) > >>>> + return hw_table[i]->type; > >>>> + } > >>>> + } > >>>> + return AV_HWDEVICE_TYPE_NONE; > >>>> +} > >>>> + > >>>> enum AVHWDeviceType av_hwdevice_find_type_by_name(const char > *name) > >>>> { > >>>> int type; > >>>> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index > >>>> c18b7e1e8b..97f94403e2 100644 > >>>> --- a/libavutil/hwcontext.h > >>>> +++ b/libavutil/hwcontext.h > >>>> @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { > >>>> int width, height; > >>>> } AVHWFramesContext; > >>>> > >>>> +/** > >>>> + * Get the device type by a given pixel format. > >>>> + * > >>>> + * @param fmt Pixel format from enum AVPixelFormat. > >>>> + * @return The type from enum AVHWDeviceType, or > AV_HWDEVICE_TYPE_NONE if > >>>> + * not found. > >>>> + */ > >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum > >>>> +AVPixelFormat fmt); > >>> > >>> I wonder if we should consider the possibility of a format being > >>> supported by more than one device type. > >> > >> For future proof, we can make it clear that there is no guarantee > >> that the device type is unique, e.g., > >> > >> "Get any device type which support the given pixel format” > >> > > > > Then you'd need to return a list or modify the user accept an iterator. > > Iterator should be fine. > > However, the use case is unclear: since we only return an AVHWDeviceType > without description like av_pix_fmt_desc_get(), user has little information to > skip to the next one, unless user only wants to get all of the device types > which support a pixel format. Since so far there's no hardware format being supported by more than one hardware device, can we just keep current implementation and clarify it in comments such as "Get any device type which support the given pixel format”? Thanks, Tong > > > > > - 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-request@ffmpeg.org with subject "unsubscribe". > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org > with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-07-01 2:37 ` Wu, Tong1 @ 2022-07-01 6:51 ` Wu, Tong1 0 siblings, 0 replies; 13+ messages in thread From: Wu, Tong1 @ 2022-07-01 6:51 UTC (permalink / raw) To: FFmpeg development discussions and patches > > > On Jun 30, 2022, at 7:56 PM, Andreas Rheinhardt > > <andreas.rheinhardt@outlook.com> wrote: > > > > > > "zhilizhao(赵志立)": > > >> > > >> > > >>> On Jun 30, 2022, at 4:43 PM, Anton Khirnov <anton@khirnov.net> > wrote: > > >>> > > >>> Quoting Tong Wu (2022-06-30 04:45:56) > > >>>> Add a function to get the corresponding AVHWDeviceType from a > > >>>> given hardware pixel format. > > >>>> > > >>>> Signed-off-by: Tong Wu <tong1.wu@intel.com> > > >>>> --- > > >>>> libavutil/hwcontext.c | 12 ++++++++++++ libavutil/hwcontext.h | > > >>>> 9 > > >>>> +++++++++ > > >>>> 2 files changed, 21 insertions(+) > > >>>> > > >>>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index > > >>>> ab9ad3703e..3521ed34f4 100644 > > >>>> --- a/libavutil/hwcontext.c > > >>>> +++ b/libavutil/hwcontext.c > > >>>> @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { > > >>>> [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; > > >>>> > > >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum > > >>>> +AVPixelFormat fmt) { > > >>>> + int i, j; > > >>> > > >>> Nit: you can and should declare loop indices in the loop statement > > >>> itself > > Sure, will modify them in v3. > > > >>> > > >>>> + for (i = 0; hw_table[i]; i++) { > > >>>> + for (j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { > > >>>> + if (hw_table[i]->pix_fmts[j] == fmt) > > >>>> + return hw_table[i]->type; > > >>>> + } > > >>>> + } > > >>>> + return AV_HWDEVICE_TYPE_NONE; } > > >>>> + > > >>>> enum AVHWDeviceType av_hwdevice_find_type_by_name(const char > > *name) > > >>>> { > > >>>> int type; > > >>>> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index > > >>>> c18b7e1e8b..97f94403e2 100644 > > >>>> --- a/libavutil/hwcontext.h > > >>>> +++ b/libavutil/hwcontext.h > > >>>> @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { > > >>>> int width, height; > > >>>> } AVHWFramesContext; > > >>>> > > >>>> +/** > > >>>> + * Get the device type by a given pixel format. > > >>>> + * > > >>>> + * @param fmt Pixel format from enum AVPixelFormat. > > >>>> + * @return The type from enum AVHWDeviceType, or > > AV_HWDEVICE_TYPE_NONE if > > >>>> + * not found. > > >>>> + */ > > >>>> +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum > > >>>> +AVPixelFormat fmt); > > >>> > > >>> I wonder if we should consider the possibility of a format being > > >>> supported by more than one device type. > > >> > > >> For future proof, we can make it clear that there is no guarantee > > >> that the device type is unique, e.g., > > >> > > >> "Get any device type which support the given pixel format” > > >> > > > > > > Then you'd need to return a list or modify the user accept an iterator. > > > > Iterator should be fine. > > > > However, the use case is unclear: since we only return an > > AVHWDeviceType without description like av_pix_fmt_desc_get(), user > > has little information to skip to the next one, unless user only wants > > to get all of the device types which support a pixel format. > > Since so far there's no hardware format being supported by more than one > hardware device, can we just keep current implementation and clarify it in > comments such as "Get any device type which support the given pixel > format”? > > Thanks, > Tong > Plus, do you think adding a AV_PIX_FMT_FLAG_HWACCEL check for the input pixel format and change the function name to av_hwdevice_get_type_by_hwaccel_pix_fmt will help? Let users know only hardware pixel formats are acceptable for this function and like I said at this moment not any hardware format is supported by more than one hardware devices. Tong > > > > > > > > - 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-request@ffmpeg.org with subject "unsubscribe". > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org > with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-06-30 12:12 ` "zhilizhao(赵志立)" 2022-07-01 2:37 ` Wu, Tong1 @ 2022-07-02 8:50 ` Anton Khirnov 2022-07-03 12:11 ` Wu, Tong1 1 sibling, 1 reply; 13+ messages in thread From: Anton Khirnov @ 2022-07-02 8:50 UTC (permalink / raw) To: FFmpeg development discussions and patches Quoting Wu, Tong1 (2022-07-01 08:51:28) > Plus, do you think adding a AV_PIX_FMT_FLAG_HWACCEL check for the > input pixel format and change the function name to > av_hwdevice_get_type_by_hwaccel_pix_fmt will help? I'd prefer not to, that name is way too long > Let users know only hardware pixel formats are acceptable for this > function and like I said at this moment not any hardware format is > supported by more than one hardware devices. Maybe just document in the doxy that it will return the preferred device type for a pixel format. Overall I don't insist on any changes here, mainly wondering if anyone can think of a potential future case where we'd want a single pixel format supported by multiple devices -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType 2022-07-02 8:50 ` Anton Khirnov @ 2022-07-03 12:11 ` Wu, Tong1 0 siblings, 0 replies; 13+ messages in thread From: Wu, Tong1 @ 2022-07-03 12:11 UTC (permalink / raw) To: FFmpeg development discussions and patches > Quoting Wu, Tong1 (2022-07-01 08:51:28) > > Plus, do you think adding a AV_PIX_FMT_FLAG_HWACCEL check for the > > input pixel format and change the function name to > > av_hwdevice_get_type_by_hwaccel_pix_fmt will help? > > I'd prefer not to, that name is way too long > > > Let users know only hardware pixel formats are acceptable for this > > function and like I said at this moment not any hardware format is > > supported by more than one hardware devices. > > Maybe just document in the doxy that it will return the preferred device type > for a pixel format. Sure, will do it in v3. Thanks for the comments. > > Overall I don't insist on any changes here, mainly wondering if anyone can > think of a potential future case where we'd want a single pixel format > supported by multiple devices > > -- > Anton Khirnov > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org > with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-07-03 12:12 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-30 2:45 [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Tong Wu 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format Tong Wu 2022-06-30 11:49 ` Paul B Mahol 2022-07-01 2:11 ` Wu, Tong1 2022-06-30 2:45 ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/avfiltergraph: add an auto hwmap filter Tong Wu 2022-06-30 8:43 ` [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext: add a function to get the AVHWDeviceType Anton Khirnov 2022-06-30 11:52 ` "zhilizhao(赵志立)" 2022-06-30 11:56 ` Andreas Rheinhardt 2022-06-30 12:12 ` "zhilizhao(赵志立)" 2022-07-01 2:37 ` Wu, Tong1 2022-07-01 6:51 ` Wu, Tong1 2022-07-02 8:50 ` Anton Khirnov 2022-07-03 12:11 ` Wu, Tong1
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git