#define UNSET_FLAG(var, val) ( (var) &= ~( 1 << (val)) )
#define CHECK_FLAG(var, val) ( (var) & ( 1 << (val)) )
-static const AVRational ass_tb = {1, 100};
+static const AVRational ms_tb = {1, 1000};
/*
* TODO list
char prev_cmd[2];
/* buffer to store pkt data */
AVBufferRef *pktbuf;
+ int readorder;
} CCaptionSubContext;
ctx->last_real_time = 0;
ctx->screen_touched = 0;
ctx->buffer_changed = 0;
+ if (!(avctx->flags2 & AV_CODEC_FLAG2_RO_FLUSH_NOOP))
+ ctx->readorder = 0;
av_bprint_clear(&ctx->buffer);
}
{
CCaptionSubContext *ctx = avctx->priv_data;
AVSubtitle *sub = data;
+ const int64_t start_time = sub->pts;
uint8_t *bptr = NULL;
int len = avpkt->size;
int ret = 0;
if(cc_type == 1)
continue;
else
- process_cc608(ctx, avpkt->pts, *(bptr + i + 1) & 0x7f, *(bptr + i + 2) & 0x7f);
+ process_cc608(ctx, start_time, *(bptr + i + 1) & 0x7f, *(bptr + i + 2) & 0x7f);
if (!ctx->buffer_changed)
continue;
if (*ctx->buffer.str || ctx->real_time)
{
- int64_t sub_pts = ctx->real_time ? avpkt->pts : ctx->start_time;
- int start_time = av_rescale_q(sub_pts, avctx->time_base, ass_tb);
- int duration = -1;
- if (!ctx->real_time) {
- int end_time = av_rescale_q(ctx->end_time, avctx->time_base, ass_tb);
- duration = end_time - start_time;
- }
ff_dlog(ctx, "cdp writing data (%s)\n",ctx->buffer.str);
- ret = ff_ass_add_rect_bprint(sub, &ctx->buffer, start_time, duration);
+ ret = ff_ass_add_rect(sub, ctx->buffer.str, ctx->readorder++, 0, NULL, NULL);
if (ret < 0)
return ret;
- sub->pts = av_rescale_q(sub_pts, avctx->time_base, AV_TIME_BASE_Q);
+ sub->pts = ctx->start_time;
+ if (!ctx->real_time)
+ sub->end_display_time = av_rescale_q(ctx->end_time - ctx->start_time,
+ AV_TIME_BASE_Q, ms_tb);
+ else
+ sub->end_display_time = -1;
ctx->buffer_changed = 0;
- ctx->last_real_time = avpkt->pts;
+ ctx->last_real_time = sub->pts;
ctx->screen_touched = 0;
}
}
if (ctx->real_time && ctx->screen_touched &&
- avpkt->pts > ctx->last_real_time + av_rescale_q(20, ass_tb, avctx->time_base)) {
- int start_time;
- ctx->last_real_time = avpkt->pts;
+ sub->pts > ctx->last_real_time + av_rescale_q(200, ms_tb, AV_TIME_BASE_Q)) {
+ ctx->last_real_time = sub->pts;
ctx->screen_touched = 0;
capture_screen(ctx);
ctx->buffer_changed = 0;
- start_time = av_rescale_q(avpkt->pts, avctx->time_base, ass_tb);
- ret = ff_ass_add_rect_bprint(sub, &ctx->buffer, start_time, -1);
+ ret = ff_ass_add_rect(sub, ctx->buffer.str, ctx->readorder++, 0, NULL, NULL);
if (ret < 0)
return ret;
- sub->pts = av_rescale_q(avpkt->pts, avctx->time_base, AV_TIME_BASE_Q);
+ sub->end_display_time = -1;
}
*got_sub = sub->num_rects > 0;