diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 7796e7698c..5bdcc4b135 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -214,53 +214,6 @@ gst_m3u8_compare_playlist_by_bitrate (gconstpointer a, gconstpointer b) return ((GstM3U8 *) (a))->bandwidth - ((GstM3U8 *) (b))->bandwidth; } -static gint -hex_char_to_int (const gchar * v) -{ - switch (*v) { - case '0': - return 0; - case '1': - return 1; - case '2': - return 2; - case '3': - return 3; - case '4': - return 4; - case '5': - return 5; - case '6': - return 6; - case '7': - return 7; - case '8': - return 8; - case '9': - return 9; - case 'A': - case 'a': - return 0xa; - case 'B': - case 'b': - return 0xb; - case 'C': - case 'c': - return 0xc; - case 'D': - case 'd': - return 0xd; - case 'E': - case 'e': - return 0xe; - case 'F': - case 'f': - return 0xf; - default: - return -1; - } -} - /* * @data: a m3u8 playlist text data, taking ownership */ @@ -451,14 +404,17 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) for (i = 0; i < 16; i++) { gint h, l; - h = hex_char_to_int (ivp++); - l = hex_char_to_int (ivp++); + h = g_ascii_xdigit_value (*ivp); + ivp++; + l = g_ascii_xdigit_value (*ivp); + ivp++; if (h == -1 || l == -1) { i = -1; break; } iv[i] = (h << 4) | l; } + if (i == -1) { GST_WARNING ("Can't read IV"); continue;