summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-23 00:23:10 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-23 00:35:31 +0200
commit28d3738428128d0bf16ff23995b08b3289179478 (patch)
treea45fc603df658badc2cb3eef0da0b340d409ca4a /ffplay.c
parent6c4cc0f640874f6098ef98bad54c3fc0fa7c615f (diff)
parentdcb9f6a20dbddd1f95b6b322fc4c5fd0b5315729 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: Add LATM demuxer avplay: flush audio decoder with empty packets at EOF if the decoder has CODEC_CAP_DELAY set. 8svx/iff: fix decoding of compressed stereo 8svx files. 8svx: log an error message if output buffer is too small 8svx: check packet size before reading the initial sample value. 8svx: output 8-bit samples instead of 16-bit. 8svx: split delta decoding into a separate function. mp4: Don't read an empty Decoder Config Descriptor fate.sh: Ignore errors from rm command during cleanup. fate.sh: Run git-pull in quiet mode to avoid console spam. Apple ProRes decoder rtmp: Make the input FLV parser handle data cut at any point rv34: Check for invalid slices offsets eval: test isnan(sqrt(-1)) instead of just sqrt(-1) Conflicts: Changelog libavcodec/8svx.c libavcodec/proresdec.c libavcodec/version.h libavformat/iff.c libavformat/version.h tests/ref/fate/eval Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/ffplay.c b/ffplay.c
index 29e1120d88..1a2eb1b08a 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1994,10 +1994,15 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
AVCodecContext *dec= is->audio_st->codec;
int n, len1, data_size;
double pts;
+ int new_packet = 0;
+ int flush_complete = 0;
for(;;) {
/* NOTE: the audio packet can contain several frames */
- while (pkt_temp->size > 0) {
+ while (pkt_temp->size > 0 || (!pkt_temp->data && new_packet)) {
+ if (flush_complete)
+ break;
+ new_packet = 0;
data_size = sizeof(is->audio_buf1);
len1 = avcodec_decode_audio3(dec,
(int16_t *)is->audio_buf1, &data_size,
@@ -2010,8 +2015,13 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
pkt_temp->data += len1;
pkt_temp->size -= len1;
- if (data_size <= 0)
+
+ if (data_size <= 0) {
+ /* stop sending empty packets if the decoder is finished */
+ if (!pkt_temp->data && dec->codec->capabilities & CODEC_CAP_DELAY)
+ flush_complete = 1;
continue;
+ }
if (dec->sample_fmt != is->audio_src_fmt) {
if (is->reformat_ctx)
@@ -2072,12 +2082,11 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
}
/* read next packet */
- if (packet_queue_get(&is->audioq, pkt, 1) < 0)
+ if ((new_packet = packet_queue_get(&is->audioq, pkt, 1)) < 0)
return -1;
- if(pkt->data == flush_pkt.data){
+
+ if (pkt->data == flush_pkt.data)
avcodec_flush_buffers(dec);
- continue;
- }
pkt_temp->data = pkt->data;
pkt_temp->size = pkt->size;
@@ -2508,6 +2517,14 @@ static int read_thread(void *arg)
pkt->stream_index= is->video_stream;
packet_queue_put(&is->videoq, pkt);
}
+ if (is->audio_stream >= 0 &&
+ is->audio_st->codec->codec->capabilities & CODEC_CAP_DELAY) {
+ av_init_packet(pkt);
+ pkt->data = NULL;
+ pkt->size = 0;
+ pkt->stream_index = is->audio_stream;
+ packet_queue_put(&is->audioq, pkt);
+ }
SDL_Delay(10);
if(is->audioq.size + is->videoq.size + is->subtitleq.size ==0){
if(loop!=1 && (!loop || --loop)){