, dcp_time_to (0)
{}
- /* XXX: content/dcp time here */
- DecodedSubtitle (boost::shared_ptr<Image> im, dcpomatic::Rect<double> r, DCPTime f, DCPTime t)
+ DecodedSubtitle (boost::shared_ptr<Image> im, dcpomatic::Rect<double> 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) {
double const packet_time = static_cast<double> (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];
void
Image::alpha_blend (shared_ptr<const Image> other, Position<int> 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;
}
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;
}
}
}
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<int> const container_offset (
(_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
}
if (!_in_subtitle.subtitle->image) {
- _out_subtitle.subtitle->image.reset ();
+ _out_subtitle.image.reset ();
return;
}
_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.
struct {
Position<int> position;
- boost::shared_ptr<DecodedSubtitle> subtitle;
+ boost::shared_ptr<Image> image;
+ DCPTime from;
+ DCPTime to;
} _out_subtitle;
#ifdef DCPOMATIC_DEBUG
* Image may be 0 to say that there is no current subtitle.
*/
void
-SubtitleDecoder::subtitle (shared_ptr<Image> image, dcpomatic::Rect<double> rect, DCPTime from, DCPTime to)
+SubtitleDecoder::subtitle (shared_ptr<Image> image, dcpomatic::Rect<double> rect, ContentTime from, ContentTime to)
{
_pending.push_back (shared_ptr<DecodedSubtitle> (new DecodedSubtitle (image, rect, from, to)));
}
SubtitleDecoder (boost::shared_ptr<const Film>);
protected:
- void subtitle (boost::shared_ptr<Image>, dcpomatic::Rect<double>, DCPTime, DCPTime);
+ void subtitle (boost::shared_ptr<Image>, dcpomatic::Rect<double>, ContentTime, ContentTime);
};
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<DecodedVideo> (new DecodedVideo (image->crop (Crop (0, 0, 0, half), true), EYES_LEFT, same, time)));
+ _pending.push_back (shared_ptr<DecodedVideo> (new DecodedVideo (image->crop (Crop (0, 0, half, 0), true), EYES_RIGHT, same, time)));
break;
}
}