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 12F6249A37 for ; Mon, 27 May 2024 13:33:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2403768D4BE; Mon, 27 May 2024 16:33:37 +0300 (EEST) 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-Google-Smtp-Source: AGHT+IHnpcBhQWNbR9LNeqWVF8r5Z7WeXCbEHRfFwy6KmGc9hPEb0iNQy1G9/NIsHiv2b68WCuALPA== 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" 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".