diff mbox series

[FFmpeg-devel,6/8] avdevice/lavfi: Simplify setting sample_fmts

Message ID AM7PR03MB666061D93BCC94658913A1B98F699@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit b7e3ae19b8d3dc1b14c600220a47171e5e3ef746
Headers show
Series [FFmpeg-devel,1/2] avdevice/lavfi: Properly free an AVDictionary
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Dec. 2, 2021, 8:24 p.m. UTC
The length of this list is a compile-time constant, so there is
no need to calculate it again at runtime.
(This also avoids an implicit requirement of -1 == AV_SAMPLE_FMT_NONE.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavdevice/lavfi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index b208b1a928..d63a6f66b3 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -271,14 +271,15 @@  av_cold static int lavfi_read_header(AVFormatContext *avctx)
         } else if (type == AVMEDIA_TYPE_AUDIO) {
             static const enum AVSampleFormat sample_fmts[] = {
                 AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
-                AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, -1
+                AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL,
             };
 
             ret = avfilter_graph_create_filter(&sink, abuffersink,
                                                inout->name, NULL,
                                                NULL, lavfi->graph);
             if (ret >= 0)
-                ret = av_opt_set_int_list(sink, "sample_fmts", sample_fmts,  AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
+                ret = av_opt_set_bin(sink, "sample_fmts", (const uint8_t*)sample_fmts,
+                                     sizeof(sample_fmts), AV_OPT_SEARCH_CHILDREN);
             if (ret < 0)
                 goto end;
             ret = av_opt_set_int(sink, "all_channel_counts", 1,