Upgrade fftools to n5.1.3

This commit is contained in:
Jerome Wu 2023-07-23 21:01:29 +08:00
parent 89e32227cc
commit dc3ca1ba71
3 changed files with 94 additions and 5 deletions

View File

@ -1,4 +1,52 @@
all: build AVPROGS-$(CONFIG_FFMPEG) += ffmpeg
AVPROGS-$(CONFIG_FFPLAY) += ffplay
AVPROGS-$(CONFIG_FFPROBE) += ffprobe
build: AVPROGS := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
cd ../../ && make PROGS += $(AVPROGS)
AVBASENAMES = ffmpeg ffplay ffprobe
ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
OBJS-ffmpeg += \
fftools/ffmpeg_filter.o \
fftools/ffmpeg_hw.o \
fftools/ffmpeg_mux.o \
fftools/ffmpeg_opt.o \
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
$$(OBJS-$(1)): | fftools
$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
-include $$(OBJS-$(1):.o=.d)
endef
$(foreach P,$(AVPROGS-yes),$(eval $(call DOFFTOOL,$(P))))
all: $(AVPROGS)
fftools/ffprobe.o fftools/cmdutils.o: libavutil/ffversion.h | fftools
OUTDIRS += fftools
ifdef AVPROGS
install: install-progs install-data
endif
install-progs-yes:
install-progs-$(CONFIG_SHARED): install-libs
install-progs: install-progs-yes $(AVPROGS)
$(Q)mkdir -p "$(BINDIR)"
$(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
uninstall: uninstall-progs
uninstall-progs:
$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
clean::
$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G) $(CLEANSUFFIXES:%=fftools/%)

View File

@ -2372,6 +2372,43 @@ static int init_complex_filters(void)
return 0; return 0;
} }
static void set_channel_layout(OutputFilter *f, OutputStream *ost)
{
int i, err;
if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
/* Pass the layout through for all orders but UNSPEC */
err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
if (err < 0)
exit_program(1);
return;
}
/* Requested layout is of order UNSPEC */
if (!ost->enc->ch_layouts) {
/* Use the default native layout for the requested amount of channels when the
encoder doesn't have a list of supported layouts */
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
return;
}
/* Encoder has a list of supported layouts. Pick the first layout in it with the
same amount of channels as the requested layout */
for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) {
if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels)
break;
}
if (ost->enc->ch_layouts[i].nb_channels) {
/* Use it if one is found */
err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]);
if (err < 0)
exit_program(1);
return;
}
/* If no layout for the amount of channels requested was found, use the default
native layout for it. */
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
}
static int open_output_file(OptionsContext *o, const char *filename) static int open_output_file(OptionsContext *o, const char *filename)
{ {
AVFormatContext *oc; AVFormatContext *oc;
@ -2774,7 +2811,7 @@ loop_end:
f->sample_rates = ost->enc->supported_samplerates; f->sample_rates = ost->enc->supported_samplerates;
} }
if (ost->enc_ctx->ch_layout.nb_channels) { if (ost->enc_ctx->ch_layout.nb_channels) {
av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); set_channel_layout(f, ost);
} else if (ost->enc->ch_layouts) { } else if (ost->enc->ch_layouts) {
f->ch_layouts = ost->enc->ch_layouts; f->ch_layouts = ost->enc->ch_layouts;
} }

View File

@ -4026,7 +4026,7 @@ int ffprobe(int argc, char **argv)
WriterContext *wctx; WriterContext *wctx;
char *buf; char *buf;
char *w_name = NULL, *w_args = NULL; char *w_name = NULL, *w_args = NULL;
int ret, i; int ret, input_ret, i;
init_dynload(); init_dynload();
@ -4150,10 +4150,14 @@ int ffprobe(int argc, char **argv)
show_error(wctx, ret); show_error(wctx, ret);
} }
input_ret = ret;
writer_print_section_footer(wctx); writer_print_section_footer(wctx);
ret = writer_close(&wctx); ret = writer_close(&wctx);
if (ret < 0) if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret)); av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret));
ret = FFMIN(ret, input_ret);
} }
end: end: