1 |
From 4cc8860a0880ad9b1a8fa6e0029a8016c2fb44fa Mon Sep 17 00:00:00 2001 |
2 |
From: elupus <elupus@xbmc.org> |
3 |
Date: Tue, 1 Nov 2011 21:36:32 +0100 |
4 |
Subject: [PATCH 113/145] Replace more depreciated ffmpeg functions (cherry |
5 |
picked from commit |
6 |
1aed04a52e753b5fd395b55d97a70226f62bc634) |
7 |
|
8 |
--- |
9 |
lib/DllAvCodec.h | 32 ++++++++++---------- |
10 |
lib/DllAvFormat.h | 10 +++--- |
11 |
xbmc/cdrip/EncoderFFmpeg.cpp | 4 +-- |
12 |
.../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 5 ++- |
13 |
.../Audio/DVDAudioCodecPassthroughFFmpeg.cpp | 2 +- |
14 |
.../Audio/Encoders/DVDAudioEncoderFFmpeg.cpp | 4 +-- |
15 |
.../DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp | 18 +++++------ |
16 |
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 10 ++++-- |
17 |
8 files changed, 44 insertions(+), 41 deletions(-) |
18 |
|
19 |
diff --git a/lib/DllAvCodec.h b/lib/DllAvCodec.h |
20 |
index 05edcb7..355b8b2 100644 |
21 |
--- a/lib/DllAvCodec.h |
22 |
+++ b/lib/DllAvCodec.h |
23 |
@@ -106,7 +106,7 @@ public: |
24 |
virtual ~DllAvCodecInterface() {} |
25 |
virtual void avcodec_register_all(void)=0; |
26 |
virtual void avcodec_flush_buffers(AVCodecContext *avctx)=0; |
27 |
- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec)=0; |
28 |
+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)=0; |
29 |
virtual AVCodec *avcodec_find_decoder(enum CodecID id)=0; |
30 |
virtual AVCodec *avcodec_find_encoder(enum CodecID id)=0; |
31 |
virtual int avcodec_close_dont_call(AVCodecContext *avctx)=0; |
32 |
@@ -117,9 +117,9 @@ public: |
33 |
virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)=0; |
34 |
virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)=0; |
35 |
virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height)=0; |
36 |
- virtual AVCodecContext *avcodec_alloc_context(void)=0; |
37 |
+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec)=0; |
38 |
virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)=0; |
39 |
- virtual void avcodec_get_context_defaults(AVCodecContext *s)=0; |
40 |
+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec)=0; |
41 |
virtual AVCodecParserContext *av_parser_init(int codec_id)=0; |
42 |
virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, |
43 |
const uint8_t *buf, int buf_size, |
44 |
@@ -165,12 +165,12 @@ public: |
45 |
::avcodec_register_all(); |
46 |
} |
47 |
virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); } |
48 |
- virtual int avcodec_open(AVCodecContext *avctx, AVCodec *codec) |
49 |
+ virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) |
50 |
{ |
51 |
CSingleLock lock(DllAvCodec::m_critSection); |
52 |
- return ::avcodec_open(avctx, codec); |
53 |
+ return ::avcodec_open2(avctx, codec, options); |
54 |
} |
55 |
- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec) { *(int *)0x0 = 0; return 0; } |
56 |
+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(int *)0x0 = 0; return 0; } |
57 |
virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(int *)0x0 = 0; return 0; } |
58 |
virtual AVCodec *avcodec_find_decoder(enum CodecID id) { return ::avcodec_find_decoder(id); } |
59 |
virtual AVCodec *avcodec_find_encoder(enum CodecID id) { return ::avcodec_find_encoder(id); } |
60 |
@@ -193,9 +193,9 @@ public: |
61 |
#endif |
62 |
virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); } |
63 |
virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); } |
64 |
- virtual AVCodecContext *avcodec_alloc_context() { return ::avcodec_alloc_context(); } |
65 |
+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); } |
66 |
virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); } |
67 |
- virtual void avcodec_get_context_defaults(AVCodecContext *s) { ::avcodec_get_context_defaults(s); } |
68 |
+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); } |
69 |
|
70 |
virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); } |
71 |
virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, |
72 |
@@ -254,12 +254,12 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface |
73 |
{ |
74 |
DECLARE_DLL_WRAPPER(DllAvCodec, DLL_PATH_LIBAVCODEC) |
75 |
DEFINE_FUNC_ALIGNED1(void, __cdecl, avcodec_flush_buffers, AVCodecContext*) |
76 |
- DEFINE_FUNC_ALIGNED2(int, __cdecl, avcodec_open_dont_call, AVCodecContext*, AVCodec *) |
77 |
+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avcodec_open2_dont_call, AVCodecContext*, AVCodec *, AVDictionary **) |
78 |
DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_video2, AVCodecContext*, AVFrame*, int*, AVPacket*) |
79 |
DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio3, AVCodecContext*, int16_t*, int*, AVPacket*) |
80 |
DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_subtitle2, AVCodecContext*, AVSubtitle*, int*, AVPacket*) |
81 |
DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_encode_audio, AVCodecContext*, uint8_t*, int, const short*) |
82 |
- DEFINE_FUNC_ALIGNED0(AVCodecContext*, __cdecl, avcodec_alloc_context) |
83 |
+ DEFINE_FUNC_ALIGNED1(AVCodecContext*, __cdecl, avcodec_alloc_context3, AVCodec *) |
84 |
DEFINE_FUNC_ALIGNED1(AVCodecParserContext*, __cdecl, av_parser_init, int) |
85 |
DEFINE_FUNC_ALIGNED9(int, __cdecl, av_parser_parse2, AVCodecParserContext*,AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t) |
86 |
DEFINE_METHOD1(int, av_dup_packet, (AVPacket *p1)) |
87 |
@@ -276,7 +276,7 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface |
88 |
DEFINE_METHOD5(int, avpicture_fill, (AVPicture *p1, uint8_t *p2, PixelFormat p3, int p4, int p5)) |
89 |
DEFINE_METHOD3(int, avpicture_get_size, (PixelFormat p1, int p2, int p3)) |
90 |
DEFINE_METHOD4(void, avcodec_string, (char *p1, int p2, AVCodecContext *p3, int p4)) |
91 |
- DEFINE_METHOD1(void, avcodec_get_context_defaults, (AVCodecContext *p1)) |
92 |
+ DEFINE_METHOD2(void, avcodec_get_context_defaults3, (AVCodecContext *p1, AVCodec *p2)) |
93 |
DEFINE_METHOD1(void, av_parser_close, (AVCodecParserContext *p1)) |
94 |
DEFINE_METHOD1(void, avpicture_free, (AVPicture *p1)) |
95 |
DEFINE_METHOD1(AVBitStreamFilterContext*, av_bitstream_filter_init, (const char *p1)) |
96 |
@@ -298,7 +298,7 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface |
97 |
const void * const p4[6], const int p5[6], int p6)) |
98 |
BEGIN_METHOD_RESOLVE() |
99 |
RESOLVE_METHOD(avcodec_flush_buffers) |
100 |
- RESOLVE_METHOD_RENAME(avcodec_open,avcodec_open_dont_call) |
101 |
+ RESOLVE_METHOD_RENAME(avcodec_open2,avcodec_open2_dont_call) |
102 |
RESOLVE_METHOD_RENAME(avcodec_close,avcodec_close_dont_call) |
103 |
RESOLVE_METHOD(avcodec_find_decoder) |
104 |
RESOLVE_METHOD(avcodec_find_encoder) |
105 |
@@ -310,9 +310,9 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface |
106 |
RESOLVE_METHOD(avcodec_decode_subtitle2) |
107 |
RESOLVE_METHOD(avcodec_encode_audio) |
108 |
RESOLVE_METHOD(avpicture_get_size) |
109 |
- RESOLVE_METHOD(avcodec_alloc_context) |
110 |
+ RESOLVE_METHOD(avcodec_alloc_context3) |
111 |
RESOLVE_METHOD(avcodec_string) |
112 |
- RESOLVE_METHOD(avcodec_get_context_defaults) |
113 |
+ RESOLVE_METHOD(avcodec_get_context_defaults3) |
114 |
RESOLVE_METHOD(av_parser_init) |
115 |
RESOLVE_METHOD(av_parser_parse2) |
116 |
RESOLVE_METHOD(av_parser_close) |
117 |
@@ -340,10 +340,10 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface |
118 |
|
119 |
public: |
120 |
static CCriticalSection m_critSection; |
121 |
- int avcodec_open(AVCodecContext *avctx, AVCodec *codec) |
122 |
+ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) |
123 |
{ |
124 |
CSingleLock lock(DllAvCodec::m_critSection); |
125 |
- return avcodec_open_dont_call(avctx,codec); |
126 |
+ return avcodec_open2_dont_call(avctx,codec, options); |
127 |
} |
128 |
int avcodec_close(AVCodecContext *avctx) |
129 |
{ |
130 |
diff --git a/lib/DllAvFormat.h b/lib/DllAvFormat.h |
131 |
index ed26a0b..9b38c9c 100644 |
132 |
--- a/lib/DllAvFormat.h |
133 |
+++ b/lib/DllAvFormat.h |
134 |
@@ -98,7 +98,7 @@ public: |
135 |
virtual void put_be32(AVIOContext *s, unsigned int val)=0; |
136 |
virtual void put_be16(AVIOContext *s, unsigned int val)=0; |
137 |
virtual AVFormatContext *avformat_alloc_context(void)=0; |
138 |
- virtual AVStream *av_new_stream(AVFormatContext *s, int id)=0; |
139 |
+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)=0; |
140 |
virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type)=0; |
141 |
virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)=0; |
142 |
virtual AVIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, |
143 |
@@ -146,7 +146,7 @@ public: |
144 |
} |
145 |
virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) { ::url_set_interrupt_cb(interrupt_cb); } |
146 |
virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) |
147 |
- { return ::avformat_open_input(ps, filename, fmt, opt, ap); } |
148 |
+ { return ::avformat_open_input(ps, filename, fmt, options); } |
149 |
virtual int init_put_byte(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, |
150 |
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
151 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
152 |
@@ -174,7 +174,7 @@ public: |
153 |
virtual void put_be32(AVIOContext *s, unsigned int val) { ::put_be32(s, val); } |
154 |
virtual void put_be16(AVIOContext *s, unsigned int val) { ::put_be16(s, val); } |
155 |
virtual AVFormatContext *avformat_alloc_context() { return ::avformat_alloc_context(); } |
156 |
- virtual AVStream *av_new_stream(AVFormatContext *s, int id) { return ::av_new_stream(s, id); } |
157 |
+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) { return ::avformat_new_stream(s, c); } |
158 |
#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8) |
159 |
virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::guess_format(short_name, filename, mime_type); } |
160 |
#else |
161 |
@@ -251,7 +251,7 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface |
162 |
DEFINE_METHOD2(int, url_close_dyn_buf, (AVIOContext *p1, uint8_t **p2)) |
163 |
DEFINE_METHOD3(offset_t, url_fseek, (AVIOContext *p1, offset_t p2, int p3)) |
164 |
DEFINE_METHOD0(AVFormatContext *, avformat_alloc_context) |
165 |
- DEFINE_METHOD2(AVStream *, av_new_stream, (AVFormatContext *p1, int p2)) |
166 |
+ DEFINE_METHOD2(AVStream *, avformat_new_stream, (AVFormatContext *p1, AVCodec *p2)) |
167 |
#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8) |
168 |
DEFINE_METHOD3(AVOutputFormat *, guess_format, (const char *p1, const char *p2, const char *p3)) |
169 |
#else |
170 |
@@ -300,7 +300,7 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface |
171 |
RESOLVE_METHOD(put_be32) |
172 |
RESOLVE_METHOD(put_be16) |
173 |
RESOLVE_METHOD(avformat_alloc_context) |
174 |
- RESOLVE_METHOD(av_new_stream) |
175 |
+ RESOLVE_METHOD(avformat_new_stream) |
176 |
#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8) |
177 |
RESOLVE_METHOD(guess_format) |
178 |
#else |
179 |
diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp |
180 |
index 1ec9805..0b3ef76 100644 |
181 |
--- a/xbmc/cdrip/EncoderFFmpeg.cpp |
182 |
+++ b/xbmc/cdrip/EncoderFFmpeg.cpp |
183 |
@@ -103,7 +103,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int |
184 |
} |
185 |
|
186 |
/* add a stream to it */ |
187 |
- m_Stream = m_dllAvFormat.av_new_stream(m_Format, 1); |
188 |
+ m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec); |
189 |
if (!m_Stream) |
190 |
{ |
191 |
m_dllAvUtil.av_freep(&m_Format->pb); |
192 |
@@ -144,7 +144,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int |
193 |
return false; |
194 |
} |
195 |
|
196 |
- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec)) |
197 |
+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL)) |
198 |
{ |
199 |
CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to open the codec"); |
200 |
m_dllAvUtil.av_freep(&m_Stream); |
201 |
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp |
202 |
index 6037781..838a27f 100644 |
203 |
--- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp |
204 |
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp |
205 |
@@ -63,8 +63,6 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
206 |
return false; |
207 |
|
208 |
m_dllAvCodec.avcodec_register_all(); |
209 |
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context(); |
210 |
- m_dllAvCodec.avcodec_get_context_defaults(m_pCodecContext); |
211 |
|
212 |
pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); |
213 |
if (!pCodec) |
214 |
@@ -73,6 +71,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
215 |
return false; |
216 |
} |
217 |
|
218 |
+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); |
219 |
m_pCodecContext->debug_mv = 0; |
220 |
m_pCodecContext->debug = 0; |
221 |
m_pCodecContext->workaround_bugs = 1; |
222 |
@@ -97,7 +96,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
223 |
memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize); |
224 |
} |
225 |
|
226 |
- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0) |
227 |
+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) |
228 |
{ |
229 |
CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec"); |
230 |
Dispose(); |
231 |
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp |
232 |
index 34e93a4..440b04b 100644 |
233 |
--- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp |
234 |
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp |
235 |
@@ -149,7 +149,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri |
236 |
} |
237 |
|
238 |
/* add a stream to it */ |
239 |
- muxer.m_pStream = m_dllAvFormat.av_new_stream(muxer.m_pFormat, 1); |
240 |
+ muxer.m_pStream = m_dllAvFormat.avformat_new_stream(muxer.m_pFormat, NULL); |
241 |
if (!muxer.m_pStream) |
242 |
{ |
243 |
CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate AVStream context"); |
244 |
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp |
245 |
index 6f30e11..6141982 100644 |
246 |
--- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp |
247 |
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp |
248 |
@@ -65,7 +65,7 @@ bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels |
249 |
return false; |
250 |
|
251 |
/* always assume 6 channels, 5.1... m_remap will give us what we want */ |
252 |
- m_CodecCtx = m_dllAvCodec.avcodec_alloc_context(); |
253 |
+ m_CodecCtx = m_dllAvCodec.avcodec_alloc_context3(codec); |
254 |
m_CodecCtx->bit_rate = AC3_ENCODE_BITRATE; |
255 |
m_CodecCtx->sample_rate = sampleRate; |
256 |
m_CodecCtx->channels = 6; |
257 |
@@ -104,7 +104,7 @@ bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels |
258 |
} |
259 |
} |
260 |
|
261 |
- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec)) |
262 |
+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL)) |
263 |
{ |
264 |
m_dllAvUtil.av_freep(&m_CodecCtx); |
265 |
return false; |
266 |
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp |
267 |
index 563ce78..754169e 100644 |
268 |
--- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp |
269 |
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp |
270 |
@@ -49,7 +49,14 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio |
271 |
|
272 |
m_dllAvCodec.avcodec_register_all(); |
273 |
|
274 |
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context(); |
275 |
+ AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); |
276 |
+ if (!pCodec) |
277 |
+ { |
278 |
+ CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec); |
279 |
+ return false; |
280 |
+ } |
281 |
+ |
282 |
+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); |
283 |
m_pCodecContext->debug_mv = 0; |
284 |
m_pCodecContext->debug = 0; |
285 |
m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT; |
286 |
@@ -100,14 +107,7 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio |
287 |
delete[] parse_extra; |
288 |
} |
289 |
|
290 |
- AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec); |
291 |
- if (!pCodec) |
292 |
- { |
293 |
- CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec); |
294 |
- return false; |
295 |
- } |
296 |
- |
297 |
- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0) |
298 |
+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) |
299 |
{ |
300 |
CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec"); |
301 |
return false; |
302 |
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp |
303 |
index 26bdb3a..c792cfd 100644 |
304 |
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp |
305 |
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp |
306 |
@@ -163,9 +163,9 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
307 |
m_dllAvFilter.avfilter_register_all(); |
308 |
|
309 |
m_bSoftware = hints.software; |
310 |
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context(); |
311 |
|
312 |
pCodec = NULL; |
313 |
+ m_pCodecContext = NULL; |
314 |
|
315 |
if (hints.codec == CODEC_ID_H264) |
316 |
{ |
317 |
@@ -196,6 +196,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
318 |
|
319 |
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec); |
320 |
CVDPAU* vdp = new CVDPAU(); |
321 |
+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); |
322 |
m_pCodecContext->codec_id = hints.codec; |
323 |
m_pCodecContext->width = hints.width; |
324 |
m_pCodecContext->height = hints.height; |
325 |
@@ -207,7 +208,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
326 |
m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set |
327 |
break; |
328 |
} |
329 |
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set |
330 |
+ m_dllAvUtil.av_freep(&m_pCodecContext); |
331 |
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device"); |
332 |
vdp->Release(); |
333 |
} |
334 |
@@ -226,6 +227,9 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
335 |
|
336 |
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name); |
337 |
|
338 |
+ if(m_pCodecContext == NULL) |
339 |
+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec); |
340 |
+ |
341 |
m_pCodecContext->opaque = (void*)this; |
342 |
m_pCodecContext->debug_mv = 0; |
343 |
m_pCodecContext->debug = 0; |
344 |
@@ -281,7 +285,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options |
345 |
|| pCodec->id == CODEC_ID_MPEG4 )) |
346 |
m_pCodecContext->thread_count = num_threads; |
347 |
|
348 |
- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0) |
349 |
+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0) |
350 |
{ |
351 |
CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec"); |
352 |
return false; |
353 |
-- |
354 |
1.7.10 |
355 |
|