aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-03-03 16:28:32 +0100
committerAnton Khirnov <anton@khirnov.net>2012-03-05 18:44:45 +0100
commitdcee811505b9f95edad73526d94cabc99331b659 (patch)
tree0d852665ae3950af090b5c1ef660dc9a9b522b15 /libavformat
parent52b0943f10a790145f990f8056ab603edc0f7edb (diff)
downloadffmpeg-dcee811505b9f95edad73526d94cabc99331b659.tar.gz
lavf: make read_from_packet_buffer() more flexible.
Make packet buffer a parameter, don't hardcode it to be AVFormatContext.packet_buffer. Also move the function higher in the file, since it will be called from read_frame_internal().
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7661e98ae4..a3f8d4e961 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1011,6 +1011,21 @@ static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_en
*pkt_buf_end = NULL;
}
+static int read_from_packet_buffer(AVPacketList **pkt_buffer,
+ AVPacketList **pkt_buffer_end,
+ AVPacket *pkt)
+{
+ AVPacketList *pktl;
+ av_assert0(*pkt_buffer);
+ pktl = *pkt_buffer;
+ *pkt = pktl->pkt;
+ *pkt_buffer = pktl->next;
+ if (!pktl->next)
+ *pkt_buffer_end = NULL;
+ av_freep(&pktl);
+ return 0;
+}
+
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
@@ -1171,23 +1186,15 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
return 0;
}
-static int read_from_packet_buffer(AVFormatContext *s, AVPacket *pkt)
-{
- AVPacketList *pktl = s->packet_buffer;
- av_assert0(pktl);
- *pkt = pktl->pkt;
- s->packet_buffer = pktl->next;
- av_freep(&pktl);
- return 0;
-}
-
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
{
const int genpts = s->flags & AVFMT_FLAG_GENPTS;
int eof = 0;
if (!genpts)
- return s->packet_buffer ? read_from_packet_buffer(s, pkt) :
+ return s->packet_buffer ? read_from_packet_buffer(&s->packet_buffer,
+ &s->packet_buffer_end,
+ pkt) :
read_frame_internal(s, pkt);
for (;;) {
@@ -1213,7 +1220,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
/* read packet from packet buffer, if there is data */
if (!(next_pkt->pts == AV_NOPTS_VALUE &&
next_pkt->dts != AV_NOPTS_VALUE && !eof))
- return read_from_packet_buffer(s, pkt);
+ return read_from_packet_buffer(&s->packet_buffer,
+ &s->packet_buffer_end, pkt);
}
ret = read_frame_internal(s, pkt);