From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4A68E49A3D for ; Mon, 27 May 2024 15:22:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2BEC468D499; Mon, 27 May 2024 18:22:15 +0300 (EEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E9B3568D084 for ; Mon, 27 May 2024 18:22:08 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so22335105e9.0 for ; Mon, 27 May 2024 08:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebox-fr.20230601.gappssmtp.com; s=20230601; t=1716823328; x=1717428128; 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=hR4XcqDXrRFaKq0ve0fgZVggGYJIgmY37qR7diBo4A4=; b=PAZnSvOQ61tx1gIXWock4MuHks9ZerWARUeLnQxPxCrxdprDx9vr7O0mLe69pdAg0m pyc8yG5K2tFK+UYWApKese65CTjg3BvBtcKCg76AiGnuQrkTE/fe9zh/Cb2m/uKIB6Sw 5bqodCX65cgwlEojJ3n5ldQ6MmFchOlP3j0jHQSZgpRNJHP8wdqfQaSAkVGtyeTpF11D 9HnHqQpuCzrvFhqrEDm3+dUzVdn+mMsH7CSd9+QQnPcoulMDepgv2qXIBqXZqhwPvlzT pdTDV7FE5eozj/lok/wsPW1j+vXTaNSbVX2u7O123JigEF91pACu6fAhMg8sVp4DrQ8r hqGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716823328; x=1717428128; 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=hR4XcqDXrRFaKq0ve0fgZVggGYJIgmY37qR7diBo4A4=; b=apLEkwpxCp3xvr2tMJV816KEFBPXIFT+Pi/LUxNnYeNCjaTl0TAcBdZwO/KG+sn9/u J6vJYc1eP4JatpNB412mexPcX2MgWkvKlt/Yi7Z6ALtlimsa1WEzsLn+sAuo3EvzJLbK 4m+wb86YnoZlMaQ7boWKfJo8mAjn08dvcyNnIGs5PQRpS1JbcSUaZ3tou3brJEi/KmH8 T362cq8/WECCSc8L6pN+vvs/X2kIFU2OxaQ3v4IsWlIV4czfCq2H02uCe2CNyVNuwerF qYLZSyJ6eF0zbWUFNU/8WEyfyWGN15XjyeEpKDinoAJSSKvUnrWDlj868xUvuJpz7KkI sCWA== X-Gm-Message-State: AOJu0YwTqdt3GrlFpSlKAc/G/DI27sAB7itD3RclddWeKNWiOU47sVLP fCnjZiyrNgss22G3q9Xm8RDn45D/3oyiuJJAg04XHfL+qWnlt9KzIIOTJCCh0RXLF5XI1UX66Q9 9c44= X-Google-Smtp-Source: AGHT+IHxLVlVgCkZ88pwwdZOhuWw2SDSWhqp1eo1RH2EAJf/Jk6Y6RCrJ/blJmHwOTfs4gNFcmyC7Q== X-Received: by 2002:a05:600c:5593:b0:420:2b2e:f6e7 with SMTP id 5b1f17b1804b1-42108a79034mr78932555e9.17.1716823327919; Mon, 27 May 2024 08:22:07 -0700 (PDT) Received: from [192.168.108.115] (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4210896676bsm113392725e9.4.2024.05.27.08.22.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 May 2024 08:22:07 -0700 (PDT) From: Hacene Bouaroua X-Google-Original-From: Hacene Bouaroua Message-ID: <1c939e57-2c6e-412e-b453-25f88ae29057@freebxo.fr> Date: Mon, 27 May 2024 17:22:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH, v2] 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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(+) 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 }, { 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 _______________________________________________ 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".