diff mbox series

[FFmpeg-devel,07/15] avformat/pcmdec: Simplify parsing MIME type

Message ID 20210224115341.794293-7-andreas.rheinhardt@gmail.com
State Accepted
Commit 5f8e01522534fa12e47a79c81be5e7fda184a591
Headers show
Series [FFmpeg-devel,01/15] avformat/movenc: Remove always true check | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 24, 2021, 11:53 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/pcmdec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 395d9ecf92..cd3e7b2e8f 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -19,6 +19,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
 #include "pcm.h"
@@ -51,14 +52,9 @@  static int pcm_read_header(AVFormatContext *s)
     av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
     if (mime_type && s->iformat->mime_type) {
         int rate = 0, channels = 0, little_endian = 0;
-        size_t len = strlen(s->iformat->mime_type);
-        if (!av_strncasecmp(s->iformat->mime_type, mime_type, len)) { /* audio/L16 */
-            uint8_t *options = mime_type + len;
-            len = strlen(mime_type);
-            while (options < mime_type + len) {
-                options = strstr(options, ";");
-                if (!options)
-                    break;
+        const char *options;
+        if (av_stristart(mime_type, s->iformat->mime_type, &options)) { /* audio/L16 */
+            while (options = strchr(options, ';')) {
                 options++;
                 if (!rate)
                     sscanf(options, " rate=%d",     &rate);