diff mbox series

[FFmpeg-devel,v2,08/22] avformat/dashenc: Simplify getting format string

Message ID AS8P250MB07441D4C8BC7BF1CF025A5C38FEEA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit c95cdf871c30a72965c65a4b3631e8a6d9b08a92
Headers show
Series [FFmpeg-devel,v2,01/22] fate/demux, lavf-container: Workaround for AV1-aspect ratio issue | expand

Commit Message

Andreas Rheinhardt Sept. 7, 2023, 1:05 a.m. UTC
A switch is simpler than a lookup over a table with
three entries, only two of which can happen at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/dashenc.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c3ba2c389..e98d54a61d 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -217,16 +217,6 @@  static const struct codec_string {
     { AV_CODEC_ID_NONE, NULL }
 };
 
-static const struct format_string {
-    SegmentType segment_type;
-    const char *str;
-} formats[] = {
-    { SEGMENT_TYPE_AUTO, "auto" },
-    { SEGMENT_TYPE_MP4, "mp4" },
-    { SEGMENT_TYPE_WEBM, "webm" },
-    { 0, NULL }
-};
-
 static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
                            AVDictionary **options) {
     DASHContext *c = s->priv_data;
@@ -265,11 +255,12 @@  static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filenam
     }
 }
 
-static const char *get_format_str(SegmentType segment_type) {
-    int i;
-    for (i = 0; i < SEGMENT_TYPE_NB; i++)
-        if (formats[i].segment_type == segment_type)
-            return formats[i].str;
+static const char *get_format_str(SegmentType segment_type)
+{
+    switch (segment_type) {
+    case SEGMENT_TYPE_MP4:  return "mp4";
+    case SEGMENT_TYPE_WEBM: return "webm";
+    }
     return NULL;
 }