X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Finternal.h;h=c87d0ebde6882c992ad9dc98b93f3e08bb5251fa;hb=9765549f551ff40869aee1a6492b6a976c86cfe9;hp=9921ce11e05643546e1ddcb4a0766b1ac9428778;hpb=30e50c50274f88f0f5ae829f401cd3c7f5266719;p=ffmpeg diff --git a/libavformat/internal.h b/libavformat/internal.h index 9921ce11e05..c87d0ebde68 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -23,6 +23,7 @@ #include #include "avformat.h" +#include "os_support.h" #define MAX_URL_SIZE 4096 @@ -48,6 +49,75 @@ struct AVFormatInternal { * Muxing only. */ int nb_interleaved_streams; + + /** + * 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_seek_frame() support */ + int64_t data_offset; /**< offset of the first packet */ + + /** + * 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; + /** + * Packets split by the parser get queued here. + */ + struct AVPacketList *parse_queue; + struct AVPacketList *parse_queue_end; + /** + * Remaining size available for raw_packet_buffer, in bytes. + */ +#define RAW_PACKET_BUFFER_SIZE 2500000 + int raw_packet_buffer_remaining_size; + + /** + * Offset to remap timestamps to be non-negative. + * Expressed in timebase units. + */ + int64_t offset; + + /** + * Timebase for the timestamp offset. + */ + AVRational offset_timebase; + +#if FF_API_COMPUTE_PKT_FIELDS2 + int missing_ts_warning; +#endif +}; + +struct AVStreamInternal { + /** + * Set to 1 if the codec allows reordering, so pts can be different + * from dts. + */ + int reorder; + /** + * The codec context used by avformat_find_stream_info, the parser, etc. + */ + AVCodecContext *avctx; + /** + * 1 if avctx has been initialized with the values from the codec parameters + */ + int avctx_inited; + + enum AVCodecID orig_codec_id; + +#if FF_API_LAVF_AVCTX + // whether the deprecated stream codec context needs + // to be filled from the codec parameters + int need_codec_update; +#endif }; void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem); @@ -306,7 +376,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt); * Interleave a packet per dts in an output media file. * * Packets with pkt->destruct == av_destruct_packet will be freed inside this - * function, so they cannot be used after it. Note that calling av_free_packet() + * function, so they cannot be used after it. Note that calling av_packet_unref() * on them is still safe. * * @param s media file handle @@ -323,7 +393,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, /** * Return the frame duration in seconds. Return 0 if not available. */ -void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st, +void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt); unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id); @@ -351,4 +421,24 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags); */ int ff_generate_avci_extradata(AVStream *st); +/** + * Wrap errno on rename() error. + * + * @param oldpath source path + * @param newpath destination path + * @return 0 or AVERROR on failure + */ +static inline int ff_rename(const char *oldpath, const char *newpath) +{ + if (rename(oldpath, newpath) == -1) + return AVERROR(errno); + return 0; +} + +/** + * A wrapper around AVFormatContext.io_close that should be used + * intead of calling the pointer directly. + */ +void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); + #endif /* AVFORMAT_INTERNAL_H */