diff options
author | Jan Schmidt <jan@centricular.com> | 2021-06-25 23:42:34 +1000 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-06-26 04:00:08 +0000 |
commit | 8c04f4bdae1c9d7cdeaf17b2ac07f4148eb528dd (patch) | |
tree | d7eff7a55f36f1ebb7c026b84e379da1cee7af84 /gst-libs | |
parent | ef324fa068699291866d29eea3e84492642b9bf9 (diff) | |
download | gstreamer-plugins-base-8c04f4bdae1c9d7cdeaf17b2ac07f4148eb528dd.tar.gz |
video-converter: Set up matrix tables only once.
When configuring a multi-thread converter, only allocate the
shared colour conversion matrices once for the first thread,
to avoid allocating multiple times and leaking memory.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1216>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/video/video-converter.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c index aa4740d47..990168eef 100644 --- a/gst-libs/gst/video/video-converter.c +++ b/gst-libs/gst/video/video-converter.c @@ -1577,7 +1577,8 @@ chain_convert_to_RGB (GstVideoConverter * convert, GstLineCache * prev, if (do_gamma) { gint scale; - if (!convert->unpack_rgb) { + /* Set up conversion matrices if needed, but only for the first thread */ + if (idx == 0 && !convert->unpack_rgb) { color_matrix_set_identity (&convert->to_RGB_matrix); compute_matrix_to_RGB (convert, &convert->to_RGB_matrix); @@ -1831,8 +1832,10 @@ chain_convert (GstVideoConverter * convert, GstLineCache * prev, gint idx) convert->current_bits = MAX (convert->in_bits, convert->out_bits); do_conversion = TRUE; - if (!same_matrix || !same_primaries) - prepare_matrix (convert, &convert->convert_matrix); + if (!same_matrix || !same_primaries) { + if (idx == 0) + prepare_matrix (convert, &convert->convert_matrix); + } if (convert->in_bits == convert->out_bits) pass_alloc = TRUE; } else @@ -1846,7 +1849,8 @@ chain_convert (GstVideoConverter * convert, GstLineCache * prev, gint idx) if (same_primaries) { do_conversion = FALSE; } else { - prepare_matrix (convert, &convert->convert_matrix); + if (idx == 0) + prepare_matrix (convert, &convert->convert_matrix); convert->in_bits = convert->out_bits = 16; pass_alloc = TRUE; do_conversion = TRUE; @@ -1968,7 +1972,7 @@ chain_convert_to_YUV (GstVideoConverter * convert, GstLineCache * prev, convert->current_bits = convert->pack_bits; convert->current_pstride = convert->current_bits >> 1; - if (!convert->pack_rgb) { + if (idx == 0 && !convert->pack_rgb) { color_matrix_set_identity (&convert->to_YUV_matrix); compute_matrix_to_YUV (convert, &convert->to_YUV_matrix, FALSE); |