Revision 769c4975

View differences:

libavcodec/bitstream.c
159 159
        /* if code matches the prefix, it is in the table */
160 160
        n -= n_prefix;
161 161
        if (n > 0) {
162
        if(flags & INIT_VLC_LE)
163
            code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1);
164
        else
165
            code_prefix2= code >> n;
166
        if (code_prefix2 == code_prefix) {
167
            if (n <= table_nb_bits) {
168
                /* no need to add another table */
169
                j = (code << (table_nb_bits - n)) & (table_size - 1);
170
                nb = 1 << (table_nb_bits - n);
171
                for(k=0;k<nb;k++) {
172
                    if(flags & INIT_VLC_LE)
173
                        j = (code >> n_prefix) + (k<<n);
162
            if(flags & INIT_VLC_LE)
163
                code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1);
164
            else
165
                code_prefix2= code >> n;
166
            if (code_prefix2 == code_prefix) {
167
                if (n <= table_nb_bits) {
168
                    /* no need to add another table */
169
                    j = (code << (table_nb_bits - n)) & (table_size - 1);
170
                    nb = 1 << (table_nb_bits - n);
171
                    for(k=0;k<nb;k++) {
172
                        if(flags & INIT_VLC_LE)
173
                            j = (code >> n_prefix) + (k<<n);
174 174
#ifdef DEBUG_VLC
175
                    av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
176
                           j, i, n);
175
                        av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
176
                               j, i, n);
177 177
#endif
178
                    if (table[j][1] /*bits*/ != 0) {
179
                        av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
180
                        return -1;
178
                        if (table[j][1] /*bits*/ != 0) {
179
                            av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
180
                            return -1;
181
                        }
182
                        table[j][1] = n; //bits
183
                        table[j][0] = symbol;
184
                        j++;
181 185
                    }
182
                    table[j][1] = n; //bits
183
                    table[j][0] = symbol;
184
                    j++;
185
                }
186
            } else {
187
                n -= table_nb_bits;
188
                j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1);
186
                } else {
187
                    n -= table_nb_bits;
188
                    j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1);
189 189
#ifdef DEBUG_VLC
190
                av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
191
                       j, n);
190
                    av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n",
191
                           j, n);
192 192
#endif
193
                /* compute table size */
194
                n1 = -table[j][1]; //bits
195
                if (n > n1)
196
                    n1 = n;
197
                table[j][1] = -n1; //bits
193
                    /* compute table size */
194
                    n1 = -table[j][1]; //bits
195
                    if (n > n1)
196
                        n1 = n;
197
                    table[j][1] = -n1; //bits
198
                }
198 199
            }
199 200
        }
200
        }
201 201
    }
202 202

  
203 203
    /* second pass : fill auxillary tables recursively */

Also available in: Unified diff