From patchwork Wed Sep 25 22:52:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51857 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b66f:0:b0:48e:c0f8:d0de with SMTP id o15csp148271vqw; Wed, 25 Sep 2024 22:59:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUA5ir8rLVeUn0G53p35aXli8Tym3oQxNei8Byb7a1NawJEI1RTWZOl2hMqbciuc5GOlwf1B2C8vCbTWxkxPGAk@gmail.com X-Google-Smtp-Source: AGHT+IEHS+k/2s4LqueMJ/RQ9jdJGb0clQjTRKs+jgc8HivmbvXrYsHnUpdQLwgDDruwqk+NXAtN X-Received: by 2002:a05:6512:3d93:b0:536:553f:a6e7 with SMTP id 2adb3069b0e04-53877530d66mr4550420e87.32.1727330361922; Wed, 25 Sep 2024 22:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727330361; cv=none; d=google.com; s=arc-20240605; b=ClRV6dEW3vgaZxDMUz+uC2NWxRN4VQcoRpe6FX8GnGe4pXv1yxLo/SIUKHgB/kA+Vp JY3Ju9G2pE/JY8AGQYtma8n7t+g33ZQY13gSaA4sQSCkFsOyzxP0M0UsMVEbm1fsgTXa q6HAHsaBpVbAH5WlTFWzic7jhz2CodVgCYX4zaHZj8mBRPjp2Id7A7DRh3PZwB0K7N3T GoLnDJ8pcljwTOghehWpMo+rMwW7FA2rH+0OFmcSecce82dn6oyw7s3J6iAcP4/gDK6Y cIh8zlkyTEgY6CwizDF+tt4muqwEj/yPKpMy0OJTJxeuq2kRJf5f7YlhQvGfUQBHfIS/ GIDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=/h3MVwI1HEFBiI0RupoFehRQPUfJdlsge1825Nj1rzc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=bMYtbLNxMw6t3e7Pv3BJMhSOdeePWShpM68U0xAbUMVt38DMjokFC2AfayZConNReU oz05oYMFeE1osn9hF/I/ln7JVKe7NgTqw71D29P/YZJwxqH6Hbjrvp7Q8SYsJXIypAd7 5cBVXFeGT4YlR9eUOnwSpqICNNy7StLnsL5/CK4R9tmeYRnxcvX4uoqDAY1Fp1DM5JMV O/BH38S4WeSfRRBKvN+dikO/roLBbOWB6gWbWLoWRiWhGsmuq8ypjfNAKZQTaoEgiuKR eomQKqmg5aP+WGGCss0nYDcEvkLFVFAqJiv9jwhTUf0P9LKxiL8g9e9FoJxN2r+O2UXc oZeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=TbqcsnE3; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-537a85e0c25si1547091e87.12.2024.09.25.22.59.21; Wed, 25 Sep 2024 22:59:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=TbqcsnE3; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D8C6D68DB65; Thu, 26 Sep 2024 01:52:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 12F9C68D9D9 for ; Thu, 26 Sep 2024 01:52:16 +0300 (EEST) Received: by mail-ua1-f48.google.com with SMTP id a1e0cc1a2514c-846bcf3677dso127951241.1 for ; Wed, 25 Sep 2024 15:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727304733; x=1727909533; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HLpiy3l/Th9pry4+BE0mFi+7fuAFEbjOUN73VvyPHl8=; b=TbqcsnE3urYP6peOqvqt+XZvzqT35JP176MfBYQFsL0GlY6czJ9pLapd+UUEYuaOi7 2SHmfrVXmmp9NzkT3MFBSY/4Cr6wnjBW574r52z92fMznFSCNrkF3Kg2a9X9SkcEcwPZ +ytBfccMXTB6WS/ggwucQth6T2r4fqL5a/PTXj5XoYOSTnU0pPuf84ksqsqU1YSqtqRM KzXP/dEvH4fqUFwaftpHDliMgP6jCBOBr6gQ6vcsbhZh+it8aPs/NwJvt8LH5JC5xRVN jMYv//yz2o3pZI5jMJ9mlJgNVtGgz5st7a9+hSLzeV9B6fWDl+KHurrjx3mAIX8GSlEK J2Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727304733; x=1727909533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HLpiy3l/Th9pry4+BE0mFi+7fuAFEbjOUN73VvyPHl8=; b=glBCmav8Fq2dXjNJSKjR8Uflz7K6YY/FaF9RTs0qkhuAZdue6Sh55GuLqjsPyLqccA TIaouc0yBPgz90bQpoEJnAgc14g3wqMnxhEDH4cE8LDb81IDSK7IyF8WjIW4ps5QCyoG +QzOVo6bw5LMwxdnzSJz0oZd7WQ1+qr7aSLB8UST56Q/xnl1kMEB2yOfjqcTc5KH+MBl wVqkUX4l2Qa4RjoF7PUEQ5pTmuzWhefl8d092Jk82wKMep2SE+Fay4TGRA2/jEHJLtPi LjaUbA2PdaznBntiWUueH8KnhX3JZkQGpRvpQI5qiUYYYFe3cJCb54c3d+jrqnsCS47r 6wdA== X-Gm-Message-State: AOJu0Yxj5tuaCg5tvrANdnV3WC4y3YPp6GAsOYiY0ByaVkai+p/LVbQt cSMdTWuDA9aAmdzpL/o6vzocZUhFCzeJj7HNOqbUAu06cAuEW0mWMcK3AQ== X-Received: by 2002:a05:6102:2acd:b0:493:c092:ea15 with SMTP id ada2fe7eead31-4a15dd237bbmr4632901137.22.1727304733552; Wed, 25 Sep 2024 15:52:13 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4a1517c0e44sm2848945137.16.2024.09.25.15.52.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 15:52:13 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Sep 2024 19:52:17 -0300 Message-ID: <20240925225219.3060-2-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240925225219.3060-1-jamrial@gmail.com> References: <20240925225219.3060-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avformat/mov: add support for auxC box 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PqhvFW7sGQ7A It's used to signal an item is an auxiliary image. Signed-off-by: James Almer --- libavformat/isom.h | 1 + libavformat/mov.c | 47 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 4723397048..5076bc5da7 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -285,6 +285,7 @@ typedef struct HEIFItem { int height; int type; int is_idat_relative; + char *aux_type; } HEIFItem; typedef struct HEIFGrid { diff --git a/libavformat/mov.c b/libavformat/mov.c index a2333ac1fd..bd502d489a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8929,6 +8929,43 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_auxc(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVBPrint bp; + int64_t size = atom.size; + char *aux_type; + int ret; + + avio_r8(pb); /* version */ + avio_rb24(pb); /* flags */ + size -= 4; + + av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); + ret = ff_read_string_to_bprint_overwrite(pb, &bp, size); + if (ret < 0) { + av_bprint_finalize(&bp, NULL); + return ret; + } + + size -= ret + 1; + if (size > 0) + avio_skip(pb, size); + + if (ret) + av_bprint_finalize(&bp, &aux_type); + + av_log(c->fc, AV_LOG_TRACE, "auxC: aux_type %s\n", aux_type); + + for (int i = 0; i < c->nb_heif_item; i++) { + if (c->heif_item[i].item_id == c->cur_item_id) { + c->heif_item[i].aux_type = aux_type; + break; + } + } + + return 0; +} + static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) { typedef struct MOVAtoms { @@ -9157,6 +9194,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('i','s','p','e'), mov_read_ispe }, { MKTAG('i','p','r','p'), mov_read_iprp }, { MKTAG('i','i','n','f'), mov_read_iinf }, +{ MKTAG('a','u','x','C'), mov_read_auxc }, { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box */ { MKTAG('l','h','v','C'), mov_read_lhvc }, { MKTAG('l','v','c','C'), mov_read_glbl }, @@ -9677,8 +9715,10 @@ static int mov_read_close(AVFormatContext *s) av_freep(&mov->aes_decrypt); av_freep(&mov->chapter_tracks); - for (i = 0; i < mov->nb_heif_item; i++) + for (i = 0; i < mov->nb_heif_item; i++) { av_freep(&mov->heif_item[i].name); + av_freep(&mov->heif_item[i].aux_type); + } av_freep(&mov->heif_item); for (i = 0; i < mov->nb_heif_grid; i++) { av_freep(&mov->heif_grid[i].tile_id_list); @@ -10149,6 +10189,11 @@ static int mov_read_header(AVFormatContext *s) if (item->item_id == mov->primary_item_id) st->disposition |= AV_DISPOSITION_DEFAULT; + if (item->aux_type && + !memcmp(item->aux_type, "urn:com:apple:photo:2020:aux:hdrgainmap", + strlen(item->aux_type))) + st->disposition |= (AV_DISPOSITION_GAINMAP | AV_DISPOSITION_DEPENDENT); + mov_build_index(mov, st); }