void MapLoderTools::LoadMapInfo(XYMap* arg) { XYMap* mapObj = arg; std::string id = mapObj->getMapId(); MapInfo info = MAPS(id); mapObj->setmapWidth(info.width); mapObj->setmapHeight(info.height); mapObj->setblockWidth(info.blockwidth); mapObj->setblockHeight(info.blockheight); mapObj->setxNum(info.blockXCount); mapObj->setyNum(info.blockYCount); }
static void gst_opus_enc_setup_channel_mappings (GstOpusEnc * enc, const GstAudioInfo * info) { #define MAPS(idx,pos) (GST_AUDIO_INFO_POSITION (info, (idx)) == GST_AUDIO_CHANNEL_POSITION_##pos) int n; GST_DEBUG_OBJECT (enc, "Setting up channel mapping for %d channels", enc->n_channels); /* Start by setting up a default trivial mapping */ enc->n_stereo_streams = 0; gst_opus_enc_setup_trivial_mapping (enc, enc->encoding_channel_mapping); gst_opus_enc_setup_trivial_mapping (enc, enc->decoding_channel_mapping); /* For one channel, use the basic RTP mapping */ if (enc->n_channels == 1) { GST_INFO_OBJECT (enc, "Mono, trivial RTP mapping"); enc->channel_mapping_family = 0; /* implicit mapping for family 0 */ return; } /* For two channels, use the basic RTP mapping if the channels are mapped as left/right. */ if (enc->n_channels == 2) { if (MAPS (0, FRONT_LEFT) && MAPS (1, FRONT_RIGHT)) { GST_INFO_OBJECT (enc, "Stereo, canonical mapping"); enc->channel_mapping_family = 0; enc->n_stereo_streams = 1; /* The channel mapping is implicit for family 0, that's why we do not attempt to create one for right/left - this will be mapped to the Vorbis mapping below. */ return; } else { GST_DEBUG_OBJECT (enc, "Stereo, but not canonical mapping, continuing"); } } /* For channels between 1 and 8, we use the Vorbis mapping if we can find a permutation that matches it. Mono will have been taken care of earlier, but this code also handles it. Same for left/right stereo. There are two mappings. One maps the input channels to an ordering which has the natural pairs first so they can benefit from the Opus stereo channel coupling, and the other maps this ordering to the Vorbis ordering. */ if (enc->n_channels >= 1 && enc->n_channels <= 8) { int c0, c1, c0v, c1v; int mapped; gboolean positions_done[256]; static const GstAudioChannelPosition pairs[][2] = { {GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, }; size_t pair; GST_DEBUG_OBJECT (enc, "In range for the Vorbis mapping, building channel mapping tables"); enc->n_stereo_streams = 0; mapped = 0; for (n = 0; n < 256; ++n) positions_done[n] = FALSE; /* First, find any natural pairs, and move them to the front */ for (pair = 0; pair < G_N_ELEMENTS (pairs); ++pair) { GstAudioChannelPosition p0 = pairs[pair][0]; GstAudioChannelPosition p1 = pairs[pair][1]; c0 = gst_opus_enc_find_channel_position (enc, info, p0); c1 = gst_opus_enc_find_channel_position (enc, info, p1); if (c0 >= 0 && c1 >= 0) { /* We found a natural pair */ GST_DEBUG_OBJECT (enc, "Natural pair '%s/%s' found at %d %d", gst_opus_channel_names[p0], gst_opus_channel_names[p1], c0, c1); /* Find where they map in Vorbis order */ c0v = gst_opus_enc_find_channel_position_in_vorbis_order (enc, p0); c1v = gst_opus_enc_find_channel_position_in_vorbis_order (enc, p1); if (c0v < 0 || c1v < 0) { GST_WARNING_OBJECT (enc, "Cannot map channel positions to Vorbis order, using unknown mapping"); enc->channel_mapping_family = 255; enc->n_stereo_streams = 0; return; } enc->encoding_channel_mapping[mapped] = c0; enc->encoding_channel_mapping[mapped + 1] = c1; enc->decoding_channel_mapping[c0v] = mapped; enc->decoding_channel_mapping[c1v] = mapped + 1; enc->n_stereo_streams++; mapped += 2; positions_done[p0] = positions_done[p1] = TRUE; } } /* Now add all other input channels as mono streams */ for (n = 0; n < enc->n_channels; ++n) { GstAudioChannelPosition position = GST_AUDIO_INFO_POSITION (info, n); /* if we already mapped it while searching for pairs, nothing else needs to be done */ if (!positions_done[position]) { int cv; GST_DEBUG_OBJECT (enc, "Channel position %s is not mapped yet, adding", gst_opus_channel_names[position]); cv = gst_opus_enc_find_channel_position_in_vorbis_order (enc, position); if (cv < 0) { GST_WARNING_OBJECT (enc, "Cannot map channel positions to Vorbis order, using unknown mapping"); enc->channel_mapping_family = 255; enc->n_stereo_streams = 0; return; } enc->encoding_channel_mapping[mapped] = n; enc->decoding_channel_mapping[cv] = mapped; mapped++; } } #ifndef GST_DISABLE_DEBUG GST_INFO_OBJECT (enc, "Mapping tables built: %d channels, %d stereo streams", enc->n_channels, enc->n_stereo_streams); gst_opus_common_log_channel_mapping_table (GST_ELEMENT (enc), opusenc_debug, "Encoding mapping table", enc->n_channels, enc->encoding_channel_mapping); gst_opus_common_log_channel_mapping_table (GST_ELEMENT (enc), opusenc_debug, "Decoding mapping table", enc->n_channels, enc->decoding_channel_mapping); #endif enc->channel_mapping_family = 1; return; } /* More than 8 channels, if future mappings are added for those */ /* For other cases, we use undefined, with the default trivial mapping and all mono streams */ GST_WARNING_OBJECT (enc, "Unknown mapping"); enc->channel_mapping_family = 255; enc->n_stereo_streams = 0; #undef MAPS }