From patchwork Mon Apr 20 17:57:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wheatley X-Patchwork-Id: 19111 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 3914044BC44 for ; Mon, 20 Apr 2020 21:06:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1501568B783; Mon, 20 Apr 2020 21:06:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B51D1689D18 for ; Mon, 20 Apr 2020 21:06:05 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id h2so558340wmb.4 for ; Mon, 20 Apr 2020 11:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iqhJX8uZDjV0ZnZc1IiVWXYI0NfU/Uq7sC7Yizt0JDc=; b=gkQo9d1hdiOZXls6y1RTE3Dwq/1CbPtPXxpC0sJ/7G4ysYzMqORL4khbbGVi8ZCPqU fyhUSgyjMVjmFx+xnisvs3LDZEedD0IhqcwOiOzaxBF/k1FFzm/qaFS/5ywRYLyfXlmM 1aVbB1KVMRHYrKXJI5O7WTCDwMkWVHYdjOgVSBVH4eDjxZiG6eBXzaVHB8DfYAOta2Jr G3+SG5s8u7ZFvOMN+AIuEXYEWgMx9bXkE92uZEWdfrSVdPWNd8cW0NGPjARtNCMkI6k+ yJYcwKdX5R22vua4rqH2DruVqXgOBHceIToHp2CZkczUo4BAH++w3ba3g3Aj+JfBS+gk 0heg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iqhJX8uZDjV0ZnZc1IiVWXYI0NfU/Uq7sC7Yizt0JDc=; b=mwbjaeT18vhXz+L7kqV4Tc+LN+XTPDbFfk//amhjdXVza61010dESY640J5VA2HmkP t+3UBG84aD0vHI+b+sVvf1VRwMhxsTL941SlggtAGBvpQ53fvuj820vxKYFN1bMg4NVF jkWKusjb68+HAhbEdhAuLu+MaiF6NZDMEs3rbiq+CxiywrByCT1WRFYpLpqtyKeJVALp EcJQ0p5bn1AU97zNwl0dI2BX8Zgu6ZH8nm61UT143NrYvVC83aVLgqy/41PIHnNOEKJs Mu97wB60AheMsBLETWcZbQ+tszfSf2dL0/6eDSEaQXoJ9z0bAUs+AV4T+TDaXarKNIR3 mxKA== X-Gm-Message-State: AGi0Pua+TOH5U3JXzzlrKHDWAR5lgDFhIbLl2BLNoZmq3wxppfDmkndP oddjx9BF7TjAEWxvmuA4wWTJIk2gtDk= X-Google-Smtp-Source: APiQypJs1vFSouJLx2dZd6qe58Nd0+Y45JYkOat5YjeDAiM1PkDOrwj3+gZu+yKb+VC1DI5GzHO4mQ== X-Received: by 2002:a1c:1985:: with SMTP id 127mr578196wmz.13.1587405514926; Mon, 20 Apr 2020 10:58:34 -0700 (PDT) Received: from derwent.ldn.framestore.com (ldndefault.framestore.com. [185.101.14.7]) by smtp.gmail.com with ESMTPSA id l5sm287930wrm.66.2020.04.20.10.58.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 10:58:34 -0700 (PDT) From: Kevin Wheatley To: ffmpeg-devel@ffmpeg.org Date: Mon, 20 Apr 2020 18:57:38 +0100 Message-Id: <1587405459-29001-3-git-send-email-kevin.j.wheatley@gmail.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1587405459-29001-1-git-send-email-kevin.j.wheatley@gmail.com> References: <1587405459-29001-1-git-send-email-kevin.j.wheatley@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/3] avformat/movenc: Use base container timescale, instead of hard coded default 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 Cc: Kevin Wheatley , Kevin Wheatley MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Kevin Wheatley --- libavformat/movenc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7d79eca..508fa73 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2879,7 +2879,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVStream *st) { int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), - MOV_TIMESCALE, track->timescale, + mov->mov_timescale, track->timescale, AV_ROUND_UP); int version = duration < INT32_MAX ? 0 : 1; int flags = MOV_TKHD_FLAG_IN_MOVIE; @@ -3027,7 +3027,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), - MOV_TIMESCALE, track->timescale, + mov->mov_timescale, track->timescale, AV_ROUND_UP); int version = duration < INT32_MAX ? 0 : 1; int entry_size, entry_count, size; @@ -3046,7 +3046,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, } } - delay = av_rescale_rnd(start_dts + start_ct, MOV_TIMESCALE, + delay = av_rescale_rnd(start_dts + start_ct, mov->mov_timescale, track->timescale, AV_ROUND_DOWN); version |= delay < INT32_MAX ? 0 : 1; @@ -3081,8 +3081,8 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, /* Avoid accidentally ending up with start_ct = -1 which has got a * special meaning. Normally start_ct should end up positive or zero * here, but use FFMIN in case dts is a small positive integer - * rounded to 0 when represented in MOV_TIMESCALE units. */ - av_assert0(av_rescale_rnd(start_dts, MOV_TIMESCALE, track->timescale, AV_ROUND_DOWN) <= 0); + * rounded to 0 when represented in mov->mov_timescale units. */ + av_assert0(av_rescale_rnd(start_dts, mov->mov_timescale, track->timescale, AV_ROUND_DOWN) <= 0); start_ct = -FFMIN(start_dts, 0); /* Note, this delay is calculated from the pts of the first sample, * ensuring that we don't reduce the duration for cases with @@ -3316,7 +3316,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) if (mov->tracks[i].entry > 0 && mov->tracks[i].timescale) { int64_t max_track_len_temp = av_rescale_rnd( calc_pts_duration(mov, &mov->tracks[i]), - MOV_TIMESCALE, + mov->mov_timescale, mov->tracks[i].timescale, AV_ROUND_UP); if (max_track_len < max_track_len_temp) @@ -3345,7 +3345,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) avio_wb32(pb, mov->time); /* creation time */ avio_wb32(pb, mov->time); /* modification time */ } - avio_wb32(pb, MOV_TIMESCALE); + avio_wb32(pb, mov->mov_timescale); (version == 1) ? avio_wb64(pb, max_track_len) : avio_wb32(pb, max_track_len); /* duration of longest track */ avio_wb32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */ @@ -5921,7 +5921,7 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum) track->mode = mov->mode; track->tag = MKTAG('t','e','x','t'); - track->timescale = MOV_TIMESCALE; + track->timescale = mov->mov_timescale; track->par = avcodec_parameters_alloc(); if (!track->par) return AVERROR(ENOMEM); @@ -5982,8 +5982,8 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum) AVChapter *c = s->chapters[i]; AVDictionaryEntry *t; - int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE}); - pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE}); + int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,mov->mov_timescale}); + pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,mov->mov_timescale}); pkt.duration = end - pkt.dts; if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { @@ -6518,7 +6518,7 @@ static int mov_init(AVFormatContext *s) } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { track->timescale = st->time_base.den; } else { - track->timescale = MOV_TIMESCALE; + track->timescale = mov->mov_timescale; } if (!track->height) track->height = st->codecpar->height;