Skip to content

Commit fca7f29

Browse files
committed
Update FFmpeg to 8.0.1
1 parent dc99022 commit fca7f29

File tree

4 files changed

+79
-47
lines changed

4 files changed

+79
-47
lines changed

Build/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ depend-ubuntu22:
176176
libssl-dev \
177177
libtool \
178178
libxss-dev \
179+
nasm \
179180
ninja-build \
180181
openjdk-25-jdk \
181182
p7zip-full \
@@ -202,6 +203,7 @@ depend-ubuntu24:
202203
libssl-dev \
203204
libtool \
204205
libxss-dev \
206+
nasm \
205207
ninja-build \
206208
openjdk-21-jdk \
207209
p7zip-full \
@@ -246,6 +248,7 @@ depend-raspios12:
246248
libssl-dev \
247249
libtool \
248250
libxss-dev \
251+
nasm \
249252
ninja-build \
250253
openjdk-17-jdk \
251254
p7zip-full \
@@ -265,6 +268,7 @@ depend-mac:
265268
automake \
266269
doxygen \
267270
libtool \
271+
nasm \
268272
ninja \
269273
pkg-config \
270274
python-setuptools \

Library/TeamTalkLib/avstream/FFmpegResampler.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,21 @@ bool FFMPEGResampler::Init()
5959
if(m_ctx != nullptr)
6060
return false;
6161

