diff options
-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; |