From patchwork Thu Sep 26 14:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51890 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d8ca:0:b0:48e:c0f8:d0de with SMTP id dy10csp812069vqb; Fri, 27 Sep 2024 22:11:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXep7Ycw/LegQD2/gU6m+GyNpWRv2dFPMmGVXij3f0PVqECpNx2cjdVIfRU2fIy7PN1/rHkiRaRbPgrIsDaDgMk@gmail.com X-Google-Smtp-Source: AGHT+IFSA5YKb3R0YB0CuSHvq+K/XU6ViOaKmr3Yk2sXzZHGrwAdpjEdWn7woD2sZ+AjSF7UpM+m X-Received: by 2002:a05:651c:2228:b0:2f6:43fd:f870 with SMTP id 38308e7fff4ca-2f9d4197bf5mr38525671fa.31.1727500271065; Fri, 27 Sep 2024 22:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727500271; cv=none; d=google.com; s=arc-20240605; b=MJ+OUozXK3KhALI4vyGxsaQXILYWClbfipT0UqG0EZczRItEBRuk27V51nF7vYZ3cW dN+GJ3r4CqY1bB4dtAGFRuhN7tq+7msU4k+PeEv/CxobxN8rjOs+dbfcOQUzgAfN/j/D /qTlZHoBRCsEPckaFD+v+FQJLxKP5Z8XdX1VVYTO5d2VNsqh66Dsz3g3QiUzZLEJ33kW SGz4oawmZxzXfF+pIO9FbjeILmFZM95y9BRjw8O1rImNDxsatOE5nr7WMIfOpCkaT5M2 oZfSQeoj8CDkV5UIBax7+GKVNeyZnpXc4NJbYkmfuMvH8+lDDnB5O3Gs8mCcaBLf5ISI uYfQ== 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=cT+l3BYoW2V/TWwTiBZxWoDID7ry+HysOG1Z4YpVUC0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=JzunQzOTZFjKGj/zc9mXLv1uXIVeXSo4t92R3fzNf/5YE67Pm3Bbew/3ps2c5rHZuz jM8oz6kcDwdHk97269NhtU8D3xMaqD0ELrMtua9wU2difsBl0ZF3ajH7VxwIu3gST5XQ QeCTX0ppBV3auaI7z8HT31gwyXcHDAYf6wcBmmyWWhzQ1+w47VdDy5ecoHFjQ/VRbgxU om3x8P+KBTRDk3Ld0/O8TZA7LPXYgnx4DDJ+PTJJyKPtoWSY3MSiwaENS2sSUdL8WWKJ 8LoB8yCUccvs98xipq8iB0wlTgS53GVsJdS6gDQtQnLFdxRom8s5eilui3i77BMfcilp CcgQ==; 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=kwd7J6Ai; 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 38308e7fff4ca-2f9d45c77cbsi11115421fa.89.2024.09.27.22.11.10; Fri, 27 Sep 2024 22:11:11 -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=kwd7J6Ai; 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 914DD68DCF3; Thu, 26 Sep 2024 17:33:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0240668AA25 for ; Thu, 26 Sep 2024 17:33:21 +0300 (EEST) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-205722ba00cso9788535ad.0 for ; Thu, 26 Sep 2024 07:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727361199; x=1727965999; 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=/WlLTJO/CpIWkU3TR2hHsZuLQ8bn97mXpQpnwalw5dw=; b=kwd7J6Aioswkz/2LT9HOe96W3MayXH2fjBARs9SZcsRNnck3tRrU9SOOtoSfSIaEFO 0fhZeXI/vQqjM0ScNPAvtph5pofVkzW3HWXQ/FTLuYid+QbeoyUY/17dMsPvaXAOq+61 HXM1jixPle1ZtySN90QKzoUMq5k6djJfPaJTesvB7RGt2Odro2rliIUm7QoxiIxX5b1L RYgBe89gdt4myVIPp9OYlRM12qH+JUY8+c73hVxWdLvYG4R9y+VlnKHBzoz5GjUpktZD 4s0lSHVgcUKOJ4mB0kCMO/ERjfa3SWhGtut2UDKFxBsO7E+m/oVSQY+qLquGkzKhlPFZ sFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727361199; x=1727965999; 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=/WlLTJO/CpIWkU3TR2hHsZuLQ8bn97mXpQpnwalw5dw=; b=Ms7ag9IvD+VVnJmuZa4Bsi3sGXwKpRlJvWt+s5q/0iaueM3E1EY6I+ePladXPpWJs+ gOQzPcSbLaAqsEkrfYFr6lKDb41s8yuKqxbRdZoLob6V7HBUet2gb9tMWAekqcliY5Br WNGm8QmK4fd+QZOhO6HJWXLxf7q2CIOtItBzH3hssNZf5eo1H4VP0btU71HkOmGbjaxD bGEf2Kn3OG0eWSJ9h6MkKIxD4n7kEvCF7YH370seHxWdVsgN1CJiAhAO0dmvLBanhQXE lYW2n7ZlZb24PXRZk87wbiw0Xv/4t0DaNY7nDzdyNnFVhbtSs8sT4nYzaVs2DMDonuzB aTUw== X-Gm-Message-State: AOJu0YyHiPeNpUU2xhxwNlUGTcyAYd7xJpJVB60UVW02nL8t+vRMydtN cEo2PbzYol9bun1MSu0afTVfw7d7wXeT8wvZHQWWeIaV6OK/ib93mJIOPQ== X-Received: by 2002:a17:903:3210:b0:207:7952:e6d4 with SMTP id d9443c01a7336-20afc42e64fmr63707795ad.4.1727361198890; Thu, 26 Sep 2024 07:33:18 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af1850674sm39331845ad.243.2024.09.26.07.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:33:18 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Sep 2024 11:33:48 -0300 Message-ID: <20240926143348.1935-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <172733049331.13000.9111838463024633754@lain.khirnov.net> References: <172733049331.13000.9111838463024633754@lain.khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/mov: add referenced thumbnail streams to tile stream groups 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: MHOEy0UlKGc0 Use the reference information present in iref boxes of type thmb to include the relevant streams into a Tile Grid stream group. This does not yet export the relation of a thumbnail and an independent stream (not a grid). For this, a new Stream group type would probably be needed. Signed-off-by: James Almer --- libavformat/dump.c | 9 ++++-- libavformat/isom.h | 3 +- libavformat/mov.c | 71 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 64 insertions(+), 19 deletions(-) diff --git a/libavformat/dump.c b/libavformat/dump.c index 5178f19685..ba30b92aaf 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -784,11 +784,16 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, dump_disposition(stg->disposition, AV_LOG_INFO); av_log(NULL, AV_LOG_INFO, "\n"); dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO); - for (int i = 0; i < stg->nb_streams; i++) { - const AVStream *st = stg->streams[i]; + for (int i = 0; i < tile_grid->nb_tiles; i++) { + const AVStream *st = stg->streams[tile_grid->offsets[i].idx]; dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE); printed[st->index] = 1; } + for (int i = 0; i < stg->nb_streams; i++) { + const AVStream *st = stg->streams[i]; + if (!printed[st->index]) + dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE); + } break; } case AV_STREAM_GROUP_PARAMS_LCEVC: { diff --git a/libavformat/isom.h b/libavformat/isom.h index 5076bc5da7..1cf69ed042 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -279,6 +279,8 @@ typedef struct HEIFItem { AVStream *st; char *name; int item_id; + struct HEIFItem **ref_item_list; + int nb_ref_item_list; int64_t extent_length; int64_t extent_offset; int width; @@ -360,7 +362,6 @@ typedef struct MOVContext { int nb_heif_item; HEIFGrid *heif_grid; int nb_heif_grid; - int thmb_item_id; int64_t idat_offset; int interleaved_read; } MOVContext; diff --git a/libavformat/mov.c b/libavformat/mov.c index bd502d489a..8a257ba535 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8844,23 +8844,55 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version) return 0; } +static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, + HEIFItem *from_item) +{ + HEIFItem **ref_item_list, *to_item = NULL; + int to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); + + for (int j = 0; j < c->nb_heif_item; j++) { + if (c->heif_item[j].item_id != to_item_id) + continue; + to_item = &c->heif_item[j]; + } + if (!to_item) { + av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); + return AVERROR_INVALIDDATA; + } + + ref_item_list = av_realloc_array(to_item->ref_item_list, to_item->nb_ref_item_list + 1U, + sizeof(*to_item->ref_item_list)); + if (!ref_item_list) + return AVERROR(ENOMEM); + to_item->ref_item_list = ref_item_list; + to_item->ref_item_list[to_item->nb_ref_item_list++] = from_item; + + return 0; +} + static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) { + HEIFItem *from_item = NULL; int entries; - int to_item_id, from_item_id = version ? avio_rb32(pb) : avio_rb16(pb); + int from_item_id = version ? avio_rb32(pb) : avio_rb16(pb); - entries = avio_rb16(pb); - if (entries > 1) { - avpriv_request_sample(c->fc, "thmb in iref referencing several items"); - return AVERROR_PATCHWELCOME; + for (int i = 0; i < c->nb_heif_item; i++) { + if (c->heif_item[i].item_id != from_item_id) + continue; + from_item = &c->heif_item[i]; + } + if (!from_item) { + av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); + return AVERROR_INVALIDDATA; } - /* 'to' item ids */ - to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); - - if (to_item_id != c->primary_item_id) - return 0; - c->thmb_item_id = from_item_id; + entries = avio_rb16(pb); + /* 'to' item ids */ + for (int i = 0; i < entries; i++) { + int ret = mov_add_ref_to_item(c, pb, version, from_item); + if (ret < 0) + return ret; + } av_log(c->fc, AV_LOG_TRACE, "thmb: from_item_id %d, entries %d\n", from_item_id, entries); @@ -9718,6 +9750,7 @@ static int mov_read_close(AVFormatContext *s) 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[i].ref_item_list); } av_freep(&mov->heif_item); for (i = 0; i < mov->nb_heif_grid; i++) { @@ -10074,6 +10107,17 @@ static int mov_parse_tiles(AVFormatContext *s) if (!loop) continue; + for (int j = 0; j < grid->item->nb_ref_item_list; j++) { + AVStream *st = grid->item->ref_item_list[j]->st; + + if (!st) + continue; + + err = avformat_stream_group_add_stream(stg, st); + if (err < 0 && err != AVERROR(EEXIST)) + return err; + } + switch (grid->item->type) { case MKTAG('g','r','i','d'): err = read_image_grid(s, grid, tile_grid); @@ -10128,7 +10172,6 @@ static int mov_read_header(AVFormatContext *s) mov->fc = s; mov->trak_index = -1; - mov->thmb_item_id = -1; mov->primary_item_id = -1; mov->cur_item_id = -1; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ @@ -10161,10 +10204,6 @@ static int mov_read_header(AVFormatContext *s) int64_t offset = 0; if (!item->st) { - if (item->item_id == mov->thmb_item_id) { - av_log(s, AV_LOG_ERROR, "HEIF thumbnail doesn't reference a stream\n"); - return AVERROR_INVALIDDATA; - } continue; } if (item->is_idat_relative) { From patchwork Thu Sep 26 14:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51908 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d8ca:0:b0:48e:c0f8:d0de with SMTP id dy10csp909080vqb; Sat, 28 Sep 2024 03:31:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVQR960VkFdcE8wFtRutdept5zSmFVatFPf785Amq9gRJMJcuKrmM+V6si90hAsSRq2G2N9xITO/7PzEMDmyyBo@gmail.com X-Google-Smtp-Source: AGHT+IEos8W/DP+L9ol+Pgg0XSvS1oY32bOD7wpTVUAcX2DXGdk4GYD5pZ5cMXWg3vlRBxnpmD7u X-Received: by 2002:a05:6402:90e:b0:5c7:18d3:633f with SMTP id 4fb4d7f45d1cf-5c8824d5ebbmr5619574a12.10.1727519473813; Sat, 28 Sep 2024 03:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727519473; cv=none; d=google.com; s=arc-20240605; b=NUQV/OoZYrLvE0KiVx+fXadgOe40De3hKYLGNtlUZMo6xnsLVQ2KCdX2WPIJslP78i UwWkSdExwrMc+VMmDjSpW1z8UfNOKSS6A9wrhLWbklmuyb3PzKML2Io0gAvpRFSQbqpv uN/hrz8WTjFSCi8q+UksCJY1EQ7tr1UnrVbX4e8CtsE/sAfjlZkZHBKZePYRShJxfL4M DjtXtl6/kSqXqSBuhkmWiIT5kpK1X5AnZq9w3cEx8MkZstFKnuQOKaM/3RSJJYuThw6v JnBorDF9JGitI+KxRmlE0UGKHOhLIRUlmo39cPoveLmWkvjAlw9dK5pqm8VNT359l4sU SlAw== 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=6zaRwNKdigHU+Znis0HMFS4qiUNGY1AfscNMJK18k+4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=QKBhruZ5fImBdD7p/H+Qhb8aclcOT0jpd0+khmCF9EClfYikcl3gzTP/IHrL7i41Vl iTdEYwWBhDBnOOMGaCA5pRMRhdgiF6FkR95B9h0PGrsc4B6MVbTyCIYR5bYGofKmGFV8 wMN/pImWXCspqO1ztZlt8EzCKk3/L0vYjXSkseld5go/5DGF5iD9aA5BIXlzMD8uaMVH qX3sZbCzMRFL6lbt+xA1xTgPDCChcwgcGmKPmwPMLCL0Di4gaaoq2cR0feSKEPMfqEB/ 2LaVuVPtFP8u0zQI6U29d0qTVT0lR/pavsqRFTgf01jqfomNj2ZVNGoEgJ0G37YyXTZ8 bOiw==; 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=NBXlWreo; 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 4fb4d7f45d1cf-5c88240819dsi2902318a12.84.2024.09.28.03.31.13; Sat, 28 Sep 2024 03:31:13 -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=NBXlWreo; 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 4E71568DD12; Thu, 26 Sep 2024 17:34:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 714AF68D97E for ; Thu, 26 Sep 2024 17:34:08 +0300 (EEST) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-206b9455460so7662355ad.0 for ; Thu, 26 Sep 2024 07:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727361246; x=1727966046; 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=ULc+ddP8lkZo8NBQpSszOW++EsFysNEDp66O+Uje9z8=; b=NBXlWreo6lPKOE8a5Bn8LEwhr5BDFB3wloe/tW+rIrTFFApL49teGWkmdOKEdriC7f 47rDt+wgH3u3Z7X5pFEf5l/f0UZ98FAobGpyUtSPkbSUFSEwk9DAIex6Nl4DcP+qAym2 tXngpfLjVDPbHDFy4etkWT7pcWPjc26cabBtW8aLC4gjEsQdjQxlIXg6gSnC/+ZVmV/N NC1mkkrq1brM3CQuRdm2qnJlTDr+pln9W1rQ7+bWlvIuwd1tKIRjg7kd789hbxVzlMFB Sc7jQknVIzdEnedv/M4q9ljgpd4a/A68xIHyfoPSKHbvRoCf7TjDj0hI41y6tuEWrHMK z9mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727361246; x=1727966046; 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=ULc+ddP8lkZo8NBQpSszOW++EsFysNEDp66O+Uje9z8=; b=l5orUFunO/gkNQLNBP6wFUkc0WyZPCCxgKOfeu32jQt/jnS70eQIV5h35x2V7WPFtv g9xSsWcGuOziBqnGoonVPw6kU5q+bbMEmI+jEpaC3Dtad5W2rCWZrJ18l5+fJlS3htNd pFa+jEmbtPMVHQ45Lhbn5JwcKDAJ7t2Ycipfousj1w6fUi7E+VS6/XNm1LdwrKgbcY7e WTG8PzB73FE1g5bM9BIX+TnPqOhb/VJFXzQgt4LDFH6LhxvtsspBXNmlNQENg+PsXEsv UJH0FfNk5Np8bTo0KQEiHp0lMnNojFbQ0m0V1vY+jH9ebv6Ax4MW4U91gVkbCyS5MVnc 1FAA== X-Gm-Message-State: AOJu0YxGGfI5tlEOZ8aC5k+h//tVDAT2PDXQzcB84s+nsYbSM3TZECC5 6VF45SLOStj7aDAJ3d9kVHf9ZG5IbLa4kmESx1XkjJq92ajpAlTcmMsI0A== X-Received: by 2002:a17:902:cec2:b0:20a:fd4e:fef6 with SMTP id d9443c01a7336-20b19bd86f1mr50289305ad.8.1727361246160; Thu, 26 Sep 2024 07:34:06 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b02566edfsm24976755ad.87.2024.09.26.07.34.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:34:05 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Sep 2024 11:34:36 -0300 Message-ID: <20240926143436.1946-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <172733053331.13000.16432068133101552247@lain.khirnov.net> References: <172733053331.13000.16432068133101552247@lain.khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/mov: support parsing auxl iref type 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: bFGiBTqyn42f Use the reference information present in iref boxes of type auxl to include the relevant streams into a Tile Grid stream group. These streams are "auxiliar", which can be things like separate alpha planes and HDR gain maps. This does not yet export the relation of a said auxiliary streams and an independent stream (not a grid). For this, a new Stream group type would probably be needed. Signed-off-by: James Almer --- libavformat/mov.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8a257ba535..f1274392f3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8844,8 +8844,8 @@ static int mov_read_iref_dimg(MOVContext *c, AVIOContext *pb, int version) return 0; } -static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, - HEIFItem *from_item) +static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, uint32_t type, + int version, HEIFItem *from_item) { HEIFItem **ref_item_list, *to_item = NULL; int to_item_id = version ? avio_rb32(pb) : avio_rb16(pb); @@ -8856,7 +8856,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, to_item = &c->heif_item[j]; } if (!to_item) { - av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); + av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n", + av_fourcc2str(type)); return AVERROR_INVALIDDATA; } @@ -8870,7 +8871,8 @@ static int mov_add_ref_to_item(MOVContext *c, AVIOContext *pb, int version, return 0; } -static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) +static int mov_read_iref_generic(MOVContext *c, AVIOContext *pb, uint32_t type, + int version) { HEIFItem *from_item = NULL; int entries; @@ -8882,20 +8884,21 @@ static int mov_read_iref_thmb(MOVContext *c, AVIOContext *pb, int version) from_item = &c->heif_item[i]; } if (!from_item) { - av_log(c->fc, AV_LOG_ERROR, "thmb in iref references a non-existent item\n"); + av_log(c->fc, AV_LOG_ERROR, "%s in iref references a non-existent item\n", + av_fourcc2str(type)); return AVERROR_INVALIDDATA; } entries = avio_rb16(pb); /* 'to' item ids */ for (int i = 0; i < entries; i++) { - int ret = mov_add_ref_to_item(c, pb, version, from_item); + int ret = mov_add_ref_to_item(c, pb, type, version, from_item); if (ret < 0) return ret; } - av_log(c->fc, AV_LOG_TRACE, "thmb: from_item_id %d, entries %d\n", - from_item_id, entries); + av_log(c->fc, AV_LOG_TRACE, "%s: from_item_id %d, entries %d\n", + av_fourcc2str(type), from_item_id, entries); return 0; } @@ -8924,8 +8927,9 @@ static int mov_read_iref(MOVContext *c, AVIOContext *pb, MOVAtom atom) case MKTAG('d','i','m','g'): mov_read_iref_dimg(c, pb, version); break; + case MKTAG('a','u','x','l'): case MKTAG('t','h','m','b'): - mov_read_iref_thmb(c, pb, version); + mov_read_iref_generic(c, pb, type, version); break; default: av_log(c->fc, AV_LOG_DEBUG, "Unknown iref type %s size %"PRIu32"\n",