From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2539B47612 for ; Thu, 11 Jul 2024 12:43:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6652968DA5F; Thu, 11 Jul 2024 15:43:56 +0300 (EEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 34F0268DA5F for ; Thu, 11 Jul 2024 15:43:50 +0300 (EEST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fb4fa1bb34so5043625ad.0 for ; Thu, 11 Jul 2024 05:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720701827; x=1721306627; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=tkvhXyQdUbbQl7mJoRkfQeXHOAB7HBkszfs6KoOBWj8=; b=Btvi5yWJnsGGUPa0fJwYakfbwnELpmmwKiO33j3EXfYWre395FW27uLd/K9gjmpi2g fDtn+GOhXR2v9qez4uZN/WZklffmYX3uCLO0fb/PwN6poe5wpT7NVPRuZ8NzcdIWU7Jg kjCgWOQDWBb9EMOcmjSuOsWbQxzaewsHMgW8+Iao55lCdBa516VJOhwkWVDx0ONIHt1U KEhNkp1kj70jF7AW+lGPcbVDvNlK1WoscPfuhty8+fUmQliL+1mtynF3husiKoUau/h2 BNnW+FL0SaIhJHElw43/9oXpaaxftnVM4TGKW/ZyKxV5oh9epWocWqloFGry3D70jCL0 RKBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720701827; x=1721306627; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tkvhXyQdUbbQl7mJoRkfQeXHOAB7HBkszfs6KoOBWj8=; b=lwZc4HDvJMCkYXOv1Mx4W4x1CZRDhF2swsQ5+J29p+HgxlpzeaBPDTUyAGR4O4yY31 yvo6fmGmBKZyMvI75BPiZWfm5dn7iZjMZogrcwB66J0DVrLLMLodDFynsX7p1KZi7q3u L1kAXnCeonktwmcBGfBgEjrTMC7SGE3MP4FL3O0pQsAT+EWavkTi4c+47WrLrWHav4WH 6dd28K3cXlHiItyNREegjJQXfzhQ1N3+nM/Wh5tLDiX9eAzqxow5r8OSutRjc/RANec+ kQ1iMttbK583Fhyn6YHsFHPWKFNqvZab4cudEszlm8F4077IxkluwBSsy9hAZ5JY4sbr xgAg== X-Gm-Message-State: AOJu0YzWo/+iI0dgvKGUL3P2F4LsAojevxI77/rGHGymxzyK4T1jfO8M hiw2O3KknywHiM+GO0iwwj4I87u6MbVehgdLgfx8CdT6C8jYEqP0qkISyg== X-Google-Smtp-Source: AGHT+IGFjlJPTX1w4AOyypecygFaMa4RgDvMvaD8aE2qJ9xMc4gIGikXkRhV2uAkFzTDXTpftnM0wQ== X-Received: by 2002:a17:902:c94a:b0:1fb:57e7:5bab with SMTP id d9443c01a7336-1fbb6d08ecdmr64658385ad.36.1720701827221; Thu, 11 Jul 2024 05:43:47 -0700 (PDT) Received: from [192.168.0.16] ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6ad5e61sm49537165ad.306.2024.07.11.05.43.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Jul 2024 05:43:46 -0700 (PDT) Message-ID: Date: Thu, 11 Jul 2024 09:43:55 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: James Almer To: ffmpeg-devel@ffmpeg.org References: <20240709172140.48976-1-jamrial@gmail.com> Content-Language: en-US In-Reply-To: <20240709172140.48976-1-jamrial@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avformat/mov: ensure pasp box derived SAR is used if present 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 7/9/2024 2:21 PM, James Almer wrote: > It's meant to override any codec specific (but container level) information, > but its position is not guaranteed, so apply the values after the entire trak > structure has been parsed. > Also, replace the ugly roundabout int -> double -> int method to set SAR from > existing dimensions while at it. > > Signed-off-by: James Almer > --- > libavformat/isom.h | 2 ++ > libavformat/mov.c | 16 ++++++++++++---- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/libavformat/isom.h b/libavformat/isom.h > index a0498f45e5..5b6125a908 100644 > --- a/libavformat/isom.h > +++ b/libavformat/isom.h > @@ -215,6 +215,8 @@ typedef struct MOVStreamContext { > int timecode_track; > int width; ///< tkhd width > int height; ///< tkhd height > + int h_spacing; ///< pasp hSpacing > + int v_spacing; ///< pasp vSpacing > int dts_shift; ///< dts shift when ctts is negative > uint32_t palette[256]; > int has_palette; > diff --git a/libavformat/mov.c b/libavformat/mov.c > index ced4b2e6b3..ce95842ce5 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1287,14 +1287,18 @@ static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom) > const int num = avio_rb32(pb); > const int den = avio_rb32(pb); > AVStream *st; > + MOVStreamContext *sc; > > if (c->fc->nb_streams < 1) > return 0; > st = c->fc->streams[c->fc->nb_streams-1]; > + sc = st->priv_data; > + > + av_log(c->fc, AV_LOG_TRACE, "pasp: hSpacing %d, vSpacing %d\n", num, den); > > if (den != 0) { > - av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, > - num, den, 32767); > + sc->h_spacing = num; > + sc->v_spacing = den; > } > return 0; > } > @@ -5031,11 +5035,15 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) > } > > if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { > + if (sc->h_spacing && sc->v_spacing) > + av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, > + sc->h_spacing, sc->v_spacing, INT_MAX); > if (!st->sample_aspect_ratio.num && st->codecpar->width && st->codecpar->height && > sc->height && sc->width && > (st->codecpar->width != sc->width || st->codecpar->height != sc->height)) { > - st->sample_aspect_ratio = av_d2q(((double)st->codecpar->height * sc->width) / > - ((double)st->codecpar->width * sc->height), INT_MAX); > + av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, > + (int64_t)st->codecpar->height * sc->width, > + (int64_t)st->codecpar->width * sc->height, INT_MAX); > } > > #if FF_API_R_FRAME_RATE Will apply. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".