diff options
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 28 | ||||
-rw-r--r-- | demux/demux_lavf.c | 13 | ||||
-rw-r--r-- | demux/stheader.h | 4 |
3 files changed, 11 insertions, 34 deletions
diff --git a/demux/demux.c b/demux/demux.c index f0652fba4d..1ae4137e62 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -92,7 +92,6 @@ const demuxer_desc_t *const demuxer_list[] = { struct demux_stream { int selected; // user wants packets from this stream int eof; // end of demuxed stream? (true if all buffer empty) - int fill_count; // number of unsuccessful tries to get a packet int packs; // number of packets in buffer int bytes; // total bytes of packets in buffer struct demux_packet *head; @@ -441,16 +440,6 @@ overflow: return true; } -static bool need_coverart_hack(struct demuxer *demux) -{ - for (int n = 0; n < demux->num_streams; n++) { - struct sh_stream *sh = demux->streams[n]; - if (sh->attached_picture && sh->ds->selected) - return true; - } - return false; -} - // return value: // 0 = EOF or no stream found or invalid type // 1 = successfully read a packet @@ -476,31 +465,14 @@ static void ds_get_packets(struct sh_stream *sh) * despite the eof flag then it's better to clear it to avoid * weird behavior. */ ds->eof = 0; - ds->fill_count = 0; return; } - // avoid buffering too far ahead in e.g. badly interleaved files - // or when one stream is shorter, without breaking large audio - // delay with well interleaved files. - // This needs to be enough for at least 1 second of packets - // since libavformat mov demuxer does not try to interleave - // with more than 1s precision. - if (ds->fill_count > 80) - break; if (demux_check_queue_full(demux)) break; - int apacks = count_packs(demux, STREAM_AUDIO); - int vpacks = count_packs(demux, STREAM_VIDEO); - if (!demux_fill_buffer(demux)) break; // EOF - - if (need_coverart_hack(demux)) { - ds->fill_count += count_packs(demux, STREAM_AUDIO) - apacks; - ds->fill_count += count_packs(demux, STREAM_VIDEO) - vpacks; - } } mp_msg(MSGT_DEMUXER, MSGL_V, "ds_get_packets: EOF reached (stream: %s)\n", stream_type_name(sh->type)); diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 385cd23006..3f330332e3 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -351,7 +351,8 @@ static void select_tracks(struct demuxer *demuxer, int start) for (int n = start; n < priv->num_streams; n++) { struct sh_stream *stream = priv->streams[n]; AVStream *st = priv->avfc->streams[n]; - bool selected = stream && demuxer_stream_is_selected(demuxer, stream); + bool selected = stream && demuxer_stream_is_selected(demuxer, stream) && + !stream->attached_picture; st->discard = selected ? AVDISCARD_DEFAULT : AVDISCARD_ALL; } } @@ -388,8 +389,12 @@ static void handle_stream(demuxer_t *demuxer, int i) break; sh_video_t *sh_video = sh->video; - if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) - sh_video->gsh->attached_picture = true; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) { + sh->attached_picture = new_demux_packet_from(st->attached_pic.data, + st->attached_pic.size); + sh->attached_picture->pts = 0; + talloc_steal(sh, sh->attached_picture); + } sh_video->format = codec->codec_tag; sh_video->disp_w = codec->width; @@ -679,8 +684,6 @@ static int demux_lavf_fill_buffer(demuxer_t *demux) dp->avpacket = pkt; int64_t ts = priv->use_dts ? pkt->dts : pkt->pts; - if (ts == AV_NOPTS_VALUE && (st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - ts = 0; if (ts != AV_NOPTS_VALUE) { dp->pts = ts * av_q2d(st->time_base); priv->last_pts = dp->pts * AV_TIME_BASE; diff --git a/demux/stheader.h b/demux/stheader.h index 0d94607fa2..2ca4bd0bae 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -61,7 +61,9 @@ struct sh_stream { char *title; char *lang; // language code bool default_track; // container default track flag - bool attached_picture; // stream is a picture (such as album art) + + // stream is a picture (such as album art) + struct demux_packet *attached_picture; // Human readable description of the running decoder, or NULL char *decoder_desc; |