summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-29 02:08:54 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-29 02:08:54 +0200
commit6faf0a21e18f314c48a886864145abe715be6572 (patch)
treef67c3e543a8b2c3283875881536d0a69da515e5e /libavformat
parented1aa8921749a1c70d4453326da7f7b5a6f6f6e7 (diff)
parent61856d06eb30955290911140e6745bad93a25323 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (53 commits) probe: Restore identification of files with very large id3 tags and no extension. probe: Remove id3 tag presence as a criteria to do file extension checking. mpegts: MP4 SL support mpegts: MP4 OD support mpegts: Add support for Sections in PMT mpegts: Replace the MP4 descriptor parser with a recursive parser. mpegts: Add support for multiple mp4 descriptors mpegts: Parse mpeg2 SL descriptors. isom: Add MPEG4SYSTEMS dummy object type indication. aacdec: allow output reconfiguration on channel changes nellymoserenc: take float input samples instead of int16 nellymoserdec: use dsp functions for overlap and windowing nellymoserdec: do not fail if there is extra data in the packet nellymoserdec: fail if output buffer is too small nellymoserdec: remove pointless buffer size check. lavf: add init_put_byte() to the list of visible symbols. seek-test: free options dictionary after use snow: do not draw_edge if emu_edge is set tools/pktdumper: update to recent avformat api seek-test: update to recent avformat api ... Conflicts: doc/APIchanges libavcodec/mpegaudiodec.c libavcodec/nellymoserdec.c libavcodec/snow.c libavcodec/version.h libavcodec/wmadec.c libavformat/avformat.h libavformat/mpegts.c libavformat/mxfdec.c libavformat/utils.c libavformat/wtv.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/asfdec.c2
-rw-r--r--libavformat/avformat.h136
-rw-r--r--libavformat/internal.h33
-rw-r--r--libavformat/isom.c2
-rw-r--r--libavformat/isom.h2
-rw-r--r--libavformat/matroskadec.c2
-rw-r--r--libavformat/mpegts.c451
-rw-r--r--libavformat/mpegts.h29
-rw-r--r--libavformat/mxfdec.c3
-rw-r--r--libavformat/nutdec.c8
-rw-r--r--libavformat/oggdec.c3
-rw-r--r--libavformat/seek-test.c11
-rw-r--r--libavformat/utils.c46
-rw-r--r--libavformat/version.h6
-rw-r--r--libavformat/wtvdec.c2
15 files changed, 643 insertions, 93 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 6af4439e87..3dc0b1716a 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1297,7 +1297,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
}
}
/* no index or seeking by index failed */
- if(av_seek_frame_binary(s, stream_index, pts, flags)<0)
+ if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
return -1;
asf_reset_header(s);
return 0;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 425198fcda..60ff6dcf03 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -523,8 +523,10 @@ typedef struct AVStream {
AVRational r_frame_rate;
void *priv_data;
+#if FF_API_REORDER_PRIVATE
/* internal data used in av_find_stream_info() */
int64_t first_dts;
+#endif
/**
* encoding: pts generation when outputting stream
@@ -539,7 +541,9 @@ typedef struct AVStream {
* encoding: set by libavformat in av_write_header
*/
AVRational time_base;
+#if FF_API_REORDER_PRIVATE
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
+#endif
#if FF_API_STREAM_COPY
/* ffmpeg.c private use */
attribute_deprecated int stream_copy; /**< If set, just copy stream. */
@@ -572,6 +576,7 @@ typedef struct AVStream {
*/
int64_t duration;
+#if FF_API_REORDER_PRIVATE
/* av_read_frame() support */
enum AVStreamParseType need_parsing;
struct AVCodecParserContext *parser;
@@ -584,14 +589,17 @@ typedef struct AVStream {
support seeking natively. */
int nb_index_entries;
unsigned int index_entries_allocated_size;
+#endif
int64_t nb_frames; ///< number of frames in this stream if known or 0
int disposition; /**< AV_DISPOSITION_* bit field */
+#if FF_API_REORDER_PRIVATE
AVProbeData probe_data;
#define MAX_REORDER_DELAY 16
int64_t pts_buffer[MAX_REORDER_DELAY+1];
+#endif
/**
* sample aspect ratio (0 if unknown)
@@ -602,6 +610,7 @@ typedef struct AVStream {
AVDictionary *metadata;
+#if FF_API_REORDER_PRIVATE
/* Intended mostly for av_read_frame() support. Not supposed to be used by */
/* external applications; try to use something else if at all possible. */
const uint8_t *cur_ptr;
@@ -630,12 +639,21 @@ typedef struct AVStream {
* used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav*
*/
struct AVPacketList *last_in_packet_buffer;
+#endif
/**
* Average framerate
*/
AVRational avg_frame_rate;
+ /*****************************************************************
+ * All fields below this line are not part of the public API. They
+ * may not be used outside of libavformat and can be changed and
+ * removed at will.
+ * New public fields should be added right above.
+ *****************************************************************
+ */
+
/**
* Number of frames that have been demuxed during av_find_stream_info()
*/
@@ -665,6 +683,49 @@ typedef struct AVStream {
* NOT PART OF PUBLIC API
*/
int request_probe;
+#if !FF_API_REORDER_PRIVATE
+ const uint8_t *cur_ptr;
+ int cur_len;
+ AVPacket cur_pkt;
+
+ // Timestamp generation support:
+ /**
+ * Timestamp corresponding to the last dts sync point.
+ *
+ * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
+ * a DTS is received from the underlying container. Otherwise set to
+ * AV_NOPTS_VALUE by default.
+ */
+ int64_t reference_dts;
+ int64_t first_dts;
+ int64_t cur_dts;
+ int last_IP_duration;
+ int64_t last_IP_pts;
+
+ /**
+ * Number of packets to buffer for codec probing
+ */
+#define MAX_PROBE_PACKETS 2500
+ int probe_packets;
+
+ /**
+ * last packet in packet_buffer for this stream when muxing.
+ */
+ struct AVPacketList *last_in_packet_buffer;
+ AVProbeData probe_data;
+#define MAX_REORDER_DELAY 16
+ int64_t pts_buffer[MAX_REORDER_DELAY+1];
+ /* av_read_frame() support */
+ enum AVStreamParseType need_parsing;
+ struct AVCodecParserContext *parser;
+
+ AVIndexEntry *index_entries; /**< Only used if the format does not
+ support seeking natively. */
+ int nb_index_entries;
+ unsigned int index_entries_allocated_size;
+
+ int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
+#endif
} AVStream;
#define AV_PROGRAM_RUNNING 1
@@ -724,6 +785,7 @@ typedef struct AVFormatContext {
#endif
int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */
+#if FF_API_REORDER_PRIVATE
/* private data for pts handling (do not modify directly). */
/**
* This buffer is only needed when packets were already buffered but
@@ -731,6 +793,7 @@ typedef struct AVFormatContext {
* streams.
*/
struct AVPacketList *packet_buffer;
+#endif
/**
* Decoding: position of the first frame of the component, in
@@ -761,11 +824,13 @@ typedef struct AVFormatContext {
*/
int bit_rate;
+#if FF_API_REORDER_PRIVATE
/* av_read_frame() support */
AVStream *cur_st;
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
+#endif
#if FF_API_MUXRATE
/**
@@ -876,6 +941,7 @@ typedef struct AVFormatContext {
int debug;
#define FF_FDEBUG_TS 0x0001
+#if FF_API_REORDER_PRIVATE
/**
* Raw packets from the demuxer, prior to parsing and decoding.
* This buffer is used for buffering packets until the codec can
@@ -886,15 +952,18 @@ typedef struct AVFormatContext {
struct AVPacketList *raw_packet_buffer_end;
struct AVPacketList *packet_buffer_end;
+#endif
AVDictionary *metadata;
+#if FF_API_REORDER_PRIVATE
/**
* Remaining size available for raw_packet_buffer, in bytes.
* NOT PART OF PUBLIC API
*/
#define RAW_PACKET_BUFFER_SIZE 2500000
int raw_packet_buffer_remaining_size;
+#endif
/**
* Start time of the stream in real world time, in microseconds
@@ -923,6 +992,43 @@ typedef struct AVFormatContext {
* This will be moved into demuxer private options. Thus no API/ABI compatibility
*/
int ts_id;
+
+ /*****************************************************************
+ * All fields below this line are not part of the public API. They
+ * may not be used outside of libavformat and can be changed and
+ * removed at will.
+ * New public fields should be added right above.
+ *****************************************************************
+ */
+#if !FF_API_REORDER_PRIVATE
+ /**
+ * Raw packets from the demuxer, prior to parsing and decoding.
+ * This buffer is used for buffering packets until the codec can
+ * be identified, as parsing cannot be done without knowing the
+ * codec.
+ */
+ struct AVPacketList *raw_packet_buffer;
+ struct AVPacketList *raw_packet_buffer_end;
+ /**
+ * Remaining size available for raw_packet_buffer, in bytes.
+ */
+#define RAW_PACKET_BUFFER_SIZE 2500000
+ int raw_packet_buffer_remaining_size;
+
+ /**
+ * This buffer is only needed when packets were already buffered but
+ * not decoded, for example to get the codec parameters in MPEG
+ * streams.
+ */
+ struct AVPacketList *packet_buffer;
+ struct AVPacketList *packet_buffer_end;
+
+ /* av_read_frame() support */
+ AVStream *cur_st;
+
+ /* av_seek_frame() support */
+ int64_t data_offset; /**< offset of the first packet */
+#endif
} AVFormatContext;
typedef struct AVPacketList {
@@ -1479,40 +1585,20 @@ int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
int size, int distance, int flags);
-/**
- * Perform a binary search using av_index_search_timestamp() and
- * AVInputFormat.read_timestamp().
- * This is not supposed to be called directly by a user application,
- * but by demuxers.
- * @param target_ts target timestamp in the time base of the given stream
- * @param stream_index stream number
- */
+#if FF_API_SEEK_PUBLIC
+attribute_deprecated
int av_seek_frame_binary(AVFormatContext *s, int stream_index,
int64_t target_ts, int flags);
-
-/**
- * Update cur_dts of all streams based on the given timestamp and AVStream.
- *
- * Stream ref_st unchanged, others set cur_dts in their native time base.
- * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
- * @param timestamp new dts expressed in time_base of param ref_st
- * @param ref_st reference stream giving time_base of param timestamp
- */
+attribute_deprecated
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
-
-/**
- * Perform a binary search using read_timestamp().
- * This is not supposed to be called directly by a user application,
- * but by demuxers.
- * @param target_ts target timestamp in the time base of the given stream
- * @param stream_index stream number
- */
+attribute_deprecated
int64_t av_gen_search(AVFormatContext *s, int stream_index,
int64_t target_ts, int64_t pos_min,
int64_t pos_max, int64_t pos_limit,
int64_t ts_min, int64_t ts_max,
int flags, int64_t *ts_ret,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
+#endif
/**
* media file output
diff --git a/libavformat/internal.h b/libavformat/internal.h
index a2e80f2de3..582a2c8fe1 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -251,4 +251,37 @@ enum CodecID ff_guess_image2_codec(const char *filename);
*/
int64_t ff_iso8601_to_unix_time(const char *datestr);
+/**
+ * Perform a binary search using av_index_search_timestamp() and
+ * AVInputFormat.read_timestamp().
+ *
+ * @param target_ts target timestamp in the time base of the given stream
+ * @param stream_index stream number
+ */
+int ff_seek_frame_binary(AVFormatContext *s, int stream_index,
+ int64_t target_ts, int flags);
+
+/**
+ * Update cur_dts of all streams based on the given timestamp and AVStream.
+ *
+ * Stream ref_st unchanged, others set cur_dts in their native time base.
+ * Only needed for timestamp wrapping or if (dts not set and pts!=dts).
+ * @param timestamp new dts expressed in time_base of param ref_st
+ * @param ref_st reference stream giving time_base of param timestamp
+ */
+void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
+
+/**
+ * Perform a binary search using read_timestamp().
+ *
+ * @param target_ts target timestamp in the time base of the given stream
+ * @param stream_index stream number
+ */
+int64_t ff_gen_search(AVFormatContext *s, int stream_index,
+ int64_t target_ts, int64_t pos_min,
+ int64_t pos_max, int64_t pos_limit,
+ int64_t ts_min, int64_t ts_max,
+ int flags, int64_t *ts_ret,
+ int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 81a89fa405..c7272ddc9c 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -61,6 +61,8 @@ const AVCodecTag ff_mp4_obj_type[] = {
{ CODEC_ID_VORBIS , 0xDD }, /* non standard, gpac uses it */
{ CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* non standard, see unsupported-embedded-subs-2.mp4 */
{ CODEC_ID_QCELP , 0xE1 },
+ { CODEC_ID_MPEG4SYSTEMS, 0x01 },
+ { CODEC_ID_MPEG4SYSTEMS, 0x02 },
{ CODEC_ID_NONE , 0 },
};
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 9269799e5e..8f92caed0c 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -150,10 +150,12 @@ int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb);
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
+#define MP4ODescrTag 0x01
#define MP4IODescrTag 0x02
#define MP4ESDescrTag 0x03
#define MP4DecConfigDescrTag 0x04
#define MP4DecSpecificDescrTag 0x05
+#define MP4SLDescrTag 0x06
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 78e337bfab..f31c731c70 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2071,7 +2071,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
matroska->skip_to_timecode = st->index_entries[index].timestamp;
matroska->done = 0;
- av_update_cur_dts(s, st, st->index_entries[index].timestamp);
+ ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
return 0;
}
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index f193b0f3a7..1bedbf2948 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -29,6 +29,7 @@
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavcodec/bytestream.h"
+#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
@@ -43,6 +44,8 @@
#define MAX_PES_PAYLOAD 200*1024
+#define MAX_MP4_DESCR_COUNT 16
+
enum MpegTSFilterType {
MPEGTS_PES,
MPEGTS_SECTION,
@@ -73,6 +76,7 @@ typedef struct MpegTSSectionFilter {
struct MpegTSFilter {
int pid;
+ int es_id;
int last_cc; /* last cc code (-1 if first packet) */
enum MpegTSFilterType type;
union {
@@ -173,6 +177,7 @@ typedef struct PESContext {
int64_t ts_packet_pos; /**< position of first TS packet of this PES packet */
uint8_t header[MAX_PES_HEADER_SIZE];
uint8_t *buffer;
+ SLConfigDescr sl;
} PESContext;
extern AVInputFormat ff_mpegts_demuxer;
@@ -327,6 +332,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int
ts->pids[pid] = filter;
filter->type = MPEGTS_SECTION;
filter->pid = pid;
+ filter->es_id = -1;
filter->last_cc = -1;
sec = &filter->u.section_filter;
sec->section_cb = section_cb;
@@ -355,6 +361,7 @@ static MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid,
ts->pids[pid] = filter;
filter->type = MPEGTS_PES;
filter->pid = pid;
+ filter->es_id = -1;
filter->last_cc = -1;
pes = &filter->u.pes_filter;
pes->pes_cb = pes_cb;
@@ -682,6 +689,83 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt)
pes->flags = 0;
}
+static uint64_t get_bits64(GetBitContext *gb, int bits)
+{
+ uint64_t ret = 0;
+ while (bits > 17) {
+ ret <<= 17;
+ ret |= get_bits(gb, 17);
+ bits -= 17;
+ }
+ ret <<= bits;
+ ret |= get_bits(gb, bits);
+ return ret;
+}
+
+static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
+{
+ GetBitContext gb;
+ int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
+ int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
+ int dts_flag = -1, cts_flag = -1;
+ int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
+ init_get_bits(&gb, buf, buf_size*8);
+
+ if (sl->use_au_start)
+ au_start_flag = get_bits1(&gb);
+ if (sl->use_au_end)
+ au_end_flag = get_bits1(&gb);
+ if (!sl->use_au_start && !sl->use_au_end)
+ au_start_flag = au_end_flag = 1;
+ if (sl->ocr_len > 0)
+ ocr_flag = get_bits1(&gb);
+ if (sl->use_idle)
+ idle_flag = get_bits1(&gb);
+ if (sl->use_padding)
+ padding_flag = get_bits1(&gb);
+ if (padding_flag)
+ padding_bits = get_bits(&gb, 3);
+
+ if (!idle_flag && (!padding_flag || padding_bits != 0)) {
+ if (sl->packet_seq_num_len)
+ skip_bits_long(&gb, sl->packet_seq_num_len);
+ if (sl->degr_prior_len)
+ if (get_bits1(&gb))
+ skip_bits(&gb, sl->degr_prior_len);
+ if (ocr_flag)
+ skip_bits_long(&gb, sl->ocr_len);
+ if (au_start_flag) {
+ if (sl->use_rand_acc_pt)
+ get_bits1(&gb);
+ if (sl->au_seq_num_len > 0)
+ skip_bits_long(&gb, sl->au_seq_num_len);
+ if (sl->use_timestamps) {
+ dts_flag = get_bits1(&gb);
+ cts_flag = get_bits1(&gb);
+ }
+ }
+ if (sl->inst_bitrate_len)
+ inst_bitrate_flag = get_bits1(&gb);
+ if (dts_flag == 1)
+ dts = get_bits64(&gb, sl->timestamp_len);
+ if (cts_flag == 1)
+ cts = get_bits64(&gb, sl->timestamp_len);
+ if (sl->au_len > 0)
+ skip_bits_long(&gb, sl->au_len);
+ if (inst_bitrate_flag)
+ skip_bits_long(&gb, sl->inst_bitrate_len);
+ }
+
+ if (dts != AV_NOPTS_VALUE)
+ pes->dts = dts;
+ if (cts != AV_NOPTS_VALUE)
+ pes->pts = cts;
+
+ av_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);
+
+ return (get_bits_count(&gb) + 7) >> 3;
+}
+
/* return non zero if a packet could be constructed */
static int mpegts_push_data(MpegTSFilter *filter,
const uint8_t *buf, int buf_size, int is_start,
@@ -833,6 +917,12 @@ static int mpegts_push_data(MpegTSFilter *filter,
/* we got the full header. We parse it and get the payload */
pes->state = MPEGTS_PAYLOAD;
pes->data_index = 0;
+ if (pes->stream_type == 0x12) {
+ int sl_header_bytes = read_sl_header(pes, &pes->sl, p, buf_size);
+ pes->pes_header_size += sl_header_bytes;
+ p += sl_header_bytes;
+ buf_size -= sl_header_bytes;
+ }
}
break;
case MPEGTS_PAYLOAD:
@@ -897,48 +987,289 @@ static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
return pes;
}
+#define MAX_LEVEL 4
+typedef struct {
+ AVFormatContext *s;
+ AVIOContext pb;
+ Mp4Descr *descr;
+ Mp4Descr *active_descr;
+ int descr_count;
+ int max_descr_count;
+ int level;
+} MP4DescrParseContext;
+
+static int init_MP4DescrParseContext(
+ MP4DescrParseContext *d, AVFormatContext *s, const uint8_t *buf,
+ unsigned size, Mp4Descr *descr, int max_descr_count)
+{
+ int ret;
+ if (size > (1<<30))
+ return AVERROR_INVALIDDATA;
+
+ if ((ret = ffio_init_context(&d->pb, (unsigned char*)buf, size, 0,
+ NULL, NULL, NULL, NULL)) < 0)
+ return ret;
+
+ d->s = s;
+ d->level = 0;
+ d->descr_count = 0;
+ d->descr = descr;
+ d->active_descr = NULL;
+ d->max_descr_count = max_descr_count;
+
+ return 0;
+}
+
+static void update_offsets(AVIOContext *pb, int64_t *off, int *len) {
+ int64_t new_off = avio_tell(pb);
+ (*len) -= new_off - *off;
+ *off = new_off;
+}
+
+static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len,
+ int target_tag);
+
+static int parse_mp4_descr_arr(MP4DescrParseContext *d, int64_t off, int len)
+{
+ while (len > 0) {
+ if (parse_mp4_descr(d, off, len, 0) < 0)
+ return -1;
+ update_offsets(&d->pb, &off, &len);
+ }
+ return 0;
+}
+
+static int parse_MP4IODescrTag(MP4DescrParseContext *d, int64_t off, int len)
+{
+ avio_rb16(&d->pb); // ID
+ avio_r8(&d->pb);
+ avio_r8(&d->pb);
+ avio_r8(&d->pb);
+ avio_r8(&d->pb);
+ avio_r8(&d->pb);
+ update_offsets(&d->pb, &off, &len);
+ return parse_mp4_descr_arr(d, off, len);
+}
+
+static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len)
+{
+ int id_flags;
+ if (len < 2)
+ return 0;
+ id_flags = avio_rb16(&d->pb);
+ if (!(id_flags & 0x0020)) { //URL_Flag
+ update_offsets(&d->pb, &off, &len);
+ return parse_mp4_descr_arr(d, off, len); //ES_Descriptor[]
+ } else {
+ return 0;
+ }
+}
+
+static int parse_MP4ESDescrTag(MP4DescrParseContext *d, int64_t off, int len)
+{
+ int es_id = 0;
+ if (d->descr_count >= d->max_descr_count)
+ return -1;
+ ff_mp4_parse_es_descr(&d->pb, &es_id);
+ d->active_descr = d->descr + (d->descr_count++);
+
+ d->active_descr->es_id = es_id;
+ update_offsets(&d->pb, &off, &len);
+ parse_mp4_descr(d, off, len, MP4DecConfigDescrTag);
+ update_offsets(&d->pb, &off, &len);
+ if (len > 0)
+ parse_mp4_descr(d, off, len, MP4SLDescrTag);
+ d->active_descr = NULL;
+ return 0;
+}
+
+static int parse_MP4DecConfigDescrTag(MP4DescrParseContext *d, int64_t off, int len)
+{
+ Mp4Descr *descr = d->active_descr;
+ if (!descr)
+ return -1;
+ d->active_descr->dec_config_descr = av_malloc(len);
+ if (!descr->dec_config_descr)
+ return AVERROR(ENOMEM);
+ descr->dec_config_descr_len = len;
+ avio_read(&d->pb, descr->dec_config_descr, len);
+ return 0;
+}
+
+static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len)
+{
+ Mp4Descr *descr = d->active_descr;
+ int predefined;
+ if (!descr)
+ return -1;
+
+ predefined = avio_r8(&d->pb);
+ if (!predefined) {
+ int lengths;
+ int flags = avio_r8(&d->pb);
+ descr->sl.use_au_start = !!(flags & 0x80);
+ descr->sl.use_au_end = !!(flags & 0x40);
+ descr->sl.use_rand_acc_pt = !!(flags & 0x20);
+ descr->sl.use_padding = !!(flags & 0x08);
+ descr->sl.use_timestamps = !!(flags & 0x04);
+ descr->sl.use_idle = !!(flags & 0x02);
+ descr->sl.timestamp_res = avio_rb32(&d->pb);
+ avio_rb32(&d->pb);
+ descr->sl.timestamp_len = avio_r8(&d->pb);
+ descr->sl.ocr_len = avio_r8(&d->pb);
+ descr->sl.au_len = avio_r8(&d->pb);
+ descr->sl.inst_bitrate_len = avio_r8(&d->pb);
+ lengths = avio_rb16(&d->pb);
+ descr->sl.degr_prior_len = lengths >> 12;
+ descr->sl.au_seq_num_len = (lengths >> 7) & 0x1f;
+ descr->sl.packet_seq_num_len = (lengths >> 2) & 0x1f;
+ } else {
+ av_log_missing_feature(d->s, "Predefined SLConfigDescriptor\n", 0);
+ }
+ return 0;
+}
+
+static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len,
+ int target_tag) {
+ int tag;
+ int len1 = ff_mp4_read_descr(d->s, &d->pb, &tag);
+ update_offsets(&d->pb, &off, &len);
+ if (len < 0 || len1 > len || len1 <= 0) {
+ av_log(d->s, AV_LOG_ERROR, "Tag %x length violation new length %d bytes remaining %d\n", tag, len1, len);
+ return -1;
+ }
+
+ if (d->level++ >= MAX_LEVEL) {
+ av_log(d->s, AV_LOG_ERROR, "Maximum MP4 descriptor level exceeded\n");
+ goto done;
+ }
+
+ if (target_tag && tag != target_tag) {
+ av_log(d->s, AV_LOG_ERROR, "Found tag %x expected %x\n", tag, target_tag);
+ goto done;
+ }
+
+ switch (tag) {
+ case MP4IODescrTag:
+ parse_MP4IODescrTag(d, off, len1);
+ break;
+ case MP4ODescrTag:
+ parse_MP4ODescrTag(d, off, len1);
+ break;
+ case MP4ESDescrTag:
+ parse_MP4ESDescrTag(d, off, len1);
+ break;
+ case MP4DecConfigDescrTag:
+ parse_MP4DecConfigDescrTag(d, off, len1);
+ break;
+ case MP4SLDescrTag:
+ parse_MP4SLDescrTag(d, off, len1);
+ break;
+ }
+
+done:
+ d->level--;
+ avio_seek(&d->pb, off + len1, SEEK_SET);
+ return 0;
+}
+
static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size,
- int *es_id, uint8_t **dec_config_descr,
- int *dec_config_descr_size)
+ Mp4Descr *descr, int *descr_count, int max_descr_count)
+{
+ MP4DescrParseContext d;
+ if (init_MP4DescrParseContext(&d, s, buf, size, descr, max_descr_count) < 0)
+ return -1;
+
+ parse_mp4_descr(&d, avio_tell(&d.pb), size, MP4IODescrTag);
+
+ *descr_count = d.descr_count;
+ return 0;
+}
+
+static int mp4_read_od(AVFormatContext *s, const uint8_t *buf, unsigned size,
+ Mp4Descr *descr, int *descr_count, int max_descr_count)
{
+ MP4DescrParseContext d;
+ if (init_MP4DescrParseContext(&d, s, buf, size, descr, max_descr_count) < 0)
+ return -1;
+
+ parse_mp4_descr_arr(&d, avio_tell(&d.pb), size);
+
+ *descr_count = d.descr_count;
+ return 0;
+}
+
+static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
+{
+ MpegTSContext *ts = filter->u.section_filter.opaque;
+ SectionHeader h;
+ const uint8_t *p, *p_end;
AVIOContext pb;
- int tag;
- unsigned len;
-
- ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
-
- len = ff_mp4_read_descr(s, &pb, &tag);
- if (tag == MP4IODescrTag) {
- avio_rb16(&pb); // ID
- avio_r8(&pb);
- avio_r8(&pb);
- avio_r8(&pb);
- avio_r8(&pb);
- avio_r8(&pb);
- len = ff_mp4_read_descr(s, &pb, &tag);
- if (tag == MP4ESDescrTag) {
- ff_mp4_parse_es_descr(&pb, es_id);
- av_dlog(s, "ES_ID %#x\n", *es_id);
- len = ff_mp4_read_descr(s, &pb, &tag);
- if (tag == MP4DecConfigDescrTag) {
- *dec_config_descr = av_malloc(len);
- if (!*dec_config_descr)
- return AVERROR(ENOMEM);
- *dec_config_descr_size = len;
- avio_read(&pb, *dec_config_descr, len);
+ Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = {{ 0 }};
+ int mp4_descr_count = 0;
+ int i, pid;
+ AVFormatContext *s = ts->stream;
+
+ p_end = section + section_len - 4;
+ p = section;
+ if (parse_section_header(&h, &p, p_end) < 0)
+ return;
+ if (h.tid != M4OD_TID)
+ return;
+
+ mp4_read_od(s, p, (unsigned)(p_end - p), mp4_descr, &mp4_descr_count, MAX_MP4_DESCR_COUNT);
+
+ for (pid = 0; pid < NB_PID_MAX; pid++) {
+ if (!ts->pids[pid])
+ continue;
+ for (i = 0; i < mp4_descr_count; i++) {
+ PESContext *pes;
+ AVStream *st;
+ if (ts->pids[pid]->es_id != mp4_descr[i].es_id)
+ continue;
+ if (!(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES)) {
+ av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid);
+ continue;
+ }
+ pes = ts->pids[pid]->u.pes_filter.opaque;
+ st = pes->st;
+ if (!st) {
+ continue;
+ }
+
+ pes->sl = mp4_descr[i].sl;
+
+ ffio_init_context(&pb, mp4_descr[i].dec_config_descr,
+ mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
+ ff_mp4_read_dec_config_descr(s, st, &pb);
+ if (st->codec->codec_id == CODEC_ID_AAC &&
+ st->codec->extradata_size > 0)
+ st->need_parsing = 0;
+ if (st->codec->codec_id == CODEC_ID_H264 &&
+ st->codec->extradata_size > 0)
+ st->need_parsing = 0;
+
+ if (st->codec->codec_id <= CODEC_ID_NONE) {
+ } else if (st->codec->codec_id < CODEC_ID_FIRST_AUDIO) {
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ } else if (st->codec->codec_id < CODEC_ID_FIRST_SUBTITLE) {
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ } else if (st->codec->codec_id < CODEC_ID_FIRST_UNKNOWN) {
+ st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
}
- return 0;
+ for (i = 0; i < mp4_descr_count; i++)
+ av_free(mp4_descr[i].dec_config_descr);
}
int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type,
const uint8_t **pp, const uint8_t *desc_list_end,
- int mp4_dec_config_descr_len, int mp4_es_id, int pid,
- uint8_t *mp4_dec_config_descr)
+ Mp4Descr *mp4_descr, int mp4_descr_count, int pid,
+ MpegTSContext *ts)
{
const uint8_t *desc_end;
- int desc_len, desc_tag;
+ int desc_len, desc_tag, desc_es_id;
char language[252];
int i;
@@ -959,13 +1290,31 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
mpegts_find_stream_type(st, desc_tag, DESC_types);
switch(desc_tag) {
+ case 0x1E: /* SL descriptor */
+ desc_es_id = get16(pp, desc_end);
+ if (ts && ts->pids[pid])
+ ts->pids[pid]->es_id = desc_es_id;
+ for (i = 0; i < mp4_descr_count; i++)
+ if (mp4_descr[i].dec_config_descr_len &&
+ mp4_descr[i].es_id == desc_es_id) {
+ AVIOContext pb;
+ ffio_init_context(&pb, mp4_descr[i].dec_config_descr,
+ mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
+ ff_mp4_read_dec_config_descr(fc, st, &pb);
+ if (st->codec->codec_id == CODEC_ID_AAC &&
+ st->codec->extradata_size > 0)
+ st->need_parsing = 0;
+ if (st->codec->codec_id == CODEC_ID_MPEG4SYSTEMS)
+ mpegts_open_section_filter(ts, pid, m4sl_cb, ts, 1);
+ }
+ break;
case 0x1F: /* FMC descriptor */
get16(pp, desc_end);
- if ((st->codec->codec_id == CODEC_ID_AAC_LATM || st->request_probe>0) &&
- mp4_dec_config_descr_len && mp4_es_id == pid) {
+ if (mp4_descr_count > 0 && (st->codec->codec_id == CODEC_ID_AAC_LATM || st->request_probe>0) &&
+ mp4_descr->dec_config_descr_len && mp4_descr->es_id == pid) {
AVIOContext pb;
- ffio_init_context(&pb, mp4_dec_config_descr,
- mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
+ ffio_init_context(&pb, mp4_descr->dec_config_descr,
+ mp4_descr->dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(fc, st, &pb);
if (st->codec->codec_id == CODEC_ID_AAC &&
st->codec->extradata_size > 0){
@@ -1054,9 +1403,10 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
int program_info_length, pcr_pid, pid, stream_type;
int desc_list_len;
uint32_t prog_reg_desc = 0; /* registration descriptor */
- uint8_t *mp4_dec_config_descr = NULL;
- int mp4_dec_config_descr_len = 0;
- int mp4_es_id = 0;
+
+ Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = {{ 0 }};
+ int mp4_descr_count = 0;
+ int i;
av_dlog(ts->stream, "PMT: len %i\n", section_len);
hex_dump_debug(ts->stream, (uint8_t *)section, section_len);
@@ -1099,8 +1449,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
get8(&p, p_end); // scope
get8(&p, p_end); // label
len -= 2;
- mp4_read_iods(ts->stream, p, len, &mp4_es_id,
- &mp4_dec_config_descr, &mp4_dec_config_descr_len);
+ mp4_read_iods(ts->stream, p, len, mp4_descr + mp4_descr_count,
+ &mp4_descr_count, MAX_MP4_DESCR_COUNT);
} else if (tag == 0x05 && len >= 4) { // registration descriptor
prog_reg_desc = bytestream_get_le32(&p);
len -= 4;
@@ -1117,6 +1467,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
for(;;) {
st = 0;
+ pes = NULL;
stream_type = get8(&p, p_end);
if (stream_type < 0)
break;
@@ -1132,19 +1483,28 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
pes->st->id = pes->pid;
}
st = pes->st;
- } else {
+ } else if (stream_type != 0x13) {
if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably
pes = add_pes_stream(ts, pid, pcr_pid);
if (pes) {
st = avformat_new_stream(pes->stream, NULL);
st->id = pes->pid;
}
+ } else {
+ int idx = ff_find_stream_index(ts->stream, pid);
+ if (idx >= 0) {
+ st = ts->stream->streams[idx];
+ } else {
+ st = avformat_new_stream(pes->stream, NULL);
+ st->id = pid;
+ st->codec->codec_type = AVMEDIA_TYPE_DATA;
+ }
}
if (!st)
goto out;
- if (!pes->stream_type)
+ if (pes && !pes->stream_type)
mpegts_set_stream_info(st, pes, stream_type, prog_reg_desc);
add_pid_to_pmt(ts, h->id, pid);
@@ -1159,10 +1519,10 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
break;
for(;;) {
if (ff_parse_mpeg2_descriptor(ts->stream, st, stream_type, &p, desc_list_end,
- mp4_dec_config_descr_len, mp4_es_id, pid, mp4_dec_config_descr) < 0)
+ mp4_descr, mp4_descr_count, pid, ts) < 0)
break;
- if (prog_reg_desc == AV_RL32("HDMV") && stream_type == 0x83 && pes->sub_st) {
+ if (pes && prog_reg_desc == AV_RL32("HDMV") && stream_type == 0x83 && pes->sub_st) {
ff_program_add_stream_index(ts->stream, h->id, pes->sub_st->index);
pes->sub_st->codec->codec_tag = st->codec->codec_tag;
}
@@ -1171,7 +1531,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
}
out:
- av_free(mp4_dec_config_descr);
+ for (i = 0; i < mp4_descr_count; i++)
+ av_free(mp4_descr[i].dec_config_descr);
}
static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
@@ -1839,7 +2200,7 @@ static int read_seek2(AVFormatContext *s,
ts_adj = target_ts;
stream_index_gen_search = stream_index;
}
- pos = av_gen_search(s, stream_index_gen_search, ts_adj,
+ pos = ff_gen_search(s, stream_index_gen_search, ts_adj,
0, INT64_MAX, -1,
AV_NOPTS_VALUE,
AV_NOPTS_VALUE,
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index e60329711b..edec79ce2f 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -39,6 +39,7 @@
/* table ids */
#define PAT_TID 0x00
#define PMT_TID 0x02
+#define M4OD_TID 0x05
#define SDT_TID 0x42
#define STREAM_TYPE_VIDEO_MPEG1 0x01
@@ -64,6 +65,30 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
const uint8_t *buf, int len);
void ff_mpegts_parse_close(MpegTSContext *ts);
+typedef struct {
+ int use_au_start;
+ int use_au_end;
+ int use_rand_acc_pt;
+ int use_padding;
+ int use_timestamps;
+ int use_idle;
+ int timestamp_res;
+ int timestamp_len;
+ int ocr_len;
+ int au_len;
+ int inst_bitrate_len;
+ int degr_prior_len;
+ int au_seq_num_len;
+ int packet_seq_num_len;
+} SLConfigDescr;
+
+typedef struct {
+ int es_id;
+ int dec_config_descr_len;
+ uint8_t *dec_config_descr;
+ SLConfigDescr sl;
+} Mp4Descr;
+
/**
* Parse an MPEG-2 descriptor
* @param[in] fc Format context (used for logging only)
@@ -79,7 +104,7 @@ void ff_mpegts_parse_close(MpegTSContext *ts);
*/
int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type,
const uint8_t **pp, const uint8_t *desc_list_end,
- int mp4_dec_config_descr_len, int mp4_es_id, int pid,
- uint8_t *mp4_dec_config_descr);
+ Mp4Descr *mp4_descr, int mp4_descr_count, int pid,
+ MpegTSContext *ts);
#endif /* AVFORMAT_MPEGTS_H */
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index e1fec3dbbb..efc4bd1aef 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -49,6 +49,7 @@
#include "libavutil/mathematics.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
+#include "internal.h"
#include "mxf.h"
typedef enum {
@@ -1141,7 +1142,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
if (avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET) < 0)
return -1;
- av_update_cur_dts(s, st, sample_time);
+ ff_update_cur_dts(s, st, sample_time);
return 0;
}
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 6015bf6900..f0b54f6982 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -874,16 +874,16 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
(void **) next_node);
av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n", next_node[0]->pos, next_node[1]->pos,
next_node[0]->ts , next_node[1]->ts);
- pos= av_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
- next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
+ pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos,
+ next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp);
if(!(flags & AVSEEK_FLAG_BACKWARD)){
dummy.pos= pos+16;
next_node[1]= &nopts_sp;
av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp,
(void **) next_node);
- pos2= av_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
- next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
+ pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos,
+ next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
if(pos2>=0)
pos= pos2;
//FIXME dir but I think it does not matter
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 8e7653c6b8..d453ae6775 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -32,6 +32,7 @@
#include <stdio.h>
#include "oggdec.h"
#include "avformat.h"
+#include "internal.h"
#include "vorbiscomment.h"
#define MAX_PAGE_SIZE 65307
@@ -661,7 +662,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
&& !(flags & AVSEEK_FLAG_ANY))
os->keyframe_seek = 1;
- ret = av_seek_frame_binary(s, stream_index, timestamp, flags);
+ ret = ff_seek_frame_binary(s, stream_index, timestamp, flags);
os = ogg->streams + stream_index;
if (ret < 0)
os->keyframe_seek = 0;
diff --git a/libavformat/seek-test.c b/libavformat/seek-test.c
index cea36cabb2..3a448cfe3b 100644
--- a/libavformat/seek-test.c
+++ b/libavformat/seek-test.c
@@ -64,10 +64,10 @@ int main(int argc, char **argv)
AVFormatContext *ic = NULL;
int i, ret, stream_id;
int64_t timestamp;
- AVFormatParameters params, *ap= &params;
- memset(ap, 0, sizeof(params));
- ap->channels=1;
- ap->sample_rate= 22050;
+ AVDictionary *format_opts = NULL;
+
+ av_dict_set(&format_opts, "channels", "1", 0);
+ av_dict_set(&format_opts, "sample_rate", "22050", 0);
/* initialize libavcodec, and register all codecs and formats */
av_register_all();
@@ -80,7 +80,8 @@ int main(int argc, char **argv)
filename = argv[1];
- ret = av_open_input_file(&ic, filename, NULL, 0, ap);
+ ret = avformat_open_input(&ic, filename, NULL, &format_opts);
+ av_dict_free(&format_opts);
if (ret < 0) {
fprintf(stderr, "cannot open %s\n", filename);
exit(1);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1c6a4684a1..8a78308447 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -340,6 +340,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score
fmt = NULL;
}
*score_ret= score_max;
+
return fmt;
}
@@ -1427,7 +1428,15 @@ void ff_read_frame_flush(AVFormatContext *s)
}
}
-void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){
+#if FF_API_SEEK_PUBLIC
+void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
+{
+ return ff_update_cur_dts(s, ref_st, timestamp);
+}
+#endif
+
+void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
+{
int i;
for(i = 0; i < s->nb_streams; i++) {
@@ -1547,7 +1556,14 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
wanted_timestamp, flags);
}
+#if FF_API_SEEK_PUBLIC
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
+ return ff_seek_frame_binary(s, stream_index, target_ts, flags);
+}
+#endif
+
+int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
+{
AVInputFormat *avif= s->iformat;
int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
int64_t ts_min, ts_max, ts;
@@ -1594,7 +1610,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
}
}
- pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp);
+ pos= ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp);
if(pos<0)
return -1;
@@ -1603,12 +1619,28 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
return ret;
ff_read_frame_flush(s);
- av_update_cur_dts(s, st, ts);
+ ff_update_cur_dts(s, st, ts);
return 0;
}
-int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )){
+#if FF_API_SEEK_PUBLIC
+int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
+ int64_t pos_min, int64_t pos_max, int64_t pos_limit,
+ int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret,
+ int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
+{
+ return ff_gen_search(s, stream_index, target_ts, pos_min, pos_max,
+ pos_limit, ts_min, ts_max, flags, ts_ret,
+ read_timestamp);
+}
+#endif
+
+int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
+ int64_t pos_min, int64_t pos_max, int64_t pos_limit,
+ int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret,
+ int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
+{
int64_t pos, ts;
int64_t start_pos, filesize;
int no_change;
@@ -1775,7 +1807,7 @@ static int seek_frame_generic(AVFormatContext *s,
ie= &st->index_entries[st->nb_index_entries-1];
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
- av_update_cur_dts(s, st, ie->timestamp);
+ ff_update_cur_dts(s, st, ie->timestamp);
}else{
if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0)
return ret;
@@ -1812,7 +1844,7 @@ static int seek_frame_generic(AVFormatContext *s,
ie = &st->index_entries[index];
if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0)
return ret;
- av_update_cur_dts(s, st, ie->timestamp);
+ ff_update_cur_dts(s, st, ie->timestamp);
return 0;
}
@@ -1853,7 +1885,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) {
ff_read_frame_flush(s);
- return av_seek_frame_binary(s, stream_index, timestamp, flags);
+ return ff_seek_frame_binary(s, stream_index, timestamp, flags);
} else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) {
ff_read_frame_flush(s);
return seek_frame_generic(s, stream_index, timestamp, flags);
diff --git a/libavformat/version.h b/libavformat/version.h
index 58c3a74bff..6494212647 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -107,5 +107,11 @@
#ifndef FF_API_STREAM_COPY
#define FF_API_STREAM_COPY (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_SEEK_PUBLIC
+#define FF_API_SEEK_PUBLIC (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_REORDER_PRIVATE
+#define FF_API_REORDER_PRIVATE (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
#endif /* AVFORMAT_VERSION_H */
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 88587c4b52..543fcb68d2 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -773,7 +773,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p
buf_size = FFMIN(len - consumed, sizeof(buf));
avio_read(pb, buf, buf_size);
consumed += buf_size;
- ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, 0, 0, 0, 0);
+ ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, NULL, 0, 0, NULL);
}
} else if (!ff_guidcmp(g, EVENTID_AudioTypeSpanningEvent)) {
int stream_index = ff_find_stream_index(s, sid);