From patchwork Mon Sep 30 21:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51944 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a303:0:b0:48e:c0f8:d0de with SMTP id v3csp95vqm; Mon, 30 Sep 2024 14:27:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXvdabIyd93hQmyCbC+fXarI9Ia+eWnB6mABGmGvRFxhU034kv7jGCFto5nySUQjsD51qAAM2y7Z0a4QTo7qCUj@gmail.com X-Google-Smtp-Source: AGHT+IHkLFa/xRT4Ho/9t4HCSpsY05FGTeD0kaLNcIw5ROpH/qg3WPC/VegqFPMe7orgMjTgMm3Z X-Received: by 2002:a17:906:f5a8:b0:a8d:439d:5c44 with SMTP id a640c23a62f3a-a93c48f2081mr1285110266b.1.1727731675029; Mon, 30 Sep 2024 14:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727731675; cv=none; d=google.com; s=arc-20240605; b=QfU3DDNnMkr4csyGf65psj2qxt0XidwEw5EeOvxS7FZ9tE19rd0xWMhOZ5sOyaZgVz 8WVrA4xdUsVGv2+qZl5Sb/SmT9Bb8GhYwzwUvqKazchswKuREGy9DXcOx/znZxAgyWna WeADgHX1mn6W7fWCwpeF16IQhR+nmw+npruQVlyLyOLkROnsq1gtXP57qVU1HX0lW4k/ 3qIdsjnmYemv/5+e0WS3W3hl8dd1pVkSkCZksDzpK1jn5562eCc50I/VWinVNCJfjR4V RZPmgBgGbXAan6JOozb/P8F/N0uWxIutaxUY/qvfDqGw06yRZYOVHjjnQ4SzAn3Wd9Qj XAgg== 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=6rTkTAxt3w4kjp+Y6DkAn+PVkT/G6+MNzi7rkJcxGjI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=D9nhO8j1c3gGTyqM/WYhcAlOapMUDFG9K1kfCmfu1yFmPSlTr5B0T9vvH8tKvD0SVo I209MQLBw938u8rFJU9D79W5uVKz75T6PgJ4kj7Su0kzDvUzNxcp1xipY9p33RS5KEeR IT9VWWcTedzmbuF4JwWZkkOB/XlPjztcLW09NdajRhnbiNC/zVXs/vWeSEKHrt+BWJHA jVsPo4zS6p8IDlOPJMk8LXSbq/FItT70NQHOAhb727CnmVS53mUSwXTxg/JLzsOdB3Ye Sd5DeuOMYe+L1Pzf6O1ud5ruDnaejFU/Tg/qvCkVdOSlL6+/BzwGcoKc938rUOkxKQdQ gfHQ==; 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=mcLAMlB4; 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 a640c23a62f3a-a93c29f11f9si661013166b.643.2024.09.30.14.27.49; Mon, 30 Sep 2024 14:27:55 -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=mcLAMlB4; 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 46A6D68DC33; Tue, 1 Oct 2024 00:27:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F35F68DC33 for ; Tue, 1 Oct 2024 00:27:39 +0300 (EEST) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20b01da232aso34494465ad.1 for ; Mon, 30 Sep 2024 14:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727731656; x=1728336456; 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=2gZlAo5t1KhDQu0H24FbfJngdvg9sPwJp4/mvVNkaDk=; b=mcLAMlB4/unSRNz7g4YS0G8ZAs9y1ldGX8CapeoQH43kRqmvw0i7FjREeERW99BTkt lAkixDPeL67Zoq45qq7Y352XVsUqcw0Ye4/P+/ux7uY0sNkDdTSix/Sy+8GsopOzO7gI 3JwTqWjOs+K3UhKsg5YzXJC0SuRKev1sTK3mNLwm+LZ9ytWFGlmCX3Z7w+XbH6zN6cMI E3Wzc/AB62BbXwrSoF88UGeudUDfQRjOGyLRyVnTUMiJk/LHu0VbORePucVNTdOmSxYT jlUG6djOc0MVUk1pQ1MQ0PrSqNLlYAIfIWsacRPmivhf+4K70mOHgNZXERkdHWT2J36a VjqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727731656; x=1728336456; 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=2gZlAo5t1KhDQu0H24FbfJngdvg9sPwJp4/mvVNkaDk=; b=xVi8q1sYbI1Em7zGNEeO/jRuTFsawCy8f5EwCJCbs77+vfjAHnjlLRwbVqD0JUuanT m538dgHP2zkQjt1TliqQrtlRJp6aYpDPUIXpVry6BKKzJSQ+jiVUPlELcUJb9dPnyQ0s 5muUG2ZQMh7pmBwm2Yh4guPMj0G3mbD47o0Bj3brCPSFlBgety5XdygXEU/OclP3oXKf x61CgKbaa0O2HvZfRG+6lBLHfS7hkP43yjAi3oMBsrahOvscI4jZ3EKoV++6QR1SgWfe DCy+N7SOKS8CMbKuZCKXEVjpw078TJnDSgNq0oS6XFTVwRpG2z/0vhWAF7wf2Psk20p3 ZiFg== X-Gm-Message-State: AOJu0YxDodFJajkk1YM1Oa7MCyAH4S6+TCZLNT+LtMPQ0JhEWf0Bd0rD fH0Kd9Q6Bh2awr5JjScACO019TMEyX+W5yUkQr7ZzsdSkjl9uVR67EC7gQ== X-Received: by 2002:a17:903:244b:b0:20b:59ae:fe1d with SMTP id d9443c01a7336-20ba9f2d74cmr17087895ad.25.1727731656257; Mon, 30 Sep 2024 14:27:36 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2c4845sm6930567a12.43.2024.09.30.14.27.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 14:27:35 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Sep 2024 18:28:13 -0300 Message-ID: <20240930212813.10903-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240930174119.6426-1-jamrial@gmail.com> References: <20240930174119.6426-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/mov: get heif image mirroring from imir 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: NMwSje3ba0ln Complements 76eb3e5ff3a35eff01dd71aca82efcda50c4441f. Signed-off-by: James Almer --- libavformat/isom.h | 2 ++ libavformat/mov.c | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index bc208772f9..49a4753fad 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -284,6 +284,8 @@ typedef struct HEIFItem { int width; int height; int rotation; + int hflip; + int vflip; int type; int is_idat_relative; uint8_t *icc_profile; diff --git a/libavformat/mov.c b/libavformat/mov.c index fdf2238d47..43444477e7 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8994,6 +8994,25 @@ static int mov_read_irot(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_imir(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + HEIFItem *item; + int axis; + + axis = avio_r8(pb) & 0x1; + + av_log(c->fc, AV_LOG_TRACE, "imir: item_id %d, axis %u\n", + c->cur_item_id, axis); + + item = heif_cur_item(c); + if (item) { + item->hflip = axis; + item->vflip = !axis; + } + + return 0; +} + static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) { typedef struct MOVAtoms { @@ -9218,6 +9237,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('p','i','t','m'), mov_read_pitm }, { MKTAG('e','v','c','C'), mov_read_glbl }, { MKTAG('i','d','a','t'), mov_read_idat }, +{ MKTAG('i','m','i','r'), mov_read_imir }, { MKTAG('i','r','e','f'), mov_read_iref }, { MKTAG('i','s','p','e'), mov_read_ispe }, { MKTAG('i','r','o','t'), mov_read_irot }, @@ -9922,6 +9942,7 @@ static int set_display_matrix_from_item(AVPacketSideData **coded_side_data, int * av_display_rotation_set() expects its argument to be * oriented clockwise, so we need to negate it. */ av_display_rotation_set(matrix, -item->rotation); + av_display_matrix_flip(matrix, item->hflip, item->vflip); return 0; } @@ -9967,7 +9988,7 @@ static int read_image_grid(AVFormatContext *s, const HEIFGrid *grid, return ret; } /* rotation */ - if (item->rotation) { + if (item->rotation || item->hflip || item->vflip) { int ret = set_display_matrix_from_item(&tile_grid->coded_side_data, &tile_grid->nb_coded_side_data, item); if (ret < 0) @@ -10066,7 +10087,7 @@ static int read_image_iovl(AVFormatContext *s, const HEIFGrid *grid, tile_grid->coded_height = (flags & 1) ? avio_rb32(s->pb) : avio_rb16(s->pb); /* rotation */ - if (item->rotation) { + if (item->rotation || item->hflip || item->vflip) { int ret = set_display_matrix_from_item(&tile_grid->coded_side_data, &tile_grid->nb_coded_side_data, item); if (ret < 0) @@ -10283,7 +10304,7 @@ static int mov_read_header(AVFormatContext *s) if (item->item_id == mov->primary_item_id) st->disposition |= AV_DISPOSITION_DEFAULT; - if (item->rotation) { + if (item->rotation || item->hflip || item->vflip) { int ret = set_display_matrix_from_item(&st->codecpar->coded_side_data, &st->codecpar->nb_coded_side_data, item); if (ret < 0)