1040
|
1 |
|
|
2 |
# HG changeset patch
|
|
3 |
# User Thomas Daede <daede003@umn.edu>
|
|
4 |
# Date 1521175629 25200
|
|
5 |
# Node ID 5cd5586a2f48424a9031a3fa4c782954a9df9a52
|
|
6 |
# Parent 494e5d5278ba6f5fdda9a2bb9ac7ca772653ee4a
|
|
7 |
Bug 1446062: libtremor Vorbis fix. r=jmspeex a=dveditz
|
|
8 |
|
|
9 |
diff --git a/media/libtremor/lib/tremor_codebook.c b/media/libtremor/lib/tremor_codebook.c
|
|
10 |
--- a/media/libtremor/lib/tremor_codebook.c
|
|
11 |
+++ b/media/libtremor/lib/tremor_codebook.c
|
|
12 |
@@ -253,26 +253,26 @@ long vorbis_book_decodevs_add(codebook *
|
|
13 |
|
|
14 |
if(shift>=0){
|
|
15 |
for (i = 0; i < step; i++) {
|
|
16 |
entry[i]=decode_packed_entry_number(book,b);
|
|
17 |
if(entry[i]==-1)return(-1);
|
|
18 |
t[i] = book->valuelist+entry[i]*book->dim;
|
|
19 |
}
|
|
20 |
for(i=0,o=0;i<book->dim;i++,o+=step)
|
|
21 |
- for (j=0;j<step;j++)
|
|
22 |
+ for (j=0;o+j<n && j<step;j++)
|
|
23 |
a[o+j]+=t[j][i]>>shift;
|
|
24 |
}else{
|
|
25 |
for (i = 0; i < step; i++) {
|
|
26 |
entry[i]=decode_packed_entry_number(book,b);
|
|
27 |
if(entry[i]==-1)return(-1);
|
|
28 |
t[i] = book->valuelist+entry[i]*book->dim;
|
|
29 |
}
|
|
30 |
for(i=0,o=0;i<book->dim;i++,o+=step)
|
|
31 |
- for (j=0;j<step;j++)
|
|
32 |
+ for (j=0;o+j<n && j<step;j++)
|
|
33 |
a[o+j]+=t[j][i]<<-shift;
|
|
34 |
}
|
|
35 |
}
|
|
36 |
return(0);
|
|
37 |
}
|
|
38 |
|
|
39 |
/* decode vector / dim granularity gaurding is done in the upper layer */
|
|
40 |
long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
|
|
41 |
@@ -282,25 +282,25 @@ long vorbis_book_decodev_add(codebook *b
|
|
42 |
ogg_int32_t *t;
|
|
43 |
int shift=point-book->binarypoint;
|
|
44 |
|
|
45 |
if(shift>=0){
|
|
46 |
for(i=0;i<n;){
|
|
47 |
entry = decode_packed_entry_number(book,b);
|
|
48 |
if(entry==-1)return(-1);
|
|
49 |
t = book->valuelist+entry*book->dim;
|
|
50 |
- for (j=0;j<book->dim;)
|
|
51 |
+ for (j=0;i<n && j<book->dim;)
|
|
52 |
a[i++]+=t[j++]>>shift;
|
|
53 |
}
|
|
54 |
}else{
|
|
55 |
for(i=0;i<n;){
|
|
56 |
entry = decode_packed_entry_number(book,b);
|
|
57 |
if(entry==-1)return(-1);
|
|
58 |
t = book->valuelist+entry*book->dim;
|
|
59 |
- for (j=0;j<book->dim;)
|
|
60 |
+ for (j=0;i<n && j<book->dim;)
|
|
61 |
a[i++]+=t[j++]<<-shift;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
}
|
|
65 |
return(0);
|
|
66 |
}
|
|
67 |
|
|
68 |
/* unlike the others, we guard against n not being an integer number
|
|
69 |
@@ -347,41 +347,41 @@ long vorbis_book_decodev_set(codebook *b
|
|
70 |
/* decode vector / dim granularity gaurding is done in the upper layer */
|
|
71 |
long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\
|
|
72 |
long offset,int ch,
|
|
73 |
oggpack_buffer *b,int n,int point){
|
|
74 |
if(book->used_entries>0){
|
|
75 |
long i,j,entry;
|
|
76 |
int chptr=0;
|
|
77 |
int shift=point-book->binarypoint;
|
|
78 |
-
|
|
79 |
+ int m=offset+n;
|
|
80 |
if(shift>=0){
|
|
81 |
|
|
82 |
- for(i=offset;i<offset+n;){
|
|
83 |
+ for(i=offset;i<m;){
|
|
84 |
entry = decode_packed_entry_number(book,b);
|
|
85 |
if(entry==-1)return(-1);
|
|
86 |
{
|
|
87 |
const ogg_int32_t *t = book->valuelist+entry*book->dim;
|
|
88 |
- for (j=0;j<book->dim;j++){
|
|
89 |
+ for (j=0;i<m && j<book->dim;j++){
|
|
90 |
a[chptr++][i]+=t[j]>>shift;
|
|
91 |
if(chptr==ch){
|
|
92 |
chptr=0;
|
|
93 |
i++;
|
|
94 |
}
|
|
95 |
}
|
|
96 |
}
|
|
97 |
}
|
|
98 |
}else{
|
|
99 |
|
|
100 |
- for(i=offset;i<offset+n;){
|
|
101 |
+ for(i=offset;i<m;){
|
|
102 |
entry = decode_packed_entry_number(book,b);
|
|
103 |
if(entry==-1)return(-1);
|
|
104 |
{
|
|
105 |
const ogg_int32_t *t = book->valuelist+entry*book->dim;
|
|
106 |
- for (j=0;j<book->dim;j++){
|
|
107 |
+ for (j=0;i<m && j<book->dim;j++){
|
|
108 |
a[chptr++][i]+=t[j]<<-shift;
|
|
109 |
if(chptr==ch){
|
|
110 |
chptr=0;
|
|
111 |
i++;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
}
|
|
116 |
|