From patchwork Mon May 27 13:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hacene Bouaroua X-Patchwork-Id: 49293 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp3267371vqf; Mon, 27 May 2024 06:33:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUj8haBdll8bG4HMrrH9gYxij5lzILE2dge/CZPtgrdVkYqF5bK0LHt5aPxIKKsOwhH9PYEgS2uFIWOl2bNcq3vZDCjfR11D+mRRQ== X-Google-Smtp-Source: AGHT+IENJWjnRI8UZFz4cpXzEVi1sQZw67M4TRpGOxXbCyGBOc5F+bciuxi77YWDZ9o1G0QjjLFI X-Received: by 2002:a17:906:174f:b0:a61:8c98:88c8 with SMTP id a640c23a62f3a-a62642e2b49mr602046466b.2.1716816821263; Mon, 27 May 2024 06:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716816821; cv=none; d=google.com; s=arc-20160816; b=YxLTt2fxAlGEIYX0VeqP/wkJWf4spZSrtlf1dLAEM3QrL3pCLklusmqSwHoHfAlcTR PeqT+wuMDr8hIvmhEIXXyPmmrcLZoH7VoLLIBDAdH3BZ1G6weH2mTcTvvGVxOMu4pu9b 95Q4tJlt+R9kmA8m0ZRQWhauZwX1qAbFXs6pcidnLCrh2sbFFg3Ue/qUKLLB9By2h1/E f8ZXrVgpd7zTcQrNgH7vIoNv2MYexTmuu8/vh64STa90j5En+dpf5p2mrozN01Uanc8d lF6YhjVZoB1jgYJgnMG1XD/kloLlbTBq8GQk/HBQpEzy5csqJYi01tYyz4NCTkiXyvtW xBqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:to:user-agent:mime-version:date :message-id:from:dkim-signature:delivered-to; bh=mr1MfgI3QQ0xx+hnCYaxuLf4Ga2BFkj9P7+WLI6d5Ck=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WK9zUDsqIt+gT2jK5Q6JGlop9uztKZAwBAqMyXRM7u3eDj+rJth3oMMCzrHtc4Az07 xVqdTo6QzKQUosigUY3J3TW/e8H6dq8hwoq54HAxxl64YHXUnFNe5CJSzaF75rL6JoS9 3RggFLB9A74Lxo/ChQnVNshY296EnpzwXKW8vUUlOJVDsDsKq7zRpgZDucvDuCeVhLHy 0uOUkyiL4CmDDuZ+pgG5OI1P+1zC5NEvinq5BgcgfnKhS/yEW7SGQDrs8xs2A8rgw5Bx +9fhMAqE7ru9Ph1+2ASvQpE1Y2qBM+0UbUKp6DYLH5b8CXaGiWlHL+0E8//ZqGFkAiKZ UW5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@freebox-fr.20230601.gappssmtp.com header.s=20230601 header.b=jrFY66td; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a626c80170dsi400839266b.131.2024.05.27.06.33.40; Mon, 27 May 2024 06:33:41 -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=@freebox-fr.20230601.gappssmtp.com header.s=20230601 header.b=jrFY66td; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8684668D4C3; Mon, 27 May 2024 16:33:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D46B868D29F for ; Mon, 27 May 2024 16:33:30 +0300 (EEST) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-354e0cc9c5cso4808445f8f.0 for ; Mon, 27 May 2024 06:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebox-fr.20230601.gappssmtp.com; s=20230601; t=1716816810; x=1717421610; darn=ffmpeg.org; h=content-transfer-encoding:content-language:to:subject:user-agent :mime-version:date:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=JSKL4X4wfhShXh25KPna+TveMYXuKMpS0mbOirW8wnk=; b=jrFY66tdZjRAY7EsuWXnMUFg8cmb0okTeYkbtBoF6LMCNn35mJa3iGSbu3+VRxcNKD niR7UO6wp1T3gu2GZQKiNwUlUCvSRAFNXQNNdB33zubu5XVypx1n26d35kj761RjLegP orJAIijSHHeWUawf9H2WDPG9MJwFW+zyqnzOQtkU6wupJF1VZXZFhuQsOVfT656UHAoC 92sQ5mAVDLAjkSHRFhzze0R12XNtgH8uPK4nJD5JKg14YuVykJhf8C6LdQbKcEmCCdTI PAHJpcARN24fpWXvCaOijO/n5JuQGUgvAQKh2lOhx93KOwYuAt6zk8fs4bK8McrVnhHO R58g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716816810; x=1717421610; h=content-transfer-encoding:content-language:to:subject:user-agent :mime-version:date:message-id:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JSKL4X4wfhShXh25KPna+TveMYXuKMpS0mbOirW8wnk=; b=CpEIMbQehOdsyvKQ8TIS00qSTURN3DEBXqbnileSWxwLmxc23MKUwmwcVL9AgOhpuQ bjsz6uQHvZHun5RjbXuhgE82vQtJtsmCPLl6Y3KHmO6bAD1Dc2ojMaoz8ZO3rkklw45x VxjAf9DTO1AL4uhptPgKZtHhH+U0WaLSxp0y2lehkLMpVAwD20RhJ2NKozxeTR0HN/Vj Jq9VblYL51EdCwedueNctoWlmC0PJZ31vaGlsJ33YkecaH7VJYPXVdW7eTxBqkQ8+49C JBOUSkure5JWT/SCi05dsLWJc5JuvUV+inXdIjfnT4D48SRHjhZx56JSnk7n7o3tPxus OFYg== X-Gm-Message-State: AOJu0Yx/8zXWaa9jO///0vZXZxTG0/kE0gMAKA9pu3aovnpHV5YgGIra FkkHa4+Wxu2cVvSsU4u8Y9swLI2xhfrUXzIvsaM5sMoSdl5ghb7zCSOkBVzO37tnOcEM57/UXnf aj5w= X-Received: by 2002:a5d:4485:0:b0:357:7ae3:2de4 with SMTP id ffacd0b85a97d-3577ae3329dmr3766176f8f.26.1716816809800; Mon, 27 May 2024 06:33:29 -0700 (PDT) Received: from [192.168.108.115] (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3557a1c9363sm9099839f8f.72.2024.05.27.06.33.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 May 2024 06:33:29 -0700 (PDT) From: Hacene Bouaroua X-Google-Original-From: Hacene Bouaroua Message-ID: <70b25af0-40fe-4aee-a5db-7be5050e0dc2@freebxo.fr> Date: Mon, 27 May 2024 15:33:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] avformat/mov: get heif image rotation from irot 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: 4MNqlYWqnDhw parse irot box to get the transformative heif item rotation angle. Signed-off-by: Hacene Bouaroua --- libavformat/avformat.h | 5 +++++ libavformat/isom.h | 1 + libavformat/mov.c | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+) { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box */ @@ -9315,6 +9337,9 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid, tile_grid->width = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); tile_grid->height = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); + /* rotation */ + tile_grid->rotation = item->rotation; + av_log(c->fc, AV_LOG_TRACE, "grid: grid_rows %d grid_cols %d output_width %d output_height %d\n", tile_rows, tile_cols, tile_grid->width, tile_grid->height); -- 2.34.1 diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8afdcd9fd0..615650ddcb 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1077,6 +1077,11 @@ typedef struct AVStreamGroupTileGrid { * final image before presentation. */ int height; + /** + * the angle which the reconstructed image is initially rotated + * (in anti-clockwise direction) in units of degrees. + */ + int rotation; } AVStreamGroupTileGrid; enum AVStreamGroupParamsType { diff --git a/libavformat/isom.h b/libavformat/isom.h index c0a5788e08..757e3f8738 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -277,6 +277,7 @@ typedef struct HEIFItem { int64_t extent_offset; int width; int height; + int rotation; int type; int is_idat_relative; } HEIFItem; diff --git a/libavformat/mov.c b/libavformat/mov.c index 45eca74d1d..5f04e68f88 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8398,6 +8398,27 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + uint32_t angle; + + angle = avio_r8(pb); + + av_log(c->fc, AV_LOG_TRACE, "irot: item_id %d, angle %u\n", + c->cur_item_id, angle); + + for (int i = 0; i < c->nb_heif_item; i++) { + if (c->heif_item[i].item_id == c->cur_item_id) { + // angle * 90 specifies the angle (in anti-clockwise direction) + // in units of degrees. + c->heif_item[i].rotation = angle * 90; + break; + } + } + + return 0; +} + static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) { typedef struct MOVAtoms { @@ -8615,6 +8636,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('i','d','a','t'), mov_read_idat }, { MKTAG('i','r','e','f'), mov_read_iref }, { MKTAG('i','s','p','e'), mov_read_ispe }, +{ MKTAG('i','r','o','t'), mov_read_irot }, { MKTAG('i','p','r','p'), mov_read_iprp }, { MKTAG('i','i','n','f'), mov_read_iinf },