diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-11 09:39:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-11 09:39:15 +0100 |
| commit | ab355641dd29d54f612e6f890ee8f2ae7578d617 (patch) | |
| tree | b6e07513cc41374a49db0805ee4bf9395a3834bd /src | |
| parent | ffb11106766b462f10bd832c26c2d84ea2d980b6 (diff) | |
Fix audio analyis hang with duplicate stream IDs (#598).
There was existing code to work around the case when FFmpeg files
have all-zero stream IDs. Extend this to cope with duplicate
stream IDs, as these have been seen in the wild.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ffmpeg.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 741716b04..8764933e3 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -132,18 +132,22 @@ FFmpeg::setup_general () throw DecodeError (N_("could not find video stream")); } - /* Hack: if the AVStreams have zero IDs, put some in. We - use the IDs so that we can cope with VOBs, in which streams + /* Hack: if the AVStreams have duplicate IDs, replace them with our + own. We use the IDs so that we can cope with VOBs, in which streams move about in index but remain with the same ID in different - VOBs. However, some files have all-zero IDs, hence this hack. + VOBs. However, some files have duplicate IDs, hence this hack. */ - - uint32_t i = 0; - while (i < _format_context->nb_streams && _format_context->streams[i]->id == 0) { - ++i; - } - if (i == _format_context->nb_streams) { + bool duplicates = false; + for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { + for (uint32_t j = i + 1; j < _format_context->nb_streams; ++j) { + if (_format_context->streams[i]->id == _format_context->streams[j]->id) { + duplicates = true; + } + } + } + + if (duplicates) { /* Put in our own IDs */ for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { _format_context->streams[i]->id = i; |
