File ffmpeg-fix-build-fdk-aac2.patch of Package A_tw-ffmpeg-3
96
1
From 141c960e21d2860e354f9b90df136184dd00a9a8 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
3
Date: Fri, 31 Aug 2018 14:25:30 +0300
4
Subject: [PATCH] libfdk-aacenc: Fix building with libfdk-aac v2
5
MIME-Version: 1.0
6
Content-Type: text/plain; charset=UTF-8
7
Content-Transfer-Encoding: 8bit
8
9
When flushing the encoder, we now need to provide non-null buffer
10
parameters for everything, even if they are unused.
11
12
The encoderDelay parameter has been replaced by two, nDelay and
13
nDelayCore.
14
15
Signed-off-by: Martin Storsjö <martin@martin.st>
16
---
17
libavcodec/libfdk-aacenc.c | 34 +++++++++++++++++++++++++---------
18
1 file changed, 25 insertions(+), 9 deletions(-)
19
20
Index: ffmpeg-3.4.5/libavcodec/libfdk-aacenc.c
21
===================================================================
22
--- ffmpeg-3.4.5.orig/libavcodec/libfdk-aacenc.c
23
+++ ffmpeg-3.4.5/libavcodec/libfdk-aacenc.c
24
25
#include "audio_frame_queue.h"
26
#include "internal.h"
27
28
+#define FDKENC_VER_AT_LEAST(vl0, vl1) \
29
+ (defined(AACENCODER_LIB_VL0) && \
30
+ ((AACENCODER_LIB_VL0 > vl0) || \
31
+ (AACENCODER_LIB_VL0 == vl0 && AACENCODER_LIB_VL1 >= vl1)))
32
+
33
typedef struct AACContext {
34
const AVClass *class;
35
HANDLE_AACENCODER handle;
36
37
}
38
39
avctx->frame_size = info.frameLength;
40
+#if FDKENC_VER_AT_LEAST(4, 0)
41
+ avctx->initial_padding = info.nDelay;
42
+#else
43
avctx->initial_padding = info.encoderDelay;
44
+#endif
45
ff_af_queue_init(avctx, &s->afq);
46
47
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
48
49
int out_buffer_size, out_buffer_element_size;
50
void *in_ptr, *out_ptr;
51
int ret;
52
+ uint8_t dummy_buf[1];
53
AACENC_ERROR err;
54
55
/* handle end-of-stream small frame and flushing */
56
if (!frame) {
57
+ /* Must be a non-null pointer, even if it's a dummy. We could use
58
+ * the address of anything else on the stack as well. */
59
+ in_ptr = dummy_buf;
60
+ in_buffer_size = 0;
61
+
62
in_args.numInSamples = -1;
63
} else {
64
- in_ptr = frame->data[0];
65
- in_buffer_size = 2 * avctx->channels * frame->nb_samples;
66
- in_buffer_element_size = 2;
67
-
68
- in_args.numInSamples = avctx->channels * frame->nb_samples;
69
- in_buf.numBufs = 1;
70
- in_buf.bufs = &in_ptr;
71
- in_buf.bufferIdentifiers = &in_buffer_identifier;
72
- in_buf.bufSizes = &in_buffer_size;
73
- in_buf.bufElSizes = &in_buffer_element_size;
74
+ in_ptr = frame->data[0];
75
+ in_buffer_size = 2 * avctx->channels * frame->nb_samples;
76
+
77
+ in_args.numInSamples = avctx->channels * frame->nb_samples;
78
79
/* add current frame to the queue */
80
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
81
return ret;
82
}
83
84
+ in_buffer_element_size = 2;
85
+ in_buf.numBufs = 1;
86
+ in_buf.bufs = &in_ptr;
87
+ in_buf.bufferIdentifiers = &in_buffer_identifier;
88
+ in_buf.bufSizes = &in_buffer_size;
89
+ in_buf.bufElSizes = &in_buffer_element_size;
90
+
91
/* The maximum packet size is 6144 bits aka 768 bytes per channel. */
92
if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels), 0)) < 0)
93
return ret;
94
95
96