Showing the changes to libavcodec/bitstream.c (1 of 1 file). Show all
Unified · Split
| @@ -107,11 +107,11 @@ static int alloc_table(VLC *vlc, int size, int use_static) · 106 unmodified lines | |||
| 107 | vlc->table_size += size; | 107 | vlc->table_size += size; |
| 108 | if (vlc->table_size > vlc->table_allocated) { | 108 | if (vlc->table_size > vlc->table_allocated) { |
| 109 | if (use_static) | 109 | if (use_static) |
| 110 | abort(); // cannot do anything, init_vlc() is used with too little memory | 110 | return AVERROR_BUG; |
| 111 | vlc->table_allocated += (1 << vlc->bits); | 111 | vlc->table_allocated += (1 << vlc->bits); |
| 112 | vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); | 112 | vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); |
| 113 | if (!vlc->table) | 113 | if (!vlc->table) |
| 114 | return -1; | 114 | return AVERROR(ENOMEM); |
| 115 | } | 115 | } |
| 116 | return index; | 116 | return index; |
| 117 | } | 117 | } |
| @@ -163,7 +163,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 45 unmodified lines | |||
| 163 | table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); | 163 | table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); |
| 164 | av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); | 164 | av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); |
| 165 | if (table_index < 0) | 165 | if (table_index < 0) |
| 166 | return -1; | 166 | return table_index; |
| 167 | table = &vlc->table[table_index]; | 167 | table = &vlc->table[table_index]; |
| 168 | 168 | ||
| 169 | for (i = 0; i < table_size; i++) { | 169 | for (i = 0; i < table_size; i++) { |
| @@ -190,7 +190,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 20 unmodified lines | |||
| 190 | av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); | 190 | av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); |
| 191 | if (table[j][1] /*bits*/ != 0) { | 191 | if (table[j][1] /*bits*/ != 0) { |
| 192 | av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); | 192 | av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); |
| 193 | return -1; | 193 | return AVERROR_INVALIDDATA; |
| 194 | } | 194 | } |
| 195 | table[j][1] = n; //bits | 195 | table[j][1] = n; //bits |
| 196 | table[j][0] = symbol; | 196 | table[j][0] = symbol; |
| @@ -221,7 +221,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 24 unmodified lines | |||
| 221 | j, codes[i].bits + table_nb_bits); | 221 | j, codes[i].bits + table_nb_bits); |
| 222 | index = build_table(vlc, subtable_bits, k-i, codes+i, flags); | 222 | index = build_table(vlc, subtable_bits, k-i, codes+i, flags); |
| 223 | if (index < 0) | 223 | if (index < 0) |
| 224 | return -1; | 224 | return index; |
| 225 | /* note: realloc has been done, so reload tables */ | 225 | /* note: realloc has been done, so reload tables */ |
| 226 | table = &vlc->table[table_index]; | 226 | table = &vlc->table[table_index]; |
| 227 | table[j][0] = index; //code | 227 | table[j][0] = index; //code |
| @@ -272,7 +272,7 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, · 44 unmodified lines | |||
| 272 | if (vlc->table_size && vlc->table_size == vlc->table_allocated) { | 272 | if (vlc->table_size && vlc->table_size == vlc->table_allocated) { |
| 273 | return 0; | 273 | return 0; |
| 274 | } else if (vlc->table_size) { | 274 | } else if (vlc->table_size) { |
| 275 | abort(); // fatal error, we are called on a partially initialized table | 275 | return AVERROR_BUG; |
| 276 | } | 276 | } |
| 277 | } else { | 277 | } else { |
| 278 | vlc->table = NULL; | 278 | vlc->table = NULL; |
| @@ -313,7 +313,7 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, · 34 unmodified lines | |||
| 313 | av_free(buf); | 313 | av_free(buf); |
| 314 | if (ret < 0) { | 314 | if (ret < 0) { |
| 315 | av_freep(&vlc->table); | 315 | av_freep(&vlc->table); |
| 316 | return -1; | 316 | return ret; |
| 317 | } | 317 | } |
| 318 | if ((flags & INIT_VLC_USE_NEW_STATIC) && | 318 | if ((flags & INIT_VLC_USE_NEW_STATIC) && |
| 319 | vlc->table_size != vlc->table_allocated) | 319 | vlc->table_size != vlc->table_allocated) |