diff --git a/libavfilter/vf_cuda_grid.c b/libavfilter/vf_cuda_grid.c index 32c4922..3bb2852 100644 --- a/libavfilter/vf_cuda_grid.c +++ b/libavfilter/vf_cuda_grid.c @@ -1450,6 +1450,39 @@ static int cuda_grid_process_command(AVFilterContext *ctx, const char *cmd, return 0; } + if (!strcmp(cmd, "reload_icon")) { + /* Invalidate cached icon atlas by name — next render re-reads file from disk. + * Used Phase 6 by controller для periodic chart/chat re-rendering. */ + char name[OVERLAY_ICON_NAME_MAX]; + int i, found = -1; + if (!arg || sscanf(arg, "%31s", name) != 1) { + if (res) av_strlcpy(res, "err parse", res_len); + return AVERROR(EINVAL); + } + pthread_mutex_lock(&s->overlay_lock); + if (s->hwctx) { + CUcontext dummy; + CHECK_CU(s->hwctx->internal->cuda_dl->cuCtxPushCurrent(s->cu_ctx)); + for (i = 0; i < s->nb_icon_atlases; i++) { + if (!strcmp(s->icon_atlases[i].icon_name, name)) { + if (s->icon_atlases[i].device_ptr) { + s->hwctx->internal->cuda_dl->cuMemFree(s->icon_atlases[i].device_ptr); + s->icon_atlases[i].device_ptr = 0; + } + memmove(&s->icon_atlases[i], &s->icon_atlases[i + 1], + (s->nb_icon_atlases - i - 1) * sizeof(IconAtlas)); + s->nb_icon_atlases--; + found = i; + break; + } + } + CHECK_CU(s->hwctx->internal->cuda_dl->cuCtxPopCurrent(&dummy)); + } + pthread_mutex_unlock(&s->overlay_lock); + if (res) snprintf(res, res_len, found >= 0 ? "ok %s reloaded" : "not_cached %s", name); + return 0; + } + /* Future: set_layout (Phase 3 на filter side — пока nb_inputs хардкодится в init) */ /* Fall back to standard option/command handling */