From d55c5a3eecf5ec857ecb27e5597582c8da6cb7e2 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 2 Mar 2023 17:23:44 +0100 Subject: [PATCH] cccombiner: fix s334-1a in place conversion The code wants to prepend one byte to every byte pair. It correctly did so by working backwards pair-wise, but then didn't work backwards instead of each individual pair / future triplet, overwriting information before attempting to read it. The code also failed to update the len pointer after prepending. This fixes both issues. Part-of: --- .../gst-plugins-bad/ext/closedcaption/gstcccombiner.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c b/subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c index b484ffe2ba..743f444bab 100644 --- a/subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c +++ b/subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c @@ -170,10 +170,12 @@ prepend_s334_to_cea608 (guint field, guint8 * data, guint * len, g_assert (*len / 2 * 3 <= alloc_len); for (i = *len / 2; i >= 0; i--) { - data[i * 3 + 0] = field == 0 ? 0x80 : 0x00; - data[i * 3 + 1] = data[i * 2 + 0]; data[i * 3 + 2] = data[i * 2 + 1]; + data[i * 3 + 1] = data[i * 2 + 0]; + data[i * 3 + 0] = field == 0 ? 0x80 : 0x00; } + + *len = *len * 3 / 2; } static void