diff options
Diffstat (limited to 'src/plugins/previewopus_extractor.c')
-rw-r--r-- | src/plugins/previewopus_extractor.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c index 9cae71f..1387044 100644 --- a/src/plugins/previewopus_extractor.c +++ b/src/plugins/previewopus_extractor.c | |||
@@ -66,10 +66,11 @@ | |||
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | //TODO: Check for ffmpeg | 68 | //TODO: Check for ffmpeg |
69 | #if HAVE_LIBAVRESAMPLE_AVRESAMPLE_H | ||
69 | #include <libavresample/avresample.h> | 70 | #include <libavresample/avresample.h> |
70 | 71 | #elif HAVE_FFMPEG_AVRESAMPLE_H | |
71 | 72 | #include <ffmpeg/avresample.h> | |
72 | 73 | #endif | |
73 | 74 | ||
74 | 75 | ||
75 | 76 | ||
@@ -201,16 +202,19 @@ static int open_output_file( | |||
201 | AVFormatContext **output_format_context, | 202 | AVFormatContext **output_format_context, |
202 | AVCodecContext **output_codec_context) | 203 | AVCodecContext **output_codec_context) |
203 | { | 204 | { |
205 | AVIOContext *output_io_context = NULL; | ||
204 | AVStream *stream = NULL; | 206 | AVStream *stream = NULL; |
205 | AVCodec *output_codec = NULL; | 207 | AVCodec *output_codec = NULL; |
206 | AVIOContext *io_ctx; | 208 | AVIOContext *io_ctx; |
207 | int error; | 209 | int error; |
208 | 210 | ||
209 | 211 | ||
212 | |||
213 | AVDictionary *options; | ||
210 | unsigned char *iob; | 214 | unsigned char *iob; |
211 | 215 | ||
212 | if (NULL == (iob = av_malloc (16 * 1024))) | 216 | if (NULL == (iob = av_malloc (16 * 1024))) |
213 | return AVERROR_EXIT; | 217 | return; |
214 | if (NULL == (io_ctx = avio_alloc_context (iob, 16 * 1024, | 218 | if (NULL == (io_ctx = avio_alloc_context (iob, 16 * 1024, |
215 | AVIO_FLAG_WRITE, NULL, | 219 | AVIO_FLAG_WRITE, NULL, |
216 | NULL, | 220 | NULL, |
@@ -218,12 +222,12 @@ static int open_output_file( | |||
218 | NULL))) | 222 | NULL))) |
219 | { | 223 | { |
220 | av_free (iob); | 224 | av_free (iob); |
221 | return AVERROR_EXIT; | 225 | return; |
222 | } | 226 | } |
223 | if (NULL == ((*output_format_context) = avformat_alloc_context ())) | 227 | if (NULL == ((*output_format_context) = avformat_alloc_context ())) |
224 | { | 228 | { |
225 | av_free (io_ctx); | 229 | av_free (io_ctx); |
226 | return AVERROR_EXIT; | 230 | return; |
227 | } | 231 | } |
228 | (*output_format_context)->pb = io_ctx; | 232 | (*output_format_context)->pb = io_ctx; |
229 | 233 | ||
@@ -821,6 +825,7 @@ static int write_output_file_trailer(AVFormatContext *output_format_context) | |||
821 | static void | 825 | static void |
822 | extract_audio (struct EXTRACTOR_ExtractContext *ec) | 826 | extract_audio (struct EXTRACTOR_ExtractContext *ec) |
823 | { | 827 | { |
828 | AVPacket packet; | ||
824 | AVIOContext *io_ctx; | 829 | AVIOContext *io_ctx; |
825 | struct AVFormatContext *format_ctx; | 830 | struct AVFormatContext *format_ctx; |
826 | AVCodecContext *codec_ctx; | 831 | AVCodecContext *codec_ctx; |
@@ -828,18 +833,23 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
828 | AVCodec *codec; | 833 | AVCodec *codec; |
829 | AVDictionary *options; | 834 | AVDictionary *options; |
830 | AVFrame *frame; | 835 | AVFrame *frame; |
836 | |||
831 | AVCodecContext* output_codec_context = NULL; | 837 | AVCodecContext* output_codec_context = NULL; |
838 | |||
839 | |||
832 | AVAudioResampleContext *resample_context = NULL; | 840 | AVAudioResampleContext *resample_context = NULL; |
833 | AVAudioFifo *fifo = NULL; | 841 | AVAudioFifo *fifo = NULL; |
834 | 842 | ||
835 | 843 | ||
836 | int audio_stream_index; | 844 | int audio_stream_index; |
845 | int thumb_width; | ||
846 | int thumb_height; | ||
837 | int i; | 847 | int i; |
838 | int err; | 848 | int err; |
849 | int frame_finished; | ||
839 | int duration; | 850 | int duration; |
840 | unsigned char *iob; | 851 | unsigned char *iob; |
841 | 852 | ||
842 | |||
843 | totalSize =0; | 853 | totalSize =0; |
844 | 854 | ||
845 | if (NULL == (iob = av_malloc (16 * 1024))) | 855 | if (NULL == (iob = av_malloc (16 * 1024))) |
@@ -972,6 +982,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
972 | 982 | ||
973 | if (err >= 0) | 983 | if (err >= 0) |
974 | avcodec_flush_buffers (codec_ctx); | 984 | avcodec_flush_buffers (codec_ctx); |
985 | frame_finished = 0; | ||
975 | 986 | ||
976 | 987 | ||
977 | /** | 988 | /** |
@@ -1109,6 +1120,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec) | |||
1109 | void | 1120 | void |
1110 | EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec) | 1121 | EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec) |
1111 | { | 1122 | { |
1123 | unsigned int i; | ||
1112 | ssize_t iret; | 1124 | ssize_t iret; |
1113 | void *data; | 1125 | void *data; |
1114 | 1126 | ||