Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/8] avformat/demux: allow demuxers to output more than one packet per read_packet() call
@ 2024-02-17 22:02 James Almer
  2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 2/8] avformat/iamfdec: further split into shareable modules James Almer
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: James Almer @ 2024-02-17 22:02 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/demux.c | 72 +++++++++++++++++++++++++++++++++------------
 libavformat/demux.h |  2 ++
 2 files changed, 56 insertions(+), 18 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index b70979c520..e0205f9dec 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -540,6 +540,59 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
     return 1;
 }
 
+static void update_timestamps(AVFormatContext *s, AVStream *st, AVPacket *pkt)
+{
+    FFStream *const sti = ffstream(st);
+
+    if (update_wrap_reference(s, st, pkt->stream_index, pkt) && sti->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
+        // correct first time stamps to negative values
+        if (!is_relative(sti->first_dts))
+            sti->first_dts = wrap_timestamp(st, sti->first_dts);
+        if (!is_relative(st->start_time))
+            st->start_time = wrap_timestamp(st, st->start_time);
+        if (!is_relative(sti->cur_dts))
+            sti->cur_dts = wrap_timestamp(st, sti->cur_dts);
+    }
+
+    pkt->dts = wrap_timestamp(st, pkt->dts);
+    pkt->pts = wrap_timestamp(st, pkt->pts);
+
+    force_codec_ids(s, st);
+
+    /* TODO: audio: time filter; video: frame reordering (pts != dts) */
+    if (s->use_wallclock_as_timestamps)
+        pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
+}
+
+int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    FFFormatContext *const si = ffformatcontext(s);
+    AVStream *st  = s->streams[pkt->stream_index];
+    FFStream *sti = ffstream(st);
+    const AVPacket *pkt1;
+    int err;
+
+    update_timestamps(s, st, pkt);
+
+    err = avpriv_packet_list_put(&si->raw_packet_buffer, pkt, NULL, 0);
+    if (err < 0) {
+        av_packet_unref(pkt);
+        return err;
+    }
+
+    pkt1 = &si->raw_packet_buffer.tail->pkt;
+    si->raw_packet_buffer_size += pkt1->size;
+
+    if (sti->request_probe <= 0)
+        return 0;
+
+    err = probe_codec(s, st, pkt1);
+    if (err < 0)
+        return err;
+
+    return 0;
+}
+
 int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     FFFormatContext *const si = ffformatcontext(s);
@@ -619,24 +672,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         st  = s->streams[pkt->stream_index];
         sti = ffstream(st);
 
-        if (update_wrap_reference(s, st, pkt->stream_index, pkt) && sti->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
-            // correct first time stamps to negative values
-            if (!is_relative(sti->first_dts))
-                sti->first_dts = wrap_timestamp(st, sti->first_dts);
-            if (!is_relative(st->start_time))
-                st->start_time = wrap_timestamp(st, st->start_time);
-            if (!is_relative(sti->cur_dts))
-                sti->cur_dts = wrap_timestamp(st, sti->cur_dts);
-        }
-
-        pkt->dts = wrap_timestamp(st, pkt->dts);
-        pkt->pts = wrap_timestamp(st, pkt->pts);
-
-        force_codec_ids(s, st);
-
-        /* TODO: audio: time filter; video: frame reordering (pts != dts) */
-        if (s->use_wallclock_as_timestamps)
-            pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
+        update_timestamps(s, st, pkt);
 
         if (!pktl && sti->request_probe <= 0)
             return 0;
diff --git a/libavformat/demux.h b/libavformat/demux.h
index d65eb16ff8..04a426c420 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -238,4 +238,6 @@ int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int
  */
 int ff_find_stream_index(const AVFormatContext *s, int id);
 
+int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt);
+
 #endif /* AVFORMAT_DEMUX_H */
-- 
2.43.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".

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-02-20 14:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-17 22:02 [FFmpeg-devel] [PATCH 1/8] avformat/demux: allow demuxers to output more than one packet per read_packet() call James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 2/8] avformat/iamfdec: further split into shareable modules James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 3/8] avformat/mov: factorize out setting the output packet properties James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 4/8] avformat/mov: make MOVStreamContext refcounted James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 5/8] avformat/mov: add support for Immersive Audio Model and Formats in ISOBMFF James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 6/8] avformat/iamfenc: further split into shareable modules James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 7/8] avformat/movenc: add support for Immersive Audio Model and Formats in ISOBMFF James Almer
2024-02-20 13:37   ` Andreas Rheinhardt
2024-02-20 14:07     ` James Almer
2024-02-20 14:21       ` Andreas Rheinhardt
2024-02-20 14:47         ` James Almer
2024-02-17 22:02 ` [FFmpeg-devel] [PATCH 8/8] fate: add IAMF in mp4 tests James Almer
2024-02-20 13:29   ` James Almer

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