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 D46394841E for ; Mon, 1 Jul 2024 15:37:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E5A0868D7F5; Mon, 1 Jul 2024 18:37:30 +0300 (EEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44EF168D785 for ; Mon, 1 Jul 2024 18:37:24 +0300 (EEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-70679845d69so1932336b3a.1 for ; Mon, 01 Jul 2024 08:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719848242; x=1720453042; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=s02LMsxjn5x6rqmUB/6O6DcfNTfvtSOpuMWO8BbXl0Y=; b=geUrJVqjnlA25cltcxapcJo2XBr97HFkhPGZ0Tf+VU+JGzS7QnprcRqbPCGNHtKycv ZxMUvhf3WrVbO/UxM49BErsE/T1o+ylJH9qt8tVZN8oVHcp+TLbXXFR9N52zi595YINM QGDhAEdqCqWh8o5l3TpubnMZAxqihmaYiCqPuccvEBDw2P0xaWmTlwIH7XmN/m+Z1QhP GxW/i6tNtNjB45rNkaFIpCDJwuTWekxG7bNwApg2x+y5J3K4IxBx+ASSPtiicIcs+uVp rnTeykybG1phC7W7eR4fo4hYvaSdiB2cf91PJEk+F1tl/xTyAwBxiODIlD12fjyLDCY9 bdAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719848242; x=1720453042; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s02LMsxjn5x6rqmUB/6O6DcfNTfvtSOpuMWO8BbXl0Y=; b=oAxGmAIh9ZpVJEJax2Mxr1qnX/+DV0qcydh0rQuKEvYzTQYeYMx4tvfDg/3GTnPtkl YOZkrNadsnC26zurLHSbQNBfwS6SsrYWD7WzH1MMqh2AnYhYKDr3mCY8DSBHQBmV5SG7 fsS+GCXFTnWh+SWB4njar5eg5wQ+EkR3MNCzC0EZdNsLm2jy7Oa95juIB6CzJryNc/PB EslnaG3Drog/HwDrsYc0gXRWHwyTOOo1Ggus7CHqjKFRCaIYtC7Z1O9oaqePzHisMMY4 x9CZJD1bGZfe+8K+xiGotK8ZkeXcYeBg/Rn23N+2KpZYn3LR8jU+L7CGXTbcJP/dym5H qfcg== X-Gm-Message-State: AOJu0YzmyAen4aqNBqya3okn81CLBMalprVzKAhdqopVPlkYpPGNj4CM DroibW8w3hpgqVM5E1Eoq0cS6pBOQUBnFKVjdTaw08sEAoxFhuc3GBhM0Q== X-Google-Smtp-Source: AGHT+IFHkXDu1SU7zAFg8NvKRkA91iHHAawGi18VWhCV728ROn0YnUa4iMVyaxqB09p5tH+fEIj90w== X-Received: by 2002:a05:6a00:4fd4:b0:706:348a:528a with SMTP id d2e1a72fcca58-70aaad3c003mr4777982b3a.10.1719848241563; Mon, 01 Jul 2024 08:37:21 -0700 (PDT) Received: from [192.168.0.16] ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70803ecfbdesm6656206b3a.105.2024.07.01.08.37.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jul 2024 08:37:21 -0700 (PDT) Message-ID: <1dd736dd-caed-43d8-a919-7e7ec0115f33@gmail.com> Date: Mon, 1 Jul 2024 12:37:50 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <1c939e57-2c6e-412e-b453-25f88ae29057@freebxo.fr> Content-Language: en-US From: James Almer In-Reply-To: <1c939e57-2c6e-412e-b453-25f88ae29057@freebxo.fr> Subject: Re: [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-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: On 5/27/2024 12:22 PM, Hacene Bouaroua wrote: > 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; This should probably be an AVRational (With range [-180.0, 180.0]), so you can easily pass av_q2d(rotation) to av_display_rotation_set(). > } 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); avio_r8(pb) & 0x3. The upper bits are reserved. > + > + 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); > _______________________________________________ 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".