Browse code

Replace all remaining occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).

AVERROR_NOMEM is deprecated and will be dropped at the next libavutil
major bump.

Originally committed as revision 22791 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/04/03 23:15:00
Showing 17 changed files
... ...
@@ -216,7 +216,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
216 216
     if (avctx->error_recognition >= FF_ER_CAREFUL) {
217 217
         s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
218 218
         if (!s->input_buffer)
219
-            return AVERROR_NOMEM;
219
+            return AVERROR(ENOMEM);
220 220
     }
221 221
 
222 222
     avctx->sample_fmt = SAMPLE_FMT_S16;
... ...
@@ -288,11 +288,11 @@ static int tgv_decode_frame(AVCodecContext *avctx,
288 288
         /* allocate additional 12 bytes to accomodate av_memcpy_backptr() OUTBUF_PADDED optimisation */
289 289
         s->frame.data[0] = av_malloc(s->width*s->height + 12);
290 290
         if (!s->frame.data[0])
291
-            return AVERROR_NOMEM;
291
+            return AVERROR(ENOMEM);
292 292
         s->frame.data[1] = av_malloc(AVPALETTE_SIZE);
293 293
         if (!s->frame.data[1]) {
294 294
             av_freep(&s->frame.data[0]);
295
-            return AVERROR_NOMEM;
295
+            return AVERROR(ENOMEM);
296 296
         }
297 297
     }
298 298
     memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
... ...
@@ -352,7 +352,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
352 352
     /* initialize MD5 context */
353 353
     s->md5ctx = av_malloc(av_md5_size);
354 354
     if(!s->md5ctx)
355
-        return AVERROR_NOMEM;
355
+        return AVERROR(ENOMEM);
356 356
     av_md5_init(s->md5ctx);
357 357
 
358 358
     streaminfo = av_malloc(FLAC_STREAMINFO_SIZE);
... ...
@@ -133,10 +133,10 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
133 133
     avctx->coded_frame = &s->picture;
134 134
     s->lzw = av_mallocz(ff_lzw_encode_state_size);
135 135
     if (!s->lzw)
136
-        return AVERROR_NOMEM;
136
+        return AVERROR(ENOMEM);
137 137
     s->buf = av_malloc(avctx->width*avctx->height*2);
138 138
     if (!s->buf)
139
-         return AVERROR_NOMEM;
139
+         return AVERROR(ENOMEM);
140 140
     return 0;
141 141
 }
142 142
 
... ...
@@ -284,7 +284,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
284 284
     st = av_new_stream(s, 0);
285 285
     if(!st) {
286 286
         vfw_read_close(s);
287
-        return AVERROR_NOMEM;
287
+        return AVERROR(ENOMEM);
288 288
     }
289 289
 
290 290
     /* Set video format */
... ...
@@ -294,7 +294,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
294 294
     bi = av_malloc(bisize);
295 295
     if(!bi) {
296 296
         vfw_read_close(s);
297
-        return AVERROR_NOMEM;
297
+        return AVERROR(ENOMEM);
298 298
     }
299 299
     ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
300 300
     if(!ret)
... ...
@@ -248,7 +248,7 @@ static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
248 248
     }
249 249
     ape->frames       = av_malloc(ape->totalframes * sizeof(APEFrame));
250 250
     if(!ape->frames)
251
-        return AVERROR_NOMEM;
251
+        return AVERROR(ENOMEM);
252 252
     ape->firstframe   = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
253 253
     ape->currentframe = 0;
254 254
 
... ...
@@ -351,7 +351,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
351 351
         nblocks = ape->blocksperframe;
352 352
 
353 353
     if (av_new_packet(pkt,  ape->frames[ape->currentframe].size + extra_size) < 0)
354
-        return AVERROR_NOMEM;
354
+        return AVERROR(ENOMEM);
355 355
 
356 356
     AV_WL32(pkt->data    , nblocks);
357 357
     AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
... ...
@@ -56,7 +56,7 @@ static int ape_tag_read_field(AVFormatContext *s)
56 56
         return -1;
57 57
     value = av_malloc(size+1);
58 58
     if (!value)
59
-        return AVERROR_NOMEM;
59
+        return AVERROR(ENOMEM);
60 60
     get_buffer(pb, value, size);
61 61
     value[size] = 0;
62 62
     av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
... ...
@@ -61,7 +61,7 @@ static int read_desc_chunk(AVFormatContext *s)
61 61
     /* new audio stream */
62 62
     st = av_new_stream(s, 0);
63 63
     if (!st)
64
-        return AVERROR_NOMEM;
64
+        return AVERROR(ENOMEM);
65 65
 
66 66
     /* parse format description */
67 67
     st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
... ...
@@ -67,7 +67,7 @@ static int flac_read_header(AVFormatContext *s,
67 67
         case FLAC_METADATA_TYPE_VORBIS_COMMENT:
68 68
             buffer = av_mallocz(metadata_size + FF_INPUT_BUFFER_PADDING_SIZE);
69 69
             if (!buffer) {
70
-                return AVERROR_NOMEM;
70
+                return AVERROR(ENOMEM);
71 71
             }
72 72
             if (get_buffer(s->pb, buffer, metadata_size) != metadata_size) {
73 73
                 av_freep(&buffer);
... ...
@@ -433,7 +433,7 @@ static int mpegts_write_header(AVFormatContext *s)
433 433
             st->codec->extradata_size > 0) {
434 434
             ts_st->adts = av_mallocz(sizeof(*ts_st->adts));
435 435
             if (!ts_st->adts)
436
-                return AVERROR_NOMEM;
436
+                return AVERROR(ENOMEM);
437 437
             if (ff_adts_decode_extradata(s, ts_st->adts, st->codec->extradata,
438 438
                                          st->codec->extradata_size) < 0)
439 439
                 return -1;
... ...
@@ -836,7 +836,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
836 836
                 return -1;
837 837
             data = av_malloc(new_size);
838 838
             if (!data)
839
-                return AVERROR_NOMEM;
839
+                return AVERROR(ENOMEM);
840 840
             ff_adts_write_frame_header(adts, data, pkt->size, adts->pce_size);
841 841
             if (adts->pce_size) {
842 842
                 memcpy(data+ADTS_HEADER_SIZE, adts->pce_data, adts->pce_size);
... ...
@@ -77,7 +77,7 @@ static int msnwc_tcp_read_header(AVFormatContext *ctx, AVFormatParameters *ap)
77 77
 
78 78
     st = av_new_stream(ctx, 0);
79 79
     if(!st)
80
-        return AVERROR_NOMEM;
80
+        return AVERROR(ENOMEM);
81 81
 
82 82
     codec = st->codec;
83 83
     codec->codec_type = AVMEDIA_TYPE_VIDEO;
... ...
@@ -121,7 +121,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
121 121
     oggstream->header[0] = av_mallocz(51); // per ogg flac specs
122 122
     p = oggstream->header[0];
123 123
     if (!p)
124
-        return AVERROR_NOMEM;
124
+        return AVERROR(ENOMEM);
125 125
     bytestream_put_byte(&p, 0x7F);
126 126
     bytestream_put_buffer(&p, "FLAC", 4);
127 127
     bytestream_put_byte(&p, 1); // major version
... ...
@@ -135,7 +135,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
135 135
     // second packet: VorbisComment
136 136
     p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m);
137 137
     if (!p)
138
-        return AVERROR_NOMEM;
138
+        return AVERROR(ENOMEM);
139 139
     oggstream->header[1] = p;
140 140
     bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
141 141
     bytestream_put_be24(&p, oggstream->header_len[1] - 4);
... ...
@@ -157,7 +157,7 @@ static int ogg_build_speex_headers(AVCodecContext *avctx,
157 157
     // first packet: Speex header
158 158
     p = av_mallocz(SPEEX_HEADER_SIZE);
159 159
     if (!p)
160
-        return AVERROR_NOMEM;
160
+        return AVERROR(ENOMEM);
161 161
     oggstream->header[0] = p;
162 162
     oggstream->header_len[0] = SPEEX_HEADER_SIZE;
163 163
     bytestream_put_buffer(&p, avctx->extradata, SPEEX_HEADER_SIZE);
... ...
@@ -166,7 +166,7 @@ static int ogg_build_speex_headers(AVCodecContext *avctx,
166 166
     // second packet: VorbisComment
167 167
     p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m);
168 168
     if (!p)
169
-        return AVERROR_NOMEM;
169
+        return AVERROR(ENOMEM);
170 170
     oggstream->header[1] = p;
171 171
 
172 172
     return 0;
... ...
@@ -106,7 +106,7 @@ static int rm_read_extradata(ByteIOContext *pb, AVCodecContext *avctx, unsigned
106 106
         return -1;
107 107
     avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
108 108
     if (!avctx->extradata)
109
-        return AVERROR_NOMEM;
109
+        return AVERROR(ENOMEM);
110 110
     avctx->extradata_size = get_buffer(pb, avctx->extradata, size);
111 111
     memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
112 112
     if (avctx->extradata_size != size)
... ...
@@ -83,7 +83,7 @@ static int amr_handle_packet(AVFormatContext *ctx,
83 83
     /* Everything except the codec mode request byte should be output. */
84 84
     if (av_new_packet(pkt, len - 1)) {
85 85
         av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
86
-        return AVERROR_NOMEM;
86
+        return AVERROR(ENOMEM);
87 87
     }
88 88
     pkt->stream_index = st->index;
89 89
     ptr = pkt->data;
... ...
@@ -78,7 +78,7 @@ static int h263_handle_packet(AVFormatContext *ctx,
78 78
 
79 79
     if (av_new_packet(pkt, len + startcode)) {
80 80
         av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
81
-        return AVERROR_NOMEM;
81
+        return AVERROR(ENOMEM);
82 82
     }
83 83
     pkt->stream_index = st->index;
84 84
     ptr = pkt->data;
... ...
@@ -134,7 +134,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
134 134
 
135 135
         if (av_new_packet(pkt, data_len)) {
136 136
             av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
137
-            return AVERROR_NOMEM;
137
+            return AVERROR(ENOMEM);
138 138
         }
139 139
         pkt->stream_index = st->index;
140 140
 
... ...
@@ -189,7 +189,7 @@ static int xiph_handle_packet(AVFormatContext * ctx,
189 189
 
190 190
             if (av_new_packet(pkt, frame_size)) {
191 191
                 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
192
-                return AVERROR_NOMEM;
192
+                return AVERROR(ENOMEM);
193 193
             }
194 194
 
195 195
             memcpy(pkt->data, xiph_data, frame_size);
... ...
@@ -272,7 +272,7 @@ parse_packed_headers(const uint8_t * packed_headers,
272 272
     ptr = codec->extradata = av_malloc(extradata_alloc);
273 273
     if (!ptr) {
274 274
         av_log(codec, AV_LOG_ERROR, "Out of memory\n");
275
-        return AVERROR_NOMEM;
275
+        return AVERROR(ENOMEM);
276 276
     }
277 277
     *ptr++ = 2;
278 278
     ptr += av_xiphlacing(ptr, length1);
... ...
@@ -331,7 +331,7 @@ static int xiph_parse_fmtp_pair(AVCodecContext * codec,
331 331
             } else {
332 332
                 av_log(codec, AV_LOG_ERROR,
333 333
                        "Out of memory while decoding SDP configuration.\n");
334
-                result = AVERROR_NOMEM;
334
+                result = AVERROR(ENOMEM);
335 335
             }
336 336
         } else {
337 337
             av_log(codec, AV_LOG_ERROR, "Packet too large\n");
... ...
@@ -356,7 +356,7 @@ static int xiph_parse_sdp_line(AVFormatContext *s, int st_index,
356 356
 
357 357
     if (!(value = av_malloc(value_size))) {
358 358
         av_log(codec, AV_LOG_ERROR, "Out of memory\n");
359
-        return AVERROR_NOMEM;
359
+        return AVERROR(ENOMEM);
360 360
     }
361 361
 
362 362
     if (av_strstart(line, "fmtp:", &p)) {
... ...
@@ -186,7 +186,7 @@ static int wc3_read_header(AVFormatContext *s,
186 186
             /* load up the name */
187 187
             buffer = av_malloc(size+1);
188 188
             if (!buffer)
189
-                return AVERROR_NOMEM;
189
+                return AVERROR(ENOMEM);
190 190
             if ((ret = get_buffer(pb, buffer, size)) != size)
191 191
                 return AVERROR(EIO);
192 192
             buffer[size] = 0;