62-
m_ctx = swr_alloc_set_opts(nullptr,
63-
GetOutputFormat().channels == 2?
64-
AV_CH_LAYOUT_STEREO :
65-
AV_CH_LAYOUT_MONO,
66-
AV_SAMPLE_FMT_S16,
67-
GetOutputFormat().samplerate,
68-
GetInputFormat().channels == 2?
69-
AV_CH_LAYOUT_STEREO :
70-
AV_CH_LAYOUT_MONO,
71-
AV_SAMPLE_FMT_S16,
72-
GetInputFormat().samplerate,
73-
0,
74-
nullptr);
75-
if(m_ctx == nullptr)
62+
AVChannelLayout out_ch_layout = GetOutputFormat().channels == 2 ?
63+
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO : (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
64+
AVChannelLayout in_ch_layout = GetInputFormat().channels == 2 ?
65+
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO : (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
66+
67+
int ret = swr_alloc_set_opts2(&m_ctx,
68+
&out_ch_layout,
69+
AV_SAMPLE_FMT_S16,
70+
GetOutputFormat().samplerate,
71+
&in_ch_layout,
72+
AV_SAMPLE_FMT_S16,
73+
GetInputFormat().samplerate,
74+
0,
75+
nullptr);
76+
if(ret < 0 || m_ctx == nullptr)
7677
return false;
7778

7879
return swr_init(m_ctx) >= 0;

Library/TeamTalkLib/avstream/FFmpegStreamer.cpp

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void FillMediaFileProp(AVFormatContext *fmt_ctx,
191191
{
192192
if (aud_dec_ctx != nullptr)
193193
{
194-
out_prop.audio = media::AudioFormat(aud_dec_ctx->sample_rate, aud_dec_ctx->channels);
194+
out_prop.audio = media::AudioFormat(aud_dec_ctx->sample_rate, aud_dec_ctx->ch_layout.nb_channels);
195195
}
196196

197197
if ((vid_dec_ctx != nullptr) && video_stream_index >= 0)
@@ -635,7 +635,7 @@ int64_t FFmpegStreamer::ProcessAudioBuffer(AVFilterContext* aud_buffersink_ctx,
635635
frame_timestamp -= start_offset;
636636
}
637637

638-
int const n_channels = av_get_channel_layout_nb_channels(filt_frame->channel_layout);
638+
int const n_channels = filt_frame->ch_layout.nb_channels;
639639
auto* audio_data = reinterpret_cast<short*>(filt_frame->data[0]);
640640

641641
AudioFrame media_frame;
@@ -741,28 +741,27 @@ AVFilterGraph* CreateAudioFilterGraph(AVFormatContext *fmt_ctx,
741741

742742
const AVFilter *abuffersrc = avfilter_get_by_name("abuffer");
743743
const AVFilter *abuffersink = avfilter_get_by_name("abuffersink");
744-
AVFilterInOut *outputs = avfilter_inout_alloc(); //TODO: Free??
745-
AVFilterInOut *inputs = avfilter_inout_alloc(); //TODO: Free??
746-
const enum AVSampleFormat OUT_SAMPLE_FMTS[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE };
747-
int64_t out_channel_layouts[] = { -1, -1 };
748-
int out_sample_rates[] = { out_samplerate, -1 };
744+
AVFilterInOut *outputs = avfilter_inout_alloc();
745+
AVFilterInOut *inputs = avfilter_inout_alloc();
749746
const AVFilterLink *outlink = nullptr;
750747
char args[512];
751748
char filter_descr[100];
749+
char ch_layout_str[64];
752750
int ret = 0;
753751
AVRational const time_base = fmt_ctx->streams[audio_stream_index]->time_base;
754-
out_channel_layouts[0] = (out_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO);
752+
AVChannelLayout out_ch_layout = out_channels == 1 ?
753+
(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO : (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
755754

756755
filter_graph = avfilter_graph_alloc();
757756

758-
/* buffer audio source: the decoded frames from the decoder will be inserted here. */
759-
if (aud_dec_ctx->channel_layout == 0u)
760-
aud_dec_ctx->channel_layout = av_get_default_channel_layout(aud_dec_ctx->channels);
757+
if (aud_dec_ctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
758+
av_channel_layout_default(&aud_dec_ctx->ch_layout, aud_dec_ctx->ch_layout.nb_channels);
761759

760+
av_channel_layout_describe(&aud_dec_ctx->ch_layout, ch_layout_str, sizeof(ch_layout_str));
762761
snprintf(args, sizeof(args),
763-
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%x",
762+
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=%s",
764763
time_base.num, time_base.den, aud_dec_ctx->sample_rate,
765-
av_get_sample_fmt_name(aud_dec_ctx->sample_fmt), (unsigned)aud_dec_ctx->channel_layout);
764+
av_get_sample_fmt_name(aud_dec_ctx->sample_fmt), ch_layout_str);
766765

767766
ret = avfilter_graph_create_filter(&aud_buffersrc_ctx, abuffersrc, "in",
768767
args, nullptr, filter_graph);
@@ -772,33 +771,52 @@ AVFilterGraph* CreateAudioFilterGraph(AVFormatContext *fmt_ctx,
772771
}
773772

774773
/* buffer audio sink: to terminate the filter chain. */
775-
ret = avfilter_graph_create_filter(&aud_buffersink_ctx, abuffersink, "out",
776-
nullptr, nullptr, filter_graph);
777-
if (ret < 0) {
774+
aud_buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, abuffersink, "out");
775+
if (!aud_buffersink_ctx) {
778776
MYTRACE(ACE_TEXT("Cannot create audio buffer sink\n"));
777+
ret = AVERROR(ENOMEM);
779778
goto error;
780779
}
781780

782-
ret = av_opt_set_int_list(aud_buffersink_ctx, "sample_fmts", OUT_SAMPLE_FMTS, -1,
783-
AV_OPT_SEARCH_CHILDREN);
781+
{
782+
const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16 };
783+
ret = av_opt_set_array(aud_buffersink_ctx, "sample_formats",
784+
AV_OPT_SEARCH_CHILDREN,
785+
0, 1, AV_OPT_TYPE_SAMPLE_FMT, sample_fmts);
786+
}
784787
if (ret < 0) {
785788
MYTRACE(ACE_TEXT("Failed to set output sample fmt\n"));
786789
goto error;
787790
}
788791

789-
ret = av_opt_set_int_list(aud_buffersink_ctx, "channel_layouts", out_channel_layouts, -1,
790-
AV_OPT_SEARCH_CHILDREN);
792+
{
793+
const AVChannelLayout channel_layouts[] = { out_ch_layout };
794+
ret = av_opt_set_array(aud_buffersink_ctx, "channel_layouts",
795+
AV_OPT_SEARCH_CHILDREN,
796+
0, 1, AV_OPT_TYPE_CHLAYOUT, channel_layouts);
797+
}
791798
if (ret < 0) {
792799
MYTRACE(ACE_TEXT("Cannot set output channel layout\n"));
793800
goto error;
794801
}
795-
ret = av_opt_set_int_list(aud_buffersink_ctx, "sample_rates", out_sample_rates, -1,
796-
AV_OPT_SEARCH_CHILDREN);
802+
803+
{
804+
const int samplerates[] = { out_samplerate };
805+
ret = av_opt_set_array(aud_buffersink_ctx, "samplerates",
806+
AV_OPT_SEARCH_CHILDREN,
807+
0, 1, AV_OPT_TYPE_INT, samplerates);
808+
}
797809
if (ret < 0) {
798810
MYTRACE(ACE_TEXT("Cannot set output sample rate\n"));
799811
goto error;
800812
}
801813

814+
ret = avfilter_init_dict(aud_buffersink_ctx, nullptr);
815+
if (ret < 0) {
816+
MYTRACE(ACE_TEXT("Cannot initialize audio buffer sink\n"));
817+
goto error;
818+
}
819+
802820
/* Endpoints for the filter graph. */
803821
outputs->name = av_strdup("in");
804822
outputs->filter_ctx = aud_buffersrc_ctx;
@@ -863,7 +881,6 @@ AVFilterGraph* CreateVideoFilterGraph(AVFormatContext *fmt_ctx,
863881
AVFilterInOut *outputs = avfilter_inout_alloc();
864882
AVFilterInOut *inputs = avfilter_inout_alloc();
865883
AVRational const time_base = fmt_ctx->streams[video_stream_index]->time_base;
866-
const enum AVPixelFormat PIX_FMTS[] = { output_pixfmt, AV_PIX_FMT_NONE };
867884
char filters_descr[100];
868885

869886
snprintf(filters_descr, sizeof(filters_descr), "scale=%d:%d",
@@ -888,20 +905,30 @@ AVFilterGraph* CreateVideoFilterGraph(AVFormatContext *fmt_ctx,
888905
}
889906

890907
/* buffer video sink: to terminate the filter chain. */
891-
ret = avfilter_graph_create_filter(&vid_buffersink_ctx, buffersink, "out",
892-
nullptr, nullptr, filter_graph);
893-
if (ret < 0) {
908+
vid_buffersink_ctx = avfilter_graph_alloc_filter(filter_graph, buffersink, "out");
909+
if (!vid_buffersink_ctx) {
894910
MYTRACE(ACE_TEXT("Cannot create buffer sink\n"));
911+
ret = AVERROR(ENOMEM);
895912
goto error;
896913
}
897914

898-
ret = av_opt_set_int_list(vid_buffersink_ctx, "pix_fmts", PIX_FMTS,
899-
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
915+
{
916+
const enum AVPixelFormat pixel_formats[] = { output_pixfmt };
917+
ret = av_opt_set_array(vid_buffersink_ctx, "pixel_formats",
918+
AV_OPT_SEARCH_CHILDREN,
919+
0, 1, AV_OPT_TYPE_PIXEL_FMT, pixel_formats);
920+
}
900921
if (ret < 0) {
901922
MYTRACE(ACE_TEXT("Cannot set output pixel format\n"));
902923
goto error;
903924
}
904925

926+
ret = avfilter_init_dict(vid_buffersink_ctx, nullptr);
927+
if (ret < 0) {
928+
MYTRACE(ACE_TEXT("Cannot initialize video buffer sink\n"));
929+
goto error;
930+
}
931+
905932
/* Endpoints for the filter graph. */
906933
outputs->name = av_strdup("in");
907934
outputs->filter_ctx = vid_buffersrc_ctx;

Library/TeamTalkLib/build/ffmpeg/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
1414

1515
ExternalProject_Add(ffmpeg-arm64-src
1616
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
17-
GIT_TAG n6.1.4
17+
GIT_TAG n8.0.1
1818
GIT_SHALLOW TRUE
1919
UPDATE_COMMAND ""
2020
PREFIX ${TOOLCHAIN_BUILD_PREFIX}/ffmpeg-arm64
@@ -52,7 +52,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
5252

5353
ExternalProject_Add(ffmpeg-intel-src
5454
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
55-
GIT_TAG n6.1.4
55+
GIT_TAG n8.0.1
5656
GIT_SHALLOW TRUE
5757
UPDATE_COMMAND ""
5858
PREFIX ${TOOLCHAIN_BUILD_PREFIX}/ffmpeg-intel
@@ -267,7 +267,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "iOS")
267267

268268
ExternalProject_Add(ffmpeg-src
269269
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
270-
GIT_TAG n6.1.4
270+
GIT_TAG n8.0.1
271271
GIT_SHALLOW TRUE
272272
UPDATE_COMMAND ""
273273
PREFIX ${TOOLCHAIN_BUILD_PREFIX}/ffmpeg
@@ -353,7 +353,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
353353
if (TOOLCHAIN_BUILD_EXTERNALPROJECTS)
354354
ExternalProject_Add(ffmpeg-src
355355
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
356-
GIT_TAG n6.1.4
356+
GIT_TAG n8.0.1
357357
GIT_SHALLOW TRUE
358358
UPDATE_COMMAND ""
359359
PREFIX ${TOOLCHAIN_BUILD_PREFIX}/ffmpeg
@@ -469,7 +469,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
469469

470470
ExternalProject_Add(ffmpeg-src
471471
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
472-
GIT_TAG n6.1.4
472+
GIT_TAG n8.0.1
473473
GIT_SHALLOW TRUE
474474
UPDATE_COMMAND ""
475475
PREFIX ${TOOLCHAIN_BUILD_PREFIX}/ffmpeg

0 commit comments

Comments
 (0)