lavf: add a header for generic-layer interfaces

Analogous to what was previously done in avcodec and avfilter.
This commit is contained in:
Anton Khirnov 2024-10-13 08:59:53 +02:00
parent de49452bc1
commit 461a359abc
10 changed files with 100 additions and 62 deletions

View File

@ -20,8 +20,8 @@
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#include "libavutil/attributes_internal.h" #include "libavutil/attributes_internal.h"
#include "libavformat/avformat_internal.h"
#include "libavformat/demux.h" #include "libavformat/demux.h"
#include "libavformat/internal.h"
#include "libavformat/mux.h" #include "libavformat/mux.h"
#include "avdevice.h" #include "avdevice.h"

View File

@ -25,6 +25,7 @@
#include "libavformat/internal.h" #include "libavformat/internal.h"
#include "avformat.h" #include "avformat.h"
#include "avformat_internal.h"
#include "demux.h" #include "demux.h"
#include "mux.h" #include "mux.h"

View File

@ -36,6 +36,7 @@
#include "libavcodec/codec_desc.h" #include "libavcodec/codec_desc.h"
#include "libavcodec/packet_internal.h" #include "libavcodec/packet_internal.h"
#include "avformat.h" #include "avformat.h"
#include "avformat_internal.h"
#include "avio.h" #include "avio.h"
#include "demux.h" #include "demux.h"
#include "mux.h" #include "mux.h"

View File

@ -0,0 +1,93 @@
/*
* 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
*/
/*
* APIs internal to the generic avformat layer.
*
* MUST NOT be included by individual muxers or demuxers.
*/
#ifndef AVFORMAT_AVFORMAT_INTERNAL_H
#define AVFORMAT_AVFORMAT_INTERNAL_H
#include <stdint.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);
typedef struct FFStreamGroup {
/**
* The public context.
*/
AVStreamGroup pub;
AVFormatContext *fmtctx;
} FFStreamGroup;
static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
{
return (FFStreamGroup*)stg;
}
static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
{
return (const FFStreamGroup*)stg;
}
void ff_flush_packet_queue(AVFormatContext *s);
const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
enum AVCodecID codec_id);
/**
* Frees a stream without modifying the corresponding AVFormatContext.
* Must only be called if the latter doesn't matter or if the stream
* is not yet attached to an AVFormatContext.
*/
void ff_free_stream(AVStream **st);
/**
* Frees a stream group without modifying the corresponding AVFormatContext.
* Must only be called if the latter doesn't matter or if the stream
* is not yet attached to an AVFormatContext.
*/
void ff_free_stream_group(AVStreamGroup **pstg);
int ff_is_intra_only(enum AVCodecID id);
struct FFOutputFormat;
struct FFInputFormat;
void avpriv_register_devices(const struct FFOutputFormat * const o[],
const struct FFInputFormat * const i[]);
#endif // AVFORMAT_AVFORMAT_INTERNAL_H

View File

@ -43,6 +43,7 @@
#include "libavcodec/raw.h" #include "libavcodec/raw.h"
#include "avformat.h" #include "avformat.h"
#include "avformat_internal.h"
#include "avio_internal.h" #include "avio_internal.h"
#include "demux.h" #include "demux.h"
#include "id3v2.h" #include "id3v2.h"

View File

@ -170,22 +170,6 @@ typedef struct FFStreamInfo {
*/ */
#define FFERROR_REDO FFERRTAG('R','E','D','O') #define FFERROR_REDO FFERRTAG('R','E','D','O')
#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. * Read a transport packet from a media file.
* *

View File

@ -426,26 +426,6 @@ static av_always_inline const FFStream *cffstream(const AVStream *st)
return (const FFStream*)st; return (const FFStream*)st;
} }
typedef struct FFStreamGroup {
/**
* The public context.
*/
AVStreamGroup pub;
AVFormatContext *fmtctx;
} FFStreamGroup;
static av_always_inline FFStreamGroup *ffstreamgroup(AVStreamGroup *stg)
{
return (FFStreamGroup*)stg;
}
static av_always_inline const FFStreamGroup *cffstreamgroup(const AVStreamGroup *stg)
{
return (const FFStreamGroup*)stg;
}
#ifdef __GNUC__ #ifdef __GNUC__
#define dynarray_add(tab, nb_ptr, elem)\ #define dynarray_add(tab, nb_ptr, elem)\
do {\ do {\
@ -461,9 +441,6 @@ do {\
} while(0) } while(0)
#endif #endif
void ff_flush_packet_queue(AVFormatContext *s);
/** /**
* Automatically create sub-directories * Automatically create sub-directories
* *
@ -591,9 +568,6 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
enum AVCodecID ff_guess_image2_codec(const char *filename); enum AVCodecID ff_guess_image2_codec(const char *filename);
const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
enum AVCodecID codec_id);
/** /**
* Set the time base and wrapping info for a given stream. This will be used * Set the time base and wrapping info for a given stream. This will be used
* to interpret the stream's timestamps. If the new time base is invalid * to interpret the stream's timestamps. If the new time base is invalid
@ -615,24 +589,12 @@ void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,
*/ */
int ff_framehash_write_header(AVFormatContext *s); int ff_framehash_write_header(AVFormatContext *s);
/**
* Frees a stream without modifying the corresponding AVFormatContext.
* Must only be called if the latter doesn't matter or if the stream
* is not yet attached to an AVFormatContext.
*/
void ff_free_stream(AVStream **st);
/** /**
* Remove a stream from its AVFormatContext and free it. * Remove a stream from its AVFormatContext and free it.
* The stream must be the last stream of the AVFormatContext. * The stream must be the last stream of the AVFormatContext.
*/ */
void ff_remove_stream(AVFormatContext *s, AVStream *st); void ff_remove_stream(AVFormatContext *s, AVStream *st);
/**
* Frees a stream group without modifying the corresponding AVFormatContext.
* Must only be called if the latter doesn't matter or if the stream
* is not yet attached to an AVFormatContext.
*/
void ff_free_stream_group(AVStreamGroup **pstg);
/** /**
* Remove a stream group from its AVFormatContext and free it. * Remove a stream group from its AVFormatContext and free it.
* The stream group must be the last stream group of the AVFormatContext. * The stream group must be the last stream group of the AVFormatContext.
@ -643,8 +605,6 @@ unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id);
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag); enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag);
int ff_is_intra_only(enum AVCodecID id);
/** /**
* Select a PCM codec based on the given parameters. * Select a PCM codec based on the given parameters.
* *
@ -752,9 +712,4 @@ int ff_match_url_ext(const char *url, const char *extensions);
int ff_get_frame_filename(char *buf, int buf_size, const char *path, int ff_get_frame_filename(char *buf, int buf_size, const char *path,
int64_t number, int flags); int64_t number, int flags);
struct FFOutputFormat;
struct FFInputFormat;
void avpriv_register_devices(const struct FFOutputFormat * const o[],
const struct FFInputFormat * const i[]);
#endif /* AVFORMAT_INTERNAL_H */ #endif /* AVFORMAT_INTERNAL_H */

View File

@ -20,6 +20,7 @@
*/ */
#include "avformat.h" #include "avformat.h"
#include "avformat_internal.h"
#include "internal.h" #include "internal.h"
#include "mux.h" #include "mux.h"
#include "version.h" #include "version.h"

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avformat.h" #include "avformat.h"
#include "avformat_internal.h"
#include "avio_internal.h" #include "avio_internal.h"
#include "demux.h" #include "demux.h"
#include "internal.h" #include "internal.h"

View File

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