From patchwork Mon Sep 26 05:57:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38321 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp2046032pzh; Sun, 25 Sep 2022 22:58:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jy8qItxYtfhMKVmxzWv6Qke03K85n96uUv1F4JD2HnLd0KbPUeg1CqjzIHFanccQBqoDg X-Received: by 2002:a05:6402:1941:b0:457:138:1e88 with SMTP id f1-20020a056402194100b0045701381e88mr9735452edz.394.1664171896977; Sun, 25 Sep 2022 22:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664171896; cv=none; d=google.com; s=arc-20160816; b=awEsEOBKdZ/g8C340olvP7OY9mL4h2MlibGR9Z5xGWcmBB34HGktfZ7pLi112avFY/ MoMdudpjzh42YaH3A4SOIW/OhoPVt25KRR8Z0BZsH6+S+xPF/CT0dr9lqcNYm+wFjA4R SV+oGr/OpZGTwmeTi/6eIe48OgPaq+ZE861UWN77XZ6ImoHUn/FbZWDZQn/3Y2fpE8Q9 RAn9NOIbroFXTmq+DQh+009LSmAYtC7CfyMgv8G1xyrr+m0S0cNmfNst0fwFekx2LlOW 25I6yDjB+rJkdndpSlhiorLO5OcqnopgXmznGkMRpxZvHSS193zf3iu8vHm/hhIPtQXf b1Qw== 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=BEiLLCcFXb3ri2P3DG75D16ltVQMJCLoRZ+/nHPrPi8=; b=W5yZunDYPFyYpEXsmDI0QRAOVauFNyF1RKdM+Tcdrn0Iijuj8ZrTdS+GW6BFgs11yk lDWGJP6x6gwcTMyDV06GWedime+V+O5thyAZKlZECjdqcnHe1rKdS0DOhi0cu9nyVm9M 6IUJdxC7CX5mqOHGpLD7kuWvOBV3dNvY9yKiNaNXfXzLDd05nFddSFM2Rh/AOqX/tMMm TEti6oUFemtxoiEks5bCkzx/MiJsM3Ub784oHbU2gfK9xUp9M0KIrpKajWog2D4sNIhO UTOXycMfm0i0Ic73PFKwuKyxBhGkPtNQyueC8BYNRehcRUfiBKAcKWLnOi+Bn8c340tp AHeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=fUGYDM+7; 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=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o5-20020a170906974500b0073d710fec77si15153968ejy.251.2022.09.25.22.58.16; Sun, 25 Sep 2022 22:58:16 -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=@mail.de header.s=mailde202009 header.b=fUGYDM+7; 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=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 985BB68BA6F; Mon, 26 Sep 2022 08:58:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1811368B5C8 for ; Mon, 26 Sep 2022 08:57:56 +0300 (EEST) Received: from postfix02.mail.de (postfix02.bt.mail.de [10.0.121.126]) by shout02.mail.de (Postfix) with ESMTP id 9BAC1A0C83 for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) Received: from smtp04.mail.de (smtp04.bt.mail.de [10.0.121.214]) by postfix02.mail.de (Postfix) with ESMTP id 81C19A03C2 for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1664171875; bh=erfJtLG0L+VZ3tF8rpd2O+Tv5PW5psREZqXeTCXF/To=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=fUGYDM+7DmoXfylKthdlyh25A+7TTBNUU4nL9MSwaRRxbrEk7pkmwBknSS73/745l P9q4A9EgvO6X398/jTGpzL/kgu6/wsA/Z3mf1jTlMgIWfcnl2oJyCWqmbB8jHTGZez BafQXYyHGacneLueiOYl6TotrjP0i8qi6nbxAFfmP+UdVbowUG6TsMt5YvxdS5ArnZ kDj2n26wU84XTMQOSVx3FaGAVSL+umkK81qHHak1pu33t14LS1g6cso8GtG3q562dp H39edykGlecJIbxO/ihtkNMIWA6of0J2qud7P+JPp0glwcrQ4doaMKtesl5sPTfcAE iyuy7AioVGm4w== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp04.mail.de (Postfix) with ESMTPSA id 3FCEBC002F for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Sep 2022 07:57:52 +0200 Message-Id: <20220926055753.88407-2-thilo.borgmann@mail.de> In-Reply-To: <20220926055753.88407-1-thilo.borgmann@mail.de> References: <20220926055753.88407-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 8960 X-purgate-ID: 154282::1664171875-000016C9-55BC3D9A/0/0 Subject: [FFmpeg-devel] [PATCH v6 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: bBiMkRVNh3u1 From: Jan Ekström This enables overriding the rotation as well as horizontal/vertical flip state of a specific video stream on the input 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 | 50 +++++++++++++++++++++++++++++++++++++ tests/fate/filter-video.mak | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 42440d93b4..6016b43892 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -912,6 +912,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,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, @code{-autorotate} logic will be affected. +For additional parameters affecting display matrix side data into which this +information is saved, see @code{-display_hflip}, @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,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,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 ede0b2bd96..c529baacc4 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -193,6 +193,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 5febe319e4..f07858333d 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 @@ -45,6 +46,7 @@ #include "libavutil/avutil.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/display.h" #include "libavutil/getenv_utf8.h" #include "libavutil/intreadwrite.h" #include "libavutil/fifo.h" @@ -86,6 +88,9 @@ static const char *const opt_name_forced_key_frames[] = {"forced_key_fra static const char *const opt_name_fps_mode[] = {"fps_mode", 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}; @@ -801,6 +806,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 rotation = DBL_MAX; + int hflip = -1, vflip = -1; + int hflip_set = 0, vflip_set = 0, rotation_set = 0; + uint8_t *buf = NULL; + + MATCH_PER_STREAM_OPT(display_rotations, dbl, rotation, ctx, st); + MATCH_PER_STREAM_OPT(display_hflips, i, hflip, ctx, st); + MATCH_PER_STREAM_OPT(display_vflips, i, vflip, ctx, st); + + rotation_set = rotation != DBL_MAX; + hflip_set = hflip != -1; + vflip_set = vflip != -1; + + if (!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, + rotation_set ? -(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; @@ -935,6 +973,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + 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); @@ -4024,6 +4064,16 @@ const OptionDef options[] = { { "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" }, + { "display_rotation", OPT_VIDEO | HAS_ARG | OPT_DOUBLE | OPT_SPEC | + OPT_INPUT, { .off = OFFSET(display_rotations) }, + "set pure counter-clockwise rotation in degrees for stream(s)", + "angle" }, + { "display_hflip", OPT_VIDEO | OPT_BOOL | OPT_SPEC | OPT_INPUT, { .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, { .off = OFFSET(display_vflips) }, + "set display vertical flip for stream(s) " + "(overrides any display rotation if it is not set)"}, { "vn", OPT_VIDEO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(video_disable) }, "disable video" }, { "rc_override", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 372c70bba7..f3c27ed1c8 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -691,7 +691,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" FATE_FILTER_CMP_METADATA-$(CONFIG_BLOCKDETECT_FILTER) += fate-filter-refcmp-blockdetect-yuv fate-filter-refcmp-blockdetect-yuv: CMD = cmp_metadata blockdetect yuv420p 0.015 From patchwork Mon Sep 26 05:57:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38322 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp2046066pzh; Sun, 25 Sep 2022 22:58:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fgb4/OdcxU/XDvxFjtIwoUQ0AqEsneyzX91NfdlBqKsi8loKIh3k4OCeaB1mXfrsVo4DE X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr20956042ede.292.1664171905902; Sun, 25 Sep 2022 22:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664171905; cv=none; d=google.com; s=arc-20160816; b=D0xSYgw+9nBYA0Nw9RK4+IvZQ9u1v80dNxlJFlcSmXIJ1rWST4N9AbgyGyr4vsNQs8 BERAI0rZLP8tTOefuej9SBHB14jmm/MVFLu2g5iqIy/4b6SSBaZCOuthPv/cyo5UpUWq gBt8Bs7GOWJvQiiqQ3q3nYPFw8PMAFg1WxYJi2lv28o6nI5oDXlDRmiur2vsBK+ppQXw nis2Bf9ApuMSbEHn0fRiDXFs8kcPKk+jYZlvJO0EMhLrPjBVTk5eI+nlvUFZT1sfuEHX ZzHoMn+LWi+hBx7Y9FqjMyS5oWSy9hEgBOb5SH9pZxHRYkSO3QqJW+yG/lhyKwkVbLC4 xsTw== 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=iQPgTTdxeruY8NGREHkyPN9luGVhePs1CvSmIox4QAg=; b=iCXLlw3ZUGj0DY1guMJPwFrOVc4FHUY8LLM24Y5MDgMI/D8SO8O8tPgLv393hQ9Bla O7zwtudAAst3mAnZoP662pbrc3nIY7oVndkVbTIf0+ktea89nlUmS2EZBIi88RLMkzAf 67n/gjnYOKIMI5NDLPZq/NpDidw2JDRdJlAXHa1I2infj3PWLgwS2YHY5MAwy/eDIqkh nzkCq6l3/Nhb5I0RN4Wk1rcxiYQDOTY+/QQSKP+I5E/AOhvdsN+0cfKfadmoakqn4lJm wQKgVWOkB1KvW6Ifq9iqpbu2/Wk6ZcYymi4yxe8Gz8ex3CuMT/M/7DouFa+vtRTgRMMe lgQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b="votu/GIR"; 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=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ay16-20020a170906d29000b007703822e214si14286292ejb.807.2022.09.25.22.58.25; Sun, 25 Sep 2022 22:58:25 -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=@mail.de header.s=mailde202009 header.b="votu/GIR"; 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=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B26BE68BA4E; Mon, 26 Sep 2022 08:58:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4872E68B5C8 for ; Mon, 26 Sep 2022 08:57:56 +0300 (EEST) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout01.mail.de (Postfix) with ESMTP id DF2FEA0762 for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) Received: from smtp04.mail.de (smtp04.bt.mail.de [10.0.121.214]) by postfix01.mail.de (Postfix) with ESMTP id C651880172 for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1664171875; bh=hH1CGFhWKzur437m9uR2HF4dOGeL7DNftBsCXo4Raww=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=votu/GIRKFNgj4xGj5nZ6PZLrCkNwR8mmAQQg2mCs1JnSmcgQKb/uaAX4SWus9wtN aYNLo5/cS1PtBotdKE/x6M67BeZCStt2/FakhQ2CifWBSwoUCq3Zoll988EVkxB0vK BBEXyg3GLYI1mqrwNYfgi6ZldjanKcomnK04LLn2dvJTkVRFzBiDvZh29yRgFtadtw pV++21o7Yud3VMpFLIJkvPu7CEZxavZzkxI5aKiyVEGOsJ8HppWQNuxz44sl3MP5n4 cGLr4GI0ISqiTJqHdzf7jOr0QV4+h52evFe1mtg8QC3QvRpu12CkSKYOQQT0LtsVom hSohihEJXRJbw== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp04.mail.de (Postfix) with ESMTPSA id 8E6E9C003B for ; Mon, 26 Sep 2022 07:57:55 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Sep 2022 07:57:53 +0200 Message-Id: <20220926055753.88407-3-thilo.borgmann@mail.de> In-Reply-To: <20220926055753.88407-1-thilo.borgmann@mail.de> References: <20220926055753.88407-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 3363 X-purgate-ID: 154282::1664171875-000016C9-B1E5DEE0/0/0 Subject: [FFmpeg-devel] [PATCH v6 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: nnJL3BP7BQ8E From: Jan Ekström 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 | 5 +++++ fftools/ffmpeg_opt.c | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0e1477299d..65b0b83a18 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2831,12 +2831,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->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index c529baacc4..529d94bea8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -53,6 +53,7 @@ #define FFMPEG_OPT_PSNR 1 #define FFMPEG_OPT_MAP_CHANNEL 1 #define FFMPEG_OPT_MAP_SYNC 1 +#define FFMPEG_ROTATION_METADATA 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -536,11 +537,15 @@ typedef struct OutputStream { int is_cfr; int force_fps; int top_field_first; +#if FFMPEG_ROTATION_METADATA int rotate_overridden; +#endif int autoscale; int bitexact; 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 f07858333d..3f2409ee28 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2859,16 +2859,26 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o) for (int j = 0; j < oc->nb_streams; j++) { OutputStream *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); if (!*tail) { 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); }