Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 5/5] avformat/mux: Don't allocate priv_pts separately
Date: Sat,  3 Feb 2024 20:33:30 +0100
Message-ID: <AS8P250MB07448F5E47BD5D12F9D7AE8A8F412@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB07440C090EEE263B0846D5838F412@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/avformat.c  |  1 -
 libavformat/internal.h  |  2 +-
 libavformat/mux.c       | 17 ++++++-----------
 libavformat/mux_utils.c |  5 +----
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index ae79ee6ef7..ca31d3dc56 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -63,7 +63,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
     av_parser_close(sti->parser);
     avcodec_free_context(&sti->avctx);
     av_bsf_free(&sti->bsfc);
-    av_freep(&sti->priv_pts);
     av_freep(&sti->index_entries);
     av_freep(&sti->probe_data.buf);
 
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 520f1a5229..c66f959e9f 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -245,7 +245,7 @@ typedef struct FFStream {
 
     int is_intra_only;
 
-    FFFrac *priv_pts;
+    FFFrac priv_pts;
 
     /**
      * Stream information used internally by avformat_find_stream_info()
diff --git a/libavformat/mux.c b/libavformat/mux.c
index de10d2c008..93280f9047 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -406,16 +406,11 @@ static int init_pts(AVFormatContext *s)
             break;
         }
 
-        if (!sti->priv_pts)
-            sti->priv_pts = av_mallocz(sizeof(*sti->priv_pts));
-        if (!sti->priv_pts)
-            return AVERROR(ENOMEM);
-
         if (den != AV_NOPTS_VALUE) {
             if (den <= 0)
                 return AVERROR_INVALIDDATA;
 
-            frac_init(sti->priv_pts, 0, 0, den);
+            frac_init(&sti->priv_pts, 0, 0, den);
         }
     }
 
@@ -550,7 +545,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
         }
         pkt->dts =
 //        pkt->pts= st->cur_dts;
-            pkt->pts = sti->priv_pts->val;
+            pkt->pts = sti->priv_pts.val;
     }
 
     //calculate dts from pts
@@ -587,7 +582,7 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
             av_ts2str(pkt->pts), av_ts2str(pkt->dts));
 
     sti->cur_dts      = pkt->dts;
-    sti->priv_pts->val = pkt->dts;
+    sti->priv_pts.val = pkt->dts;
 
     /* update pts */
     switch (st->codecpar->codec_type) {
@@ -599,12 +594,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 || sti->priv_pts->num != sti->priv_pts->den >> 1 || sti->priv_pts->val)) {
-            frac_add(sti->priv_pts, (int64_t)st->time_base.den * frame_size);
+        if (frame_size >= 0 && (pkt->size || sti->priv_pts.num != sti->priv_pts.den >> 1 || sti->priv_pts.val)) {
+            frac_add(&sti->priv_pts, (int64_t)st->time_base.den * frame_size);
         }
         break;
     case AVMEDIA_TYPE_VIDEO:
-        frac_add(sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
+        frac_add(&sti->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
         break;
     }
     return 0;
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index 3e63b8039a..c7ac2a9c97 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -33,10 +33,7 @@
 #if FF_API_GET_END_PTS
 int64_t av_stream_get_end_pts(const AVStream *st)
 {
-    if (cffstream(st)->priv_pts) {
-        return cffstream(st)->priv_pts->val;
-    } else
-        return AV_NOPTS_VALUE;
+    return cffstream(st)->priv_pts.val;
 }
 #endif
 
-- 
2.34.1

_______________________________________________
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".

  parent reply	other threads:[~2024-02-03 19:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-03 11:25 [FFmpeg-devel] [PATCH 1/3] avformat/avformat: Remove dead check, write-only assignment Andreas Rheinhardt
2024-02-03 11:29 ` [FFmpeg-devel] [PATCH 2/3] avformat/avformat: Remove obsolete comment Andreas Rheinhardt
2024-02-03 11:29 ` [FFmpeg-devel] [PATCH 3/3] avformat/options: Only allocate AVCodecContext for demuxers Andreas Rheinhardt
2024-02-03 19:33 ` [FFmpeg-devel] [PATCH 4/5] avformat/avformat: Avoid av_strdup(NULL) Andreas Rheinhardt
2024-02-03 19:33 ` Andreas Rheinhardt [this message]
2024-02-06  8:57 ` [FFmpeg-devel] [PATCH 1/3] avformat/avformat: Remove dead check, write-only assignment Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB07448F5E47BD5D12F9D7AE8A8F412@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git