diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-06 13:29:00 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-06 13:29:00 +0000 |
| commit | ae9b0b509787d244366eb8f69bdf9d563b6c6bb6 (patch) | |
| tree | 571878e1daeafb0a5583e3d13cb6109e987623d1 /src/lib/ffmpeg_decoder.cc | |
| parent | d7b23d44dec9d6357619e8e009e564e475215470 (diff) | |
| parent | 3a51cc23de37ff0821009af780ef56e0e28394f7 (diff) | |
Merge master.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index dae0ddbe8..a2b3e5d3b 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -561,7 +561,7 @@ FFmpegDecoder::decode_subtitle_packet () /* Subtitle PTS in seconds (within the source, not taking into account any of the source that we may have chopped off for the DCP) */ - double const packet_time = static_cast<double> (sub.pts) / AV_TIME_BASE; + double const packet_time = (static_cast<double> (sub.pts ) / AV_TIME_BASE) + _video_pts_offset; /* hence start time for this sub */ ContentTime const from = (packet_time + (double (sub.start_display_time) / 1e3)) * TIME_HZ; @@ -572,21 +572,27 @@ FFmpegDecoder::decode_subtitle_packet () if (rect->type != SUBTITLE_BITMAP) { throw DecodeError (_("non-bitmap subtitles not yet supported")); } - + + /* Note RGBA is expressed little-endian, so the first byte in the word is R, second + G, third B, fourth A. + */ shared_ptr<Image> image (new Image (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 */ + /* sub_p looks up into a BGRA palette which is here + (i.e. first byte B, second G, third R, fourth A) + */ 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++]; + uint32_t const p = palette[*sub_line_p++]; + *out_line_p++ = ((p & 0xff) << 16) | (p & 0xff00) | ((p & 0xff0000) >> 16) | (p & 0xff000000); } sub_p += rect->pict.linesize[0]; out_p += image->stride()[0] / sizeof (uint32_t); |
