+
+/**
+ * Parse a vlc code.
+ *
+ * \param gbc The getbit context structure.
+ * \param vlc The vlc tables to use.
+ *
+ * \return The vlc code.
+ */
+int get_vlc(struct getbit_context *gbc, const struct vlc *vlc)
+{
+ int n, idx, nb_bits, code;
+
+ idx = show_bits(gbc, vlc->bits);
+ code = vlc->table[idx][0];
+ n = vlc->table[idx][1];
+ if (n < 0) {
+ skip_bits(gbc, vlc->bits);
+ nb_bits = -n;
+ idx = show_bits(gbc, nb_bits) + code;
+ code = vlc->table[idx][0];
+ n = vlc->table[idx][1];
+ if (n < 0) {
+ skip_bits(gbc, nb_bits);
+ nb_bits = -n;
+ idx = show_bits(gbc, nb_bits) + code;
+ code = vlc->table[idx][0];
+ n = vlc->table[idx][1];
+ }
+ }
+ skip_bits(gbc, n);
+ return code >= 0? code : -E_VLC;
+}