From patchwork Wed May 18 18:04:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 35824 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp458181pzb; Wed, 18 May 2022 11:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrAAULw8jCRu0sIquar6S1D8sM8Lm9vYNw7i8SLDD5LDsxIB8BDX0EmeNCtxUbLhMJgk6p X-Received: by 2002:a17:907:6297:b0:6da:6388:dc58 with SMTP id nd23-20020a170907629700b006da6388dc58mr763269ejc.472.1652897115617; Wed, 18 May 2022 11:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652897115; cv=none; d=google.com; s=arc-20160816; b=emjt8H5Verflb4Dfj/1bsnP6XflE3Njeu8BYT4kE6gRWxVUmTntoU1JKoYltATCNbT dkn02ibr2Cecyy/mRTzWTkPUEzy4tduYq9d+zE53ppnb4+UmwZJNoLHg8yG+bLyAII/B Qv7sGV4ab8zb+CQqFgw6dKN35N97nDAWjec8zLnMP1vviPysXIlHCskSCQtlkK7ZuniF Uwilng5oYoMX4Ki2K60umbfIWxGacgi1gV8ZlrNkscEBn8u3jas4H7jKgCKa0vNCPUQc TxjgkCAvYceCB5+zlxtWgC6mU6K+B9H1xH0K23ezcuQMHjDhmHZCB5a5o8hadlwHIEnc ABBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:message-id:date:to:from :dkim-signature:delivered-to; bh=PB2xxItcY7Xmed+OjmJpgl3PoVet0Gs981KDPOJS/1Y=; b=OqJ+dEVbTCHhN/VemVqUFDhCSoQgHCYicK1XE7pSr/IdluLTEsHNCaR0s8Q5YLcNEt eVW/eHdmYxA4gxs6clp2aYZzWJY7mrTLNz//nabGzBZsPuW0vtLNoJwtxeN062P7Gskh 7HFDeJlp1p8oRcxpDyeKVzo0mUllDjQe09rcAFuO9b2StRfr6IJX8w4jSpeTnE9/wr60 7s+A2uHXcxtjpj8vj5uawarcrOuJiNwf5QejWS0lV8y5w/8ueRRaiEbj+/YBwNVhesi/ AgfGkvO6X00Vn8SNlY4aCRl2jSHXhrRIuzQ+htROdI70b2m2r+e5UlNede8Fl6HimzcC VClw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=CCm2zjMZ; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n21-20020a5099d5000000b0042839620d77si2625074edb.631.2022.05.18.11.05.14; Wed, 18 May 2022 11:05:15 -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=20210112 header.b=CCm2zjMZ; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5629868B47C; Wed, 18 May 2022 21:05:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2809468B42E for ; Wed, 18 May 2022 21:05:04 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id e4so2907787ljb.13 for ; Wed, 18 May 2022 11:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9e3Eu+O4UzRPldf1F7BSfXNlOdPB5DjzRwwq0Q13M2c=; b=CCm2zjMZmAPn0WeHSFx+CLwyseurjMTy/JS809rMXDXjuFMQ8FDEmUryEEyttWaHVm GBxvibtiP/qnylv+x2Wf1tRjobRVEXwqaCXtsNybmKiOb10QBOx3suzuiUpQN0jR0dPU qkVdmSq8rTRttD4C32hLrP/ykZYVDgxIcAwmr3m50kMOn2akJb4nycYAxdAtVxNgqhP4 rZAWQCPX/HJPIUuktr4xFVOljMeYqKiDnu98NU6OaPI0oIiD3FvaSBW15UfUdjq8TGkq 9G6reOdexwhZKTtiOQQIpi6E2uett3O8AOv8iHhNtLxOSG/WfjZPHBRr231ntZxBDOz0 fIvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9e3Eu+O4UzRPldf1F7BSfXNlOdPB5DjzRwwq0Q13M2c=; b=xA9aqQ2IX2aMzw/PRyhh2LBwQu/aVWigRP42a0nt+n6Jtucu0WAGFPpXVFOnRTD4T7 3exG6FPUFOqmkyLPkPmJiQB5rgR0AfQHKMI4LIwpZjrNPRq8SzhqqPeywT4uWGmR5Lpy OLnT4M2up94O+D5gUVCFu5RAGa3w9V7R0sDrj43PNm2Jip4bUW+KkFbQ513n03IxzN4l Ck7O0/KO7Ho7c0gGhxua/iS1rl2L2pBh8VXLub4kaPhIhqmf38wJdOu+bkSMzHVV/ukE UoxckHo1PePgfM5uaAqXRVG233yLTXPUESyBn9L929tl48rTr6ydgS8xjORGIvC+LTuz coYA== X-Gm-Message-State: AOAM530edNq4cLBW0xVTZZv1jZU8Jpo2ZZHPaxIYeME9NXRCqWV2utbK /cjNngdFClw5lT2p5ghNGLeqE1q/zfo= X-Received: by 2002:a05:651c:1a11:b0:24f:50d8:545c with SMTP id by17-20020a05651c1a1100b0024f50d8545cmr334566ljb.133.1652897103067; Wed, 18 May 2022 11:05:03 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id f14-20020ac24e4e000000b0047255d2115esm14878lfr.141.2022.05.18.11.05.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 11:05:02 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 18 May 2022 21:04:53 +0300 Message-Id: <20220518180454.53301-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: add display_{rotation, hflip, vflip} options 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: q0w9U7X8qSSt This enables overriding the rotation as well as horizontal/vertical flip state of a specific video stream on either the input or output side. Additionally, switch the singular test that was utilizing the rotation metadata to instead override the input display rotation, thus leading to the same result. --- doc/ffmpeg.texi | 29 +++++++++++++++++++++ fftools/ffmpeg.h | 6 +++++ fftools/ffmpeg_opt.c | 52 +++++++++++++++++++++++++++++++++++++ tests/fate/filter-video.mak | 2 +- 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 0d7e1a479d..f44d863f02 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -897,6 +897,35 @@ If used together with @option{-vcodec copy}, it will affect the aspect ratio stored at container level, but not the aspect ratio stored in encoded frames, if it exists. +@item -display_rotation[:@var{stream_specifier}] @var{rotation} (@emph{input/output,per-stream}) +Set the video display rotation in degrees specified by @var{rotation}. + +@var{rotation} is a floating point number that describes a pure +counter-clockwise rotation in degrees. + +When setting this for input streams, @code{-autorotate} logic will be affected. +For additional parameters affecting display matrix side data into which this +information is saved, see @code{-display_hflip} and @code{-display_vflip}. + +These options work as a unit, so if only one of them is set, then the display +matrix will be overridden to that specific value with the rest being set to +default values. + +If unset, the default value if a display matrix is being defined is a rotation +of zero degrees. + +@item -display_hflip[:@var{stream_specifier}] (@emph{input/output,per-stream}) +Set whether on display the image should be horizontally flipped. + +If unset, the default value if a display matrix is being defined is that there +is no additional horizontal flip. See @code{-display_rotation}. + +@item -display_vflip[:@var{stream_specifier}] (@emph{input/output,per-stream}) +Set whether on display the image should be vertically flipped. + +If unset, the default value if a display matrix is being defined is that there +is no additional vertical flip. See @code{-display_rotation}. + @item -vn (@emph{input/output}) As an input option, blocks all video streams of a file from being filtered or being automatically selected or mapped for any output. See @code{-discard} diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9f0c093e34..0da01b0668 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -180,6 +180,12 @@ typedef struct OptionsContext { int nb_force_fps; SpecifierOpt *frame_aspect_ratios; int nb_frame_aspect_ratios; + SpecifierOpt *display_rotations; + int nb_display_rotations; + SpecifierOpt *display_hflips; + int nb_display_hflips; + SpecifierOpt *display_vflips; + int nb_display_vflips; SpecifierOpt *rc_overrides; int nb_rc_overrides; SpecifierOpt *intra_matrices; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 47e8b9b7bd..0d1c84d6df 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -20,6 +20,7 @@ #include "config.h" +#include #include #if HAVE_SYS_RESOURCE_H @@ -43,6 +44,7 @@ #include "libavutil/avutil.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/display.h" #include "libavutil/intreadwrite.h" #include "libavutil/fifo.h" #include "libavutil/mathematics.h" @@ -82,6 +84,9 @@ static const char *const opt_name_qscale[] = {"q", "qscale", static const char *const opt_name_forced_key_frames[] = {"forced_key_frames", NULL}; static const char *const opt_name_force_fps[] = {"force_fps", NULL}; static const char *const opt_name_frame_aspect_ratios[] = {"aspect", NULL}; +static const char *const opt_name_display_rotations[] = {"display_rotation", NULL}; +static const char *const opt_name_display_hflips[] = {"display_hflip", NULL}; +static const char *const opt_name_display_vflips[] = {"display_vflip", NULL}; static const char *const opt_name_rc_overrides[] = {"rc_override", NULL}; static const char *const opt_name_intra_matrices[] = {"intra_matrix", NULL}; static const char *const opt_name_inter_matrices[] = {"inter_matrix", NULL}; @@ -739,6 +744,39 @@ static int opt_recording_timestamp(void *optctx, const char *opt, const char *ar return 0; } +static void add_display_matrix_to_stream(OptionsContext *o, + AVFormatContext *ctx, AVStream *st) +{ + double display_rotation = DBL_MAX; + int hflip = -1, vflip = -1, + hflip_set = 0, vflip_set = 0, display_rotation_set = 0; + uint8_t *buf = NULL; + + MATCH_PER_STREAM_OPT(display_rotations, dbl, display_rotation, ctx, st); + MATCH_PER_STREAM_OPT(display_hflips, i, hflip, ctx, st); + MATCH_PER_STREAM_OPT(display_vflips, i, vflip, ctx, st); + + display_rotation_set = display_rotation != DBL_MAX; + hflip_set = hflip != -1; + vflip_set = vflip != -1; + + if (!display_rotation_set && !hflip_set && !vflip_set) + return; + + if (!(buf = av_stream_new_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, + sizeof(int32_t) * 9))) { + av_log(NULL, AV_LOG_FATAL, "Failed to generate a display matrix!\n"); + exit_program(1); + } + + av_display_rotation_set((int32_t *)buf, + display_rotation_set ? -display_rotation : + -0.0f); + av_display_matrix_flip((int32_t *)buf, + hflip_set ? hflip : 0, + vflip_set ? vflip : 0); +} + static const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder) { const AVCodecDescriptor *desc; @@ -893,6 +931,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->top_field_first = -1; MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st); + add_display_matrix_to_stream(o, ic, st); + MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); MATCH_PER_STREAM_OPT(hwaccel_output_formats, str, hwaccel_output_format, ic, st); @@ -1752,6 +1792,8 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->frame_aspect_ratio = q; } + add_display_matrix_to_stream(o, oc, st); + MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); @@ -3731,6 +3773,16 @@ const OptionDef options[] = { { "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(frame_aspect_ratios) }, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" }, + { "display_rotation", OPT_VIDEO | HAS_ARG | OPT_DOUBLE | OPT_SPEC | OPT_INPUT | + OPT_OUTPUT, { .off = OFFSET(display_rotations) }, + "set pure counter-clockwise rotation in degrees for stream(s)", + "rotation" }, + { "display_hflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(display_hflips) }, + "set display horizontal flip for stream(s) " + "(overrides any display rotation if it is not set)"}, + { "display_vflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(display_vflips) }, + "set display vertical flip for stream(s) " + "(overrides any display rotation if it is not set)"}, { "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_pix_fmts) }, "set pixel format", "format" }, diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 86408dd58c..ce6ae255b4 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -856,7 +856,7 @@ fate-filter-metadata-avf-aphase-meter-out-of-phase: SRC = $(TARGET_SAMPLES)/filt fate-filter-metadata-avf-aphase-meter-out-of-phase: CMD = run $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',aphasemeter=video=0" FATE_FILTER_SAMPLES-$(call TRANSCODE, RAWVIDEO H264, MOV, ARESAMPLE_FILTER AAC_FIXED_DECODER) += fate-filter-meta-4560-rotate0 -fate-filter-meta-4560-rotate0: CMD = transcode mov $(TARGET_SAMPLES)/filter/sample-in-issue-505.mov mov "-c copy -metadata:s:v:0 rotate=0" "-af aresample" "" "" "-flags +bitexact -c:a aac_fixed" +fate-filter-meta-4560-rotate0: CMD = transcode "mov -display_rotation:v:0 0" $(TARGET_SAMPLES)/filter/sample-in-issue-505.mov mov "-c copy" "-af aresample" "" "" "-flags +bitexact -c:a aac_fixed" REFCMP_DEPS = FFMPEG LAVFI_INDEV TESTSRC2_FILTER AVGBLUR_FILTER METADATA_FILTER From patchwork Wed May 18 18:04:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 35825 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp458261pzb; Wed, 18 May 2022 11:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDPBBy1lg3aKczE9hxc8AZ+G/zup3j5vC76GdS4ek7KI+kukM9+6D0Jv3gBjJuazmTC7Ul X-Received: by 2002:a17:907:97d4:b0:6f4:c876:6f6b with SMTP id js20-20020a17090797d400b006f4c8766f6bmr700780ejc.627.1652897124655; Wed, 18 May 2022 11:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652897124; cv=none; d=google.com; s=arc-20160816; b=lSNhTn2exEXkvBkME2k+pN0LVj6GvLg6iiMSB94uA9z2LmI7gpJD6jzZF9LwstwqrI 8RC7jT6sVDVC/mssnZpETsf8GhSipG9vuLL+7lieeBqVK6GkGvy3icyujXFG3nA1miWa zS3aUtiHJ5f1F6uYUmTCsX+bzo8qwk7XsGLgvotWuaNr7Z0lSAzDM0fy/+BimNJDhjFQ yypBgjdYQjN+9u8VAh8os0gzQi3CBfs0uWNFx71q2+9yUb2lplTehDw+D735uFwmeszZ xkUqGPa3AFWKKtcUPzbg6N7pdH2iIBuDfa7v6ea33DQcNes4pRIOCousNnDnEXNT8XHd PkZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=7QQtjxRaojALx+huvA5ko+x0weKXwcWQEJv7rzyE3bc=; b=ucJ33/4f8aBh/J5EVadX08nFlW45eKyG+Ia+tfqR/FPTbtw664oiHAItcSQxR7TKxF ynkzq6zTUVoSK+X4qfm0AltsYxfEs4F0m7UlcObddLvtiEQwemtLTsBYrM1i9oPnKX7g FQi7IpfzPIuU/l4oizUGwIGnOtk8TzniBchFjexo4lmFf8oApsZ4BKsxJviDdcuPjDGx Etp+6IKN8KgJ92mWngeGWPYMn3FtjyPlSvSyPZGWnq/XTtS8Wdobc9kJvIj1BHyEPAOA INt/nQ8S1jYgzTbW+/Yz1xjP+4JWKGOlvUZNKKyT5Sn+cin5IfTX0EAeddm7vHT5gYj1 HnlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=nFW86DYQ; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ek6-20020a056402370600b0042ac0eb02acsi3050141edb.338.2022.05.18.11.05.24; Wed, 18 May 2022 11:05:24 -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=20210112 header.b=nFW86DYQ; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9272268B48C; Wed, 18 May 2022 21:05:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4699668B42E for ; Wed, 18 May 2022 21:05:04 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id u7so2746625ljd.11 for ; Wed, 18 May 2022 11:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=83Dfu2pX4QzTDgXpX9d7VPQiHQgbb+Oum9LximPxcG8=; b=nFW86DYQqfB4Rn+9w4VmNEgnnpkWay8gSf+Wpc2VsmaDoAme9AABJ+qViLace8njb7 kIxRwznrvvQj/HldtW4F9n4x761eJhAyQAv37frtDKqwyBaAik6Tv7Ab8+lSL9ntKiQF TR+Td1hFHo5xgU7+RGI2a+z50886gFplOhNl6hyu+s/V1UwBB2v3z8A2jmsq0T7RwrYE vOnR10wHGbMhah9OlxOvu4VVB0sMz9+3SodeYP1+kv+a78J+HQh43k6LXw5pQVb1MKoC b42awkFYj4kAuiaC4mg5qohZOzbe0LzHncfsNSGKinauwN1GS6tIx1LxD96tlIi/XQHw qEjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=83Dfu2pX4QzTDgXpX9d7VPQiHQgbb+Oum9LximPxcG8=; b=NFm9nc9O5EThMYcXjDUvzxGWyT+0MW7m9GuPZl9Gv3856z373FrqpPT4HzhFZU9F3L fm4lhlOHC9X7Z6MpLEINIpBp6m9luC2X5eKLxZjmBnfTnn9OkfqhPYLTqDGZNYBFujo8 J77aYZFn4qpB2JcPTbNLc41IHnKkbbIghyIgtZBtu8SNe/HPupkVxTAgUXcRaroETQQi kgopFEmIRWdIUB65bfqOkVhhynXnMFRxm5P/YHz9w8K947kRYIkwCc+3JGqZpz5Hmx0a H/au22kmc5SYlyGkVH6laogn9TaDM213UYr9fCpSo7k7Qa8lIBggQRXdqyVq2Q4j+8g1 cqkg== X-Gm-Message-State: AOAM530Iiy3Uu+28lriLorMZcMNLQ3W3bQBH7muPwHivA6Wth56BuNt3 oIYZKLk47cAGgIbr33AqGTzWc4EhHhc= X-Received: by 2002:a2e:3219:0:b0:250:664c:900d with SMTP id y25-20020a2e3219000000b00250664c900dmr346450ljy.105.1652897103573; Wed, 18 May 2022 11:05:03 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id f14-20020ac24e4e000000b0047255d2115esm14878lfr.141.2022.05.18.11.05.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 11:05:03 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 18 May 2022 21:04:54 +0300 Message-Id: <20220518180454.53301-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220518180454.53301-1-jeebjp@gmail.com> References: <20220518180454.53301-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] ffmpeg: deprecate display rotation override with a metadata key 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: grzuUFz5zJg6 Now that we have proper options for defining display matrix overrides, this should no longer be required. fftools does not have its own versioning, so for now the define is just set to 1 and disables the functionality if set to zero. --- fftools/ffmpeg.c | 2 ++ fftools/ffmpeg.h | 6 ++++++ fftools/ffmpeg_opt.c | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a85ed18b08..5ccf3778ce 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2837,12 +2837,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) } } +#if FFMPEG_ROTATION_METADATA if (ost->rotate_overridden) { uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (sd) av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); } +#endif switch (par_dst->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0da01b0668..58d3aaa987 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -47,6 +47,8 @@ #include "libswresample/swresample.h" +#define FFMPEG_ROTATION_METADATA 1 + enum VideoSyncMethod { VSYNC_AUTO = -1, VSYNC_PASSTHROUGH, @@ -497,10 +499,14 @@ typedef struct OutputStream { int is_cfr; int force_fps; int top_field_first; +#if FFMPEG_ROTATION_METADATA int rotate_overridden; +#endif int autoscale; int bits_per_raw_sample; +#if FFMPEG_ROTATION_METADATA double rotate_override_value; +#endif AVRational frame_aspect_ratio; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 0d1c84d6df..5a00886e05 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2916,6 +2916,7 @@ loop_end: for (j = 0; j < oc->nb_streams; j++) { ost = output_streams[nb_output_streams - oc->nb_streams + j]; if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) { +#if FFMPEG_ROTATION_METADATA if (!strcmp(o->metadata[i].u.str, "rotate")) { char *tail; double theta = av_strtod(val, &tail); @@ -2923,9 +2924,18 @@ loop_end: ost->rotate_overridden = 1; ost->rotate_override_value = theta; } + + av_log(NULL, AV_LOG_WARNING, + "Conversion of a 'rotate' metadata key to a " + "proper display matrix rotation is deprecated. " + "See -display_rotation for setting rotation " + "instead."); } else { +#endif av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); +#if FFMPEG_ROTATION_METADATA } +#endif } else if (ret < 0) exit_program(1); }