mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-29 06:15:24 +00:00
HEVC/h.265 ES reader: clear parser's buffer after reading the headers
After reading the headers, the file is read again from the start. Therefore no data must be left in the parser's internal buffers. That was the intention behind calling `flush()` - but that isn't actually what flush does. Instead it tries to use the remaining data in the buffers as a frame. This is not only wrong, it can also fail and cause an exception to be thrown. That in turn causes a failure when reading the headers — both identification and muxing abort at that point. This is the HEVC analog for what was fixed for AVC in #2325.
This commit is contained in:
parent
ee46e1c7ab
commit
9afc43b209
3
NEWS.md
3
NEWS.md
@ -8,6 +8,9 @@
|
||||
* mkvmerge: AVC/h.264: fixed file identification failing for certain
|
||||
elementary streams due to internal buffers not being cleared properly. Fixes
|
||||
#2325.
|
||||
* mkvmerge: HEVC/h.265: fixed file identification failing for certain
|
||||
elementary streams due to internal buffers not being cleared properly. This
|
||||
is the HEVC analog to what was fixed for AVC in #2325.
|
||||
|
||||
|
||||
# Version 24.0.0 "Beyond The Pale" 2018-06-10
|
||||
|
@ -192,6 +192,13 @@ es_parser_c::flush() {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
es_parser_c::clear() {
|
||||
m_unparsed_buffer.reset();
|
||||
m_have_incomplete_frame = false;
|
||||
m_parsed_position = 0;
|
||||
}
|
||||
|
||||
void
|
||||
es_parser_c::add_timestamp(int64_t timestamp) {
|
||||
m_provided_timestamps.emplace_back(timestamp, m_stream_position);
|
||||
|
@ -119,6 +119,7 @@ public:
|
||||
}
|
||||
|
||||
void flush();
|
||||
void clear();
|
||||
|
||||
bool frame_available() {
|
||||
return !m_frames_out.empty();
|
||||
|
@ -89,14 +89,13 @@ hevc_es_reader_c::read_headers() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (parser.headers_parsed())
|
||||
parser.flush();
|
||||
|
||||
m_width = parser.get_width();
|
||||
m_height = parser.get_height();
|
||||
|
||||
m_in->setFilePointer(0, seek_beginning);
|
||||
|
||||
parser.clear();
|
||||
|
||||
} catch (...) {
|
||||
throw mtx::input::open_x();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user