diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-13 23:38:49 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-05-13 23:38:49 +0100 |
| commit | 419c025709132e21ce948c4a6051a323f06ee61d (patch) | |
| tree | 55995d400bb4d8e64208845ee36e6812ad738c7b /src/lib/ffmpeg_decoder.cc | |
| parent | 1504f8460d6c438525489ee22eb9a4b437cb449e (diff) | |
Token effort toward non-bitmap subtitles from FFmpegDecoder.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 6122a547e..35e15a331 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -453,15 +453,43 @@ FFmpegDecoder::decode_subtitle_packet () AVSubtitleRect const * rect = sub.rects[0]; - if (rect->type != SUBTITLE_BITMAP) { - throw DecodeError (_("non-bitmap subtitles not yet supported")); + switch (rect->type) { + case SUBTITLE_NONE: + break; + case SUBTITLE_BITMAP: + decode_bitmap_subtitle (rect, period); + break; + case SUBTITLE_TEXT: + cout << "XXX: SUBTITLE_TEXT " << rect->text << "\n"; + break; + case SUBTITLE_ASS: + cout << "XXX: SUBTITLE_ASS " << rect->ass << "\n"; + break; } + + avsubtitle_free (&sub); +} + +list<ContentTimePeriod> +FFmpegDecoder::image_subtitles_during (ContentTimePeriod p, bool starting) const +{ + return _ffmpeg_content->subtitles_during (p, starting); +} +list<ContentTimePeriod> +FFmpegDecoder::text_subtitles_during (ContentTimePeriod, bool) const +{ + return list<ContentTimePeriod> (); +} + +void +FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimePeriod period) +{ /* 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, dcp::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 BGRA palette which is here @@ -470,7 +498,7 @@ FFmpegDecoder::decode_subtitle_packet () 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; @@ -481,7 +509,7 @@ FFmpegDecoder::decode_subtitle_packet () sub_p += rect->pict.linesize[0]; out_p += image->stride()[0] / sizeof (uint32_t); } - + dcp::Size const vs = _ffmpeg_content->video_size (); dcpomatic::Rect<double> const scaled_rect ( static_cast<double> (rect->x) / vs.width, @@ -489,20 +517,7 @@ FFmpegDecoder::decode_subtitle_packet () static_cast<double> (rect->w) / vs.width, static_cast<double> (rect->h) / vs.height ); - - image_subtitle (ContentTimePeriod (period.from, period.to), image, scaled_rect); - avsubtitle_free (&sub); -} - -list<ContentTimePeriod> -FFmpegDecoder::image_subtitles_during (ContentTimePeriod p, bool starting) const -{ - return _ffmpeg_content->subtitles_during (p, starting); + image_subtitle (period, image, scaled_rect); } -list<ContentTimePeriod> -FFmpegDecoder::text_subtitles_during (ContentTimePeriod, bool) const -{ - return list<ContentTimePeriod> (); -} |
