avformat/demux: Add new demux.h header

And move those stuff already in demuxer-only files to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-05-06 18:28:08 +02:00
parent 20ca491664
commit 35ec5c819b
33 changed files with 175 additions and 130 deletions

View File

@ -37,6 +37,7 @@
#include "libavutil/opt.h"
#include "libavformat/avformat.h"
#include "libavformat/demux.h"
#include "libavformat/internal.h"
typedef struct CDIOContext {

View File

@ -24,6 +24,7 @@
*/
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"

View File

@ -33,6 +33,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "avlanguage.h"
#include "demux.h"
#include "internal.h"
#include "riff.h"
#include "asf.h"

View File

@ -27,8 +27,8 @@
#include "libavutil/time_internal.h"
#include "avformat.h"
#include "avio_internal.h"
#include "avlanguage.h"
#include "demux.h"
#include "internal.h"
#include "riff.h"
#include "asf.h"

View File

@ -32,6 +32,7 @@
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "avi.h"
#include "demux.h"
#include "dv.h"
#include "internal.h"
#include "isom.h"

View File

@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
typedef struct BRSTMCoeffOffset {

View File

@ -28,6 +28,7 @@
#include "libavcodec/bsf.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "url.h"

View File

@ -21,13 +21,13 @@
*/
#include <libxml/parser.h>
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/parseutils.h"
#include "internal.h"
#include "avio_internal.h"
#include "dash.h"
#include "demux.h"
#define INITIAL_BUFFER_SIZE 32768

View File

@ -21,7 +21,6 @@
#include <stdint.h>
#include "config.h"
#include "config_components.h"
#include "libavutil/avassert.h"
@ -42,6 +41,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "id3v2.h"
#include "internal.h"
#include "url.h"

145
libavformat/demux.h Normal file
View File

@ -0,0 +1,145 @@
/*
* copyright (c) 2001 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFORMAT_DEMUX_H
#define AVFORMAT_DEMUX_H
#include <stdint.h>
#include "libavutil/rational.h"
#include "libavcodec/packet.h"
#include "avformat.h"
#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
static av_always_inline int is_relative(int64_t ts)
{
return ts > (RELATIVE_TS_BASE - (1LL << 48));
}
/**
* Wrap a given time stamp, if there is an indication for an overflow
*
* @param st stream
* @param timestamp the time stamp to wrap
* @return resulting time stamp
*/
int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
/**
* Read a transport packet from a media file.
*
* @param s media file handle
* @param pkt is filled
* @return 0 if OK, AVERROR_xxx on error
*/
int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
void ff_read_frame_flush(AVFormatContext *s);
/**
* 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 avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
/**
* 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 ));
/**
* Internal version of av_index_search_timestamp
*/
int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
int64_t wanted_timestamp, int flags);
/**
* Internal version of av_add_index_entry
*/
int ff_add_index_entry(AVIndexEntry **index_entries,
int *nb_index_entries,
unsigned int *index_entries_allocated_size,
int64_t pos, int64_t timestamp, int size, int distance, int flags);
void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance);
/**
* Ensure the index uses less memory than the maximum specified in
* AVFormatContext.max_index_size by discarding entries if it grows
* too large.
*/
void ff_reduce_index(AVFormatContext *s, int stream_index);
/**
* add frame for rfps calculation.
*
* @param dts timestamp of the i-th frame
* @return 0 if OK, AVERROR_xxx on error
*/
int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts);
void ff_rfps_calculate(AVFormatContext *ic);
/**
* Rescales a timestamp and the endpoints of an interval to which the temstamp
* belongs, from a timebase `tb_in` to a timebase `tb_out`.
*
* The upper (lower) bound of the output interval is rounded up (down) such that
* the output interval always falls within the intput interval. The timestamp is
* rounded to the nearest integer and halfway cases away from zero, and can
* therefore fall outside of the output interval.
*
* Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2()
*
* @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts`
* @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts`
* @param[in,out] min_ts Lower bound of the interval
* @param[in,out] ts Timestamp
* @param[in,out] max_ts Upper bound of the interval
*/
void ff_rescale_interval(AVRational tb_in, AVRational tb_out,
int64_t *min_ts, int64_t *ts, int64_t *max_ts);
#endif /* AVFORMAT_DEMUX_H */

