File: 0009-ip-ffmpeg-remember-swr_frame-s-capacity.patch

package info (click to toggle)
cmus 2.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,404 kB
  • sloc: ansic: 40,498; sh: 1,642; makefile: 255; python: 157
file content (38 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download
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
From: ihy123 <aladinandreyy@gmail.com>
Date: Sun, 17 Aug 2025 15:02:34 +0300
Subject: ip/ffmpeg: remember swr_frame's capacity

---
 ip/ffmpeg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ip/ffmpeg.c b/ip/ffmpeg.c
index 775e7de..c659c13 100644
--- a/ip/ffmpeg.c
+++ b/ip/ffmpeg.c
@@ -49,6 +49,7 @@ struct ffmpeg_private {
 
 	/* A buffer to hold swr_convert()-ed samples */
 	AVFrame *swr_frame;
+	int swr_frame_samples_cap;
 	int swr_frame_start;
 
 	/* Bitrate estimation */
@@ -213,6 +214,7 @@ static int ffmpeg_init_swr_frame(struct ffmpeg_private *priv,
 		d_print("av_frame_get_buffer(): %s\n", ffmpeg_errmsg(res));
 		return -IP_ERROR_INTERNAL;
 	}
+	priv->swr_frame_samples_cap = frame->nb_samples;
 	frame->nb_samples = 0;
 
 	priv->swr_frame = frame;
@@ -378,8 +380,7 @@ static int ffmpeg_convert_frame(struct ffmpeg_private *priv)
 {
 	int res = swr_convert(priv->swr,
 			priv->swr_frame->extended_data,
-			/* TODO: proper buffer capacity */
-			priv->frame->nb_samples,
+			priv->swr_frame_samples_cap,
 			(const uint8_t **)priv->frame->extended_data,
 			priv->frame->nb_samples);
 	if (res >= 0) {