From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 0E0B84C485 for <ffmpegdev@gitmailbox.com>; Fri, 4 Apr 2025 21:16:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 571EF68B912; Sat, 5 Apr 2025 00:15:10 +0300 (EEST) Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C18D168B83F for <ffmpeg-devel@ffmpeg.org>; Sat, 5 Apr 2025 00:15:03 +0300 (EEST) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-60402c94319so1204839eaf.1 for <ffmpeg-devel@ffmpeg.org>; Fri, 04 Apr 2025 14:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743801302; x=1744406102; 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=b0gH4nL4cGGyvOjPQUIk04w5+ziqRnR4Os0818gimYg=; b=BXvUiVM96YP/4Wp6SOeJULaXQrOt3IyDKQ4bNfcIO+wT8J+hCDEsUu+3N29GNgju4C zP7CSrLb8sf2LvmPhr71i3bgfxrZI0/7DNUc19NZcxwW/uzk2fYPptth6dqhUq5+QhhC k6cSrnF4Foy+D5QLk3jQ1lCWouSHuzZ45FvAvrLbA/sZBPIGsjVDJiiwJ2ILDv+0c3OA EoX4EVrv6F89mREeLECprkfTQfwvwudq7BT0iuvsPWPhPjdd5AaHBbS/0b/qZe8M4B3K D0/glvsuaMPIQcWVlLwEJrHIL+SgINJec+MWvOz+T+J4VFyw0ESVldhp9fh/Kr4qHf4s Wjpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743801302; x=1744406102; 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=b0gH4nL4cGGyvOjPQUIk04w5+ziqRnR4Os0818gimYg=; b=B8sJuhsWBxcMRykip3DG7DLThyuaQPIvx9vC79XSuMZ3AbLGDCB1VJ0NQqqYE5Rxlv 3CJlQzPi6gvaNJreHAUqQXGt7+rJYXajIPJH1pAp9BrFgLXVxMaSNe0bIAmN7fAKWt+7 GKhZr1zmggkyCrEyoa5B1myCUYTeoM8bhRYy1hRppSpcga8oeVsRycnP3s/pRmhAr8nI f4+LlcqW9eUVKDN46d2aTwOlaC81RAR7OSDs29q+fsdu/KRvvH193tO4ZSB+XmRaXymy aCZMX2qi96y/CBxZvPUmwzPpZ8eTQXmwkVvW/cepO15ODoxM6d237wkMjnb6+yHBxEr7 3K3g== X-Gm-Message-State: AOJu0Yxz123CpAQSOxcoE65jggPUCSH4X7WC4q2rMkMVV1n2DOTonZwW CXiB7t52nR13CajLxtcIGt7OkLFpH4tZvFCx0iTLKtO+06sKWRoMz286kePr X-Gm-Gg: ASbGnctzompxoxbXMMKSRahSGJWODT9YtfCIt4gxZjEb3OvES4XZJXXrNKXbPtAlrqh RMlqRp/afgiR/7cB6lUaUVHN65onBd/Ur+s/E8UrZVWyxn4y12JoxSZb+lMScctzEKWYWlkqwsN QCQPGDDmY216TO2eT+ppuZZgBadFOEASIvr+1mSb9xq40p2G88GJhRSJG8iCsW57LNeE5CnaDHR ahwsqZSS3y+ZwrJvDCOKVoJz2erWjOt+cY8fbUrjOMCzbwckHvONVxybXnUnh5vF0Nz1dn11quC jGJy+xwfqVY+EUMuD4XkSk/lAEwA8hNOCQHedXN2o2HR86Dsb8KLg0fYUi7qbkcsvHuPDJxgx7U GPEWAU0Q62cdU X-Google-Smtp-Source: AGHT+IHFG+zRtqTjz8Fyl0VswX0BRJIZXgWGK6TOQqqRVkYgtANPS2HChPaBU9ejb6StelNfLBRxAA== X-Received: by 2002:a05:6820:c97:b0:602:2bd5:121c with SMTP id 006d021491bc7-604156d370emr2630426eaf.3.1743801302115; Fri, 04 Apr 2025 14:15:02 -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 006d021491bc7-6040c4ea9e1sm788661eaf.17.2025.04.04.14.15.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Apr 2025 14:15:01 -0700 (PDT) From: Romain Beauxis <romain.beauxis@gmail.com> To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Apr 2025 16:14:47 -0500 Message-Id: <20250404211451.91394-5-romain.beauxis@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250404211451.91394-1-romain.beauxis@gmail.com> References: <20250404211451.91394-1-romain.beauxis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v11 4/8] 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 <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Romain Beauxis <romain.beauxis@gmail.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250404211451.91394-5-romain.beauxis@gmail.com/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> --- 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 43df23f4cb..c8460a66e9 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -151,6 +151,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 9f50ab9ffc..308deb7feb 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; @@ -293,6 +289,19 @@ static int vorbis_update_metadata(AVFormatContext *s, int idx) return ret; } +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".