Added
Link Here
|
1 |
*** diff |
2 |
|
3 |
Update to use the new ffmpeg library API, but still work with |
4 |
the old one. |
5 |
|
6 |
--- src/ffmpeg.c 2011-06-07 00:29:34.000000000 -0500 |
7 |
+++ src/ffmpeg.c 2011-06-07 00:34:12.830996927 -0500 |
8 |
@@ -50,6 +50,11 @@ |
9 |
#include <ctype.h> |
10 |
#include "ffmpeg.h" |
11 |
|
12 |
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 64, 0) |
13 |
+#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO |
14 |
+#define AV_PKT_FLAG_KEY PKT_FLAG_KEY |
15 |
+#endif |
16 |
+ |
17 |
/* Private data for ffmpeg files */ |
18 |
typedef struct { |
19 |
int audio_index; |
20 |
@@ -91,7 +96,7 @@ static int stream_component_open(priv_t |
21 |
|
22 |
if (!codec || avcodec_open(enc, codec) < 0) |
23 |
return -1; |
24 |
- if (enc->codec_type != CODEC_TYPE_AUDIO) { |
25 |
+ if (enc->codec_type != AVMEDIA_TYPE_AUDIO) { |
26 |
lsx_fail("ffmpeg CODEC %x is not an audio CODEC", enc->codec_type); |
27 |
return -1; |
28 |
} |
29 |
@@ -182,7 +187,7 @@ static int startread(sox_format_t * ft) |
30 |
/* Find audio stream (FIXME: allow different stream to be selected) */ |
31 |
for (i = 0; (unsigned)i < ffmpeg->ctxt->nb_streams; i++) { |
32 |
AVCodecContext *enc = ffmpeg->ctxt->streams[i]->codec; |
33 |
- if (enc->codec_type == CODEC_TYPE_AUDIO && ffmpeg->audio_index < 0) { |
34 |
+ if (enc->codec_type == AVMEDIA_TYPE_AUDIO && ffmpeg->audio_index < 0) { |
35 |
ffmpeg->audio_index = i; |
36 |
break; |
37 |
} |
38 |
@@ -273,7 +278,7 @@ static AVStream *add_audio_stream(sox_fo |
39 |
|
40 |
c = st->codec; |
41 |
c->codec_id = codec_id; |
42 |
- c->codec_type = CODEC_TYPE_AUDIO; |
43 |
+ c->codec_type = AVMEDIA_TYPE_AUDIO; |
44 |
|
45 |
/* put sample parameters */ |
46 |
c->bit_rate = 256000; /* FIXME: allow specification */ |
47 |
@@ -423,7 +428,7 @@ static size_t write_samples(sox_format_t |
48 |
av_init_packet(&pkt); |
49 |
pkt.size = avcodec_encode_audio(c, ffmpeg->audio_buf_aligned, AVCODEC_MAX_AUDIO_FRAME_SIZE, ffmpeg->samples); |
50 |
pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, ffmpeg->audio_st->time_base); |
51 |
- pkt.flags |= PKT_FLAG_KEY; |
52 |
+ pkt.flags |= AV_PKT_FLAG_KEY; |
53 |
pkt.stream_index = ffmpeg->audio_st->index; |
54 |
pkt.data = ffmpeg->audio_buf_aligned; |
55 |
|