From patchwork Wed Feb 24 11:53:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 25958 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CEBFF44B5C7 for ; Wed, 24 Feb 2021 13:54:30 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AC90A68A980; Wed, 24 Feb 2021 13:54:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51A2068A5A8 for ; Wed, 24 Feb 2021 13:54:24 +0200 (EET) Received: by mail-wr1-f48.google.com with SMTP id l12so1623233wry.2 for ; Wed, 24 Feb 2021 03:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gmRxbF5D9YWO1s3YhrZLrYoYDYUXUcuJbeYxvGDk36U=; b=QH2ORr20IwJ4npIsytGHH8sCxRbAsaRopVUREhp5I/QyKYB3iXPSS8Eq69WYyTXVgI G07Uk5R9PAbYd1MGiZ+9xwm34ZnRwpzjjbyYIIKIJM8q9P84Wy8vB0SEPZZdSps9HcjI vl09bDbA2d37Rrs1ctZvym6frDNYu0z8RkLvmio1x2uY83fXDvluORAh7YxRFta/nmpv o6TSJJr7Z4iAemCDDj3T4spjRjkhm0JhUybT4PtVyb98ZvL7hXrq9NTdASTDLEbPFrSo yOd9QEm/hnKuRxHb410Q1YYxZ3pmVqj+m5QcXQUHdobN27PJOYTRXoqbjUmadlDe0tda oqEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gmRxbF5D9YWO1s3YhrZLrYoYDYUXUcuJbeYxvGDk36U=; b=rGY2NeKLrpV62PwVMorfloSoddT/QGvJVJhaHpPXwB7zbBKK4us6cNIvLxlMf148Wz KRWKa4qoB0jJRRL5C5oD+BCYHptu/JdO+HG1h888BBjmVD3OuwlZnninGJ3Xa4cht5ty is3R3DhuCnKjsX4RvS72xTyWVnB8JmfDjgyp2/9tcFVt9EJ80KV7r+UgHvOi61aRbRfz PupD+WBp5xlHjenEs45qFXiWn8s4jY2N/CHU2EgmfCbRfbcl9xjIxSWYX3jdaGFWHl80 VMW67rcjOCgOlKKxuhYZbYZ0Ed6Th/fDbGb8q0hcFSDjamcqSQxGKIq9ZPZq0NCJpAUf g3+w== X-Gm-Message-State: AOAM530ZvAknHsZWaemX84PI0Pj81VsM23w9c6mPpXDznbC9HB23p1cE g7QNgW+jyunN7n1tjL3Gq2x75i4Kf4M= X-Google-Smtp-Source: ABdhPJzgGU+adBqxKt7AoU8I6OB+GKbnZw/8vn/WuSJSaFpS0iq7w+1c4Lr43I56JGTCymveC1/Hgw== X-Received: by 2002:a5d:5441:: with SMTP id w1mr31101412wrv.366.1614167663477; Wed, 24 Feb 2021 03:54:23 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id k15sm3911776wrn.0.2021.02.24.03.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 03:54:23 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Feb 2021 12:53:33 +0100 Message-Id: <20210224115341.794293-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224115341.794293-1-andreas.rheinhardt@gmail.com> References: <20210224115341.794293-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/15] avformat/pcmdec: Simplify parsing MIME type X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/pcmdec.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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);