aboutsummaryrefslogtreecommitdiff
path: root/makemkv/ffmpeg.patch
blob: 3bc9f91e766b61d5d3be81c6fc602b915dae3a46 (plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
--- a/libffabi/src/ffabi.c	2024-05-14 18:23:17.000000000 +0200
+++ b/libffabi/src/ffabi.c	2026-09-19 00:02:11.395239310 +0200
@@ -33,6 +33,33 @@
 static ffm_realloc_t        proc_realloc = NULL;
 static ffm_free_t           proc_free = NULL;
 
+static const AVChannelLayout *ffabi_get_ch_layouts(const AVCodec *codec)
+{
+    const AVChannelLayout *ch_layouts = NULL;
+    int nb = 0;
+    avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0,
+                                  (const void **)&ch_layouts, &nb);
+    return ch_layouts;
+}
+
+static const int *ffabi_get_supported_samplerates(const AVCodec *codec)
+{
+    const int *rates = NULL;
+    int nb = 0;
+    avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0,
+                                  (const void **)&rates, &nb);
+    return rates;
+}
+
+static const enum AVSampleFormat *ffabi_get_sample_fmts(const AVCodec *codec)
+{
+    const enum AVSampleFormat *fmts = NULL;
+    int nb = 0;
+    avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
+                                  (const void **)&fmts, &nb);
+    return fmts;
+}
+
 void *ffabi_memalign(size_t align, size_t size)
 {
     return (*proc_memalign)(align,size);
@@ -211,8 +238,7 @@
     av_packet_free(&ctx->pck);
 
     if (ctx->avctx) {
-        avcodec_close(ctx->avctx);
-        av_free(ctx->avctx);
+        avcodec_free_context(&(ctx->avctx));
     }
 
     av_free(ctx);
@@ -374,7 +400,7 @@
 #endif
 
     ctx->avctx->profile = (info->profile != FFM_PROFILE_UNKNOWN) ?
-        info->profile : FF_PROFILE_UNKNOWN;
+        info->profile : AV_PROFILE_UNKNOWN;
 
     if ((CodecFlags&FFM_CODEC_FLAG_GLOBAL_HEADER)!=0)
         ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
@@ -420,8 +446,7 @@
     av_freep(&ctx->frame_extended_data);
 
     if (ctx->avctx) {
-        avcodec_close(ctx->avctx);
-        av_free(ctx->avctx);
+        avcodec_free_context(&(ctx->avctx));
     }
 
     av_free(ctx);
@@ -537,12 +562,13 @@
     unsigned int count_ch_layouts_out = 0;
     uint64_t*   channel_layouts;
     unsigned int i;
+    const AVChannelLayout* ch_layouts = ffabi_get_ch_layouts(codec);
 
     len = strlen(codec->name);
     if (len >= FFM_CODEC_INFO_NAME_MAX_LENGTH) return -1;
 
-    if (NULL != codec->ch_layouts) {
-        while (0 != codec->ch_layouts[count_ch_layouts_in].nb_channels)
+    if (NULL != ch_layouts) {
+        while (0 != ch_layouts[count_ch_layouts_in].nb_channels)
         {
             count_ch_layouts_in++;
         }
@@ -560,8 +586,8 @@
 
     for (i = 0; i < count_ch_layouts_in; i++)
     {
-        if (AV_CHANNEL_ORDER_NATIVE != codec->ch_layouts[i].order) continue;
-        channel_layouts[count_ch_layouts_out++] = codec->ch_layouts[i].u.mask;
+        if (AV_CHANNEL_ORDER_NATIVE != ch_layouts[i].order) continue;
+        channel_layouts[count_ch_layouts_out++] = ch_layouts[i].u.mask;
     }
     channel_layouts[count_ch_layouts_out] = 0;
 
@@ -573,6 +599,8 @@
 {
     AVCodec* codec;
     int i;
+    const AVChannelLayout* ch_layouts;
+    const enum AVSampleFormat* sample_fmts;
 
     memset(info, 0, sizeof(*info));
 
@@ -588,11 +616,11 @@
 
     info->name = codec->name;
     info->long_name = codec->long_name;
-    info->sample_rates = codec->supported_samplerates;
+    info->sample_rates = ffabi_get_supported_samplerates(codec);
 #ifdef FFABI_HAVE_OLD_CHANNEL_LAYOUT
     info->channel_layouts = codec->channel_layouts;
 #else
-    if (NULL == codec->ch_layouts) {
+    if (NULL == ch_layouts) {
         info->channel_layouts = NULL;
     } else {
         if (set_codec_info_extended(info, codec)) {
@@ -604,18 +632,19 @@
     info->capabilities = codec->capabilities;
     if (codec->profiles) {
         for (i=0;i<32;i++) {
-            if (codec->profiles[i].profile==FF_PROFILE_UNKNOWN)
+            if (codec->profiles[i].profile==AV_PROFILE_UNKNOWN)
                 break;
             info->profiles_names[i]=codec->profiles[i].name;
             info->profiles_values[i]=codec->profiles[i].profile;
             info->profiles_count = i+1;
         }
     }
-    if (codec->sample_fmts) {
+    sample_fmts = ffabi_get_sample_fmts(codec);
+    if (sample_fmts) {
         for (i=0;i<16;i++) {
-            if (codec->sample_fmts[i]==AV_SAMPLE_FMT_NONE)
+            if (sample_fmts[i]==AV_SAMPLE_FMT_NONE)
                 break;
-            info->sample_formats[i]=(uint8_t)back_translate_sample_fmt(codec->sample_fmts[i]);
+            info->sample_formats[i]=(uint8_t)back_translate_sample_fmt(sample_fmts[i]);
             info->sample_formats_count = i+1;
         }
     }
@@ -695,8 +724,7 @@
     }
 
     if (avctx) {
-        avcodec_close(avctx);
-        av_free(avctx);
+        avcodec_free_context(&avctx);
     }
     return err;
 }