+ auto const palette = rect->pict.data[1];
+#else
+ /* Start of the first line in the subtitle */
+ auto sub_p = rect->data[0];
+ /* sub_p looks up into a BGRA palette which is at rect->data[1].
+ (first byte B, second G, third R, fourth A)
+ */
+ auto const* palette = rect->data[1];
+#endif
+ /* And the stream has a map of those palette colours to colours
+ chosen by the user; created a `mapped' palette from those settings.
+ */
+ auto colour_map = ffmpeg_content()->subtitle_stream()->colours();
+ vector<RGBA> mapped_palette (rect->nb_colors);
+ for (int i = 0; i < rect->nb_colors; ++i) {
+ RGBA c (palette[2], palette[1], palette[0], palette[3]);
+ auto j = colour_map.find (c);
+ if (j != colour_map.end ()) {
+ mapped_palette[i] = j->second;
+ } else {
+ /* This colour was not found in the FFmpegSubtitleStream's colour map; probably because
+ it is from a project that was created before this stuff was added. Just use the
+ colour straight from the original palette.
+ */
+ mapped_palette[i] = c;
+ }
+ palette += 4;
+ }
+