diff options
author | wm4 <wm4@nowhere> | 2016-11-09 16:35:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-11-09 16:44:06 +0100 |
commit | 67467103e8c7a143c8eafda86d312dfa0c949266 (patch) | |
tree | 5adee2ce7c9bd653ec9afab40457d7d37c50631a | |
parent | a55e8ff31cc974843e28282ccbdc46dd3e70a5af (diff) |
dec_video, dec_audio: avoid full reinit on switches to the same segment
Same deal as with the previous commit.
(Unfortunately, this code is still duplicated.)
-rw-r--r-- | audio/decode/dec_audio.c | 15 | ||||
-rw-r--r-- | video/decode/dec_video.c | 15 |
2 files changed, 18 insertions, 12 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 3028d9988e..39e867cf42 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -257,12 +257,15 @@ void audio_work(struct dec_audio *da) struct demux_packet *new_segment = da->new_segment; da->new_segment = NULL; - // Could avoid decoder reinit; would still need flush. - da->codec = new_segment->codec; - if (da->ad_driver) - da->ad_driver->uninit(da); - da->ad_driver = NULL; - audio_init_best_codec(da); + if (da->codec == new_segment->codec) { + audio_reset_decoding(da); + } else { + da->codec = new_segment->codec; + if (da->ad_driver) + da->ad_driver->uninit(da); + da->ad_driver = NULL; + audio_init_best_codec(da); + } da->start = new_segment->start; da->end = new_segment->end; diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 0dc51943bc..ed7cd875ea 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -459,12 +459,15 @@ void video_work(struct dec_video *d_video) struct demux_packet *new_segment = d_video->new_segment; d_video->new_segment = NULL; - // Could avoid decoder reinit; would still need flush. - d_video->codec = new_segment->codec; - if (d_video->vd_driver) - d_video->vd_driver->uninit(d_video); - d_video->vd_driver = NULL; - video_init_best_codec(d_video); + if (d_video->codec == new_segment->codec) { + video_reset(d_video); + } else { + d_video->codec = new_segment->codec; + if (d_video->vd_driver) + d_video->vd_driver->uninit(d_video); + d_video->vd_driver = NULL; + video_init_best_codec(d_video); + } d_video->start = new_segment->start; d_video->end = new_segment->end; |