| @@ -237,7 +237,7 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts) · 236 unmodified lines |
| 237 | } | 237 | } |
| 238 | } | 238 | } |
| 239 | | 239 | |
| 240 | void sub2video_update(InputStream *ist, AVSubtitle *sub) | 240 | void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub) |
| 241 | { | 241 | { |
| 242 | AVFrame *frame = ist->sub2video.frame; | 242 | AVFrame *frame = ist->sub2video.frame; |
| 243 | int8_t *dst; | 243 | int8_t *dst; |
| @@ -254,7 +254,12 @@ void sub2video_update(InputStream *ist, AVSubtitle *sub) · 10 unmodified lines |
| 254 | AV_TIME_BASE_Q, ist->st->time_base); | 254 | AV_TIME_BASE_Q, ist->st->time_base); |
| 255 | num_rects = sub->num_rects; | 255 | num_rects = sub->num_rects; |
| 256 | } else { | 256 | } else { |
| 257 | pts = ist->sub2video.end_pts; | 257 | /* If we are initializing the system, utilize current heartbeat |
| | 258 | PTS as the start time, and show until the following subpicture |
| | 259 | is received. Otherwise, utilize the previous subpicture's end time |
| | 260 | as the fall-back value. */ |
| | 261 | pts = ist->sub2video.initialize ? |
| | 262 | heartbeat_pts : ist->sub2video.end_pts; |
| 258 | end_pts = INT64_MAX; | 263 | end_pts = INT64_MAX; |
| 259 | num_rects = 0; | 264 | num_rects = 0; |
| 260 | } | 265 | } |
| @@ -269,6 +274,7 @@ void sub2video_update(InputStream *ist, AVSubtitle *sub) · 8 unmodified lines |
| 269 | sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]); | 274 | sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]); |
| 270 | sub2video_push_ref(ist, pts); | 275 | sub2video_push_ref(ist, pts); |
| 271 | ist->sub2video.end_pts = end_pts; | 276 | ist->sub2video.end_pts = end_pts; |
| | 277 | ist->sub2video.initialize = 0; |
| 272 | } | 278 | } |
| 273 | | 279 | |
| 274 | static void sub2video_heartbeat(InputStream *ist, int64_t pts) | 280 | static void sub2video_heartbeat(InputStream *ist, int64_t pts) |
| @@ -291,9 +297,11 @@ static void sub2video_heartbeat(InputStream *ist, int64_t pts) · 16 unmodified lines |
| 291 | /* do not send the heartbeat frame if the subtitle is already ahead */ | 297 | /* do not send the heartbeat frame if the subtitle is already ahead */ |
| 292 | if (pts2 <= ist2->sub2video.last_pts) | 298 | if (pts2 <= ist2->sub2video.last_pts) |
| 293 | continue; | 299 | continue; |
| 294 | if (pts2 >= ist2->sub2video.end_pts || | 300 | if (pts2 >= ist2->sub2video.end_pts || ist2->sub2video.initialize) |
| 295 | (!ist2->sub2video.frame->data[0] && ist2->sub2video.end_pts < INT64_MAX)) | 301 | /* if we have hit the end of the current displayed subpicture, |
| 296 | sub2video_update(ist2, NULL); | 302 | or if we need to initialize the system, update the |
| | 303 | overlayed subpicture and its start/end times */ |
| | 304 | sub2video_update(ist2, pts2 + 1, NULL); |
| 297 | for (j = 0, nb_reqs = 0; j < ist2->nb_filters; j++) | 305 | for (j = 0, nb_reqs = 0; j < ist2->nb_filters; j++) |
| 298 | nb_reqs += av_buffersrc_get_nb_failed_requests(ist2->filters[j]->filter); | 306 | nb_reqs += av_buffersrc_get_nb_failed_requests(ist2->filters[j]->filter); |
| 299 | if (nb_reqs) | 307 | if (nb_reqs) |
| @@ -307,7 +315,7 @@ static void sub2video_flush(InputStream *ist) · 7 unmodified lines |
| 307 | int ret; | 315 | int ret; |
| 308 | | 316 | |
| 309 | if (ist->sub2video.end_pts < INT64_MAX) | 317 | if (ist->sub2video.end_pts < INT64_MAX) |
| 310 | sub2video_update(ist, NULL); | 318 | sub2video_update(ist, INT64_MAX, NULL); |
| 311 | for (i = 0; i < ist->nb_filters; i++) { | 319 | for (i = 0; i < ist->nb_filters; i++) { |
| 312 | ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); | 320 | ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); |
| 313 | if (ret != AVERROR_EOF && ret < 0) | 321 | if (ret != AVERROR_EOF && ret < 0) |
| @@ -2507,7 +2515,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, · 2193 unmodified lines |
| 2507 | return ret; | 2515 | return ret; |
| 2508 | | 2516 | |
| 2509 | if (ist->sub2video.frame) { | 2517 | if (ist->sub2video.frame) { |
| 2510 | sub2video_update(ist, &subtitle); | 2518 | sub2video_update(ist, INT64_MIN, &subtitle); |
| 2511 | } else if (ist->nb_filters) { | 2519 | } else if (ist->nb_filters) { |
| 2512 | if (!ist->sub2video.sub_queue) | 2520 | if (!ist->sub2video.sub_queue) |
| 2513 | ist->sub2video.sub_queue = av_fifo_alloc(8 * sizeof(AVSubtitle)); | 2521 | ist->sub2video.sub_queue = av_fifo_alloc(8 * sizeof(AVSubtitle)); |