From: Carl Hetherington Date: Tue, 24 Dec 2013 01:12:40 +0000 (+0000) Subject: Merge 1.0 and some subtitling fixes. X-Git-Tag: v2.0.48~922^2~31 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=dc87445987c00b85a44b6372e43894067fae44b3;p=dcpomatic.git Merge 1.0 and some subtitling fixes. --- diff --git a/src/lib/decoded.h b/src/lib/decoded.h index a9b922769..1de2ff79e 100644 --- a/src/lib/decoded.h +++ b/src/lib/decoded.h @@ -94,13 +94,12 @@ public: , dcp_time_to (0) {} - /* XXX: content/dcp time here */ - DecodedSubtitle (boost::shared_ptr im, dcpomatic::Rect r, DCPTime f, DCPTime t) + DecodedSubtitle (boost::shared_ptr im, dcpomatic::Rect r, ContentTime f, ContentTime t) : Decoded (f) , image (im) , rect (r) , content_time_to (t) - , dcp_time_to (t) + , dcp_time_to (0) {} void set_dcp_times (float speed_up, DCPTime offset) { diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index c6e4217b6..298284512 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -562,8 +562,8 @@ FFmpegDecoder::decode_subtitle_packet () double const packet_time = static_cast (sub.pts) / AV_TIME_BASE; /* hence start time for this sub */ - DCPTime const from = (packet_time + (double (sub.start_display_time) / 1e3)) * TIME_HZ; - DCPTime const to = (packet_time + (double (sub.end_display_time) / 1e3)) * TIME_HZ; + ContentTime const from = (packet_time + (double (sub.start_display_time) / 1e3)) * TIME_HZ; + ContentTime const to = (packet_time + (double (sub.end_display_time) / 1e3)) * TIME_HZ; AVSubtitleRect const * rect = sub.rects[0]; diff --git a/src/lib/image.cc b/src/lib/image.cc index 18ddbc98d..5b5491101 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -376,8 +376,11 @@ Image::make_black () void Image::alpha_blend (shared_ptr other, Position position) { - /* Only implemented for RGBA onto RGB24 so far */ - assert (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGBA); + /* Only implemented for RGBA onto BGRA so far */ + assert (_pixel_format == PIX_FMT_BGRA && other->pixel_format() == PIX_FMT_RGBA); + + int const this_bpp = 4; + int const other_bpp = 4; int start_tx = position.x; int start_ox = 0; @@ -396,15 +399,15 @@ Image::alpha_blend (shared_ptr other, Position position) } for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) { - uint8_t* tp = data()[0] + ty * stride()[0] + position.x * 3; + uint8_t* tp = data()[0] + ty * stride()[0] + position.x * this_bpp; uint8_t* op = other->data()[0] + oy * other->stride()[0]; for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) { float const alpha = float (op[3]) / 255; tp[0] = (tp[0] * (1 - alpha)) + op[0] * alpha; tp[1] = (tp[1] * (1 - alpha)) + op[1] * alpha; tp[2] = (tp[2] * (1 - alpha)) + op[2] * alpha; - tp += 3; - op += 4; + tp += this_bpp; + op += other_bpp; } } } diff --git a/src/lib/player.cc b/src/lib/player.cc index a5f0006d9..0f2cc0365 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -232,8 +232,8 @@ Player::emit_video (weak_ptr weak_piece, shared_ptr video) if ( _film->with_subtitles () && - _out_subtitle.subtitle->image && - video->dcp_time >= _out_subtitle.subtitle->dcp_time && video->dcp_time <= _out_subtitle.subtitle->dcp_time_to + _out_subtitle.image && + video->dcp_time >= _out_subtitle.from && video->dcp_time <= _out_subtitle.to ) { Position const container_offset ( @@ -241,7 +241,7 @@ Player::emit_video (weak_ptr weak_piece, shared_ptr video) (_video_container_size.height - image_size.width) / 2 ); - pi->set_subtitle (_out_subtitle.subtitle->image, _out_subtitle.position + container_offset); + pi->set_subtitle (_out_subtitle.image, _out_subtitle.position + container_offset); } #ifdef DCPOMATIC_DEBUG @@ -561,7 +561,7 @@ Player::update_subtitle () } if (!_in_subtitle.subtitle->image) { - _out_subtitle.subtitle->image.reset (); + _out_subtitle.image.reset (); return; } @@ -591,16 +591,16 @@ Player::update_subtitle () _out_subtitle.position.x = rint (_video_container_size.width * (in_rect.x + (in_rect.width * (1 - sc->subtitle_scale ()) / 2))); _out_subtitle.position.y = rint (_video_container_size.height * (in_rect.y + (in_rect.height * (1 - sc->subtitle_scale ()) / 2))); - - _out_subtitle.subtitle->image = _in_subtitle.subtitle->image->scale ( + + _out_subtitle.image = _in_subtitle.subtitle->image->scale ( scaled_size, Scaler::from_id ("bicubic"), - _in_subtitle.subtitle->image->pixel_format (), + PIX_FMT_RGBA, true ); - - _out_subtitle.subtitle->dcp_time = _in_subtitle.subtitle->dcp_time; - _out_subtitle.subtitle->dcp_time = _in_subtitle.subtitle->dcp_time; + + _out_subtitle.from = _in_subtitle.subtitle->dcp_time; + _out_subtitle.to = _in_subtitle.subtitle->dcp_time_to; } /** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles. diff --git a/src/lib/player.h b/src/lib/player.h index b4454b859..ffc9cf3e3 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -148,7 +148,9 @@ private: struct { Position position; - boost::shared_ptr subtitle; + boost::shared_ptr image; + DCPTime from; + DCPTime to; } _out_subtitle; #ifdef DCPOMATIC_DEBUG diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 389e4b13a..7ba969933 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -34,7 +34,7 @@ SubtitleDecoder::SubtitleDecoder (shared_ptr f) * Image may be 0 to say that there is no current subtitle. */ void -SubtitleDecoder::subtitle (shared_ptr image, dcpomatic::Rect rect, DCPTime from, DCPTime to) +SubtitleDecoder::subtitle (shared_ptr image, dcpomatic::Rect rect, ContentTime from, ContentTime to) { _pending.push_back (shared_ptr (new DecodedSubtitle (image, rect, from, to))); } diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index 4836e31fa..fd1d71f33 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -33,5 +33,5 @@ public: SubtitleDecoder (boost::shared_ptr); protected: - void subtitle (boost::shared_ptr, dcpomatic::Rect, DCPTime, DCPTime); + void subtitle (boost::shared_ptr, dcpomatic::Rect, ContentTime, ContentTime); }; diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 1503af955..6a16557cd 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -51,8 +51,8 @@ VideoDecoder::video (shared_ptr image, bool same, ContentTime time) case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM: { int const half = image->size().height / 2; - Video (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, same, frame); - Video (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, same, frame); + _pending.push_back (shared_ptr (new DecodedVideo (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, same, time))); + _pending.push_back (shared_ptr (new DecodedVideo (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, same, time))); break; } }