View File

@ -39,6 +39,7 @@
#include "libavutil/dict.h"
#include "libavutil/time.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "avio_internal.h"
#include "id3v2.h"

View File

@ -72,6 +72,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#define HUFFMAN_TABLE_SIZE (64 * 1024)

View File

@ -63,6 +63,7 @@
*/
#include "avio_internal.h"
#include "demux.h"
#include "imf.h"
#include "internal.h"
#include "libavcodec/packet.h"
@ -71,7 +72,6 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "mxf.h"
#include "url.h"
#include <inttypes.h>
#include <libxml/parser.h>

View File

@ -460,21 +460,6 @@ do {\
} while(0)
#endif
#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
static av_always_inline int is_relative(int64_t ts)
{
return ts > (RELATIVE_TS_BASE - (1LL << 48));
}
/**
* Wrap a given time stamp, if there is an indication for an overflow
*
* @param st stream
* @param timestamp the time stamp to wrap
* @return resulting time stamp
*/
int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp);
void ff_flush_packet_queue(AVFormatContext *s);
@ -509,8 +494,6 @@ char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase);
*/
int ff_hex_to_data(uint8_t *data, const char *p);
void ff_read_frame_flush(AVFormatContext *s);
#define NTP_OFFSET 2208988800ULL
#define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
@ -611,22 +594,6 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
*/
int ff_find_stream_index(const AVFormatContext *s, int id);
/**
* Internal version of av_index_search_timestamp
*/
int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
int64_t wanted_timestamp, int flags);
/**
* Internal version of av_add_index_entry
*/
int ff_add_index_entry(AVIndexEntry **index_entries,
int *nb_index_entries,
unsigned int *index_entries_allocated_size,
int64_t pos, int64_t timestamp, int size, int distance, int flags);
void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance);
/**
* Add a new chapter.
*
@ -641,52 +608,10 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance);
AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base,
int64_t start, int64_t end, const char *title);
/**
* Ensure the index uses less memory than the maximum specified in
* AVFormatContext.max_index_size by discarding entries if it grows
* too large.
*/
void ff_reduce_index(AVFormatContext *s, int stream_index);
enum AVCodecID ff_guess_image2_codec(const char *filename);
const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
enum AVCodecID codec_id);
/**
* 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 avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
/**
* 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 ));
/**
* Set the time base and wrapping info for a given stream. This will be used
@ -717,15 +642,6 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
*/
int ff_framehash_write_header(AVFormatContext *s);
/**
* Read a transport packet from a media file.
*
* @param s media file handle
* @param pkt is filled
* @return 0 if OK, AVERROR_xxx on error
*/
int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
/**
* Add an attached pic to an AVStream.
*
@ -819,16 +735,6 @@ int ff_alloc_extradata(AVCodecParameters *par, int size);
*/
int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size);
/**
* add frame for rfps calculation.
*
* @param dts timestamp of the i-th frame
* @return 0 if OK, AVERROR_xxx on error
*/
int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts);
void ff_rfps_calculate(AVFormatContext *ic);
/**
* Copies the whilelists from one context to the other
*/
@ -880,24 +786,4 @@ void ff_format_set_url(AVFormatContext *s, char *url);
void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]);
/**
* Rescales a timestamp and the endpoints of an interval to which the temstamp
* belongs, from a timebase `tb_in` to a timebase `tb_out`.
*
* The upper (lower) bound of the output interval is rounded up (down) such that
* the output interval always falls within the intput interval. The timestamp is
* rounded to the nearest integer and halfway cases away from zero, and can
* therefore fall outside of the output interval.
*
* Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2()
*
* @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts`
* @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts`
* @param[in,out] min_ts Lower bound of the interval
* @param[in,out] ts Timestamp
* @param[in,out] max_ts Upper bound of the interval
*/
void ff_rescale_interval(AVRational tb_in, AVRational tb_out,
int64_t *min_ts, int64_t *ts, int64_t *max_ts);
#endif /* AVFORMAT_INTERNAL_H */

