From patchwork Sun Nov 5 18:06:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 5868 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp2110928jah; Sun, 5 Nov 2017 10:08:09 -0800 (PST) X-Google-Smtp-Source: ABhQp+SRzMsbt6UOG1BzGre6TyX9K4hE8nw3j2y5N6RHY/gSO1+bWiRvET8Oo6p66nY2k5Q7EUvK X-Received: by 10.223.151.211 with SMTP id t19mr2880424wrb.2.1509905289383; Sun, 05 Nov 2017 10:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509905289; cv=none; d=google.com; s=arc-20160816; b=syg7+eiPyxYmr4ZUnFg2hHDomoQknsqXi+0bgS/rwker9YCtA5MJ3Dw1FDvRdEY8Wc 2dgYKdz30p+3fNKX6urfD0frpSoDNJKYcPBoCH1r+HZGRqiunOxOIck0WYgDJFML2cws B2NxUoD8iuX7r9HVuHA7pMg4sFJ450JvQKaY9OlgqRvRLyuQ9nn7EqEPLfzCPb3v3hoV iYLUPQIfjKYsjxvRQdW3Gzuxy+r2Ma86BPYgU2NlpEOrWv0+IFBtDoK5qi+aPTxCf4w4 sIHOv7mNgd5TB4AoxQoisNpIjubN8HnerbbJcEp5TXRgLjf4qbKvbAKVxsMH1rNKD5Wd U4cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=+Hh8G5VJ7dthi3wdYeRN5P9CYy51lywlKFu0KqzlLLk=; b=xohB7/8/G9e1nrjIc20ufbEnKH+HCT9PHYmpnI/Y2xoswTuvhDU/N2vxzQXZz/gvb9 g5qGldFAQTGDRfbzvYXIfbD5q3o6xHfa6OFo6tkrtXFNmjKzWI6+5B3xzUNnJXpEKEt/ JjglFNTZZcGWzaHYbH1ihsbKxsG9PoDjJ9JcTk0Ml9beib7dMEV0lXsTr9O9AhhQ3v+9 riwvTsHpvZM2ApZXH3el/wGN+FTLMrzyUVC3TFOCFFzZ+rEAUC8vW13EPgywnRSJxT4i QFDz6Ajly7x3+nxDP5ZRN4J8qy9kFS/WekDRdfhybikfneegtmuU+RtTgyS7iK5L71Ss ci7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=dpKHIWLl; 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=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 p25si8775860wra.111.2017.11.05.10.08.06; Sun, 05 Nov 2017 10:08:09 -0800 (PST) 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=20161025 header.b=dpKHIWLl; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4332F689D43; Sun, 5 Nov 2017 20:07:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E343B688290 for ; Sun, 5 Nov 2017 20:07:47 +0200 (EET) Received: by mail-qt0-f193.google.com with SMTP id z28so8474586qtz.13 for ; Sun, 05 Nov 2017 10:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Rv60rWrBegVDBlAioo66M9Wc3RcFGfT3hXgG4cmVoTc=; b=dpKHIWLlrEKtEKiQJbI4exdH3bKgd2lfcpL41szyDyfUgUJROMJxsUkJJrT2zGPO++ zAdvMGbqphum1NKMFASXxhodYQe9IJ/KUr+h4ab4CH7a940K0KTO9vvIi4cBbDMg5KZc iSDAGA3sCnXYLeOco5zkDVt0Jtd1GIN/jiEfPJfhu2rMFH7g5qavRhY6ZiynPGa5dpyt qcKaX0pAHRqR36uI2QkldH4uNq+sClvV6+70Xp3XNMF/DYwAbJIEYGyv0AZeorjo3dOP SqJ+9x3DzaUtQZBs2N753P5+UGvwcSiuKh50bqGEL1KlOPrwOOgZsGkZJnr+r+yaQL9B qEcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Rv60rWrBegVDBlAioo66M9Wc3RcFGfT3hXgG4cmVoTc=; b=FlSFq5K0b+yzjCcgt0Zj7pbU/Ub8WZrl50xGN7lQmkAxp4oizZB6Sa3tjEPFb/wlSu UiaJrUqvKZ/ML5982bM7zHPNLYY7u2XTC0wSCiTt5zLSkzm7sQg+raGEj5/2W/j5qdbz DyHri2dGlwN3bcwoW9S1xyhDxJjHqtkzc2y83iBG58x2d9krxO2J+zzoC8wQDdXJHqNu oGgfRjYsV3bdGPX9zLayCzk5CPkPW3YmFn33muOHw+ixRqcK1HOAtSa0wgzVzk6xpZnb +b3icgi2HncD8ew9wDqKobFlbPeEth/p/ldQtAIpHAKY7FOcg8V7AumKFKZUIKwq5KLu cFzw== X-Gm-Message-State: AJaThX7ZGZmnY+orM/Z5XzrbsqWPSeF6/U2fKMA4THwBXfGnBFnUZRXQ Eh1ndbJ5dO3eZWKxRpNYigxcAA== X-Received: by 10.200.9.91 with SMTP id z27mr19448469qth.207.1509905278210; Sun, 05 Nov 2017 10:07:58 -0800 (PST) Received: from localhost.localdomain ([181.231.59.220]) by smtp.gmail.com with ESMTPSA id a189sm6912934qkb.84.2017.11.05.10.07.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Nov 2017 10:07:57 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 5 Nov 2017 15:06:56 -0300 Message-Id: <20171105180656.4004-1-jamrial@gmail.com> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH] avformat: move priv_pts from AVStream to an internal struct 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It has no reason to be in a public header, even if defined as private. Signed-off-by: James Almer --- To be honest, none of the fields below the "not part of the API" notice have any reason to be in the public struct, but this one is particularly pointless and ugly to have there as FFFrac is defined in internal.h libavformat/avformat.h | 2 -- libavformat/internal.h | 2 ++ libavformat/mux.c | 18 +++++++++--------- libavformat/utils.c | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index b36e2a3bd4..c068aa8009 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1200,8 +1200,6 @@ typedef struct AVStream { */ AVRational display_aspect_ratio; - struct FFFrac *priv_pts; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index d136c79bdd..fcd47840a5 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -196,6 +196,8 @@ struct AVStreamInternal { * Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar) */ int need_context_update; + + FFFrac *priv_pts; }; #ifdef __GNUC__ diff --git a/libavformat/mux.c b/libavformat/mux.c index 1445e7dcd6..b1244c67f3 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -432,16 +432,16 @@ static int init_pts(AVFormatContext *s) break; } - if (!st->priv_pts) - st->priv_pts = av_mallocz(sizeof(*st->priv_pts)); - if (!st->priv_pts) + if (!st->internal->priv_pts) + st->internal->priv_pts = av_mallocz(sizeof(*st->internal->priv_pts)); + if (!st->internal->priv_pts) return AVERROR(ENOMEM); if (den != AV_NOPTS_VALUE) { if (den <= 0) return AVERROR_INVALIDDATA; - frac_init(st->priv_pts, 0, 0, den); + frac_init(st->internal->priv_pts, 0, 0, den); } } @@ -601,7 +601,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * } pkt->dts = // pkt->pts= st->cur_dts; - pkt->pts = st->priv_pts->val; + pkt->pts = st->internal->priv_pts->val; } //calculate dts from pts @@ -638,7 +638,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * av_ts2str(pkt->pts), av_ts2str(pkt->dts)); st->cur_dts = pkt->dts; - st->priv_pts->val = pkt->dts; + st->internal->priv_pts->val = pkt->dts; /* update pts */ switch (st->codecpar->codec_type) { @@ -650,12 +650,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * /* HACK/FIXME, we skip the initial 0 size packets as they are most * likely equal to the encoder delay, but it would be better if we * had the real timestamps from the encoder */ - if (frame_size >= 0 && (pkt->size || st->priv_pts->num != st->priv_pts->den >> 1 || st->priv_pts->val)) { - frac_add(st->priv_pts, (int64_t)st->time_base.den * frame_size); + if (frame_size >= 0 && (pkt->size || st->internal->priv_pts->num != st->internal->priv_pts->den >> 1 || st->internal->priv_pts->val)) { + frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * frame_size); } break; case AVMEDIA_TYPE_VIDEO: - frac_add(st->priv_pts, (int64_t)st->time_base.den * st->time_base.num); + frac_add(st->internal->priv_pts, (int64_t)st->time_base.den * st->time_base.num); break; } return 0; diff --git a/libavformat/utils.c b/libavformat/utils.c index cbfb78bf4d..2b2411ffe7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -123,8 +123,8 @@ FF_ENABLE_DEPRECATION_WARNINGS int64_t av_stream_get_end_pts(const AVStream *st) { - if (st->priv_pts) { - return st->priv_pts->val; + if (st->internal->priv_pts) { + return st->internal->priv_pts->val; } else return AV_NOPTS_VALUE; } @@ -4263,6 +4263,7 @@ static void free_stream(AVStream **pst) av_bsf_free(&st->internal->bsfcs[i]); av_freep(&st->internal->bsfcs); } + av_freep(&st->internal->priv_pts); av_bsf_free(&st->internal->extract_extradata.bsf); av_packet_free(&st->internal->extract_extradata.pkt); } @@ -4282,7 +4283,6 @@ FF_ENABLE_DEPRECATION_WARNINGS av_freep(&st->info->duration_error); av_freep(&st->info); av_freep(&st->recommended_encoder_configuration); - av_freep(&st->priv_pts); av_freep(pst); }