#include "subtitle.h"
#include "image.h"
#include "exceptions.h"
-#include "film_state.h"
using namespace std;
using namespace boost;
/** Construct a TimedSubtitle. This is a subtitle image, position,
* and a range of time over which it should be shown.
* @param sub AVSubtitle to read.
+ * @param c Fractional seconds that should be subtracted from the AVSubtitle's PTS.
*/
-TimedSubtitle::TimedSubtitle (AVSubtitle const & sub)
+TimedSubtitle::TimedSubtitle (AVSubtitle const & sub, double c)
{
+ assert (sub.rects > 0);
+
/* subtitle PTS in seconds */
- float const packet_time = (sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6;
+ double const packet_time = ((sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6) - c;
/* hence start time for this sub */
_from = packet_time + (double (sub.start_display_time) / 1e3);
* in the coordinate space of the source.
* @param subtitle_scale scaling factor to apply to the subtitle image.
*/
-Rectangle
+Rect
subtitle_transformed_area (
float target_x_scale, float target_y_scale,
- Rectangle sub_area, int subtitle_offset, float subtitle_scale
+ Rect sub_area, int subtitle_offset, float subtitle_scale
)
{
- Rectangle tx;
+ Rect tx;
sub_area.y += subtitle_offset;
}
/** @return area that this subtitle take up, in the original uncropped source's coordinate space */
-Rectangle
+Rect
Subtitle::area () const
{
- return Rectangle (_position.x, _position.y, _image->size().width, _image->size().height);
+ return Rect (_position.x, _position.y, _image->size().width, _image->size().height);
}