- AVSubtitleRect const * rect = sub.rects[0];
-
- if (rect->type != SUBTITLE_BITMAP) {
- throw DecodeError ("non-bitmap subtitles not yet supported");
- }
-
- shared_ptr<Image> image (new SimpleImage (PIX_FMT_RGBA, libdcp::Size (rect->w, rect->h), true));
-
- /* Start of the first line in the subtitle */
- uint8_t* sub_p = rect->pict.data[0];
- /* sub_p looks up into a RGB palette which is here */
- uint32_t const * palette = (uint32_t *) rect->pict.data[1];
- /* Start of the output data */
- uint32_t* out_p = (uint32_t *) image->data()[0];
-
- for (int y = 0; y < rect->h; ++y) {
- uint8_t* sub_line_p = sub_p;
- uint32_t* out_line_p = out_p;
- for (int x = 0; x < rect->w; ++x) {
- *out_line_p++ = palette[*sub_line_p++];
- }
- sub_p += rect->pict.linesize[0];
- out_p += image->stride()[0] / sizeof (uint32_t);