opusdec: Use proper guint/guint8 type conversion

Do not cast, that might yield wrong results.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3494>
This commit is contained in:
Vivia Nikolaidou 2022-11-30 20:48:28 +02:00
parent c9afaf5cd9
commit a0e61539f8

View file

@ -363,6 +363,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
{
GstAudioChannelPosition pos[64];
const GstAudioChannelPosition *posn = NULL;
guint8 n_channels;
if (!gst_opus_header_is_id_header (buf)) {
GST_ELEMENT_ERROR (dec, STREAM, FORMAT, (NULL),
@ -372,7 +373,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
if (!gst_codec_utils_opus_parse_header (buf,
&dec->sample_rate,
(guint8 *) & dec->n_channels,
&n_channels,
&dec->channel_mapping_family,
&dec->n_streams,
&dec->n_stereo_streams,
@ -381,6 +382,7 @@ gst_opus_dec_parse_header (GstOpusDec * dec, GstBuffer * buf)
("Failed to parse Opus ID header"));
return GST_FLOW_ERROR;
}
dec->n_channels = n_channels;
dec->r128_gain_volume = gst_opus_dec_get_r128_volume (dec->r128_gain);
GST_INFO_OBJECT (dec,
@ -886,13 +888,15 @@ gst_opus_dec_set_format (GstAudioDecoder * bdec, GstCaps * caps)
}
} else {
const GstAudioChannelPosition *posn = NULL;
guint8 n_channels;
if (!gst_codec_utils_opus_parse_caps (caps, &dec->sample_rate,
(guint8 *) & dec->n_channels, &dec->channel_mapping_family,
&n_channels, &dec->channel_mapping_family,
&dec->n_streams, &dec->n_stereo_streams, dec->channel_mapping)) {
ret = FALSE;
goto done;
}
dec->n_channels = n_channels;
if (dec->channel_mapping_family == 1 && dec->n_channels <= 8)
posn = gst_opus_channel_positions[dec->n_channels - 1];