Skip to content

Commit ac2d961

Browse files
committed
Bring av_read_frame_flush in line with ffmpeg git.
Current version failed to build with ffmpeg git. This patch uses the new code when we are building against libavformat 54.
1 parent f4b1c8c commit ac2d961

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/xbmc-dll-symbols/DllAvFormat.c

+35
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <libavformat/avformat.h>
2929

3030
/* Taken from libavformat/utils.c */
31+
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0)
3132
static void flush_packet_queue(AVFormatContext *s)
3233
{
3334
AVPacketList *pktl;
@@ -53,6 +54,27 @@ static void flush_packet_queue(AVFormatContext *s)
5354
s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
5455
#endif
5556
}
57+
#else
58+
static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_end)
59+
{
60+
while (*pkt_buf) {
61+
AVPacketList *pktl = *pkt_buf;
62+
*pkt_buf = pktl->next;
63+
av_free_packet(&pktl->pkt);
64+
av_freep(&pktl);
65+
}
66+
*pkt_buf_end = NULL;
67+
}
68+
/* XXX: suppress the packet queue */
69+
static void flush_packet_queue(AVFormatContext *s)
70+
{
71+
free_packet_buffer(&s->parse_queue, &s->parse_queue_end);
72+
free_packet_buffer(&s->packet_buffer, &s->packet_buffer_end);
73+
free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end);
74+
75+
s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
76+
}
77+
#endif
5678

5779
/* Taken from libavformat/utils.c */
5880
void av_read_frame_flush(AVFormatContext *s)
@@ -62,7 +84,9 @@ void av_read_frame_flush(AVFormatContext *s)
6284

6385
flush_packet_queue(s);
6486

87+
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0)
6588
s->cur_st = NULL;
89+
#endif
6690

6791
/* for each stream, reset read state */
6892
for(i = 0; i < s->nb_streams; i++) {
@@ -71,14 +95,25 @@ void av_read_frame_flush(AVFormatContext *s)
7195
if (st->parser) {
7296
av_parser_close(st->parser);
7397
st->parser = NULL;
98+
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0)
7499
av_free_packet(&st->cur_pkt);
100+
#endif
75101
}
76102
st->last_IP_pts = AV_NOPTS_VALUE;
103+
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54,0,0)
77104
st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
78105
st->reference_dts = AV_NOPTS_VALUE;
79106
/* fail safe */
80107
st->cur_ptr = NULL;
81108
st->cur_len = 0;
109+
#else
110+
#define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
111+
if(st->first_dts == AV_NOPTS_VALUE) st->cur_dts = RELATIVE_TS_BASE;
112+
else st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
113+
st->reference_dts = AV_NOPTS_VALUE;
114+
115+
st->probe_packets = MAX_PROBE_PACKETS;
116+
#endif
82117

83118
for(j=0; j<MAX_REORDER_DELAY+1; j++)
84119
st->pts_buffer[j]= AV_NOPTS_VALUE;

0 commit comments

Comments
 (0)