Skip to content
Snippets Groups Projects
Commit 863c5276 authored by Philippe de Lagrange's avatar Philippe de Lagrange
Browse files

Fix parcat to support multi-layer

parent 61efcc7d
No related branches found
No related tags found
No related merge requests found
...@@ -212,8 +212,8 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -212,8 +212,8 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
int sz = (int) v.size(); int sz = (int) v.size();
int nal_start, nal_end; int nal_start, nal_end;
int off = 0; int off = 0;
int cnt = 0; int cnt[MAX_VPS_LAYERS] = { 0 };
bool idr_found = false; bool idr_found[MAX_VPS_LAYERS] = { false };
bool is_pre_sei_before_idr = true; bool is_pre_sei_before_idr = true;
std::vector<uint8_t> out; std::vector<uint8_t> out;
...@@ -269,6 +269,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -269,6 +269,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
HLSReader.parsePPS( pps ); HLSReader.parsePPS( pps );
parameterSetManager.storePPS( pps, inp_nalu.getBitstream().getFifo() ); parameterSetManager.storePPS( pps, inp_nalu.getBitstream().getFifo() );
} }
int nalu_layerId = nalu[0] & 0x3F;
if (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP) if (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)
{ {
...@@ -280,7 +281,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -280,7 +281,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
new_poc = *poc_base + poc; new_poc = *poc_base + poc;
if (first_idr_slice_after_ph_nal) if (first_idr_slice_after_ph_nal)
{ {
cnt--; cnt[nalu_layerId]--;
} }
first_idr_slice_after_ph_nal = false; first_idr_slice_after_ph_nal = false;
} }
...@@ -324,7 +325,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -324,7 +325,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
#if ENABLE_TRACING #if ENABLE_TRACING
std::cout << "Changed poc " << poc << " to " << new_poc << std::endl; std::cout << "Changed poc " << poc << " to " << new_poc << std::endl;
#endif #endif
++cnt; ++cnt[nalu_layerId];
change_poc = false; change_poc = false;
} }
} }
...@@ -332,10 +333,10 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -332,10 +333,10 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
if(idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)) if(idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP))
{ {
skip_next_sei = true; skip_next_sei = true;
idr_found = true; idr_found[nalu_layerId] = true;
} }
if ((idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)) if ((idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP))
|| ((idx > 1 && !idr_found) && (nalu_type == NAL_UNIT_OPI || nalu_type == NAL_UNIT_DCI || nalu_type == NAL_UNIT_VPS || nalu_type == NAL_UNIT_SPS || nalu_type == NAL_UNIT_PPS || nalu_type == NAL_UNIT_PREFIX_APS || nalu_type == NAL_UNIT_SUFFIX_APS || nalu_type == NAL_UNIT_PH || nalu_type == NAL_UNIT_ACCESS_UNIT_DELIMITER)) || ((idx > 1 && !idr_found[nalu_layerId]) && (nalu_type == NAL_UNIT_OPI || nalu_type == NAL_UNIT_DCI || nalu_type == NAL_UNIT_VPS || nalu_type == NAL_UNIT_SPS || nalu_type == NAL_UNIT_PPS || nalu_type == NAL_UNIT_PREFIX_APS || nalu_type == NAL_UNIT_SUFFIX_APS || nalu_type == NAL_UNIT_PH || nalu_type == NAL_UNIT_ACCESS_UNIT_DELIMITER))
|| (nalu_type == NAL_UNIT_SUFFIX_SEI && skip_next_sei) || (nalu_type == NAL_UNIT_SUFFIX_SEI && skip_next_sei)
|| (idx > 1 && nalu_type == NAL_UNIT_PREFIX_SEI && is_pre_sei_before_idr)) || (idx > 1 && nalu_type == NAL_UNIT_PREFIX_SEI && is_pre_sei_before_idr))
{ {
...@@ -356,7 +357,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int ...@@ -356,7 +357,7 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
sz -= nal_end; sz -= nal_end;
} }
*poc_base += cnt; *poc_base += *std::max_element(std::begin(cnt), std::end(cnt));
return out; return out;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment