Browse code

libopencore-amr, libvo-amrwbenc: Return proper error codes in most places

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2011/04/13 06:10:56
Showing 2 changed files
... ...
@@ -92,7 +92,7 @@ static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
92 92
 
93 93
     if (avctx->channels > 1) {
94 94
         av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
95
-        return -1;
95
+        return AVERROR(ENOSYS);
96 96
     }
97 97
 
98 98
     return 0;
... ...
@@ -126,7 +126,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
126 126
     if (packet_size > buf_size) {
127 127
         av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
128 128
                buf_size, packet_size);
129
-        return -1;
129
+        return AVERROR_INVALIDDATA;
130 130
     }
131 131
 
132 132
     s->frameCount++;
... ...
@@ -159,12 +159,12 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
159 159
 
160 160
     if (avctx->sample_rate != 8000) {
161 161
         av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
162
-        return -1;
162
+        return AVERROR(ENOSYS);
163 163
     }
164 164
 
165 165
     if (avctx->channels != 1) {
166 166
         av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
167
-        return -1;
167
+        return AVERROR(ENOSYS);
168 168
     }
169 169
 
170 170
     avctx->frame_size  = 160;
... ...
@@ -178,7 +178,7 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
178 178
 
179 179
     if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
180 180
         av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
181
-        return -1;
181
+        return AVERROR(ENOSYS);
182 182
     }
183 183
 
184 184
     return 0;
... ...
@@ -202,7 +202,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx,
202 202
 
203 203
     if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
204 204
         av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
205
-        return -1;
205
+        return AVERROR(ENOSYS);
206 206
     }
207 207
 
208 208
     written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
... ...
@@ -250,7 +250,7 @@ static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
250 250
 
251 251
     if (avctx->channels > 1) {
252 252
         av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
253
-        return -1;
253
+        return AVERROR(ENOSYS);
254 254
     }
255 255
 
256 256
     return 0;
... ...
@@ -277,7 +277,7 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
277 277
     if (packet_size > buf_size) {
278 278
         av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
279 279
                buf_size, packet_size + 1);
280
-        return -1;
280
+        return AVERROR_INVALIDDATA;
281 281
     }
282 282
 
283 283
     s->frameCount++;
... ...
@@ -65,17 +65,17 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
65 65
 
66 66
     if (avctx->sample_rate != 16000) {
67 67
         av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
68
-        return -1;
68
+        return AVERROR(ENOSYS);
69 69
     }
70 70
 
71 71
     if (avctx->channels != 1) {
72 72
         av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
73
-        return -1;
73
+        return AVERROR(ENOSYS);
74 74
     }
75 75
 
76 76
     if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
77 77
         av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
78
-        return -1;
78
+        return AVERROR(ENOSYS);
79 79
     }
80 80
 
81 81
     avctx->frame_size  = 320;
... ...
@@ -105,7 +105,7 @@ static int amr_wb_encode_frame(AVCodecContext *avctx,
105 105
 
106 106
     if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
107 107
         av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
108
-        return -1;
108
+        return AVERROR(ENOSYS);
109 109
     }
110 110
     size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
111 111
     return size;