View File

@ -55,6 +55,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "dovi_isom.h"
#include "internal.h"
#include "isom.h"

View File

@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
typedef struct MCADemuxContext {

View File

@ -24,12 +24,11 @@
* Magic Lantern Video (MLV) demuxer
*/
#include "libavutil/eval.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/rational.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "riff.h"

View File

@ -36,11 +36,9 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/time_internal.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/display.h"
#include "libavutil/opt.h"
#include "libavutil/aes.h"
#include "libavutil/aes_ctr.h"
@ -49,7 +47,6 @@
#include "libavutil/spherical.h"
#include "libavutil/stereo3d.h"
#include "libavutil/timecode.h"
#include "libavutil/dovi_meta.h"
#include "libavcodec/ac3tab.h"
#include "libavcodec/flac.h"
#include "libavcodec/hevc.h"
@ -58,6 +55,7 @@
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "dovi_isom.h"
#include "riff.h"
#include "isom.h"

View File

@ -20,14 +20,13 @@
*/
#include "libavutil/opt.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/crc.h"
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "id3v2.h"
#include "id3v1.h"
#include "replaygain.h"

View File

@ -23,6 +23,7 @@
#include "libavcodec/unary.h"
#include "apetag.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "avio_internal.h"

View File

@ -24,6 +24,7 @@
#include "libavutil/channel_layout.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "mpeg.h"

View File

@ -39,6 +39,7 @@
#include "mpegts.h"
#include "internal.h"
#include "avio_internal.h"
#include "demux.h"
#include "mpeg.h"
#include "isom.h"
#if CONFIG_ICONV

View File

@ -59,6 +59,7 @@
#include "libavutil/opt.h"
#include "avformat.h"
#include "avlanguage.h"
#include "demux.h"
#include "internal.h"
#include "mxf.h"

View File

@ -29,6 +29,7 @@
#include "libavutil/tree.h"
#include "libavcodec/bytestream.h"
#include "avio_internal.h"
#include "demux.h"
#include "isom.h"
#include "nut.h"
#include "riff.h"

View File

@ -32,10 +32,10 @@
#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "avio_internal.h"
#include "demux.h"
#include "oggdec.h"
#include "avformat.h"
#include "internal.h"
#include "vorbiscomment.h"
#define MAX_PAGE_SIZE 65307
#define DECODER_BUFFER_SIZE MAX_PAGE_SIZE

View File

@ -26,7 +26,6 @@
#define AVFORMAT_OGGDEC_H
#include "avformat.h"
#include "metadata.h"
struct ogg_codec {
const int8_t *magic;

View File

@ -19,6 +19,7 @@
*/
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "libavcodec/avcodec.h"

View File

@ -22,13 +22,13 @@
#include <inttypes.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "rmsipr.h"
#include "rm.h"

View File

@ -28,11 +28,11 @@
#include "libavutil/base64.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "rtp.h"
#include "rtpdec_formats.h"
#include "rtsp.h"
#include "asf.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
/**

View File

@ -27,6 +27,7 @@
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavformat/internal.h"
#include "libavformat/demux.h"
int main(void)
{

View File

@ -21,6 +21,7 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
typedef struct VPKDemuxContext {

View File

@ -32,6 +32,7 @@
#include "libavutil/intfloat.h"
#include "libavutil/time_internal.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "wtv.h"
#include "mpegts.h"