Lines 1-100
Link Here
|
1 |
Index: m4/ffmpeg.m4 |
|
|
2 |
=================================================================== |
3 |
--- m4/ffmpeg.m4.orig |
4 |
+++ m4/ffmpeg.m4 |
5 |
@@ -49,7 +49,7 @@ then |
6 |
LIBS="$LIBS $FFMPEG_LIBS" |
7 |
have_ffmpeg="no" |
8 |
AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/avformat.h], |
9 |
- [AC_CHECK_LIB(avformat, av_open_input_file, |
10 |
+ [AC_CHECK_LIB(avformat, avformat_open_input, |
11 |
[AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h], |
12 |
[AC_CHECK_LIB(avcodec, avcodec_decode_audio3, have_ffmpeg=yes)])]) |
13 |
break]) |
14 |
Index: src/ffmpeg.c |
15 |
=================================================================== |
16 |
--- src/ffmpeg.c.orig |
17 |
+++ src/ffmpeg.c |
18 |
@@ -92,8 +92,10 @@ static int stream_component_open(priv_t |
19 |
enc->workaround_bugs = 1; |
20 |
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) |
21 |
enc->error_resilience = 1; |
22 |
-#else |
23 |
+#elif LIBAVCODEC_VERSION_INT < ((54<<16)+(0<<8)+0) |
24 |
enc->error_recognition = 1; |
25 |
+#else |
26 |
+ ic->error_recognition = 1; |
27 |
#endif |
28 |
|
29 |
if (!codec || avcodec_open(enc, codec) < 0) |
30 |
@@ -157,7 +159,7 @@ static int audio_decode_frame(priv_t * f |
31 |
static int startread(sox_format_t * ft) |
32 |
{ |
33 |
priv_t * ffmpeg = (priv_t *)ft->priv; |
34 |
- AVFormatParameters params; |
35 |
+ AVDictionary *params; |
36 |
int ret; |
37 |
int i; |
38 |
|
39 |
@@ -172,7 +174,7 @@ static int startread(sox_format_t * ft) |
40 |
|
41 |
/* Open file and get format */ |
42 |
memset(¶ms, 0, sizeof(params)); |
43 |
- if ((ret = av_open_input_file(&ffmpeg->ctxt, ft->filename, NULL, 0, ¶ms)) < 0) { |
44 |
+ if ((ret = avformat_open_input(&ffmpeg->ctxt, ft->filename, NULL, ¶ms)) < 0) { |
45 |
lsx_fail("ffmpeg cannot open file for reading: %s (code %d)", ft->filename, ret); |
46 |
return SOX_EOF; |
47 |
} |
48 |
@@ -231,7 +233,7 @@ static size_t read_samples(sox_format_t |
49 |
/* If input buffer empty, read more data */ |
50 |
if (ffmpeg->audio_buf_index * 2 >= ffmpeg->audio_buf_size) { |
51 |
if ((ret = av_read_frame(ffmpeg->ctxt, pkt)) < 0 && |
52 |
- (ret == AVERROR_EOF || url_ferror(ffmpeg->ctxt->pb))) |
53 |
+ (ret == AVERROR_EOF || ( ffmpeg->ctxt->pb && ffmpeg->ctxt->pb->error))) |
54 |
break; |
55 |
ffmpeg->audio_buf_size = audio_decode_frame(ffmpeg, ffmpeg->audio_buf_aligned, AVCODEC_MAX_AUDIO_FRAME_SIZE); |
56 |
ffmpeg->audio_buf_index = 0; |
57 |
@@ -373,13 +375,6 @@ static int startwrite(sox_format_t * ft) |
58 |
return SOX_EOF; |
59 |
} |
60 |
|
61 |
- /* set the output parameters (must be done even if no |
62 |
- parameters). */ |
63 |
- if (av_set_parameters(ffmpeg->ctxt, NULL) < 0) { |
64 |
- lsx_fail("ffmpeg invalid output format parameters"); |
65 |
- return SOX_EOF; |
66 |
- } |
67 |
- |
68 |
/* Next line for debugging */ |
69 |
/* dump_format(ffmpeg->ctxt, 0, ft->filename, 1); */ |
70 |
|
71 |
@@ -391,14 +386,14 @@ static int startwrite(sox_format_t * ft) |
72 |
|
73 |
/* open the output file, if needed */ |
74 |
if (!(ffmpeg->fmt->flags & AVFMT_NOFILE)) { |
75 |
- if (url_fopen(&ffmpeg->ctxt->pb, ft->filename, URL_WRONLY) < 0) { |
76 |
+ if (avio_open(&ffmpeg->ctxt->pb, ft->filename, AVIO_FLAG_WRITE) < 0) { |
77 |
lsx_fail("ffmpeg could not open `%s'", ft->filename); |
78 |
return SOX_EOF; |
79 |
} |
80 |
} |
81 |
|
82 |
/* write the stream header, if any */ |
83 |
- av_write_header(ffmpeg->ctxt); |
84 |
+ avformat_write_header(ffmpeg->ctxt, NULL); |
85 |
|
86 |
return SOX_SUCCESS; |
87 |
} |
88 |
@@ -475,11 +470,7 @@ static int stopwrite(sox_format_t * ft) |
89 |
|
90 |
if (!(ffmpeg->fmt->flags & AVFMT_NOFILE)) { |
91 |
/* close the output file */ |
92 |
-#if (LIBAVFORMAT_VERSION_INT < 0x340000) |
93 |
- url_fclose(&ffmpeg->ctxt->pb); |
94 |
-#else |
95 |
- url_fclose(ffmpeg->ctxt->pb); |
96 |
-#endif |
97 |
+ avio_close(ffmpeg->ctxt->pb); |
98 |
} |
99 |
|
100 |
/* Free the output context */ |