diff --git a/ffplay.c b/ffplay.c
index 74915c9..946e9b3 100644
|
a
|
b
|
typedef struct VideoPicture {
|
| 134 | 134 | typedef struct SubPicture { |
| 135 | 135 | double pts; /* presentation time stamp for this picture */ |
| 136 | 136 | AVSubtitle sub; |
| | 137 | int serial; |
| 137 | 138 | } SubPicture; |
| 138 | 139 | |
| 139 | 140 | typedef struct AudioParams { |
| … |
… |
typedef struct VideoState {
|
| 230 | 231 | |
| 231 | 232 | SDL_Thread *subtitle_tid; |
| 232 | 233 | int subtitle_stream; |
| 233 | | int subtitle_stream_changed; |
| 234 | 234 | AVStream *subtitle_st; |
| 235 | 235 | PacketQueue subtitleq; |
| 236 | 236 | SubPicture subpq[SUBPICTURE_QUEUE_SIZE]; |
| … |
… |
retry:
|
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | if (is->subtitle_st) { |
| 1403 | | if (is->subtitle_stream_changed) { |
| 1404 | | SDL_LockMutex(is->subpq_mutex); |
| 1405 | | |
| 1406 | | while (is->subpq_size) { |
| 1407 | | free_subpicture(&is->subpq[is->subpq_rindex]); |
| 1408 | | |
| 1409 | | /* update queue size and signal for next picture */ |
| 1410 | | if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) |
| 1411 | | is->subpq_rindex = 0; |
| 1412 | | |
| 1413 | | is->subpq_size--; |
| 1414 | | } |
| 1415 | | is->subtitle_stream_changed = 0; |
| 1416 | | |
| 1417 | | SDL_CondSignal(is->subpq_cond); |
| 1418 | | SDL_UnlockMutex(is->subpq_mutex); |
| 1419 | | } else { |
| 1420 | | if (is->subpq_size > 0) { |
| | 1403 | while (is->subpq_size > 0) { |
| 1421 | 1404 | sp = &is->subpq[is->subpq_rindex]; |
| 1422 | 1405 | |
| 1423 | 1406 | if (is->subpq_size > 1) |
| … |
… |
retry:
|
| 1425 | 1408 | else |
| 1426 | 1409 | sp2 = NULL; |
| 1427 | 1410 | |
| 1428 | | if ((is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) |
| | 1411 | if (sp->serial != is->subtitleq.serial |
| | 1412 | || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) |
| 1429 | 1413 | || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) |
| 1430 | 1414 | { |
| 1431 | 1415 | free_subpicture(sp); |
| … |
… |
retry:
|
| 1438 | 1422 | is->subpq_size--; |
| 1439 | 1423 | SDL_CondSignal(is->subpq_cond); |
| 1440 | 1424 | SDL_UnlockMutex(is->subpq_mutex); |
| | 1425 | } else { |
| | 1426 | break; |
| 1441 | 1427 | } |
| 1442 | 1428 | } |
| 1443 | | } |
| 1444 | 1429 | } |
| 1445 | 1430 | |
| 1446 | 1431 | display: |
| … |
… |
static int subtitle_thread(void *arg)
|
| 2000 | 1985 | SubPicture *sp; |
| 2001 | 1986 | AVPacket pkt1, *pkt = &pkt1; |
| 2002 | 1987 | int got_subtitle; |
| | 1988 | int serial; |
| 2003 | 1989 | double pts; |
| 2004 | 1990 | int i, j; |
| 2005 | 1991 | int r, g, b, y, u, v, a; |
| … |
… |
static int subtitle_thread(void *arg)
|
| 2008 | 1994 | while (is->paused && !is->subtitleq.abort_request) { |
| 2009 | 1995 | SDL_Delay(10); |
| 2010 | 1996 | } |
| 2011 | | if (packet_queue_get(&is->subtitleq, pkt, 1, NULL) < 0) |
| | 1997 | if (packet_queue_get(&is->subtitleq, pkt, 1, &serial) < 0) |
| 2012 | 1998 | break; |
| 2013 | 1999 | |
| 2014 | 2000 | if (pkt->data == flush_pkt.data) { |
| … |
… |
static int subtitle_thread(void *arg)
|
| 2039 | 2025 | if (sp->sub.pts != AV_NOPTS_VALUE) |
| 2040 | 2026 | pts = sp->sub.pts / (double)AV_TIME_BASE; |
| 2041 | 2027 | sp->pts = pts; |
| | 2028 | sp->serial = serial; |
| 2042 | 2029 | |
| 2043 | 2030 | for (i = 0; i < sp->sub.num_rects; i++) |
| 2044 | 2031 | { |
| … |
… |
static void stream_component_close(VideoState *is, int stream_index)
|
| 2633 | 2620 | /* note: we also signal this mutex to make sure we deblock the |
| 2634 | 2621 | video thread in all cases */ |
| 2635 | 2622 | SDL_LockMutex(is->subpq_mutex); |
| 2636 | | is->subtitle_stream_changed = 1; |
| 2637 | | |
| 2638 | 2623 | SDL_CondSignal(is->subpq_cond); |
| 2639 | 2624 | SDL_UnlockMutex(is->subpq_mutex); |
| 2640 | 2625 | |