summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/ass.c9
-rw-r--r--libavcodec/ass.h5
-rw-r--r--libavcodec/jacosubdec.c4
-rw-r--r--libavcodec/microdvddec.c14
-rw-r--r--libavcodec/srtdec.c2
5 files changed, 19 insertions, 15 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index 8c94d724eb..4fe593ee8b 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -70,15 +70,18 @@ static int ts_to_string(char *str, int strlen, int ts)
}
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
- int ts_start, int ts_end, int raw)
+ int ts_start, int duration, int raw)
{
- int len = 0, dlen, duration = ts_end - ts_start;
+ int len = 0, dlen;
char s_start[16], s_end[16], header[48] = {0};
AVSubtitleRect **rects;
if (!raw) {
ts_to_string(s_start, sizeof(s_start), ts_start);
- ts_to_string(s_end, sizeof(s_end), ts_end );
+ if (duration == -1)
+ snprintf(s_end, sizeof(s_end), "9:59:59.99");
+ else
+ ts_to_string(s_end, sizeof(s_end), ts_start + duration);
len = snprintf(header, sizeof(header), "Dialogue: 0,%s,%s,",
s_start, s_end);
}
diff --git a/libavcodec/ass.h b/libavcodec/ass.h
index efff44d6ed..4606563300 100644
--- a/libavcodec/ass.h
+++ b/libavcodec/ass.h
@@ -74,7 +74,8 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx);
* @param sub pointer to the AVSubtitle
* @param dialog ASS dialog to add to sub
* @param ts_start start timestamp for this dialog (in 1/100 second unit)
- * @param ts_end end timestamp for this dialog (in 1/100 second unit)
+ * @param duration duration for this dialog (in 1/100 second unit), can be -1
+ * to last until the end of the presentation
* @param raw when set to 1, it indicates that dialog contains a whole ASS
* dialog line which should be copied as is.
* when set to 0, it indicates that dialog contains only the Text
@@ -85,6 +86,6 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx);
* A negative value indicates an error.
*/
int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
- int ts_start, int ts_end, int raw);
+ int ts_start, int duration, int raw);
#endif /* AVCODEC_ASS_H */
diff --git a/libavcodec/jacosubdec.c b/libavcodec/jacosubdec.c
index 8c02d3b2c8..90ce5df227 100644
--- a/libavcodec/jacosubdec.c
+++ b/libavcodec/jacosubdec.c
@@ -175,8 +175,6 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
goto end;
if (*ptr) {
- int ts_start = avpkt->pts;
- int ts_end = avpkt->pts + avpkt->duration;
AVBPrint buffer;
char *dec_sub;
@@ -188,7 +186,7 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
av_bprint_init(&buffer, JSS_MAX_LINESIZE, JSS_MAX_LINESIZE);
jacosub_to_ass(avctx, &buffer, ptr);
av_bprint_finalize(&buffer, &dec_sub);
- ff_ass_add_rect(sub, dec_sub, ts_start, ts_end, 0);
+ ff_ass_add_rect(sub, dec_sub, avpkt->pts, avpkt->duration, 0);
av_free(dec_sub);
}
diff --git a/libavcodec/microdvddec.c b/libavcodec/microdvddec.c
index 083efdb94f..33a75c4f9e 100644
--- a/libavcodec/microdvddec.c
+++ b/libavcodec/microdvddec.c
@@ -261,10 +261,6 @@ static int microdvd_decode_frame(AVCodecContext *avctx,
char *decoded_sub;
char *line = avpkt->data;
char *end = avpkt->data + avpkt->size;
- int64_t frame_start = avpkt->pts;
- int64_t frame_end = avpkt->pts + avpkt->duration;
- int ts_start = av_rescale_q(frame_start, avctx->time_base, (AVRational){1,100});
- int ts_end = av_rescale_q(frame_end, avctx->time_base, (AVRational){1,100});
struct microdvd_tag tags[sizeof(MICRODVD_TAGS) - 1] = {{0}};
if (avpkt->size <= 0)
@@ -299,8 +295,14 @@ static int microdvd_decode_frame(AVCodecContext *avctx,
end:
av_bprint_finalize(&new_line, &decoded_sub);
- if (*decoded_sub)
- ff_ass_add_rect(sub, decoded_sub, ts_start, ts_end, 0);
+ if (*decoded_sub) {
+ int64_t start = avpkt->pts;
+ int64_t duration = avpkt->duration;
+ int ts_start = av_rescale_q(start, avctx->time_base, (AVRational){1,100});
+ int ts_duration = duration != -1 ?
+ av_rescale_q(duration, avctx->time_base, (AVRational){1,100}) : -1;
+ ff_ass_add_rect(sub, decoded_sub, ts_start, ts_duration, 0);
+ }
av_free(decoded_sub);
*got_sub_ptr = sub->num_rects > 0;
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index b6f2dade0c..ed6909bcca 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -222,7 +222,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
break;
ptr = srt_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
x1, y1, x2, y2);
- ff_ass_add_rect(sub, buffer, ts_start, ts_end, 0);
+ ff_ass_add_rect(sub, buffer, ts_start, ts_end-ts_start, 0);
}
*got_sub_ptr = sub->num_rects > 0;