ffplay: always queue attachment pictures after flushing the video packet queue

Requeue them after seeking and also after opening a video stream. Also don't
fill the video queue in case of an attached picture video stream since there
will be no more than one packet from that stream.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2013-03-28 01:58:14 +01:00
parent de81d8da47
commit 1c2ac44947

View File

@ -2552,6 +2552,7 @@ static int stream_component_open(VideoState *is, int stream_index)
packet_queue_start(&is->videoq); packet_queue_start(&is->videoq);
is->video_tid = SDL_CreateThread(video_thread, is); is->video_tid = SDL_CreateThread(video_thread, is);
is->queue_attachments_req = 1;
break; break;
case AVMEDIA_TYPE_SUBTITLE: case AVMEDIA_TYPE_SUBTITLE:
is->subtitle_stream = stream_index; is->subtitle_stream = stream_index;
@ -2851,12 +2852,18 @@ static int read_thread(void *arg)
} }
} }
is->seek_req = 0; is->seek_req = 0;
is->queue_attachments_req = 1;
eof = 0; eof = 0;
if (is->paused) if (is->paused)
step_to_next_frame(is); step_to_next_frame(is);
} }
if (is->queue_attachments_req) { if (is->queue_attachments_req) {
avformat_queue_attached_pictures(ic); if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) {
AVPacket copy;
if ((ret = av_copy_packet(&copy, &is->video_st->attached_pic)) < 0)
goto fail;
packet_queue_put(&is->videoq, &copy);
}
is->queue_attachments_req = 0; is->queue_attachments_req = 0;
} }
@ -2864,7 +2871,8 @@ static int read_thread(void *arg)
if (infinite_buffer<1 && if (infinite_buffer<1 &&
(is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE (is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE
|| ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0 || is->audioq.abort_request) || ( (is->audioq .nb_packets > MIN_FRAMES || is->audio_stream < 0 || is->audioq.abort_request)
&& (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0 || is->videoq.abort_request) && (is->videoq .nb_packets > MIN_FRAMES || is->video_stream < 0 || is->videoq.abort_request
|| (is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC))
&& (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0 || is->subtitleq.abort_request)))) { && (is->subtitleq.nb_packets > MIN_FRAMES || is->subtitle_stream < 0 || is->subtitleq.abort_request)))) {
/* wait 10 ms */ /* wait 10 ms */
SDL_LockMutex(wait_mutex); SDL_LockMutex(wait_mutex);
@ -2919,7 +2927,8 @@ static int read_thread(void *arg)
<= ((double)duration / 1000000); <= ((double)duration / 1000000);
if (pkt->stream_index == is->audio_stream && pkt_in_play_range) { if (pkt->stream_index == is->audio_stream && pkt_in_play_range) {
packet_queue_put(&is->audioq, pkt); packet_queue_put(&is->audioq, pkt);
} else if (pkt->stream_index == is->video_stream && pkt_in_play_range) { } else if (pkt->stream_index == is->video_stream && pkt_in_play_range
&& !(is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
packet_queue_put(&is->videoq, pkt); packet_queue_put(&is->videoq, pkt);
} else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) { } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) {
packet_queue_put(&is->subtitleq, pkt); packet_queue_put(&is->subtitleq, pkt);
@ -3050,8 +3059,6 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
the_end: the_end:
stream_component_close(is, old_index); stream_component_close(is, old_index);
stream_component_open(is, stream_index); stream_component_open(is, stream_index);
if (codec_type == AVMEDIA_TYPE_VIDEO)
is->queue_attachments_req = 1;
} }