From 09bffb7aef6adc609c235ab43a80b7c0a4cc3150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Sun, 15 Apr 2007 23:14:51 +0200 Subject: Avoid sending BUF_FLAG_FRAME_END before the first frame. When BUF_FLAG_FRAME_END is sent before the first frame, decoding fails as there is no data and a "bad" frame of size 0x0 will be allocated, which is really bad as such as frame is simply invalid. --- src/demuxers/demux_mpeg_pes.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index c5769e3e3..fbfde4e60 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -1135,17 +1135,20 @@ static int32_t parse_video_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen */ if (this->mpeg12_h264_detected & 1) { buf_type = BUF_VIDEO_H264; - int nal_type_code = -1; - if (payload_size >= 4 && p[2] == 0x01 && p[1] == 0x00 && p[0] == 0x00) - nal_type_code = p[3] & 0x1f; - if (nal_type_code == 9) { /* access unit delimiter */ - buf_element_t *b = this->video_fifo->buffer_pool_alloc (this->video_fifo); - b->content = b->mem; - b->size = 0; - b->pts = 0; - b->type = buf_type; - b->decoder_flags = BUF_FLAG_FRAME_END; - this->video_fifo->put (this->video_fifo, b); + /* omit sending BUF_FLAG_FRAME_END for the first AUD occurence */ + if (this->mpeg12_h264_detected > 2) { + int nal_type_code = -1; + if (payload_size >= 4 && p[2] == 0x01 && p[1] == 0x00 && p[0] == 0x00) + nal_type_code = p[3] & 0x1f; + if (nal_type_code == 9) { /* access unit delimiter */ + buf_element_t *b = this->video_fifo->buffer_pool_alloc (this->video_fifo); + b->content = b->mem; + b->size = 0; + b->pts = 0; + b->type = buf_type; + b->decoder_flags = BUF_FLAG_FRAME_END; + this->video_fifo->put (this->video_fifo, b); + } } } -- cgit v1.2.3