void choose_layer (ConfigSVC *Config) { if (GetLastDqId() == -1){ int DecMaxLayer = GetMaxDecLayer(); int WantedDqId = Config -> SetLayer; if ( WantedDqId >= 15 && WantedDqId <= (DecMaxLayer << 4) || WantedDqId < 16 && WantedDqId <= DecMaxLayer ){ SetLastDqId(WantedDqId); }else { WantedDqId = 0; SetLastDqId (0); } } }
void switch_layer(int *NumOfLayers, NAL *Nal,decoder_context* pdecoder_context) { int LayerChanged = GetLayerChanged(); int TemporalId = *NumOfLayers >> 16; int WantedDqId = *NumOfLayers & 0xff; if(LayerChanged ){ //IDR frame and a valid command to change of layer int i ; int test = 0; int SaveDqId = GetSaveDqId(); for ( i = 0; i < 8; i++){ if (SaveDqId == Nal -> layer_id_table[i]){ //we find it break; } else if(i < 7 && SaveDqId > Nal -> layer_id_table[i] && Nal -> layer_id_table[i + 1] == -1){ //we did not find it, but we should wait test = 1; break; }else if (i < 7 && SaveDqId > Nal -> layer_id_table[i] && SaveDqId < Nal -> layer_id_table[i + 1]){ //we did not find it, but the value must be wrong, so we choose another one test = 2; break; } } if ( test != 1){ if (test == 2){ //The DQId has not been found. //we know that the DQId wanted, is between the layer_id_table [i] and layer_id_table [i + 1] WantedDqId = Nal -> layer_id_table [i + 1]; SetSaveDqId(SaveDqId); } else { int WantedLayer = GetLayerNumber(Nal, SaveDqId); //we have to update the WantedDqId parameter to decode correctly the base layer if it's the one wanted if (WantedLayer < pdecoder_context -> MaxNumLayer){ WantedDqId = Nal -> layer_id_table[WantedLayer]; }else { WantedDqId = Nal -> layer_id_table[pdecoder_context -> MaxNumLayer - 1]; } } SaveDqId = Nal -> DqIdToDisplay = Nal -> DqIdWanted = WantedDqId; SetArgLayer(SaveDqId); SetLastDqId(SaveDqId); ResetLayerChanged(); }else { Nal -> DqIdToDisplay = WantedDqId = SaveDqId; } } *NumOfLayers = (TemporalId << 16) + WantedDqId; }