Fix being tested.
authorCarl Hetherington <cth@carlh.net>
Tue, 18 Dec 2012 16:18:10 +0000 (16:18 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Dec 2012 16:18:10 +0000 (16:18 +0000)
src/lib/ffmpeg_decoder.cc
src/lib/subtitle.cc
src/lib/subtitle.h
src/lib/video_decoder.cc

index a05b331cce32ae84947115813543748f0af327ca..f81f00b19e230fa4ae364258b3ae291e9f53a620 100644 (file)
@@ -334,7 +334,7 @@ FFmpegDecoder::pass ()
                        if (sub.num_rects > 0) {
                                shared_ptr<TimedSubtitle> ts;
                                try {
-                                       emit_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub, _first_video.get())));
+                                       emit_subtitle (shared_ptr<TimedSubtitle> (new TimedSubtitle (sub)));
                                } catch (...) {
                                        /* some problem with the subtitle; we probably didn't understand it */
                                }
index 4b7f81947f66480401b8cde3b6387bf31a117b80..1af277255462f367337f36194a5d15215bfe0cf2 100644 (file)
@@ -31,14 +31,15 @@ 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, double c)
+TimedSubtitle::TimedSubtitle (AVSubtitle const & sub)
 {
        assert (sub.rects > 0);
        
-       /* subtitle PTS in seconds */
-       double const packet_time = ((sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6) - c;
+       /* 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 = ((sub.pts / AV_TIME_BASE) + float (sub.pts % AV_TIME_BASE) / 1e6);
        
        /* hence start time for this sub */
        _from = packet_time + (double (sub.start_display_time) / 1e3);
index 590e0dd31b8ac2865d680b5f3e7343bc76560e39..38ba4e70e0170fabd5e2a71ee2ad9eadceb5a2ee 100644 (file)
@@ -63,7 +63,7 @@ subtitle_transformed_area (
 class TimedSubtitle
 {
 public:
-       TimedSubtitle (AVSubtitle const &, double c);
+       TimedSubtitle (AVSubtitle const &);
 
        bool displayed_at (double t) const;
        
index 4c05d5fcdf335e931414e72e569125b4ef535fe2..f4501bbf3e5e5672033b88f868ddbc049907fd49 100644 (file)
@@ -38,13 +38,15 @@ VideoDecoder::VideoDecoder (shared_ptr<Film> f, shared_ptr<const DecodeOptions>
 
 /** Called by subclasses to tell the world that some video data is ready.
  *  We find a subtitle then emit it for listeners.
- *  @param frame to emit.
+ *  @param image frame to emit.
+ *  @param f Frame within the source.
  */
 void
 VideoDecoder::emit_video (shared_ptr<Image> image, SourceFrame f)
 {
        shared_ptr<Subtitle> sub;
        if (_timed_subtitle && _timed_subtitle->displayed_at (f / _film->frames_per_second())) {
+               _film->log()->log (String::compose ("putting subtitle using %1 instead of %2", f, video_frame()));
                sub = _timed_subtitle->subtitle ();
        }