Ticket #7515: t7515_srt_subtitle_fix.diff
File t7515_srt_subtitle_fix.diff, 3.5 KB (added by , 14 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
7202 7202 } 7203 7203 else 7204 7204 { 7205 // BEGIN HACK 7206 // Like frame based subtitles this can get out of sync after 7207 // transcoding, using the raw timecode doesn't work either 7208 // with DTV broadcasts where the timecode isn't zero on the 7209 // first frame, and may roll over during the broadcast. 7210 playPos = (uint64_t) 7211 ((currentFrame->frameNumber / video_frame_rate) * 1000); 7212 // END HACK 7205 // Use timecodes for time based SRT subtitles. Feeding this into 7206 // NormalizeVideoTimecode should adjust for non-zero start times 7207 // and wraps. For MPEG wraps will occur just once every 26.5 hours 7208 // so this should be sufficient. 7209 playPos = GetDecoder()->NormalizeVideoTimecode(currentFrame->timecode); 7213 7210 } 7214 7211 7215 7212 if (!textSubtitles.HasSubtitleChanged(playPos)) -
libs/libmythtv/decoderbase.h
113 113 virtual bool DoRewind(long long desiredFrame, bool doflush = true); 114 114 virtual bool DoFastForward(long long desiredFrame, bool doflush = true); 115 115 116 virtual int64_t NormalizeVideoTimecode(int64_t timecode) { return timecode; } 117 116 118 virtual bool isLastFrameKey() = 0; 117 119 virtual void WriteStoredData(RingBuffer *rb, bool storevid, 118 120 long timecodeOffset) = 0; -
libs/libmythtv/avformatdecoder.cpp
616 616 return ((lsb - base_ts)&mask); 617 617 } 618 618 619 int64_t AvFormatDecoder::NormalizeVideoTimecode(int64_t timecode) 620 { 621 AVStream *st = NULL; 622 for (uint i = 0; i < ic->nb_streams; i++) 623 { 624 AVStream *st1 = ic->streams[i]; 625 if (st1 && st1->codec->codec_type == CODEC_TYPE_VIDEO) 626 { 627 st = st1; 628 break; 629 } 630 } 631 if (!st) 632 return false; 633 634 // convert timecode and start_time to AV_TIME_BASE units 635 int64_t start_ts = av_rescale(ic->start_time, 636 st->time_base.den, 637 AV_TIME_BASE * (int64_t)st->time_base.num); 638 639 int64_t ts = av_rescale(timecode / 1000.0 * AV_TIME_BASE, 640 st->time_base.den, 641 AV_TIME_BASE * (int64_t)st->time_base.num); 642 643 // adjust for start time and wrap 644 ts = lsb3full(ts, start_ts, st->pts_wrap_bits); 645 646 return (int64_t)(av_q2d(st->time_base) * ts * 1000); 647 } 648 619 649 int AvFormatDecoder::GetNumChapters() 620 650 { 621 651 return ic->nb_chapters; -
libs/libmythtv/avformatdecoder.h
141 141 virtual bool DoRewind(long long desiredFrame, bool doflush = true); 142 142 virtual bool DoFastForward(long long desiredFrame, bool doflush = true); 143 143 144 virtual int64_t NormalizeVideoTimecode(int64_t timecode); 145 144 146 virtual int GetTeletextDecoderType(void) const; 145 147 virtual void SetTeletextDecoderViewer(TeletextViewer*); 146 148