From 22873931f874a87fcf6a0077eddbec0f97eb3423 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 1 Feb 2016 00:26:37 +0000 Subject: 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. --- src/lib/ffmpeg.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/lib/ffmpeg.cc') 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 @@ -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 -- cgit v1.2.3