From patchwork Sun Jan 19 21:41:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 17427 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 2054B44A255 for ; Sun, 19 Jan 2020 23:48:22 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A2E568B255; Sun, 19 Jan 2020 23:48:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64FEC68B166 for ; Sun, 19 Jan 2020 23:48:15 +0200 (EET) Received: by mail-qk1-f194.google.com with SMTP id j9so28353561qkk.1 for ; Sun, 19 Jan 2020 13:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=MkLyjf8lqJ/YYJOtm33ON79RcB8LB3h1Ds1t51qUMPw=; b=AKfsxDzQcby4/RCXjN/TiWIIBy3+dSyfNP1nNOHnDvDtOzuSj4e4VZAg25y4m28S4O VDeGYmjpHL3Ptcbhwp4QDaas1kINMM0cdDbvISwmp89CwsW2I92zvtiO6P1arAE9dMH2 P1PfJ7DA5ybxArRED0ezIr1vUWThOAp1uPUMDtuxblBf1Owekdb/zSak+hIeGmGfFXsm Da0PTW+Y2hNFIiHWowN9ej7i4fEnv41gg9CoWLiqIPI52aWFw0mHEO0dzMq7TLVv6TtP ooNGhlVtuORcrg9rHG+k6+qfiqCq1YlqW97OooywS8R9t7fglnAwJSwv5GnYqwPJ9M25 mBng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=MkLyjf8lqJ/YYJOtm33ON79RcB8LB3h1Ds1t51qUMPw=; b=Lr2ChU/ZvqjFSpzOBcx+3VWZab5tcWqnwzyvlBY7gAwcOJ8g5D8f9fQ23ZWGRJTiFO 7gvx0iqW3d8uLfswBOtudO+WKgAONpqghG413NzSM57emtTiB9Kgq4Qxatl9vALCT6d/ FOdFAhy2Zf1mFY/9WcNpQS+t8sdACaldh9hpG+7pe5/PIBPnXoeordJ3d6cNXMrVyBwY GgR7OmLnSxYPGrJSAbVPCO2TU0TtaI/t4djtDdESGQQwIV9qDLIIRIccBvXul85aIGGQ JxSM72YxKXH+8fz2pkDe/s1dIg/AZx/crcAyJMIuv9WLZdAJ24wHYaKuzBWo3s4YuONC 2erQ== X-Gm-Message-State: APjAAAXNOpP4LkIp/TTtTTHFz5xD5ptRxXWxlqxYJoRvPaveUnoJ9UKa d1gC2YpP6VcKzzFqY/IvIgx3MA+Ybz0= X-Google-Smtp-Source: APXvYqzXuDpBfT7azSZLy4gTlkik+T6/OKXqPUNVAoxfd3mjhMUxVEGzij2NBlxrCAIuckybF4pLXQ== X-Received: by 2002:ae9:c112:: with SMTP id z18mr48449719qki.145.1579470154788; Sun, 19 Jan 2020 13:42:34 -0800 (PST) Received: from localhost.localdomain ([181.23.86.46]) by smtp.gmail.com with ESMTPSA id z15sm5860616qtv.56.2020.01.19.13.42.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2020 13:42:34 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Jan 2020 18:41:58 -0300 Message-Id: <20200119214200.2369-1-jamrial@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/dashenc: make AdaptationSet id an integer value 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Unlike Representation id, it's defined as an integer in the spec, and not as a string. Signed-off-by: James Almer --- libavformat/dashenc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 3d8515d9ca..243194d33e 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -80,7 +80,7 @@ typedef struct Segment { } Segment; typedef struct AdaptationSet { - char id[10]; + int id; char *descriptor; int64_t seg_duration; int64_t frag_duration; @@ -805,7 +805,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind AVDictionaryEntry *lang, *role; int i; - avio_printf(out, "\t\tid, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio"); if (as->media_type == AVMEDIA_TYPE_VIDEO && as->max_frame_rate.num && !as->ambiguous_frame_rate && av_cmp_q(as->min_frame_rate, as->max_frame_rate) < 0) avio_printf(out, " maxFrameRate=\"%d/%d\"", as->max_frame_rate.num, as->max_frame_rate.den); @@ -932,7 +932,7 @@ static int parse_adaptation_sets(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { if ((ret = add_adaptation_set(s, &as, s->streams[i]->codecpar->codec_type)) < 0) return ret; - snprintf(as->id, sizeof(as->id), "%d", i); + as->id = i; c->streams[i].as_idx = c->nb_as; ++as->nb_streams; @@ -953,12 +953,20 @@ static int parse_adaptation_sets(AVFormatContext *s) p++; continue; } else if (state == new_set && av_strstart(p, "id=", &p)) { + char id_str[10], *end_str; + + n = strcspn(p, ","); + snprintf(id_str, sizeof(id_str), "%.*s", n, p); + + i = strtol(id_str, &end_str, 10); + if (id_str == end_str || i < 0 || i > c->nb_as) { + av_log(s, AV_LOG_ERROR, "\"%s\" is not a valid value for an AdaptationSet id\n", id_str); + return AVERROR(EINVAL); + } if ((ret = add_adaptation_set(s, &as, AVMEDIA_TYPE_UNKNOWN)) < 0) return ret; - - n = strcspn(p, ","); - snprintf(as->id, sizeof(as->id), "%.*s", n, p); + as->id = i; p += n; if (*p)