1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
Index: wxsvg-1.5.23/include/wxSVG/mediadec_ffmpeg.h
===================================================================
--- wxsvg-1.5.23.orig/include/wxSVG/mediadec_ffmpeg.h
+++ wxsvg-1.5.23/include/wxSVG/mediadec_ffmpeg.h
@@ -81,6 +81,7 @@ private:
bool OpenVideoDecoder();
void CloseVideoDecoder();
AVStream* GetVideoStream();
+ int64_t m_cur_dts;
};
#endif //FFMPEG_MEDIA_DECODER_H
Index: wxsvg-1.5.23/src/mediadec_ffmpeg.cpp
===================================================================
--- wxsvg-1.5.23.orig/src/mediadec_ffmpeg.cpp
+++ wxsvg-1.5.23/src/mediadec_ffmpeg.cpp
@@ -20,6 +20,7 @@
#define UINT64_C(val) val##ULL
#endif
extern "C" {
+#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavutil/avutil.h>
@@ -153,6 +154,9 @@ StreamType wxFfmpegMediaDecoder::GetStre
}
wxString wxFfmpegMediaDecoder::GetCodecName(unsigned int streamIndex) {
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+ const
+#endif
AVCodec *codec = avcodec_find_decoder(m_formatCtx->streams[streamIndex]->codecpar->codec_id);
if (codec) {
return wxString(codec->name, wxConvLocal);
@@ -193,6 +197,9 @@ bool wxFfmpegMediaDecoder::OpenVideoDeco
// find and open the decoder for the video stream
AVStream* stream = m_formatCtx->streams[m_videoStream];
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+ const
+#endif
AVCodec* codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (!codec)
return false;
@@ -255,7 +262,11 @@ double wxFfmpegMediaDecoder::GetPosition
AVStream *st = GetVideoStream();
if (st == NULL)
return -1;
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+ int64_t timestamp = m_cur_dts;
+#else
int64_t timestamp = st->cur_dts;
+#endif
if (timestamp == (int64_t)AV_NOPTS_VALUE)
return -1;
timestamp = av_rescale(timestamp, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
@@ -308,6 +319,7 @@ wxImage wxFfmpegMediaDecoder::GetNextFra
uint8_t *rgbSrc[3] = { img.GetData(), NULL, NULL };
int rgbStride[3] = { 3 * m_width, 0, 0 };
sws_scale(imgConvertCtx, m_frame->data, m_frame->linesize, 0, m_codecCtx->height, rgbSrc, rgbStride);
+ m_cur_dts = packet.dts;
av_packet_unref(&packet);
sws_freeContext(imgConvertCtx);
return img;
|