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 5EBB44D03F for ; Wed, 5 Nov 2025 21:03:26 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'p1Z0PG7VFZwVUZsuj6JnZzuw6uhUg2nWk2R1NcSDi/w=', expected b'0ngMfVckR6Jha3nQG9gMkrNqCo2JgUBSd/IC5KMmfss=')) header.d=googlemail.com header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1762376581; h=mime-version : references : in-reply-to : date : message-id : to : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=Ej+pj502UUGthh6GcOT+wrREC12+rsW84soQZ2E9KL4=; b=YU9qD0AGvd7f28viVgJHmOdeDJsgJeL1anUSYPl5v/VXnIRaQvZaGtlcf5Pcl+INeMJK8 7GAZ52JLSskOHTaEIT/rjO1eKmds03RXxsX5UnHsbarC7GDte0+PKgxhCwbqZ7oyfGdohdg G9CK+s29C8DjIpjGq1SU2HGrpcYsXdifvpBeXiH7ZUM6NnBGL8VHjWjQ5jPn6ONYmzC+JyH K8yoZWJlJamj39k8sxn46IT2TCLLhUg+aOeibD7SaneEzdEwkigVQGVBO0EBPewlkv/OnKI cpLj50bjMtclZzh8EtYmMfHIBvLS4pQqb7Z+B4e01nkVxVvYd73AcDPfq9RA== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id B075768FBA9; Wed, 5 Nov 2025 23:03:01 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1762376567; b=h2eTGSNn5PnDdrZYQapEW7X8o+rmdQV1mackDVGE9/kQUJcb3qDA+9DiemBTGAWUegSR9 4C7zC8eVTLP/CqobGjiksOQxqaNUtAx4jhGYXIl4PAkVsXmXl8f2HC15WOe/YGBDA4SnHNz rgsUeKQO9ZGNmwsr80e1wTWLR7xKoxWCseWK3FZm5OVoGoOeINQrqHdmoPprxGkYy7Jh3fo xzCzDjSFEoXKeER/vfdKeyswxfmuyyNjvqHlkzmdyoZW28QPPpRjrFUdAj1K+LJ70D66Ecj 2V9fbAMQkbFjhixajiXaIyXoXHtAAh/x6f95PPMcKxBq0ZQspGy16ST9VfHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1762376567; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=p1Z0PG7VFZwVUZsuj6JnZzuw6uhUg2nWk2R1NcSDi/w=; b=lMJvXixEsYeInN/GTQJ8tq70GKBWTEbneB5y/LP37+bZlr7fI5J4RFcb6U/foT4rjkTRW 5fF+eE1RjPaFFN5olKY2w/IS0O+NRv+GSnpuT0jC6yisEuIaw53aCAtQWiOI2PIvR+GEcCL b4oFdnOe0ytHE4A8ffO1q4d/Q/4tdFJ1CtAX8zMtJyI+4tdO6ogj7ZXkR74hA4dYxi3D9In ScCsjjVR5aTNUNPPNYnZVa+EffFqbIfZGLUxqtNYgHQffCp06ApdbN9fHSSs1pU0tPsSXfw +nNtPj+4BFGm6ZsX5L6oLtr6VHWYURTWtCrrKJQyQZrG0ZEfLHzQkDLQgjcA== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=googlemail.com; arc=none; dmarc=pass header.from=googlemail.com policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=googlemail.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=googlemail.com policy.dmarc=quarantine Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id AE7C468FA9F for ; Wed, 5 Nov 2025 23:02:34 +0200 (EET) Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-63e2cc1ac4aso313553d50.2 for ; Wed, 05 Nov 2025 13:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1762376552; x=1762981352; darn=ffmpeg.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0ngMfVckR6Jha3nQG9gMkrNqCo2JgUBSd/IC5KMmfss=; b=LOwGhP3LHo2QE3K3fYEh411dzq57kBAbQNdkgsInJT3hkt250qsxEqcIEWHi/+c5B3 5sTu6ovsu0yEvKao99OrskjeBB2ppRSk184bw7HccUJCHnTM60OzkgmkAPgZ25EKCTHB 7G+jPkK3kO0QwObwAdAJtGIx7DNUCVV/dt2Non+lKmuIN7D6X3jeLWubYSMxKorYM8Ge 55nk3tL6Q8AvpvxDOdL1I7QDBwXFZqh4zGlF0KjjC9oIg4naqr2I/FAeLX50SwYWjT+q sApSCeIAoPpnixQyRtACjlFG2svtnJESRcn2e9QjkC1LOwtus54RUIcxCtUkjcdLO4bM m5EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762376552; x=1762981352; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0ngMfVckR6Jha3nQG9gMkrNqCo2JgUBSd/IC5KMmfss=; b=NkjCv6kBC2v7Sf7IsHVL28vTiQW7pK2Tmfuiqy+dRKlIB5RtMRwJVF5Udr4HRS/+xf mijsy7grcUyIdFowxqXNBSjVnIkQhJK450t3101xymT/6YXhmyuNuNb8VJ5uR7t6p6rj ObERmvNilRkUUE1527q5wZ3gHeK/eqEUIT6YwdmKHRnO8WXukrDM92kjkIMWT/6DmMHC h5AqKawkF6jYxISt/cNu7SwwMYiSkq8qzNVL6eXqIjmuvjvNRtBafQAVodfSLUmI6r3j GNO3B9f8R8GFMJPbe7BEI7rmjgTnpt9xKQf1pTA9s68KXCMeozLrW4a3kf3yDH+1A8Pq WjCQ== X-Gm-Message-State: AOJu0YyzkyZ2CPy78JPipyOc6vfJ7cpG8obwKs8MLlTypHjIFNy2O/FE kKCwByRsBfCOceXRHziUGfux66KXK2fFBiRvn69ilYpmLU+TyXhGCT+CZAqeKOH7onQ1C+fdfGe 0Huj6FaRNc1YO1ZUYwN9l2yPMXP5OgGq0zF7o X-Gm-Gg: ASbGncukABAbBwtT2AnD81XwghG9k10muaGIjW6K4343YUzdqMxRwcgcWACt8LYJN+a WihXBGhCpqPl5s7kpUkMlQalMDo+2r/R3j/89CR5hQTa+z/PvFGxsqBFcnCircmQjJAjW7G/iVE IrRRoy9WDMDjNO37pDLfJLILXHbEu2RDrDOXkCEeVWE4Cb8clcDB6uuKtADZiLUvwz0+TsIR5we kBfvatNWPSV7iIeQ4RiP565LIM9hFCEoqGGZv7t1Rjtd+YVifvMpKO69qCcMtwLb5pjQkV8FRRN ulg5ftyfagDNOv0CJDEGuy2r X-Google-Smtp-Source: AGHT+IHV4lRXDSlCCrbuS2suP3sgc97bwBdrvJyCUN85SMcogS9rsv9L4H4Kq+UeHMXyej9N0YaZt+BYc8ZgHl7QwXE= X-Received: by 2002:a05:690e:2598:b0:63f:a818:6d34 with SMTP id 956f58d0204a3-63fd3571ab8mr3499648d50.32.1762376551496; Wed, 05 Nov 2025 13:02:31 -0800 (PST) MIME-Version: 1.0 References: <176237143329.25.11466857126401484102@2cb04c0e5124> In-Reply-To: <176237143329.25.11466857126401484102@2cb04c0e5124> Date: Wed, 5 Nov 2025 22:02:20 +0100 X-Gm-Features: AWmQ_bkwZ_Tm2NHl2e0OyeTiyDT4NbqmAB26ODX7MpZysETcnpvcArghNvq2oPs Message-ID: To: FFmpeg development discussions and patches Message-ID-Hash: UBCPUEXQOKK3L67UXFYWKRUD2AG4KYX7 X-Message-ID-Hash: UBCPUEXQOKK3L67UXFYWKRUD2AG4KYX7 X-MailFrom: SRS0=ojpU=5N=googlemail.com=kieran618@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Content-Filtered-By: Mailman/MimeDel 3.3.10 X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] Re: [PATCH] libavutil: add qtff well-known type functions (PR #20846) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Kieran Kunhya via ffmpeg-devel Cc: Lukas , Kieran Kunhya Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: On Wed, 5 Nov 2025, 20:37 Lukas via ffmpeg-devel, wrote: > PR #20846 opened by Lukas (lholliger) > URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20846 > Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20846.patch > > QuickTime File Format (QTFF/MOV) have a list of well-known datatypes > and there is currently little in place to decode or encode these > values besides a small part in mov.c. This adds the ability to encode > and decode various types for integers, floats, and strings. These > well-known types have usage to decoding some parts on the moov atom > or for metadata boxed/mebx values. > > Also updated mov.c to use this function. > > > > > >From 9a4c805ea90401f8c51f31be1c4c523815dfa100 Mon Sep 17 00:00:00 2001 > From: lholliger > Date: Wed, 5 Nov 2025 14:15:08 -0500 > Subject: [PATCH 1/2] libavutil: add qtff well-known type functions > > QuickTime File Format (QTFF/MOV) have a list of well-known datatypes > and there is currently little in place to decode or encode these > values besides a small part in mov.c. This adds the ability to encode > and decode various types for integers, floats, and strings. These > well-known types have usage to decoding some parts on the moov atom > or for metadata boxed/mebx values. > > Signed-off-by: lholliger > --- > libavutil/Makefile | 2 + > libavutil/qtff.c | 380 +++++++++++++++++++++++++++++++++++++++++++++ > libavutil/qtff.h | 59 +++++++ > 3 files changed, 441 insertions(+) > create mode 100644 libavutil/qtff.c > create mode 100644 libavutil/qtff.h > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index ee77e51c08..792b587529 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -75,6 +75,7 @@ HEADERS = adler32.h > \ > pixdesc.h \ > pixelutils.h \ > pixfmt.h \ > + qtff.h \ > random_seed.h \ > rc4.h \ > rational.h \ > @@ -168,6 +169,7 @@ OBJS = adler32.o > \ > parseutils.o \ > pixdesc.o \ > pixelutils.o \ > + qtff.o \ > random_seed.o \ > rational.o \ > refstruct.o \ > diff --git a/libavutil/qtff.c b/libavutil/qtff.c > new file mode 100644 > index 0000000000..a58d360958 > --- /dev/null > +++ b/libavutil/qtff.c > @@ -0,0 +1,380 @@ > +/* > + * copyright (c) 2025 Lukas Holliger > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > + */ > + > +#include > +#include > +#include > + > +#include "qtff.h" > +#include "intfloat.h" > +#include "intreadwrite.h" > +#include "error.h" > + > +int av_qtff_convert_well_known_to_str(int data_type, const uint8_t *data, > int data_size, > + char *str, int str_size) > +{ > + if (!data || !str || str_size <= 0) > + return AVERROR(EINVAL); > + > + switch (data_type) { > + case 0: // Reserved > + case 2: // UTF-16 > + case 3: // S/JIS > + case 4: // UTF-8 sort > + case 5: // UTF-16 sort > + case 13: // JPEG > + case 14: // PNG > + case 27: // BMP > + case 28: // QuickTime Metadata atom > + case 70: // BE PointF32 > + case 71: // BE DimensionsF32 > + case 72: // BE RectF32 > + case 79: // AffineTransformF64 > + return AVERROR_PATCHWELCOME; > + case 1: { // UTF-8 > + int len = data_size < str_size - 1 ? data_size : str_size - 1; > + memcpy(str, data, len); > + str[len] = '\0'; > + break; > + } > + case 21: { // BE Signed Integer (variable size, not usable for timed > metadata) > + int val = 0; > + switch (data_size) { > + case 1: > + val = (int8_t)AV_RB8(data); > + break; > + case 2: > + val = (int16_t)AV_RB16(data); > + break; > + case 3: > + val = ((int32_t)(AV_RB24(data) << 8)) >> 8; > + break; > + case 4: > + val = (int32_t)AV_RB32(data); > + break; > + default: > + return AVERROR(EINVAL); > + } > + > + if (snprintf(str, str_size, "%d", val) >= str_size) > + return AVERROR(ENOMEM); > + break; > + } > + case 22: { // BE Unsigned Integer (variable size, not usable for > timed metadata) > + unsigned int val = 0; > + switch (data_size) { > + case 1: > + val = AV_RB8(data); > + break; > + case 2: > + val = AV_RB16(data); > + break; > + case 3: > + val = AV_RB24(data); > + break; > + case 4: > + val = AV_RB32(data); > + break; > + default: > + return AVERROR(EINVAL); > + } > + > + if (snprintf(str, str_size, "%u", val) >= str_size) > + return AVERROR(ENOMEM); > + break; > + } > + case 23: { // BE float32 > + float val; > + if (data_size != 4) > + return AVERROR(EINVAL); > + > + val = av_int2float(AV_RB32(data)); > + if (snprintf(str, str_size, "%f", val) >= str_size) > + return AVERROR(ENOMEM); > + break; > + } > + case 24: { // BE float64 > + double val; > + if (data_size != 8) > + return AVERROR(EINVAL); > + > + val = av_int2double(AV_RB64(data)); > + if (snprintf(str, str_size, "%f", val) >= str_size) > + return AVERROR(ENOMEM); > + break; > + } > + case 65: // 8-bit Signed Integer > + if (data_size != 1) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%d", (int)(int8_t)data[0]) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 66: // BE 16-bit Signed Integer > + if (data_size != 2) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%d", (int)(int16_t)AV_RB16(data)) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 67: // BE 32-bit Signed Integer > + if (data_size != 4) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%d", (int)(int32_t)AV_RB32(data)) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 74: // BE 64-bit Signed Integer > + if (data_size != 8) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%lld", (long > long)(int64_t)AV_RB64(data)) >= str_size) > + return AVERROR(ENOMEM); > + break; > + case 75: // 8-bit Unsigned Integer > + if (data_size != 1) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%u", (unsigned int)data[0]) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 76: // BE 16-bit Unsigned Integer > + if (data_size != 2) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%u", (unsigned int)AV_RB16(data)) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 77: // BE 32-bit Unsigned Integer > + if (data_size != 4) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%u", (unsigned int)AV_RB32(data)) >= > str_size) > + return AVERROR(ENOMEM); > + break; > + case 78: // BE 64-bit Unsigned Integer > + if (data_size != 8) > + return AVERROR(EINVAL); > + if (snprintf(str, str_size, "%llu", (unsigned long > long)AV_RB64(data)) >= str_size) > + return AVERROR(ENOMEM); > + break; > + default: > + return AVERROR(EINVAL); > + } > + > + return 0; > +} > + > +int av_qtff_convert_str_to_well_known(int data_type, const char *str, > uint8_t *data, int data_size) > +{ > + if (!str || !data) > + return AVERROR(EINVAL); > + > + switch (data_type) { > + case 0: // Reserved > + case 2: // UTF-16 > + case 3: // S/JIS > + case 4: // UTF-8 sort > + case 5: // UTF-16 sort > + case 13: // JPEG > + case 14: // PNG > + case 27: // BMP > + case 28: // QuickTime Metadata atom > + case 70: // BE PointF32 > + case 71: // BE DimensionsF32 > + case 72: // BE RectF32 > + case 79: // AffineTransformF64 > + return AVERROR_PATCHWELCOME; // these are defined well-known > types, but not implemented to be parsed > + case 1: { // UTF-8 > + int len = strlen(str); > + if (len > data_size) > + return AVERROR(ENOMEM); > + memcpy(data, str, len); > + return len; > + } > + case 21: { // BE Signed Integer (variable size, not usable for timed > metadata) > + long long val; > + char *endptr; > + > + val = strtoll(str, &endptr, 10); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + switch (data_size) { > + case 1: > + if (val < INT8_MIN || val > INT8_MAX) > + return AVERROR(ERANGE); > + AV_WB8(data, (uint8_t)val); > + break; > + case 2: > + if (val < INT16_MIN || val > INT16_MAX) > + return AVERROR(ERANGE); > + AV_WB16(data, (int16_t)val); > + break; > + case 3: > + if (val < -8388608 || val > 8388607) // 24-bit signed range > + return AVERROR(ERANGE); > + AV_WB24(data, (int32_t)val); > + break; > + case 4: > + if (val < INT32_MIN || val > INT32_MAX) > + return AVERROR(ERANGE); > + AV_WB32(data, (int32_t)val); > + break; > + default: > + return AVERROR(EINVAL); > + } > + break; > + } > + case 22: { // BE unsigned integer, variable size > + unsigned long long val; > + char *endptr; > + > + val = strtoull(str, &endptr, 10); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + switch (data_size) { > + case 1: > + if (val > UINT8_MAX) > + return AVERROR(ERANGE); > + AV_WB8(data, (uint8_t)val); > + break; > + case 2: > + if (val > UINT16_MAX) > + return AVERROR(ERANGE); > + AV_WB16(data, (uint16_t)val); > + break; > + case 3: > + if (val > 16777215) // 24-bit unsigned range > + return AVERROR(ERANGE); > + AV_WB24(data, (uint32_t)val); > + break; > + case 4: > + if (val > UINT32_MAX) > + return AVERROR(ERANGE); > + AV_WB32(data, (uint32_t)val); > + break; > + default: > + return AVERROR(EINVAL); > + } > + break; > + } > + case 23: { // BE float32 > + float val; > + char *endptr; > + > + if (data_size != 4) > + return AVERROR(EINVAL); > + > + val = strtof(str, &endptr); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + AV_WB32(data, av_float2int(val)); > + break; > + } > + case 24: { // BE float64 > + double val; > + char *endptr; > + > + if (data_size != 8) > + return AVERROR(EINVAL); > + > + val = strtod(str, &endptr); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + AV_WB64(data, av_double2int(val)); > + break; > + } > + case 65: // 8-bit Signed Integer > + case 66: // BE 16-bit Signed Integer > + case 67: // BE 32-bit Signed Integer > + case 74: { // BE 64-bit Signed Integer > + long long val; > + char *endptr; > + int expected_size = (data_type == 65) ? 1 : (data_type == 66) ? 2 > : (data_type == 67) ? 4 : 8; > + > + if (data_size != expected_size) > + return AVERROR(EINVAL); > + > + val = strtoll(str, &endptr, 10); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + switch (data_type) { > + case 65: > + if (val < INT8_MIN || val > INT8_MAX) > + return AVERROR(ERANGE); > + AV_WB8(data, (uint8_t)val); > + break; > + case 66: > + if (val < INT16_MIN || val > INT16_MAX) > + return AVERROR(ERANGE); > + AV_WB16(data, (int16_t)val); > + break; > + case 67: > + if (val < INT32_MIN || val > INT32_MAX) > + return AVERROR(ERANGE); > + AV_WB32(data, (int32_t)val); > + break; > + case 74: > + AV_WB64(data, (int64_t)val); > + break; > + } > + break; > + } > + case 75: // 8-bit Unsigned Integer > + case 76: // BE 16-bit Unsigned Integer > + case 77: // BE 32-bit Unsigned Integer > + case 78: { // BE 64-bit Unsigned Integer > + unsigned long long val; > + char *endptr; > + int expected_size = (data_type == 75) ? 1 : (data_type == 76) ? 2 > : (data_type == 77) ? 4 : 8; > + > + if (data_size != expected_size) > + return AVERROR(EINVAL); > + > + val = strtoull(str, &endptr, 10); > + if (endptr == str || *endptr != '\0') > + return AVERROR(EINVAL); > + > + switch (data_type) { > + case 75: > + if (val > UINT8_MAX) > + return AVERROR(ERANGE); > + AV_WB8(data, (uint8_t)val); > + break; > + case 76: > + if (val > UINT16_MAX) > + return AVERROR(ERANGE); > + AV_WB16(data, (uint16_t)val); > + break; > + case 77: > + if (val > UINT32_MAX) > + return AVERROR(ERANGE); > + AV_WB32(data, (uint32_t)val); > + break; > + case 78: > + AV_WB64(data, (uint64_t)val); > + break; > + } > + break; > + } > + default: > + return AVERROR(EINVAL); > + } > + > + return data_size; > +} > diff --git a/libavutil/qtff.h b/libavutil/qtff.h > new file mode 100644 > index 0000000000..912ea9e870 > --- /dev/null > +++ b/libavutil/qtff.h > @@ -0,0 +1,59 @@ > +/* > + * copyright (c) 2025 Lukas Holliger > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > + */ > + > +#ifndef AVUTIL_QTFF_H > +#define AVUTIL_QTFF_H > + > +#include > + > +/** > + * @file > + * QuickTime File Format (QTFF) utilities > + */ > + > +/** > + * Convert a QuickTime well-known type to a string > + * > + * @param data_type QuickTime metadata data type > + * @param data Pointer to the binary data > + * @param data_size Size of the binary data in bytes > + * @param str Buffer to write the string representation to > + * @param str_size Size of the output buffer > + * @return 0 on success, negative AVERROR code on failure > + * > + * @see > https://developer.apple.com/documentation/quicktime-file-format/well-known_types > + */ > +int av_qtff_convert_well_known_to_str(int data_type, const uint8_t *data, > int data_size, > + char *str, int str_size); > + > +/** > + * Convert a string to QuickTime well-known value > + * > + * @param data_type QuickTime metadata data type > + * @param str Input string to convert > + * @param data Buffer to write the binary data to > + * @param data_size Size to use for the binary data > + * @return Number of bytes written on success, negative AVERROR > code on failure > + * > + * @see > https://developer.apple.com/documentation/quicktime-file-format/well-known_types > + */ > +int av_qtff_convert_str_to_well_known(int data_type, const char *str, > uint8_t *data, int data_size); > + > +#endif /* AVUTIL_QTFF_H */ > -- > 2.49.1 > > > >From 3616592b585440ca4984052e53c85ff5df29f3bf Mon Sep 17 00:00:00 2001 > From: lholliger > Date: Wed, 5 Nov 2025 14:33:22 -0500 > Subject: [PATCH 2/2] libavformat/mov: use qtff decoder util > > There was previously a segment here to attempt to decode some of the > well-known QTFF types but in order to simplify the function and > implement more types this segment can be replaced with a call to > the qtff util. > > Signed-off-by: lholliger > --- > libavformat/mov.c | 78 +++++++++++++++++------------------------------ > 1 file changed, 28 insertions(+), 50 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 45c562cdc6..9cf62955c2 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -45,6 +45,7 @@ > #include "libavutil/aes.h" > #include "libavutil/aes_ctr.h" > #include "libavutil/pixdesc.h" > +#include "libavutil/qtff.h" > #include "libavutil/sha.h" > #include "libavutil/spherical.h" > #include "libavutil/stereo3d.h" > @@ -521,61 +522,38 @@ retry: > else { > if (!raw && (data_type == 3 || (data_type == 0 && (langcode < > 0x400 || langcode == 0x7fff)))) { // MAC Encoded > mov_read_mac_string(c, pb, str_size, str, str_size_alloc); > - } else if (data_type == 21) { // BE signed integer, variable size > - int val = 0; > - if (str_size == 1) > - val = (int8_t)avio_r8(pb); > - else if (str_size == 2) > - val = (int16_t)avio_rb16(pb); > - else if (str_size == 3) > - val = ((int32_t)(avio_rb24(pb)<<8))>>8; > - else if (str_size == 4) > - val = (int32_t)avio_rb32(pb); > - if (snprintf(str, str_size_alloc, "%d", val) >= > str_size_alloc) { > - av_log(c->fc, AV_LOG_ERROR, > - "Failed to store the number (%d) in string.\n", > val); > - av_free(str); > - return AVERROR_INVALIDDATA; > - } > - } else if (data_type == 22) { // BE unsigned integer, variable > size > - unsigned int val = 0; > - if (str_size == 1) > - val = avio_r8(pb); > - else if (str_size == 2) > - val = avio_rb16(pb); > - else if (str_size == 3) > - val = avio_rb24(pb); > - else if (str_size == 4) > - val = avio_rb32(pb); > - if (snprintf(str, str_size_alloc, "%u", val) >= > str_size_alloc) { > - av_log(c->fc, AV_LOG_ERROR, > - "Failed to store the number (%u) in string.\n", > val); > - av_free(str); > - return AVERROR_INVALIDDATA; > - } > - } else if (data_type == 23 && str_size >= 4) { // BE float32 > - float val = av_int2float(avio_rb32(pb)); > - if (snprintf(str, str_size_alloc, "%f", val) >= > str_size_alloc) { > - av_log(c->fc, AV_LOG_ERROR, > - "Failed to store the float32 number (%f) in > string.\n", val); > - av_free(str); > - return AVERROR_INVALIDDATA; > - } > - } else if (data_type > 1 && data_type != 4) { > - // data_type can be 0 if not set at all above. data_type 1 > means > - // UTF8 and 4 means "UTF8 sort". For any other type (UTF16 or > e.g. > - // a picture), don't return it blindly in a string that is > supposed > - // to be UTF8 text. > - av_log(c->fc, AV_LOG_WARNING, "Skipping unhandled metadata %s > of type %d\n", key, data_type); > - av_free(str); > - return 0; > } else { > - int ret = ffio_read_size(pb, str, str_size); > + uint8_t *data_buf = av_malloc(str_size); > + int ret; > + > + if (!data_buf) { > + av_free(str); > + return AVERROR(ENOMEM); > + } > + > + ret = ffio_read_size(pb, data_buf, str_size); > if (ret < 0) { > + av_free(data_buf); > + av_free(str); > + return ret; > + } > + > + // Data types 0 and 4 are technically reserved and a special > case, but were previously > + // decoded to UTF-8 here. > + ret = av_qtff_convert_well_known_to_str(data_type == 0 || > data_type == 4 ? 1 : data_type, > + data_buf, str_size, > str, str_size_alloc); > + av_free(data_buf); > + > + if (ret == AVERROR_PATCHWELCOME || ret == AVERROR(EINVAL)) { > + av_log(c->fc, AV_LOG_WARNING, "Skipping unhandled > metadata %s of type %d\n", key, data_type); > + av_free(str); > + return 0; > + } else if (ret < 0) { > + av_log(c->fc, AV_LOG_ERROR, > + "Failed to convert metadata %s of type %d to > string.\n", key, data_type); > av_free(str); > return ret; > } > - str[str_size] = 0; > } > c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; > av_dict_set(metadata, key, str, 0); > -- > 2.49.1 > > _______________________________________________ > ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org > To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org Why does this need to be in avutil? Kieran > > _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org