AVC/HEVC ES: re-order functions

This commit is contained in:
Moritz Bunkus 2021-08-23 23:03:08 +02:00
parent 9f290808e8
commit f2121dd897
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 43 additions and 43 deletions

View File

@ -95,6 +95,38 @@ es_parser_c::clear() {
m_parsed_position = 0;
}
void
es_parser_c::flush_incomplete_frame() {
if (!m_have_incomplete_frame || !m_configuration_record_ready)
return;
m_frames.push_back(m_incomplete_frame);
m_incomplete_frame.clear();
m_have_incomplete_frame = false;
}
void
es_parser_c::add_sps_and_pps_to_extra_data() {
mxdebug_if(m_debug_sps_pps_changes, fmt::format("avc: adding all SPS & PPS before key frame due to changes from AVCC\n"));
m_extra_data.erase(std::remove_if(m_extra_data.begin(), m_extra_data.end(), [this](memory_cptr const &nalu) -> bool {
if (nalu->get_size() < static_cast<std::size_t>(m_nalu_size_length + 1))
return true;
auto const type = *(nalu->get_buffer() + m_nalu_size_length) & 0x1f;
return (type == NALU_TYPE_SEQ_PARAM) || (type == NALU_TYPE_PIC_PARAM);
}), m_extra_data.end());
std::vector<memory_cptr> tmp;
tmp.reserve(m_extra_data.size() + m_sps_list.size() + m_pps_list.size());
std::transform(m_sps_list.begin(), m_sps_list.end(), std::back_inserter(tmp), [this](memory_cptr const &nalu) { return create_nalu_with_size(nalu); });
std::transform(m_pps_list.begin(), m_pps_list.end(), std::back_inserter(tmp), [this](memory_cptr const &nalu) { return create_nalu_with_size(nalu); });
tmp.insert(tmp.end(), m_extra_data.begin(), m_extra_data.end());
m_extra_data = std::move(tmp);
}
bool
es_parser_c::flush_decision(mtx::avc_hevc::slice_info_t &si,
mtx::avc_hevc::slice_info_t &ref) {
@ -133,38 +165,6 @@ es_parser_c::flush_decision(mtx::avc_hevc::slice_info_t &si,
return false;
}
void
es_parser_c::flush_incomplete_frame() {
if (!m_have_incomplete_frame || !m_configuration_record_ready)
return;
m_frames.push_back(m_incomplete_frame);
m_incomplete_frame.clear();
m_have_incomplete_frame = false;
}
void
es_parser_c::add_sps_and_pps_to_extra_data() {
mxdebug_if(m_debug_sps_pps_changes, fmt::format("avc: adding all SPS & PPS before key frame due to changes from AVCC\n"));
m_extra_data.erase(std::remove_if(m_extra_data.begin(), m_extra_data.end(), [this](memory_cptr const &nalu) -> bool {
if (nalu->get_size() < static_cast<std::size_t>(m_nalu_size_length + 1))
return true;
auto const type = *(nalu->get_buffer() + m_nalu_size_length) & 0x1f;
return (type == NALU_TYPE_SEQ_PARAM) || (type == NALU_TYPE_PIC_PARAM);
}), m_extra_data.end());
std::vector<memory_cptr> tmp;
tmp.reserve(m_extra_data.size() + m_sps_list.size() + m_pps_list.size());
std::transform(m_sps_list.begin(), m_sps_list.end(), std::back_inserter(tmp), [this](memory_cptr const &nalu) { return create_nalu_with_size(nalu); });
std::transform(m_pps_list.begin(), m_pps_list.end(), std::back_inserter(tmp), [this](memory_cptr const &nalu) { return create_nalu_with_size(nalu); });
tmp.insert(tmp.end(), m_extra_data.begin(), m_extra_data.end());
m_extra_data = std::move(tmp);
}
void
es_parser_c::handle_slice_nalu(memory_cptr const &nalu,
uint64_t nalu_pos) {

View File

@ -107,6 +107,17 @@ es_parser_c::clear() {
m_parsed_position = 0;
}
void
es_parser_c::flush_incomplete_frame() {
if (m_pending_frame_data.empty() || !m_configuration_record_ready)
return;
build_frame_data();
m_frames.push_back(m_incomplete_frame);
m_incomplete_frame.clear();
}
void
es_parser_c::add_parameter_sets_to_extra_data() {
std::unordered_map<uint32_t, bool> is_in_extra_data;
@ -139,17 +150,6 @@ es_parser_c::add_parameter_sets_to_extra_data() {
m_extra_data_initial.clear();
}
void
es_parser_c::flush_incomplete_frame() {
if (m_pending_frame_data.empty() || !m_configuration_record_ready)
return;
build_frame_data();
m_frames.push_back(m_incomplete_frame);
m_incomplete_frame.clear();
}
void
es_parser_c::add_nalu_to_extra_data(memory_cptr const &nalu,
extra_data_position_e position) {