diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-26 21:06:27 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-26 21:06:27 +0000 |
| commit | cef07676fb15c9f1c3c3073d22f06ffe95d9c2ce (patch) | |
| tree | ad67d2991961429c52dda4d7adc1ded37ce71c0a /src/lib/ffmpeg_examiner.cc | |
| parent | 2b54b284e2c2ffcaa082b1c201abecf25edc21c9 (diff) | |
Allow changes to colours of FFmpeg subtitles (#795).
Diffstat (limited to 'src/lib/ffmpeg_examiner.cc')
| -rw-r--r-- | src/lib/ffmpeg_examiner.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 29cc69063..850b8ba5f 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -246,6 +246,23 @@ FFmpegExaminer::subtitle_packet (AVCodecContext* context, shared_ptr<FFmpegSubti _last_subtitle_start[stream] = SubtitleStart (id, image, period.from); } } + + for (unsigned int i = 0; i < sub.num_rects; ++i) { + if (sub.rects[i]->type == SUBTITLE_BITMAP) { + uint32_t* palette = (uint32_t *) sub.rects[i]->pict.data[1]; + for (int j = 0; j < sub.rects[i]->nb_colors; ++j) { + RGBA rgba ( + (palette[j] & 0x00ff0000) >> 16, + (palette[j] & 0x0000ff00) >> 8, + (palette[j] & 0x000000ff) >> 0, + (palette[j] & 0xff000000) >> 24 + ); + + stream->set_colour (rgba, rgba); + } + } + } + avsubtitle_free (&sub); } } |
