From patchwork Sun Jun 23 14:14:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 50100 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp1522954vqz; Sun, 23 Jun 2024 07:15:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWKH0smKhYZNxa2IW739ezZ0JypKin4GW4W8aZdBzXNR3HL2E1aZ9fSeKzkEwXd8DdpILU51SjjZh8XG2zmCtwMOSsJHWHIGTbFAg== X-Google-Smtp-Source: AGHT+IEGKePnZKfd9+7H8PbEMZhwFbPUtsMHEd9rTvhr/lXv9mEtrWAd/XtA4A00dU4byku/O2Cb X-Received: by 2002:a2e:3219:0:b0:2ec:3d2e:2408 with SMTP id 38308e7fff4ca-2ec5b2dd7ffmr13610901fa.33.1719152128602; Sun, 23 Jun 2024 07:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719152128; cv=none; d=google.com; s=arc-20160816; b=Bap66KU3sdX8dLrQPJlPXrkVDzMwCrZbTGK/Zc4Olikj4u5vwlj8IZA3YzPNG6WwH9 oJuaovhOkM4kRq9sGYcJJVO4fDWySqLeYOJWcyLVheg+S2qFrv17VgEv6aMNrB5q2WhD duRD/t5k38oWu54Xkh4etbuydOC0dgl65kXs7t1Xr9xPPLVehyPzFF7NxDndxxzX/qFY d+gfYOXWqoJbW4UQB7GNmtnU/nAQEJEcJJbPhyDHm2UMGvyNLrCs27ZqMRGsWFP0jXrv G9eCj5L8rm2nhViETAK0i7roT9VYHf5qQ8crixzAKO86DTs75dS//8aHrmLYE7rukA1D BaYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=auoi5+H9Bsa+B7B4XvDGBAcOFASpmggvsVbwwmniNPw=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=aLzXyA5e0qlZz2qknY20iZnSp3Zb6AORygCTVNHY9uNkYCFHDRKu6n65f0Z+J6f24V 8DNuGfsVlKN4NVe2rls1mHDWLZzV3ux7tQdiHjLhNMiy6Utu66LqRtXEodEinJ4AWCPM D0mUTjVgJRgWb+9OohpeqmnS8V/Gn+Y4i8uNiUH+x17eAEiVywFJKHHaDKx8R135tewW 9EE4K/6ihEcn6PDRoUBeN5vAc3TqQrcfJIYus2gJsk/KJj2Mcpj1pmTGeglFLI1GZjCU e3kTO8QsBQT0ZPfFK5sCr5bxBA93B4qgMhfbqN6TI7/Wx60jwi4/AEYk+nhYRVHOb2YI yABw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2ec532b73fesi11170291fa.90.2024.06.23.07.15.28; Sun, 23 Jun 2024 07:15:28 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D147068D517; Sun, 23 Jun 2024 17:15:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6492268D517 for ; Sun, 23 Jun 2024 17:15:15 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Jun 2024 16:14:53 +0200 Message-ID: <20240623141508.908804-1-dev@lynne.ee> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] lavu/stereo3d: change the horizontal FOV field to a rational 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PbigMK3S3MFv This avoids hardcoding any implementation-specific limitiations as part of the API, and allows for future expandability. This also allows API users to more conveniently convert the values into floats without hardcoding specific conversion constants. The API was committed 2 days ago, so changing this field now is within the realms of acceptable. --- fftools/ffprobe.c | 2 +- libavformat/dump.c | 5 +++-- libavformat/mov.c | 3 ++- libavutil/stereo3d.c | 1 + libavutil/stereo3d.h | 4 ++-- tests/ref/fate/matroska-spherical-mono | 2 +- tests/ref/fate/matroska-spherical-mono-remux | 4 ++-- tests/ref/fate/matroska-stereo_mode | 8 ++++---- tests/ref/fate/matroska-vp8-alpha-remux | 2 +- tests/ref/fate/mov-spherical-mono | 2 +- 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index d7ba980ff9..b69a75ff9a 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2548,7 +2548,7 @@ static void print_pkt_side_data(WriterContext *w, print_str("primary_eye", av_stereo3d_primary_eye_name(stereo->primary_eye)); print_int("baseline", stereo->baseline); print_q("horizontal_disparity_adjustment", stereo->horizontal_disparity_adjustment, '/'); - print_int("horizontal_field_of_view", stereo->horizontal_field_of_view); + print_q("horizontal_field_of_view", stereo->horizontal_field_of_view, '/'); } else if (sd->type == AV_PKT_DATA_SPHERICAL) { const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data; print_str("projection", av_spherical_projection_name(spherical->projection)); diff --git a/libavformat/dump.c b/libavformat/dump.c index 61a2c6a29f..b71b5356dc 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -267,8 +267,9 @@ static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level) if (stereo->horizontal_disparity_adjustment.num && stereo->horizontal_disparity_adjustment.den) av_log(ctx, log_level, ", horizontal_disparity_adjustment: %d/%d", stereo->horizontal_disparity_adjustment.num, stereo->horizontal_disparity_adjustment.den); - if (stereo->horizontal_field_of_view) - av_log(ctx, log_level, ", horizontal_field_of_view: %"PRIu32"", stereo->horizontal_field_of_view); + if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den) + av_log(ctx, log_level, ", horizontal_field_of_view: %d/%d", stereo->horizontal_field_of_view.num, + stereo->horizontal_field_of_view.den); if (stereo->flags & AV_STEREO3D_FLAG_INVERT) av_log(ctx, log_level, " (inverted)"); diff --git a/libavformat/mov.c b/libavformat/mov.c index f08fec3fb6..fe8a963c6e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6782,7 +6782,8 @@ static int mov_read_hfov(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); } - sc->stereo3d->horizontal_field_of_view = avio_rb32(pb); + sc->stereo3d->horizontal_field_of_view.num = avio_rb32(pb); + sc->stereo3d->horizontal_field_of_view.den = 1000; // thousands of a degree return 0; } diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c index 19e81e4124..ad6064e5d9 100644 --- a/libavutil/stereo3d.c +++ b/libavutil/stereo3d.c @@ -29,6 +29,7 @@ static void get_defaults(AVStereo3D *stereo) { stereo->horizontal_disparity_adjustment = (AVRational) { 0, 1 }; + stereo->horizontal_field_of_view = (AVRational) { 0, 1 }; } AVStereo3D *av_stereo3d_alloc(void) diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h index 00a5c3900e..d8b191118c 100644 --- a/libavutil/stereo3d.h +++ b/libavutil/stereo3d.h @@ -224,9 +224,9 @@ typedef struct AVStereo3D { AVRational horizontal_disparity_adjustment; /** - * Horizontal field of view in thousanths of a degree. Zero if unset. + * Horizontal field of view, in degrees. Zero if unset. */ - uint32_t horizontal_field_of_view; + AVRational horizontal_field_of_view; } AVStereo3D; /** diff --git a/tests/ref/fate/matroska-spherical-mono b/tests/ref/fate/matroska-spherical-mono index b108596350..8b011e332f 100644 --- a/tests/ref/fate/matroska-spherical-mono +++ b/tests/ref/fate/matroska-spherical-mono @@ -7,7 +7,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping diff --git a/tests/ref/fate/matroska-spherical-mono-remux b/tests/ref/fate/matroska-spherical-mono-remux index eec41b77f3..31dbf6cdd8 100644 --- a/tests/ref/fate/matroska-spherical-mono-remux +++ b/tests/ref/fate/matroska-spherical-mono-remux @@ -31,7 +31,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping @@ -60,7 +60,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping diff --git a/tests/ref/fate/matroska-stereo_mode b/tests/ref/fate/matroska-stereo_mode index 26c325b20e..656a712e89 100644 --- a/tests/ref/fate/matroska-stereo_mode +++ b/tests/ref/fate/matroska-stereo_mode @@ -136,7 +136,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [/STREAM] [STREAM] @@ -156,7 +156,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [/STREAM] [STREAM] @@ -174,7 +174,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [/STREAM] [STREAM] @@ -193,7 +193,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [/STREAM] [STREAM] diff --git a/tests/ref/fate/matroska-vp8-alpha-remux b/tests/ref/fate/matroska-vp8-alpha-remux index 06bcc4b4ba..bfc25fea7a 100644 --- a/tests/ref/fate/matroska-vp8-alpha-remux +++ b/tests/ref/fate/matroska-vp8-alpha-remux @@ -39,6 +39,6 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/0 [/SIDE_DATA] [/STREAM] diff --git a/tests/ref/fate/mov-spherical-mono b/tests/ref/fate/mov-spherical-mono index b108596350..065b109a41 100644 --- a/tests/ref/fate/mov-spherical-mono +++ b/tests/ref/fate/mov-spherical-mono @@ -7,7 +7,7 @@ view=packed primary_eye=none baseline=0 horizontal_disparity_adjustment=0/1 -horizontal_field_of_view=0 +horizontal_field_of_view=0/1 [/SIDE_DATA] [SIDE_DATA] side_data_type=Spherical Mapping