|
3 | 3 | * \brief abstraction for all consumer services |
4 | 4 | * \see mlt_consumer_s |
5 | 5 | * |
6 | | - * Copyright (C) 2003-2023 Meltytech, LLC |
| 6 | + * Copyright (C) 2003-2025 Meltytech, LLC |
7 | 7 | * |
8 | 8 | * This library is free software; you can redistribute it and/or |
9 | 9 | * modify it under the terms of the GNU Lesser General Public |
|
21 | 21 | */ |
22 | 22 |
|
23 | 23 | #include "mlt_consumer.h" |
| 24 | +#include "mlt_cache.h" |
24 | 25 | #include "mlt_factory.h" |
25 | 26 | #include "mlt_frame.h" |
26 | 27 | #include "mlt_log.h" |
@@ -682,12 +683,43 @@ mlt_frame mlt_consumer_get_frame(mlt_consumer self) |
682 | 683 | mlt_properties_set(frame_properties, |
683 | 684 | "consumer.color_trc", |
684 | 685 | mlt_properties_get(properties, "color_trc")); |
| 686 | + mlt_properties_set(frame_properties, |
| 687 | + "consumer.mlt_color_trc", |
| 688 | + mlt_properties_get(properties, "mlt_color_trc")); |
685 | 689 | mlt_properties_set(frame_properties, |
686 | 690 | "consumer.channel_layout", |
687 | 691 | mlt_properties_get(properties, "channel_layout")); |
688 | 692 | mlt_properties_set(frame_properties, |
689 | 693 | "consumer.color_range", |
690 | 694 | mlt_properties_get(properties, "color_range")); |
| 695 | + |
| 696 | + if (mlt_properties_get(properties, "mlt_color_trc")) { |
| 697 | + // Add a normalize filter to convert the mlt_color_trc to color_trc |
| 698 | + mlt_cache_item cache_item = mlt_service_cache_get(service, "cs_filter"); |
| 699 | + if (!cache_item) { |
| 700 | + mlt_profile profile = mlt_service_profile(service); |
| 701 | + mlt_filter cs_filter = mlt_factory_filter(profile, "colorspace", NULL); |
| 702 | + mlt_properties cs_properties = MLT_FILTER_PROPERTIES(cs_filter); |
| 703 | + if (cs_filter) { |
| 704 | + const char *color_trc_str = mlt_properties_get(properties, "color_trc"); |
| 705 | + mlt_color_trc trc = mlt_image_color_trc_id(color_trc_str); |
| 706 | + if (trc == mlt_color_trc_none) |
| 707 | + trc = mlt_image_default_trc(profile->colorspace); |
| 708 | + mlt_properties_set_int(cs_properties, "force_trc", trc); |
| 709 | + mlt_service_cache_put(service, |
| 710 | + "cs_filter", |
| 711 | + cs_filter, |
| 712 | + 0, |
| 713 | + (mlt_destructor) mlt_filter_close); |
| 714 | + } |
| 715 | + cache_item = mlt_service_cache_get(service, "cs_filter"); |
| 716 | + } |
| 717 | + if (cache_item) { |
| 718 | + mlt_filter cs_filter = mlt_cache_item_data(cache_item, NULL); |
| 719 | + mlt_filter_process(cs_filter, frame); |
| 720 | + mlt_cache_item_close(cache_item); |
| 721 | + } |
| 722 | + } |
691 | 723 | } |
692 | 724 |
|
693 | 725 | // Return the frame |
@@ -1716,6 +1748,7 @@ void mlt_consumer_close(mlt_consumer self) |
1716 | 1748 |
|
1717 | 1749 | pthread_mutex_destroy(&priv->position_mutex); |
1718 | 1750 |
|
| 1751 | + mlt_service_cache_purge(&self->parent); |
1719 | 1752 | mlt_service_close(&self->parent); |
1720 | 1753 | free(priv); |
1721 | 1754 | } |
|
0 commit comments