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 ESMTPS id 488384D260 for ; Wed, 19 Feb 2025 05:26:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C638268C153; Wed, 19 Feb 2025 07:25:18 +0200 (EET) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D59C68C160 for ; Wed, 19 Feb 2025 07:25:12 +0200 (EET) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-6f74b78df93so56338907b3.0 for ; Tue, 18 Feb 2025 21:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739942710; x=1740547510; 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=RUTWzoC1Ap0HC3qtT9kVT8GOibNR9yMCdoLcZn+rGm0=; b=ePh75lelhr2pqmSrBOnbqSm8JPvrxpNC4UuVQD71SWAW1mOImniA9WCufvxiXAvIjS XgFtNxzk0ySJcqYBzGu9azbcosAcjMNs897osqSB3Ckjgvq/IHCKmOFW5mFOQTZqVDz2 jVRWNVAzdYNAgJ4TtSM5PyeVmC/oeq4yl3AhFpTXuY8Cr6ArusVdMZ9nAWhnHaCoRgyp h34TEwHEQn9t6rqAf4riKb204UwEqHJ2OhdSECPGBeSuXKv0usutR+39UbQpsJYfr3KX SR+kx1vFWo+G20fAx17n7p/DXM4dBkQK+aNugo4N/ODdY0dwkgR4JevraaZC87MCh10X gIrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739942710; x=1740547510; 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=RUTWzoC1Ap0HC3qtT9kVT8GOibNR9yMCdoLcZn+rGm0=; b=aqqSkfiThVbdmtMdRfbazJLKeaETiJ65qk5oNVJTvSMbXGw42PviPMxHZcDHqwYTgp 6v2RGl/RLVm4HFwrkBQfAC3x4k82iRncX3qRVqMKLfJ6Rx+vPgA0yiSc9YUIbOfTqp8x qnUIr+EpiiC/QhLaj5MeaBGZnVEcmLCPj32CNPHlJ2odsm9z0SbeMXc7KcT04PrWcTRR Mvfnk1WnefXOm5335irObLxS7U9ZPcUB6620uVV/iAfp6hED1xJhLk1GaE7XMX++vgT6 ySIbJzHMCuwkTvUNN4wreX729WDR+9WJ0IsDeoaJLcUQYkqrfOK/RDZ7TB7ErRfox0aN YERQ== X-Gm-Message-State: AOJu0YzqVwD/Q9nIJrlX4XGfDoP8/1yx/ueBxK5sFXnWQc6I8AH6E9Vk fymPY1JpjrH0XGGCZTQ9hqYt9QOz/+ibdjPJeRaJ0TZ7ui2l7S/1APL2gg== X-Gm-Gg: ASbGncsNxTw4DWJAmbm88IAUrRqvR7U6jmau7+fC6NFtCseBxVG0DddCG2EYmejkJeM VlRODIAPcbdRRoH0w4VluxvoNlzm4TOCdScE22oljIx0r5v56MlwiSR0gc+xBNijVIgas+t/clc RAS6B9eI6kdFo+E+LJMmx8Q9+wfHhc4ryKIl3I9SU5GkvdH9QOHlFAJQOZpSw1o0G2DvUEKiTAs 3qtjIYgEhLBvvLkS2sfr52EiP3DIUjf6l4LSkJ0JQHgoZm2MxIhuJStb4GExfRGV54k2tDhH9pf lK5tviTKLWs/VEhvhkgKKUacwtymsen7qpTjXAS35BYJ1ixexbCT X-Google-Smtp-Source: AGHT+IF76vSW0tPu6ebk1V8UxN0IUx5ugy5mBHhrMe0QFVP8ORX/udRI+wSt9fXwP82X4lAh/a7Mtw== X-Received: by 2002:a05:690c:74c2:b0:6f9:b12b:8943 with SMTP id 00721157ae682-6fba56e4acbmr23982047b3.19.1739942710331; Tue, 18 Feb 2025 21:25:10 -0800 (PST) Received: from localhost.localdomain ([2607:fb91:fe2:71a6:2854:c007:54e:fca]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6fb5a15f082sm20783537b3.54.2025.02.18.21.25.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Feb 2025 21:25:09 -0800 (PST) From: Romain Beauxis To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Feb 2025 23:24:41 -0600 Message-Id: <20250219052445.86383-6-romain.beauxis@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250219052445.86383-1-romain.beauxis@gmail.com> References: <20250219052445.86383-1-romain.beauxis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v6 5/9] 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 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 0033d1a224..a36e883649 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -261,20 +261,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; @@ -291,6 +287,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_stream_comment(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".