From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2AB4440C5F for ; Fri, 5 May 2023 13:30:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2AC268B7F1; Fri, 5 May 2023 16:30:21 +0300 (EEST) Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 646616808D8 for ; Fri, 5 May 2023 16:30:15 +0300 (EEST) Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6a603577a89so292501a34.0 for ; Fri, 05 May 2023 06:30:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683293414; x=1685885414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n+gvlP8Jvf/WoUGCdx4dKuNRNBklTtDPdyP471QJD/g=; b=dWdcEPTJzhlA44meyKcpjUROQnzT5wF1oaz0V4wAE5un41c9ZTFzGIMoGRUQX37k/b K4RkW/RICH2hCHubtyALTvmO8SjunkE6rWp2fzSdYamqsHouoKvfEwX3ty+4rDAKNtOA 9HlUEZ747lKc7zBmIrVo2g0ZHqzfcpR0qKSthjjtUfNgqUP6m2j2Wz7lc3BXNKxBgl0I MxAPGEKdOFnRs3iTITQHxdAatVl2GomnOPot98u6NLBTPZnGNw+ygTVbG+/q4Pp+X0B7 WVOjq8hm694f9pz1rHPXnpujOv4jvKOv4smUm4GiyzubL4a+fmUtTTgDlQ83Et2BjJeC MFJg== X-Gm-Message-State: AC+VfDx/RjCcfGbZRNvkWhC9f2N2xOZZnGWxbVqGzF7xUHTbrQq89n3N UmqKDhmkQPU8IzPfzsmua9+b4tHFj1c/pQ== X-Google-Smtp-Source: ACHHUZ7J0preQG1HeJUeF2O9bLV8HbOQOTF63OaB/my/ZLLh5eOwuG7c2Gm2eNjAp+yAuqftkPqJUg== X-Received: by 2002:a05:6830:4686:b0:6a6:88d:eb77 with SMTP id ay6-20020a056830468600b006a6088deb77mr532803otb.3.1683293413633; Fri, 05 May 2023 06:30:13 -0700 (PDT) Received: from romains-mbp.lan (ip24-252-77-224.no.no.cox.net. [24.252.77.224]) by smtp.gmail.com with ESMTPSA id h5-20020a9d6405000000b006a632c6af05sm801469otl.54.2023.05.05.06.30.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 05 May 2023 06:30:13 -0700 (PDT) From: toots@rastageeks.org To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 08:28:49 -0500 Message-Id: <20230505132848.18011-2-toots@rastageeks.org> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230505132848.18011-1-toots@rastageeks.org> References: <20230505132848.18011-1-toots@rastageeks.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] libavformat/oggparseopus.c: Accept empty packets, decode metadata packets. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Romain Beauxis Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Romain Beauxis This patch provides the same functionality as the previous patch but for ogg/opus. The need to accept empty packets on end of stream (EOS) is explained in the final patch of the series. --- libavformat/oggparseopus.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c index 54aa725be6..7991e9db42 100644 --- a/libavformat/oggparseopus.c +++ b/libavformat/oggparseopus.c @@ -117,8 +117,9 @@ static int opus_packet(AVFormatContext *avf, int idx) uint8_t *packet = os->buf + os->pstart; int ret; - if (!os->psize) + if (!os->psize && !(os->flags & OGG_FLAG_EOS)) return AVERROR_INVALIDDATA; + if (os->granule > (1LL << 62)) { av_log(avf, AV_LOG_ERROR, "Unsupported huge granule pos %"PRId64 "\n", os->granule); return AVERROR_INVALIDDATA; @@ -152,14 +153,23 @@ static int opus_packet(AVFormatContext *avf, int idx) os->lastdts = os->granule - duration; } - if ((ret = opus_duration(packet, os->psize)) < 0) - return ret; + if (os->psize > 0) { + if ((ret = opus_duration(packet, os->psize)) < 0) + return ret; + + os->pduration = ret; + if (os->lastpts != AV_NOPTS_VALUE) { + if (st->start_time == AV_NOPTS_VALUE) + st->start_time = os->lastpts; + priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip; + } + } - os->pduration = ret; - if (os->lastpts != AV_NOPTS_VALUE) { - if (st->start_time == AV_NOPTS_VALUE) - st->start_time = os->lastpts; - priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip; + if (os->psize > 8 && !memcmp(os->buf + os->pstart, "OpusTags", 8)) { + av_dict_free(&st->metadata); + ret = ff_vorbis_stream_comment(avf, st, os->buf + os->pstart + 8, + os->psize - 8); + if (ret < 0) return ret; } priv->cur_dts += os->pduration; -- 2.37.1 (Apple Git-137.1) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".