From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id C2C444BB0D for ; Sun, 1 Jun 2025 16:49:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id DEF1F68D4D8; Sun, 1 Jun 2025 19:49:43 +0300 (EEST) Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id D4D9068D221 for ; Sun, 1 Jun 2025 19:49:36 +0300 (EEST) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2e94deefa95so768084fac.2 for ; Sun, 01 Jun 2025 09:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748796575; x=1749401375; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WNXugc78twIsjfT6gp7JPTPxEC01KD+cldWtk8QRNpo=; b=VsGS8A7NjIcKiHQ3VRJT39TdjfB2yDQWbtlbcpCXwcjjEjgY4G0vKiVakDhtN0b58I QoUQ+/DFEw58JOHaMmqb6ekYuaKjA4kMD/zey6ak+XTdtMTomPT/z9H+Mi1oaVLqfC1p OdpJUpaYVwhiGodBSSoyBCFGoxplNhLVOKoZHWyTcAU1IiGDZ7O7yOD6XLulIhC2hz2o +BhJN3I16b9uYSHOaFLeka5u8JP0KTxnqmf1cpmtmAQGvJ12SgxfjEE1l8fZOB0AapIq 4CWNwOlUo2X8F7OX8W6m4Hp9wvVwuQmrMsDUvoFrSdaeNsHLAEVu/9F6M9e8c/ROHqif +Rcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748796575; x=1749401375; 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=WNXugc78twIsjfT6gp7JPTPxEC01KD+cldWtk8QRNpo=; b=h/m1PeMyAF6PSvQg2s/zT4gOESbgb+/CMIZ8DQdXZ+zH6qhawaaXu7rN1vLpmv1NDT wU3f6DukT380QjwBdx2dCRdaaVl37r+hU8W0iR7jh8YOK5Wsj90PwcRu/tMK2wAUHeFj 6hvp8vyDm7aOKhgPaCoXgNGLt5OozVtX3CFc4sltGTv1Dq1EOJJM2UB8eqQkYoDF9noB dCb3k87ydw9Afl2PzmtT4wZ1OSBqE/9lsh0u8zLgvygCrUGFDzK/ITnC1IeXxzqxZ3KC qB8HUSJUbyO1Be0OZJRsQpmcSLJwDgwBdz1NEWlMRhKIhfzTs9JR+J7oflN/Avk85PUq grHg== X-Gm-Message-State: AOJu0YwcfMUV2CdC0glPiutdnqumEFUpwvgxJkTPwpUBL24OEnpVAI9D XuEoEv6Igqwn5/wQdcyip+x+CmtRRxzafKMXr6US9PRhiwLZzWC6ILnXU2pf4/l9 X-Gm-Gg: ASbGncvLhBOl8ECmGMdAGAHroDJW6Ir1Don0HKysjicBXWlhwBsJ4OMaDN9zu8t5uk+ +B5sa+4Oe8d5RBGKGSSyWm5kn+/UDCnTNqU7fCILA4hVOsADfMh7OV0kmwm8wXSK6TNrkHjoQUs 1cG7bS99Y+HXfVb0oKGhHEBvMfXmccYx3a6ey19DaQf7GaHyTtvpCi8inrQZWFXu5Mu//MoliRW j1PRX0VtevCwpbhTuWLhOIG4OgV/bsji2VBqGXzjkwNe6zD6e3AwnOcvyOsRx1xcKE8SQ3feFti oQfmtiFJUhK07bmYjsilhZ/2wnYBD8AEOU7HobUx4BbISDzf6SIBc/Coyl9Igf0DuondHiABSYj yYKzkH0IjsCGhlHlvv18= X-Google-Smtp-Source: AGHT+IGwftL5onDhFFdM+1KJ1Lc+op/nCtv7q6TkgrHebxw/ouSG6rjEkN8E635VqLCtDF9FqH2YEA== X-Received: by 2002:a05:6871:d20f:b0:2e9:e5e:8456 with SMTP id 586e51a60fabf-2e92a3aef3bmr5166547fac.22.1748796575053; Sun, 01 Jun 2025 09:49:35 -0700 (PDT) Received: from mac.lan (ip72-211-125-114.no.no.cox.net. [72.211.125.114]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2e906c13c13sm1467151fac.45.2025.06.01.09.49.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 01 Jun 2025 09:49:34 -0700 (PDT) From: Romain Beauxis To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 Jun 2025 11:49:27 -0500 Message-Id: <20250601164930.72816-2-romain.beauxis@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250601164930.72816-1-romain.beauxis@gmail.com> References: <20250601164930.72816-1-romain.beauxis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] libavformat/oggdec.h, libavformat/oggparsevorbis.c: Factor out vorbis metadata update mechanism. 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: --- libavformat/oggdec.h | 14 ++++++++++++++ libavformat/oggparsevorbis.c | 25 +++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index c15fbe738e..d10a9b1a89 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -160,6 +160,20 @@ int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, const uint8_t *buf, int size); +/** + * Parse Vorbis comments, add metadata to an AVStream + * + * This function also attaches the metadata to the next decoded + * packet as AV_PKT_DATA_METADATA_UPDATE + * + * @note The buffer will be temporarily modifed by this function, + * so it needs to be writable. Furthermore it must be padded + * by a single byte (not counted in size). + * All changes will have been reverted upon return. + */ +int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, + const uint8_t *buf, int size); + static inline int ogg_find_stream (struct ogg * ogg, int serial) { diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 7e812846fe..7b7c76a3e0 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -263,20 +263,16 @@ static void vorbis_cleanup(AVFormatContext *s, int idx) } } -static int vorbis_update_metadata(AVFormatContext *s, int idx) +int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, + const uint8_t *buf, int size) { struct ogg *ogg = s->priv_data; - struct ogg_stream *os = ogg->streams + idx; - AVStream *st = s->streams[idx]; + struct ogg_stream *os = ogg->streams + st->index; int ret; - if (os->psize <= 8) - return 0; - /* New metadata packet; release old data. */ av_dict_free(&st->metadata); - ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, - os->psize - 8); + ret = ff_vorbis_stream_comment(s, st, buf, size); if (ret < 0) return ret; @@ -349,6 +345,19 @@ static int vorbis_parse_header(AVFormatContext *s, AVStream *st, return 1; } +static int vorbis_update_metadata(AVFormatContext *s, int idx) +{ + struct ogg *ogg = s->priv_data; + struct ogg_stream *os = ogg->streams + idx; + AVStream *st = s->streams[idx]; + + if (os->psize <= 8) + return 0; + + return ff_vorbis_update_metadata(s, st, os->buf + os->pstart + 7, + os->psize - 8); +} + static int vorbis_header(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; -- 2.39.5 (Apple Git-154) _______________________________________________ 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".