File: ffmpeg-7.patch

package info (click to toggle)
renpy 8.3.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,772 kB
  • sloc: python: 55,363; ansic: 13,858; javascript: 849; makefile: 87; sh: 13
file content (105 lines) | stat: -rw-r--r-- 3,489 bytes parent folder | download | duplicates (2)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
--- a/module/ffmedia.c
+++ b/module/ffmedia.c
@@ -4,6 +4,7 @@
 #include <libavutil/time.h>
 #include <libavutil/pixfmt.h>
 #include <libswscale/swscale.h>
+#include <libavformat/version_major.h>
 
 #include <SDL.h>
 #include <SDL_thread.h>
@@ -71,7 +72,11 @@
 
 }
 
+#if (LIBAVFORMAT_VERSION_MAJOR < 61)
 static int rwops_write(void *opaque, uint8_t *buf, int buf_size) {
+#else
+static int rwops_write(void *opaque, const uint8_t *buf, int buf_size) {
+#endif
     printf("Writing to an SDL_rwops is a really bad idea.\n");
     return -1;
 }
@@ -585,7 +590,6 @@
 		return NULL;
 	}
 
-	const AVCodec *codec = NULL;
 	AVCodecContext *codec_ctx = NULL;
 
 	codec_ctx = avcodec_alloc_context3(NULL);
@@ -600,7 +604,7 @@
 
 	codec_ctx->pkt_timebase = ctx->streams[index]->time_base;
 
-    codec = avcodec_find_decoder(codec_ctx->codec_id);
+    const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);
 
     if (codec == NULL) {
         goto fail;
@@ -690,9 +694,14 @@
 			}
 
             converted_frame->sample_rate = audio_sample_rate;
+#if (LIBAVUTIL_VERSION_MAJOR < 59)
             converted_frame->channel_layout = AV_CH_LAYOUT_STEREO;
+#else
+            converted_frame->ch_layout = (AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO;
+#endif
             converted_frame->format = AV_SAMPLE_FMT_S16;
 
+#if (LIBAVUTIL_VERSION_MAJOR < 59)
 			if (!ms->audio_decode_frame->channel_layout) {
 				ms->audio_decode_frame->channel_layout = av_get_default_channel_layout(ms->audio_decode_frame->channels);
 
@@ -711,6 +720,26 @@
 				    swr_set_matrix(ms->swr, stereo_matrix, 1);
 				}
 			}
+#else
+			if (ms->audio_decode_frame->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
+				av_channel_layout_default(&ms->audio_decode_frame->ch_layout, ms->audio_decode_frame->ch_layout.nb_channels);
+
+				if (audio_equal_mono && (ms->audio_decode_frame->ch_layout.nb_channels == 1)) {
+				    swr_alloc_set_opts2(
+                        &ms->swr,
+                        &converted_frame->ch_layout,
+                        converted_frame->format,
+                        converted_frame->sample_rate,
+                        &ms->audio_decode_frame->ch_layout,
+                        ms->audio_decode_frame->format,
+                        ms->audio_decode_frame->sample_rate,
+                        0,
+                        NULL);
+
+				    swr_set_matrix(ms->swr, stereo_matrix, 1);
+				}
+			}
+#endif
 
 			if(swr_convert_frame(ms->swr, converted_frame, ms->audio_decode_frame)) {
 				av_frame_free(&converted_frame);
@@ -1159,7 +1188,11 @@
 
 	// Compute the number of samples we need to play back.
 	if (ms->audio_duration < 0) {
+#if (LIBAVFORMAT_VERSION_MAJOR < 62)
 		if (av_fmt_ctx_get_duration_estimation_method(ctx) != AVFMT_DURATION_FROM_BITRATE) {
+#else
+		if (ctx->duration_estimation_method != AVFMT_DURATION_FROM_BITRATE) {
+#endif
 
 			long long duration = ((long long) ctx->duration) * audio_sample_rate;
 			ms->audio_duration = (unsigned int) (duration /  AV_TIME_BASE);
@@ -1319,7 +1352,11 @@
 
 	// Compute the number of samples we need to play back.
 	if (ms->audio_duration < 0) {
+#if (LIBAVFORMAT_VERSION_MAJOR < 62)
 		if (av_fmt_ctx_get_duration_estimation_method(ctx) != AVFMT_DURATION_FROM_BITRATE) {
+#else
+		if (ctx->duration_estimation_method != AVFMT_DURATION_FROM_BITRATE) {
+#endif
 
 			long long duration = ((long long) ctx->duration) * audio_sample_rate;
 			ms->audio_duration = (unsigned int) (duration /  AV_TIME_BASE);