Skip to content

Commit 5780111

Browse files
ddennedyCopilot
andauthored
Refactor image conversion (#1235)
* Refactor image conversion - Refactored image conversion handling across various modules to use new framework functions for better clarity and maintainability. - Now, there can be multiple possible image converters per frame stopping after the first success. But also, one converter can part of the work (e.g. dowload from GPU) while a later one converts it to the actual requested format. - Replaced direct calls to `convert_image` with `mlt_frame_convert_image` and added checks for the existence of conversion functions. - Improved documentation in YAML files to clarify the purpose of image conversion callbacks. - Added tests to verify the correct propagation of image conversion functions through frames and producers. * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix early returns not releasing lock * change a log to debug level * add `mlt_frame_prepend_convert_image()` * fix cppcheck and redundant workflow runs * fix ctest on msvc * mlt_frame_append_convert_image() --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 76be501 commit 5780111

39 files changed

Lines changed: 701 additions & 240 deletions

.github/workflows/build-distros.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ on:
2020
- debian-stable
2121
- fedora-44
2222
- fedora-38
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
25+
cancel-in-progress: true
2326

2427
jobs:
2528
build:

.github/workflows/build-linux.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: build-test-linux-on-push
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
412

513
jobs:
614
python:

.github/workflows/build-msys2-mingw64.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
name: build-test-msys2-mingw64-on-push
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
413

514
jobs:
615
build:

.github/workflows/build-windows-msvc.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: build-test-windows-msvc-on-push
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
412

513
permissions:
614
packages: write
@@ -55,4 +63,4 @@ jobs:
5563
5664
- name: Run tests
5765
run: |
58-
ctest --test-dir build -C Debug
66+
ctest --test-dir build -C Debug --rerun-failed --output-on-failure

.github/workflows/static-code-analysis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: static-code-analysis
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
412

513
jobs:
614
cppcheck:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ endif()
103103

104104
if(NOT EXISTS ${MLT_DATA_OUTPUT_DIRECTORY})
105105
if(WIN32) # symlinks require admin rights on Windows
106-
file(COPY "${CMAKE_SOURCE_DIR}/src/modules" DESTINATION "${CMAKE_BINARY_DIR}/out/share" FILES_MATCHING REGEX yml|txt)
106+
file(COPY "${CMAKE_SOURCE_DIR}/src/modules" DESTINATION "${CMAKE_BINARY_DIR}/out/share" FILES_MATCHING REGEX "yml|txt|ini|dict")
107107
file(RENAME "${CMAKE_BINARY_DIR}/out/share/modules" "${MLT_DATA_OUTPUT_DIRECTORY}")
108108
file(COPY "${CMAKE_SOURCE_DIR}/presets" DESTINATION "${MLT_DATA_OUTPUT_DIRECTORY}")
109109
file(COPY "${CMAKE_SOURCE_DIR}/profiles" DESTINATION "${MLT_DATA_OUTPUT_DIRECTORY}")

NEWS

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
MLT Release Notes
22
-----------------
33

4+
Version 7.42.0
5+
6+
Framework
7+
- Added list-based image-conversion callback dispatch on mlt_frame.
8+
Use `mlt_frame_append_convert_image()` to register a converter instead of
9+
setting `frame->convert_image` directly. Multiple converters are tried in
10+
registration order; the first that succeeds wins. New public API:
11+
- `mlt_frame_prepend_convert_image()`
12+
- `mlt_frame_append_convert_image()`
13+
- `mlt_frame_convert_image()`
14+
- `mlt_frame_next_convert_image()`
15+
- `mlt_frame_has_convert_image()`
16+
- `mlt_frame_copy_convert_image()`
17+
- API behavior change: `mlt_frame_s::convert_image` is now read-only after
18+
init and is permanently set to the dispatcher `mlt_frame_convert_image()`.
19+
External code that set this field directly to a custom function will no
20+
longer have that function called. If you really need that (never heard of
21+
someone who does), clear the frame's "_convert_image_callbacks" property
22+
and use `mlt_frame_append_convert_image()` instead.
23+
24+
Modules
25+
- Image converters (`movit.convert`, `avcolor_space`, `imageconvert`) are
26+
now attached data-driven via `loader.ini` key `image_convert`.
27+
28+
429
Version 7.40.0
530

631
Framework

makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ cppcheck:
2929
--include=src/framework/mlt_types.h \
3030
--library=cppcheck.cfg \
3131
--suppress=ctuOneDefinitionRuleViolation \
32-
--suppress=syntaxError:src/modules/xml/common.c
32+
--suppress=syntaxError:src/modules/xml/common.c \
33+
--suppress=syntaxError:src/modules/placebo/filter_placebo_convert.c \
34+
--suppress=syntaxError:src/modules/placebo/filter_placebo_render.c \
35+
--suppress=syntaxError:src/modules/placebo/filter_placebo_shader.c \
36+
--suppress=syntaxError:src/modules/placebo/gpu_context.c

src/framework/mlt.vers

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,13 @@ MLT_7.36.0 {
687687
mlt_color_convert_trc;
688688
mlt_profile_is_valid;
689689
} MLT_7.34.0;
690+
691+
MLT_7.40.0 {
692+
global:
693+
mlt_frame_append_convert_image;
694+
mlt_frame_prepend_convert_image;
695+
mlt_frame_has_convert_image;
696+
mlt_frame_convert_image;
697+
mlt_frame_next_convert_image;
698+
mlt_frame_copy_convert_image;
699+
} MLT_7.36.0;

0 commit comments

Comments
 (0)