Browse code

Remove libvorbis Vorbis decoding support. Our native decoder is complete and has no known bugs, any remaining issues will hopefully be uncovered now.

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

Diego Biurrun authored on 2007/11/04 21:55:32
Showing 4 changed files
... ...
@@ -101,6 +101,7 @@ version <next>
101 101
 - H.264 PAFF decoding
102 102
 - Nellymoser ASAO decoder
103 103
 - Beam Software SIFF demuxer and decoder
104
+- libvorbis Vorbis decoding removed in favor of native decoder
104 105
 
105 106
 version 0.4.9-pre1:
106 107
 
... ...
@@ -93,8 +93,8 @@ show_help(){
93 93
   echo "                           native demuxer exists [default=no]"
94 94
   echo "  --enable-libogg          enable Ogg muxing via libogg [default=no]"
95 95
   echo "  --enable-libtheora       enable Theora encoding via libtheora [default=no]"
96
-  echo "  --enable-libvorbis       enable Vorbis en/decoding via libvorbis,"
97
-  echo "                           native implementations exist [default=no]"
96
+  echo "  --enable-libvorbis       enable Vorbis encoding via libvorbis,"
97
+  echo "                           native implementation exists [default=no]"
98 98
   echo "  --enable-libx264         enable H.264 encoding via x264 [default=no]"
99 99
   echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
100 100
   echo "                           native MPEG-4/Xvid encoder exists [default=no]"
... ...
@@ -782,7 +782,6 @@ libgsm_ms_decoder_deps="libgsm"
782 782
 libgsm_ms_encoder_deps="libgsm"
783 783
 libmp3lame_encoder_deps="libmp3lame"
784 784
 libtheora_encoder_deps="libtheora"
785
-libvorbis_decoder_deps="libvorbis"
786 785
 libvorbis_encoder_deps="libvorbis"
787 786
 libx264_encoder_deps="libx264"
788 787
 libxvid_encoder_deps="libxvid"
... ...
@@ -1568,7 +1567,7 @@ enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1568 1568
 enabled libnut     && require libnut libnut.h nut_demuxer_init -lnut
1569 1569
 enabled libogg     && require libogg ogg/ogg.h ogg_sync_init -logg
1570 1570
 enabled libtheora  && require libtheora theora/theora.h theora_info_init -ltheora -logg
1571
-enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1571
+enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -logg
1572 1572
 enabled libx264    && require x264 x264.h x264_encoder_open -lx264
1573 1573
 enabled libxvid    && require Xvid xvid.h xvid_global -lxvidcore
1574 1574
 enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
... ...
@@ -1750,7 +1749,7 @@ check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1750 1750
 enabled libdc1394 && append pkg_requires "libraw1394"
1751 1751
 enabled libogg    && append pkg_requires "ogg >= 1.1"
1752 1752
 enabled libtheora && append pkg_requires "theora"
1753
-enabled libvorbis && append pkg_requires "vorbis vorbisenc"
1753
+enabled libvorbis && append pkg_requires "vorbisenc"
1754 1754
 
1755 1755
 echo "install prefix            $PREFIX"
1756 1756
 echo "source path               $source_path"
... ...
@@ -272,7 +272,7 @@ void avcodec_register_all(void)
272 272
     REGISTER_ENCDEC  (LIBGSM_MS, libgsm_ms);
273 273
     REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
274 274
     REGISTER_ENCODER (LIBTHEORA, libtheora);
275
-    REGISTER_ENCDEC  (LIBVORBIS, libvorbis);
275
+    REGISTER_ENCODER (LIBVORBIS, libvorbis);
276 276
     REGISTER_ENCODER (LIBX264, libx264);
277 277
     REGISTER_ENCODER (LIBXVID, libxvid);
278 278
 
... ...
@@ -218,160 +218,3 @@ AVCodec libvorbis_encoder = {
218 218
     oggvorbis_encode_close,
219 219
     .capabilities= CODEC_CAP_DELAY,
220 220
 } ;
221
-
222
-static int oggvorbis_decode_init(AVCodecContext *avccontext) {
223
-    OggVorbisContext *context = avccontext->priv_data ;
224
-    uint8_t *p= avccontext->extradata;
225
-    int i, hsizes[3];
226
-    unsigned char *headers[3], *extradata = avccontext->extradata;
227
-
228
-    vorbis_info_init(&context->vi) ;
229
-    vorbis_comment_init(&context->vc) ;
230
-
231
-    if(! avccontext->extradata_size || ! p) {
232
-        av_log(avccontext, AV_LOG_ERROR, "vorbis extradata absent\n");
233
-        return -1;
234
-    }
235
-
236
-    if(p[0] == 0 && p[1] == 30) {
237
-        for(i = 0; i < 3; i++){
238
-            hsizes[i] = bytestream_get_be16(&p);
239
-            headers[i] = p;
240
-            p += hsizes[i];
241
-        }
242
-    } else if(*p == 2) {
243
-        unsigned int offset = 1;
244
-        p++;
245
-        for(i=0; i<2; i++) {
246
-            hsizes[i] = 0;
247
-            while((*p == 0xFF) && (offset < avccontext->extradata_size)) {
248
-                hsizes[i] += 0xFF;
249
-                offset++;
250
-                p++;
251
-            }
252
-            if(offset >= avccontext->extradata_size - 1) {
253
-                av_log(avccontext, AV_LOG_ERROR,
254
-                       "vorbis header sizes damaged\n");
255
-                return -1;
256
-            }
257
-            hsizes[i] += *p;
258
-            offset++;
259
-            p++;
260
-        }
261
-        hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset;
262
-#if 0
263
-        av_log(avccontext, AV_LOG_DEBUG,
264
-               "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n",
265
-               hsizes[0], hsizes[1], hsizes[2], avccontext->extradata_size);
266
-#endif
267
-        headers[0] = extradata + offset;
268
-        headers[1] = extradata + offset + hsizes[0];
269
-        headers[2] = extradata + offset + hsizes[0] + hsizes[1];
270
-    } else {
271
-        av_log(avccontext, AV_LOG_ERROR,
272
-               "vorbis initial header len is wrong: %d\n", *p);
273
-        return -1;
274
-    }
275
-
276
-    for(i=0; i<3; i++){
277
-        context->op.b_o_s= i==0;
278
-        context->op.bytes = hsizes[i];
279
-        context->op.packet = headers[i];
280
-        if(vorbis_synthesis_headerin(&context->vi, &context->vc, &context->op)<0){
281
-            av_log(avccontext, AV_LOG_ERROR, "%d. vorbis header damaged\n", i+1);
282
-            return -1;
283
-        }
284
-    }
285
-
286
-    avccontext->channels = context->vi.channels;
287
-    avccontext->sample_rate = context->vi.rate;
288
-    avccontext->time_base= (AVRational){1, avccontext->sample_rate};
289
-
290
-    vorbis_synthesis_init(&context->vd, &context->vi);
291
-    vorbis_block_init(&context->vd, &context->vb);
292
-
293
-    return 0 ;
294
-}
295
-
296
-
297
-static inline int conv(int samples, float **pcm, char *buf, int channels) {
298
-    int i, j;
299
-    ogg_int16_t *ptr, *data = (ogg_int16_t*)buf ;
300
-    float *mono ;
301
-
302
-    for(i = 0 ; i < channels ; i++){
303
-        ptr = &data[i];
304
-        mono = pcm[i] ;
305
-
306
-        for(j = 0 ; j < samples ; j++) {
307
-            *ptr = av_clip_int16(mono[j] * 32767.f);
308
-            ptr += channels;
309
-        }
310
-    }
311
-
312
-    return 0 ;
313
-}
314
-
315
-
316
-static int oggvorbis_decode_frame(AVCodecContext *avccontext,
317
-                        void *data, int *data_size,
318
-                        uint8_t *buf, int buf_size)
319
-{
320
-    OggVorbisContext *context = avccontext->priv_data ;
321
-    float **pcm ;
322
-    ogg_packet *op= &context->op;
323
-    int samples, total_samples, total_bytes;
324
-
325
-    if(!buf_size){
326
-    //FIXME flush
327
-        return 0;
328
-    }
329
-
330
-    op->packet = buf;
331
-    op->bytes  = buf_size;
332
-
333
-//    av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %"PRId64" %"PRId64" %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate);
334
-
335
-/*    for(i=0; i<op->bytes; i++)
336
-      av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]);
337
-    av_log(avccontext, AV_LOG_DEBUG, "\n");*/
338
-
339
-    if(vorbis_synthesis(&context->vb, op) == 0)
340
-        vorbis_synthesis_blockin(&context->vd, &context->vb) ;
341
-
342
-    total_samples = 0 ;
343
-    total_bytes = 0 ;
344
-
345
-    while((samples = vorbis_synthesis_pcmout(&context->vd, &pcm)) > 0) {
346
-        conv(samples, pcm, (char*)data + total_bytes, context->vi.channels) ;
347
-        total_bytes += samples * 2 * context->vi.channels ;
348
-        total_samples += samples ;
349
-        vorbis_synthesis_read(&context->vd, samples) ;
350
-    }
351
-
352
-    *data_size = total_bytes ;
353
-    return buf_size ;
354
-}
355
-
356
-
357
-static int oggvorbis_decode_close(AVCodecContext *avccontext) {
358
-    OggVorbisContext *context = avccontext->priv_data ;
359
-
360
-    vorbis_info_clear(&context->vi) ;
361
-    vorbis_comment_clear(&context->vc) ;
362
-
363
-    return 0 ;
364
-}
365
-
366
-
367
-AVCodec libvorbis_decoder = {
368
-    "libvorbis",
369
-    CODEC_TYPE_AUDIO,
370
-    CODEC_ID_VORBIS,
371
-    sizeof(OggVorbisContext),
372
-    oggvorbis_decode_init,
373
-    NULL,
374
-    oggvorbis_decode_close,
375
-    oggvorbis_decode_frame,
376
-    .capabilities= CODEC_CAP_DELAY,
377
-} ;