Skip to content

Commit 7c9c1c1

Browse files
committed
Upgrade fftools to n5.1.3
1 parent 36f65a2 commit 7c9c1c1

File tree

3 files changed

+94
-5
lines changed

3 files changed

+94
-5
lines changed

src/fftools/Makefile

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
all: build
1+
AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
2+
AVPROGS-$(CONFIG_FFPLAY) += ffplay
3+
AVPROGS-$(CONFIG_FFPROBE) += ffprobe
24

3-
build:
4-
cd ../../ && make
5+
AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
6+
PROGS += $(AVPROGS)
7+
8+
AVBASENAMES = ffmpeg ffplay ffprobe
9+
ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
10+
ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
11+
12+
OBJS-ffmpeg += \
13+
fftools/ffmpeg_filter.o \
14+
fftools/ffmpeg_hw.o \
15+
fftools/ffmpeg_mux.o \
16+
fftools/ffmpeg_opt.o \
17+
18+
define DOFFTOOL
19+
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
20+
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
21+
$$(OBJS-$(1)): | fftools
22+
$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
23+
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
24+
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
25+
-include $$(OBJS-$(1):.o=.d)
26+
endef
27+
28+
$(foreach P,$(AVPROGS-yes),$(eval $(call DOFFTOOL,$(P))))
29+
30+
all: $(AVPROGS)
31+
32+
fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools
33+
OUTDIRS += fftools
34+
35+
ifdef AVPROGS
36+
install: install-progs install-data
37+
endif
38+
39+
install-progs-yes:
40+
install-progs-$(CONFIG_SHARED): install-libs
41+
42+
install-progs: install-progs-yes $(AVPROGS)
43+
$(Q)mkdir -p "$(BINDIR)"
44+
$(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
45+
46+
uninstall: uninstall-progs
47+
48+
uninstall-progs:
49+
$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
50+
51+
clean::
52+
$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G) $(CLEANSUFFIXES:%=fftools/%)

src/fftools/ffmpeg_opt.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,43 @@ static int init_complex_filters(void)
23722372
return 0;
23732373
}
23742374

2375+
static void set_channel_layout(OutputFilter *f, OutputStream *ost)
2376+
{
2377+
int i, err;
2378+
2379+
if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
2380+
/* Pass the layout through for all orders but UNSPEC */
2381+
err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
2382+
if (err < 0)
2383+
exit_program(1);
2384+
return;
2385+
}
2386+
2387+
/* Requested layout is of order UNSPEC */
2388+
if (!ost->enc->ch_layouts) {
2389+
/* Use the default native layout for the requested amount of channels when the
2390+
encoder doesn't have a list of supported layouts */
2391+
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
2392+
return;
2393+
}
2394+
/* Encoder has a list of supported layouts. Pick the first layout in it with the
2395+
same amount of channels as the requested layout */
2396+
for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) {
2397+
if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels)
2398+
break;
2399+
}
2400+
if (ost->enc->ch_layouts[i].nb_channels) {
2401+
/* Use it if one is found */
2402+
err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]);
2403+
if (err < 0)
2404+
exit_program(1);
2405+
return;
2406+
}
2407+
/* If no layout for the amount of channels requested was found, use the default
2408+
native layout for it. */
2409+
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
2410+
}
2411+
23752412
static int open_output_file(OptionsContext *o, const char *filename)
23762413
{
23772414
AVFormatContext *oc;
@@ -2774,7 +2811,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
27742811
f->sample_rates = ost->enc->supported_samplerates;
27752812
}
27762813
if (ost->enc_ctx->ch_layout.nb_channels) {
2777-
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
2814+
set_channel_layout(f, ost);
27782815
} else if (ost->enc->ch_layouts) {
27792816
f->ch_layouts = ost->enc->ch_layouts;
27802817
}

src/fftools/ffprobe.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4026,7 +4026,7 @@ int ffprobe(int argc, char **argv)
40264026
WriterContext *wctx;
40274027
char *buf;
40284028
char *w_name = NULL, *w_args = NULL;
4029-
int ret, i;
4029+
int ret, input_ret, i;
40304030

40314031
init_dynload();
40324032

@@ -4150,10 +4150,14 @@ int ffprobe(int argc, char **argv)
41504150
show_error(wctx, ret);
41514151
}
41524152

4153+
input_ret = ret;
4154+
41534155
writer_print_section_footer(wctx);
41544156
ret = writer_close(&wctx);
41554157
if (ret < 0)
41564158
av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret));
4159+
4160+
ret = FFMIN(ret, input_ret);
41574161
}
41584162

41594163
end:

0 commit comments

Comments
 (0)