shithub: sox

Download patch

ref: 5a326905f20dbdddf78d6c71e5dce948e89d2afe
parent: 01062242081b8aae7aae69ddd6b93eaed26528db
author: cbagwell <cbagwell>
date: Sun Jun 14 21:31:47 EDT 2009

Revert new API usage since it wasn't optional and failing
on at least a few standard distributions off ffmpeg.

--- a/src/ffmpeg.c
+++ b/src/ffmpeg.c
@@ -126,16 +126,12 @@
   for (;;) {
     /* NOTE: the audio packet can contain several frames */
     while (ffmpeg->audio_pkt_size > 0) {
-      AVPacket avpkt;
-      av_init_packet(&avpkt);
-      avpkt.data = ffmpeg->audio_pkt_data;
-      avpkt.size = ffmpeg->audio_pkt_size;
       data_size = buf_size;
-
-      len1 = avcodec_decode_audio3(ffmpeg->audio_st->codec,
-                                   (int16_t *)audio_buf, &data_size, &avpkt);
+      len1 = avcodec_decode_audio2(ffmpeg->audio_st->codec,
+                                   (int16_t *)audio_buf, &data_size,
+                                   ffmpeg->audio_pkt_data, ffmpeg->audio_pkt_size);
       if (len1 < 0) /* if error, we skip the rest of the packet */
-        return 0;
+	return 0;
 
       ffmpeg->audio_pkt_data += len1;
       ffmpeg->audio_pkt_size -= len1;
@@ -225,7 +221,7 @@
     /* If input buffer empty, read more data */
     if (ffmpeg->audio_buf_index * 2 >= ffmpeg->audio_buf_size) {
       if ((ret = av_read_frame(ffmpeg->ctxt, pkt)) < 0 &&
-          (ret == AVERROR_EOF || url_ferror(ffmpeg->ctxt->pb)))
+	  (ret == AVERROR_EOF || url_ferror(ffmpeg->ctxt->pb)))
         break;
       ffmpeg->audio_buf_size = audio_decode_frame(ffmpeg, ffmpeg->audio_buf, AVCODEC_MAX_AUDIO_FRAME_SIZE);
       ffmpeg->audio_buf_index = 0;
@@ -348,7 +344,7 @@
   }
 
   /* allocate the output media context */
-  ffmpeg->ctxt = avformat_alloc_context();
+  ffmpeg->ctxt = av_alloc_format_context();
   if (!ffmpeg->ctxt) {
     fprintf(stderr, "ffmpeg out of memory error");
     return SOX_EOF;