diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-01 00:26:37 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-01 00:26:37 +0000 |
| commit | 22873931f874a87fcf6a0077eddbec0f97eb3423 (patch) | |
| tree | cabf1595fd8814e62730e8d846ca4288682d5cdd /src/lib/ffmpeg.cc | |
| parent | 030c74f085718ea276c6e55a7a7c7de267a9ebf3 (diff) | |
Subtitle "to" times used to be stored against their "from" times.
Sadly an example shows that from times are not unique. This patch
uses a hash of stuff from the first AVSubtitle as the key.
Diffstat (limited to 'src/lib/ffmpeg.cc')
| -rw-r--r-- | src/lib/ffmpeg.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 6103ccd50..df708d923 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -26,6 +26,7 @@ #include "log.h" #include "ffmpeg_subtitle_stream.h" #include "ffmpeg_audio_stream.h" +#include "md5_digester.h" #include "compose.hpp" extern "C" { #include <libavcodec/avcodec.h> @@ -268,6 +269,27 @@ FFmpeg::subtitle_period (AVSubtitle const & sub) ); } +string +FFmpeg::subtitle_id (AVSubtitle const & sub) +{ + MD5Digester digester; + digester.add (sub.start_display_time); + digester.add (sub.end_display_time); + digester.add (sub.pts); + for (unsigned int i = 0; i < sub.num_rects; ++i) { + AVSubtitleRect* rect = sub.rects[i]; + digester.add (rect->x); + digester.add (rect->y); + digester.add (rect->w); + digester.add (rect->h); + int const line = rect->pict.linesize[0]; + for (int j = 0; j < rect->h; ++j) { + digester.add (rect->pict.data[0] + j * line, line); + } + } + return digester.get (); +} + /** Compute the pts offset to use given a set of audio streams and some video details. * Sometimes these parameters will have just been determined by an Examiner, sometimes * they will have been retrieved from a piece of Content, hence the need for this method |
