History

bitstream: forward error values and drop few abort()

Luca Barbato committed 13 years ago

Commit f80b60a1 parent f7768991 file · +7 −7Browse files

Unified · Split

libavcodec/bitstream.c+7−7
@@ -107,11 +107,11 @@ static int alloc_table(VLC *vlc, int size, int use_static) · 106 unmodified lines
107107 vlc->table_size += size;
108108 if (vlc->table_size > vlc->table_allocated) {
109109 if (use_static)
110− abort(); // cannot do anything, init_vlc() is used with too little memory
110+ return AVERROR_BUG;
111111 vlc->table_allocated += (1 << vlc->bits);
112112 vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
113113 if (!vlc->table)
114− return -1;
114+ return AVERROR(ENOMEM);
115115 }
116116 return index;
117117 }
@@ -163,7 +163,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 45 unmodified lines
163163 table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
164164 av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
165165 if (table_index < 0)
166− return -1;
166+ return table_index;
167167 table = &vlc->table[table_index];
168168
169169 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
190190 av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n);
191191 if (table[j][1] /*bits*/ != 0) {
192192 av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
193− return -1;
193+ return AVERROR_INVALIDDATA;
194194 }
195195 table[j][1] = n; //bits
196196 table[j][0] = symbol;
@@ -221,7 +221,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, · 24 unmodified lines
221221 j, codes[i].bits + table_nb_bits);
222222 index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
223223 if (index < 0)
224− return -1;
224+ return index;
225225 /* note: realloc has been done, so reload tables */
226226 table = &vlc->table[table_index];
227227 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
272272 if (vlc->table_size && vlc->table_size == vlc->table_allocated) {
273273 return 0;
274274 } else if (vlc->table_size) {
275− abort(); // fatal error, we are called on a partially initialized table
275+ return AVERROR_BUG;
276276 }
277277 } else {
278278 vlc->table = NULL;
@@ -313,7 +313,7 @@ int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, · 34 unmodified lines
313313 av_free(buf);
314314 if (ret < 0) {
315315 av_freep(&vlc->table);
316− return -1;
316+ return ret;
317317 }
318318 if ((flags & INIT_VLC_USE_NEW_STATIC) &&
319319 vlc->table_size != vlc->table_allocated)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t