]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vorbisdec.c
dxva2_h264: add a workaround for old Intel GPUs
[ffmpeg] / libavcodec / vorbisdec.c
index 718f7607a2ed18cb028ea513d59cc256c2482d59..d7fec98c6e4204be38e63b464bfbf55ab6b93b93 100644 (file)
@@ -42,9 +42,6 @@
 #define V_MAX_VLCS (1 << 16)
 #define V_MAX_PARTITIONS (1 << 20)
 
-#undef NDEBUG
-#include <assert.h>
-
 typedef struct {
     uint8_t      dimensions;
     uint8_t      lookup_type;
@@ -1319,14 +1316,22 @@ static av_always_inline int setup_classifs(vorbis_context *vc,
 
             av_dlog(NULL, "Classword: %u\n", temp);
 
-            assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
+            if (temp <= 65536) {
+                for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
+                    temp2 = (((uint64_t)temp) * inverse_class) >> 32;
 
-            for (i = 0; i < c_p_c; ++i) {
-                temp2 = (((uint64_t)temp) * inverse_class) >> 32;
-                if (partition_count + c_p_c - 1 - i < vr->ptns_to_read)
-                    vr->classifs[p + partition_count + c_p_c - 1 - i] =
-                        temp - temp2 * vr->classifications;
-                temp = temp2;
+                    if (i < vr->ptns_to_read)
+                        vr->classifs[p + i] = temp - temp2 * vr->classifications;
+                    temp = temp2;
+                }
+            } else {
+                for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
+                    temp2 = temp / vr->classifications;
+
+                    if (i < vr->ptns_to_read)
+                        vr->classifs[p + i] = temp - temp2 * vr->classifications;
+                    temp = temp2;
+                }
             }
         }
         p += vr->ptns_to_read;
@@ -1365,7 +1370,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
 
     if (max_output > ch_left * vlen) {
         av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
 
     av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d  cpc %d  \n", ch, c_p_c);
@@ -1616,7 +1621,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
         residue = &vc->residues[mapping->submap_residue[i]];
         if (ch_left < ch) {
             av_log(vc->avctx, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
-            return -1;
+            return AVERROR_INVALIDDATA;
         }
         if (ch) {
             ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left);
@@ -1756,6 +1761,7 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx)
 
 AVCodec ff_vorbis_decoder = {
     .name            = "vorbis",
+    .long_name       = NULL_IF_CONFIG_SMALL("Vorbis"),
     .type            = AVMEDIA_TYPE_AUDIO,
     .id              = AV_CODEC_ID_VORBIS,
     .priv_data_size  = sizeof(vorbis_context),
@@ -1764,7 +1770,6 @@ AVCodec ff_vorbis_decoder = {
     .decode          = vorbis_decode_frame,
     .flush           = vorbis_decode_flush,
     .capabilities    = CODEC_CAP_DR1,
-    .long_name       = NULL_IF_CONFIG_SMALL("Vorbis"),
     .channel_layouts = ff_vorbis_channel_layouts,
     .sample_fmts     = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                        AV_SAMPLE_FMT_NONE },