From patchwork Thu May 16 23:34:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ted Meyer X-Patchwork-Id: 13179 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E0B0944817D for ; Fri, 17 May 2019 02:34:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B84806809C2; Fri, 17 May 2019 02:34:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE0B8680352 for ; Fri, 17 May 2019 02:34:18 +0300 (EEST) Received: by mail-wm1-f48.google.com with SMTP id n25so4636284wmk.4 for ; Thu, 16 May 2019 16:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Wy5SshXsba88Xn+ftUivYPLzs92tqG4K3a4VsJ+ThqQ=; b=rYCJpzThXTza90ElKvHcs8+9tjrl8+rXu/BrCkwhRU7zlq7YZzFQOsa1PLRgULWtIZ NAV1RujLgVLgTxTqsnOsHc/gPDpG0F0LOExPne8vIWrp45+RErJlI8H8fyqnuChOP+NS 8DujP6/HFMeTvhS54KNNvL0hLatnuSasaLk0yc0zo9A72DaDLYzaTr+ANVrmxJlVud2v f/RjXByYoYZv+d1yCd6io20Tdai2YKLkJRvDU7GOjvo/gJIsEVGthZtv/iF0oru/rui2 q/phIyZQ4ggiIv9qxg8+mW1TXPQD1UpDXc8CJmmKyUMg42nm1pHT+TT+SaVbJ4zIarLu H3DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Wy5SshXsba88Xn+ftUivYPLzs92tqG4K3a4VsJ+ThqQ=; b=ev3sdjAJP2/a1IHyeDyrzIEvRe3ZjQZ8QmyXfzt6Zl9/hMxRw5zl7iYlqj/llvtNbV D+J8P1UkgWUy+GjngKTkThQvEcoQSECQtXZE4TpLJqCNPaTpbxA+tHcwSTYmbEgCYCCX sfYhEuAxVRV8YAcKVQkKS07DeT50z4rGf91DfCkgK39yMOuwII13jVF5pIh4ZDzRjk5a Ar4i8QhTBYKqU1mbzLHIfLRCuJG+C9YOEGg+FcRybuTBlQklTfmz0Veo2QgkF8dgG4EL qRiOT98MYHLgTsAeG31CVX40yCGAOPU8rAMiku1LMwvgjZhu5ETJN78+TJqToc0g5LjE 2aVA== X-Gm-Message-State: APjAAAVl/FqyslY6PwdQCT3fdlU5Q1vx/UV3d18YwBXAsDMiebekj/Ja nGsj1wlZjTiUu8ZR3h3Ev26jaO+695N3pazzhs9B6hy1RsgxIw== X-Google-Smtp-Source: APXvYqwXYk6ljchBwCTx03BpnNDQS5b+Rv9mP56aPakzb+1fVgBsjw+eNu9izdvQG92fxdjH9vI83Ljlyraii9vEKZE= X-Received: by 2002:a1c:be12:: with SMTP id o18mr12093457wmf.124.1558049657618; Thu, 16 May 2019 16:34:17 -0700 (PDT) MIME-Version: 1.0 From: Ted Meyer Date: Thu, 16 May 2019 16:34:06 -0700 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] Export display matrix mirroring info as part of the rotate API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Right now ffmpeg doesn't export a mirroring status when checking the display matrix for rotation. Here is an example video: https://files.tedm.io/flip.mp4 -Ted From 7121cecdd54f403cb857dbfd056ca22253d6948a Mon Sep 17 00:00:00 2001 From: Ted Meyer Date: Thu, 16 May 2019 14:17:51 -0700 Subject: [PATCH 1/1] Export display matrix mirroring information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit normally a display matrix will look like: [ cos(Θ), -sin(Θ), ...] [ sin(Θ), cos(Θ), ...] [ ..., ..., ...] but switching the signs can be used to imply a mirroring effect. If the cosine values are of a different sign, then there is a mirroring about the y-axis, and if the sine values are the same sign, but non-zero, then there is a mirroring about the x-axis. Signed-off-by: Ted Meyer --- libavformat/mov.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index e40bcf3b86..b8748ee374 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4560,6 +4560,16 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) snprintf(rotate_buf, sizeof(rotate_buf), "%g", rotate); av_dict_set(&st->metadata, "rotate", rotate_buf, 0); } + + if (sc->display_matrix[0] != sc->display_matrix[4]) { + av_dict_set(&st->metadata, "mirror-y", "yes", 0); + } + + // non-mirrored matricies have differing signs - except 0 + if (sc->display_matrix[1] == sc->display_matrix[3] && + sc->display_matrix[1] != 0) { + av_dict_set(&st->metadata, "mirror-x", "yes", 0); + } #endif } -- 2.21.0.1020.gf2820cf01a-goog