[FFmpeg-devel] [PATCH 10/10] libavcodec/ccaption_dec: extract ass time base into constant
Aman Gupta
ffmpeg at tmm1.net
Wed Jan 6 08:41:42 CET 2016
From: Aman Gupta <aman at tmm1.net>
---
libavcodec/ccaption_dec.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 56b2b52..6dff761 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -30,6 +30,8 @@
#define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
#define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
+static const AVRational ass_tb = {1, 100};
+
/*
* TODO list
* 1) handle font and color completely
@@ -557,8 +559,8 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
if (ctx->calculate_duration) {
if (ctx->prev_string) {
- int start_time = av_rescale_q(ctx->prev_time, avctx->time_base, (AVRational){ 1, 100 });
- int end_time = av_rescale_q(avpkt->pts, avctx->time_base, (AVRational){ 1, 100 });
+ int start_time = av_rescale_q(ctx->prev_time, avctx->time_base, ass_tb);
+ int end_time = av_rescale_q(avpkt->pts, avctx->time_base, ass_tb);
ret = ff_ass_add_rect(sub, ctx->prev_string, start_time, end_time - start_time, 0);
if (ret < 0)
return ret;
@@ -570,7 +572,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp
ctx->prev_string = av_strdup(ctx->buffer.str);
ctx->prev_time = avpkt->pts;
} else {
- int start_time = av_rescale_q(avpkt->pts, avctx->time_base, (AVRational){ 1, 100 });
+ int start_time = av_rescale_q(avpkt->pts, avctx->time_base, ass_tb);
ret = ff_ass_add_rect_bprint(sub, &ctx->buffer, start_time, -1);
if (ret < 0)
return ret;
--
2.5.3
More information about the ffmpeg-devel
mailing list