Files
cuframes-composer/src/layouts.c
T
gx 2d7fc1e640 Phase 9 #193: runtime layout switching через ZMQ set_layout
10 predefined layouts (single, dual_horizontal, dual_vertical, quad,
main_plus_preview, six_grid, nine_grid, sixteen_grid, panoramic,
main_with_strip) — normalized [0..1] координаты, port из vf_cuda_grid.c
старого FFmpeg patch'а. Применяются к фактическому output разрешению
композитора через cfc_composer_set_layout(name).

Source pool НЕ пересоздаётся: sources привязаны к индексам cells, layout
меняет только геометрию (cell.x/y/w/h). Это даёт zero-disruption switch
без потери накопленного state и без re-subscribe к cuframes publishers.

ZMQ verbs: set_layout / list_layouts / get_layout. CLI: --layout=NAME
перетирает --cell координаты на старте.

Используется ONVIF wrapper'ом (gx/cctv-onvif:0.1) для PTZ presets:
GotoPreset(token) → ZMQ set_layout(token).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 18:14:58 +01:00

101 lines
3.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Predefined layouts table — port из vf_cuda_grid.c (старый FFmpeg patch).
*
* Layouts normalized [0..1], apply'ятся к фактическому output разрешению
* композитора в момент set_layout — не привязаны к конкретным cell coords.
*
* Лицензия: LGPL-2.1+
*/
#include "../include/cuframes_composer/layouts.h"
#include <stddef.h>
#include <string.h>
static const cfc_layout_t g_layouts[] = {
{
"single", 1,
{ {0.0f, 0.0f, 1.0f, 1.0f} }
},
{
"dual_horizontal", 2,
{ {0.0f, 0.0f, 0.5f, 1.0f}, {0.5f, 0.0f, 0.5f, 1.0f} }
},
{
"dual_vertical", 2,
{ {0.0f, 0.0f, 1.0f, 0.5f}, {0.0f, 0.5f, 1.0f, 0.5f} }
},
{
"quad", 4,
{
{0.0f, 0.0f, 0.5f, 0.5f}, {0.5f, 0.0f, 0.5f, 0.5f},
{0.0f, 0.5f, 0.5f, 0.5f}, {0.5f, 0.5f, 0.5f, 0.5f},
}
},
{
/* Main 2/3 width слева + 3 preview справа сверху вниз. */
"main_plus_preview", 4,
{
{0.0f, 0.0f, 2.0f/3, 1.0f},
{2.0f/3, 0.0f, 1.0f/3, 1.0f/3},
{2.0f/3, 1.0f/3, 1.0f/3, 1.0f/3},
{2.0f/3, 2.0f/3, 1.0f/3, 1.0f/3},
}
},
{
"six_grid", 6,
{
{0.0f, 0.0f, 1.0f/3, 0.5f}, {1.0f/3, 0.0f, 1.0f/3, 0.5f}, {2.0f/3, 0.0f, 1.0f/3, 0.5f},
{0.0f, 0.5f, 1.0f/3, 0.5f}, {1.0f/3, 0.5f, 1.0f/3, 0.5f}, {2.0f/3, 0.5f, 1.0f/3, 0.5f},
}
},
{
"nine_grid", 9,
{
{0.0f, 0.0f, 1.0f/3, 1.0f/3}, {1.0f/3, 0.0f, 1.0f/3, 1.0f/3}, {2.0f/3, 0.0f, 1.0f/3, 1.0f/3},
{0.0f, 1.0f/3, 1.0f/3, 1.0f/3}, {1.0f/3, 1.0f/3, 1.0f/3, 1.0f/3}, {2.0f/3, 1.0f/3, 1.0f/3, 1.0f/3},
{0.0f, 2.0f/3, 1.0f/3, 1.0f/3}, {1.0f/3, 2.0f/3, 1.0f/3, 1.0f/3}, {2.0f/3, 2.0f/3, 1.0f/3, 1.0f/3},
}
},
{
"sixteen_grid", 16,
{
{0.00f, 0.00f, 0.25f, 0.25f}, {0.25f, 0.00f, 0.25f, 0.25f}, {0.50f, 0.00f, 0.25f, 0.25f}, {0.75f, 0.00f, 0.25f, 0.25f},
{0.00f, 0.25f, 0.25f, 0.25f}, {0.25f, 0.25f, 0.25f, 0.25f}, {0.50f, 0.25f, 0.25f, 0.25f}, {0.75f, 0.25f, 0.25f, 0.25f},
{0.00f, 0.50f, 0.25f, 0.25f}, {0.25f, 0.50f, 0.25f, 0.25f}, {0.50f, 0.50f, 0.25f, 0.25f}, {0.75f, 0.50f, 0.25f, 0.25f},
{0.00f, 0.75f, 0.25f, 0.25f}, {0.25f, 0.75f, 0.25f, 0.25f}, {0.50f, 0.75f, 0.25f, 0.25f}, {0.75f, 0.75f, 0.25f, 0.25f},
}
},
{
"panoramic", 1,
{ {0.0f, 0.0f, 1.0f, 1.0f} }
},
{
/* Main 16:9 (75%×75%) + 3 preview right + bottom info strip. */
"main_with_strip", 5,
{
{0.0f, 0.0f, 0.75f, 0.75f},
{0.75f, 0.0f, 0.25f, 0.25f},
{0.75f, 0.25f, 0.25f, 0.25f},
{0.75f, 0.5f, 0.25f, 0.25f},
{0.0f, 0.75f, 1.0f, 0.25f},
}
},
};
static const int g_layouts_count = (int)(sizeof(g_layouts) / sizeof(g_layouts[0]));
const cfc_layout_t *cfc_layout_find(const char *name)
{
if (!name) return NULL;
for (int i = 0; i < g_layouts_count; i++) {
if (!strcmp(g_layouts[i].name, name)) return &g_layouts[i];
}
return NULL;
}
const cfc_layout_t *cfc_layout_all(int *out_count)
{
if (out_count) *out_count = g_layouts_count;
return g_layouts;
}