author | Zhiwei Yan <zhiwei.yan@amlogic.com> | 2016-11-11 08:51:51 (GMT) |
---|---|---|
committer | Zhiwei Yan <zhiwei.yan@amlogic.com> | 2016-11-11 08:51:51 (GMT) |
commit | 281e85ab90524a110ae2107b97569b4436ea9f43 (patch) | |
tree | 7c12fa034c16771d47a3f1921aaecdd01a9f77d9 | |
parent | 2d5ca94ef31d7d3974c3f46e25d606ae43c7c66f (diff) | |
download | SubTitle-281e85ab90524a110ae2107b97569b4436ea9f43.zip SubTitle-281e85ab90524a110ae2107b97569b4436ea9f43.tar.gz SubTitle-281e85ab90524a110ae2107b97569b4436ea9f43.tar.bz2 |
pd#134670:change subtitle rate according to value read from decode information
Change-Id: I211fd9adafc91b0a08962ff219caf634fa488b54
-rw-r--r-- | jni/subtitle/sub_api.c | 26 | ||||
-rw-r--r-- | jni/subtitle/sub_api.h | 6 |
2 files changed, 19 insertions, 13 deletions
diff --git a/jni/subtitle/sub_api.c b/jni/subtitle/sub_api.c index 70309cf..934f0f6 100644 --- a/jni/subtitle/sub_api.c +++ b/jni/subtitle/sub_api.c @@ -49,6 +49,7 @@ static unsigned subfile_read; //init pts rate int ptsrate = 24; +bool ptsRateGot = true; static inline int subtitle_uni_Utf16toUtf8(const UTF16 *in, int inLen, UTF8 *out, int outMax) @@ -733,18 +734,17 @@ subtitle_t *internal_sub_read_line_microdvd(int fd, subtitle_t *current) char line2[LINE_LEN + 1]; char *p, *next; int i; - /*int ptsrate = 0; - /*ptsrate = get_subtitle_fps() / 100; - - if (get_subtitle_fps() % 100) - ptsrate ++; - - if (ptsrate <= 0) - { - ptsrate = 24; //30; - } - - log_print("--------internal_sub_read_line_microdvd---get frame rate: %f--\n", ptsrate); */ + if (!ptsRateGot) { + ptsrate = get_subtitle_fps() / 100; + if (get_subtitle_fps() % 100) { + ptsrate ++; + } + if (ptsrate <= 0) { + ptsrate = 24; //30; + } + ptsRateGot = true; + log_print("--------internal_sub_read_line_microdvd---get frame rate: %f--\n", ptsrate); + } current->end = 0; do { @@ -813,6 +813,7 @@ subtitle_t *internal_sub_read_line_mpl1(int fd, subtitle_t *current) && current->start == current->end == 1)) { ptsrate = atoi(line2); + ptsRateGot = true; } current->start = (current->start * 100) / ptsrate; current->end = (current->end * 100) / ptsrate; @@ -2190,6 +2191,7 @@ static int internal_sub_autodetect(int fd) } SUBAPI void reset_variate() { + ptsRateGot = false; mpsub_position = 0; } diff --git a/jni/subtitle/sub_api.h b/jni/subtitle/sub_api.h index cecb2b3..986c58f 100644 --- a/jni/subtitle/sub_api.h +++ b/jni/subtitle/sub_api.h @@ -28,7 +28,11 @@ /* Maximal length of line of a subtitle */ #define LINE_LEN 1024*5 - +typedef enum + { + false, + true +} bool; typedef enum { SUB_ALIGNMENT_BOTTOMLEFT = 1, |