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 B6AC34CFD8 for <ffmpegdev@gitmailbox.com>; Tue, 15 Apr 2025 22:23:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DECC8687D81; Wed, 16 Apr 2025 01:22:54 +0300 (EEST) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58A4C687D32 for <ffmpeg-devel@ffmpeg.org>; Wed, 16 Apr 2025 01:22:46 +0300 (EEST) Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-72bceb93f2fso77861a34.0 for <ffmpeg-devel@ffmpeg.org>; Tue, 15 Apr 2025 15:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744755765; x=1745360565; 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=eEs1gDvsgfCjMQeXpxUS21ACItxMaxizVSBEM5pw5dEfCIRw50eY9s7819mzxkNz5k g+6SpfGvqk3PA6RSZjr9rCsAz1JJx0d7aHhJhM6Pf+c9Vs2Tylx6r9CmJWtpJ4YYf55P UYpS6d75QssWFDjuLlz1s+HEn5ybnAB5V6IQHke8rCJ//6YfmKVgb82UGO0JuPqccv3Z c8u/gLdrEbU5lhR+ltmZAn95tASzZv8e1gGgzKLaZ7u5QRh47QKdbDtfKhiih6hmcuTC tHo2vqdLxeOlyuTVls3bTk5ImuTLIuNeEYn0+TpxWYSAIg15GhWHxSMCfpMQhyjhB9pm oiqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744755765; x=1745360565; 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=FOuGGuPki6GtWuMtDz4tE8qB5qx+l9CJdVuJeXq2FoFoyoya4+N5tye1mhotkzlb+T uDStWjXorQQUZqbRZZFLDE7izbIoShBblK050c145qeUcURTDn+XdvCHvGMKw1lhje5A LXJapf+09V1lT/D/g2+9W3y1OYasvxe5myk4cVrT2SdOGhe1aAB+so652oHUecvYG0dB ygDUKCCaWTplK5VVyAerhSSwprwhRpYTB1OnXGMLg0tZV7AdiY2lEsjDQoTfmfSm8tRP tQeuEZyvTFsvda8T+WMAw+LtnH2LQjjRP/a4Z+98lpGpXiBlNCCvVF8TbJmBhbI9FZ70 9G1g== X-Gm-Message-State: AOJu0YyV7XWaz9yQh9x04P6rANWQv+fixzPXIbLpG5A9gafrTgYL8Hqg u4BjzExjknOWZxUjUOaYimd2kI+vg+Zinpv6wUo6l1IoWsbw2YAFnYJqzU6j X-Gm-Gg: ASbGnctXzcyL/asJkpsGvRnTDojKDAcZ4jCux73nDiiRy0oswq/9+x3MuViRitD3+C4 IcYoWWzw+SZ7dWxmbxY8xoGN+rSD/usS4nACYYV8OamGYRZuPhmWysFSo4qPxqDeUZyGPvJydGR hDF/nckZ52ZqzAaJsudhSMTOSvzfWx4BWRNuTbuFmqsBwnyW+5E6YXYj2jFnZH7xGrn2dX4m1Aq 1b2320DUpDAmRXvJkD2Lg1aPyB16k5Bkz6aGi6XtB5O/RpnZtxxUxd20MYHClfdMZj0Z5UQaROl rlHH4GZJOPY+q9dcTJnDB6NikTpfK/uQpKNlETvSMnUblOC4VHfmBVbZsni5EKhkovhlTJOJFGV 7W5JlWZc+ X-Google-Smtp-Source: AGHT+IEobfn/fFwiJz2p1maO6bk3b7aSzr9wiKUp8o0PX8vhlLOw1543asptelpr0mcHT4/+UnynFA== X-Received: by 2002:a05:6830:3982:b0:72b:88b0:d8dc with SMTP id 46e09a7af769-72ec1312b7dmr729668a34.5.1744755764600; Tue, 15 Apr 2025 15:22:44 -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 46e09a7af769-72e73e4d7edsm2576615a34.47.2025.04.15.15.22.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 15 Apr 2025 15:22:44 -0700 (PDT) From: Romain Beauxis <romain.beauxis@gmail.com> To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Apr 2025 17:22:32 -0500 Message-Id: <20250415222236.78392-5-romain.beauxis@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250415222236.78392-1-romain.beauxis@gmail.com> References: <20250415222236.78392-1-romain.beauxis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v12 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/20250415222236.78392-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".