diff options
author | Clément Bœsch <u@pkh.me> | 2016-01-06 13:43:23 +0100 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2016-02-26 21:49:34 +0100 |
commit | 29412821241050c846dbceaad4b9752857659977 (patch) | |
tree | eb42444a7a6bf5d2dc66cdec8c7aa26be32bed99 /libavcodec/assdec.c | |
parent | 805685fffd3115d3f9260d8df15ef36b6b3b8006 (diff) | |
download | ffmpeg-29412821241050c846dbceaad4b9752857659977.tar.gz |
lavc: allow subtitle text format to be ASS without timing
Diffstat (limited to 'libavcodec/assdec.c')
-rw-r--r-- | libavcodec/assdec.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c index 624052efe6..3178f2953c 100644 --- a/libavcodec/assdec.c +++ b/libavcodec/assdec.c @@ -40,24 +40,23 @@ static av_cold int ass_decode_init(AVCodecContext *avctx) static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt) { - int ret; AVSubtitle *sub = data; - const char *ptr = avpkt->data; - static const AVRational ass_tb = {1, 100}; - const int ts_start = av_rescale_q(avpkt->pts, avctx->time_base, ass_tb); - const int ts_duration = av_rescale_q(avpkt->duration, avctx->time_base, ass_tb); if (avpkt->size <= 0) return avpkt->size; - ret = ff_ass_add_rect(sub, ptr, ts_start, ts_duration, 2); - if (ret < 0) { - if (ret == AVERROR_INVALIDDATA) - av_log(avctx, AV_LOG_ERROR, "Invalid ASS packet\n"); - return ret; - } - - *got_sub_ptr = avpkt->size > 0; + sub->rects = av_malloc(sizeof(*sub->rects)); + if (!sub->rects) + return AVERROR(ENOMEM); + sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); + if (!sub->rects[0]) + return AVERROR(ENOMEM); + sub->num_rects = 1; + sub->rects[0]->type = SUBTITLE_ASS; + sub->rects[0]->ass = av_strdup(avpkt->data); + if (!sub->rects[0]->ass) + return AVERROR(ENOMEM); + *got_sub_ptr = 1; return avpkt->size; } |