Also constify AVProbeData.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
API changes, most recent first:
+
+2021-04-27 - xxxxxxxxxx - lavf yyyyyyyyy - avformat.h
+ Constified the pointers to AVInputFormats and AVOutputFormats
+ in AVFormatContext, avformat_alloc_output_context2(),
+ av_find_input_format(), av_probe_input_format(),
+ av_probe_input_format2(), av_probe_input_format3(),
+ av_probe_input_buffer2(), av_probe_input_buffer(),
+ avformat_open_input(), av_guess_format() and av_guess_codec().
+ Furthermore, constified the AVProbeData in av_probe_input_format(),
+ av_probe_input_format2() and av_probe_input_format3().
+
2021-04-19 - xxxxxxxxxx - lavu 56.74.100 - tx.h
Add AV_TX_FULL_IMDCT and AV_TX_UNALIGNED.
int main(int argc, char **argv)
{
OutputStream video_st = { 0 }, audio_st = { 0 };
+ const AVOutputFormat *fmt;
const char *filename;
- AVOutputFormat *fmt;
AVFormatContext *oc;
AVCodec *audio_codec, *video_codec;
int ret;
int main(int argc, char **argv)
{
- AVOutputFormat *ofmt = NULL;
+ const AVOutputFormat *ofmt = NULL;
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
AVPacket pkt;
const char *in_filename, *out_filename;
{
InputFile *f;
AVFormatContext *ic;
- AVInputFormat *file_iformat = NULL;
+ const AVInputFormat *file_iformat = NULL;
int err, i, ret;
int64_t timestamp;
AVDictionary *unused_opts = NULL;
av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);
}
if (o->nb_audio_channels) {
+ const AVClass *priv_class;
/* because we set audio_channels based on both the "ac" and
* "channel_layout" options, we need to check that the specified
* demuxer actually has the "channels" option before setting it */
- if (file_iformat && file_iformat->priv_class &&
- av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
+ if (file_iformat && (priv_class = file_iformat->priv_class) &&
+ av_opt_find(&priv_class, "channels", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set_int(&o->g->format_opts, "channels", o->audio_channels[o->nb_audio_channels - 1].u.i, 0);
}
}
if (o->nb_frame_rates) {
+ const AVClass *priv_class;
/* set the format-level framerate option;
* this is important for video grabbers, e.g. x11 */
- if (file_iformat && file_iformat->priv_class &&
- av_opt_find(&file_iformat->priv_class, "framerate", NULL, 0,
+ if (file_iformat && (priv_class = file_iformat->priv_class) &&
+ av_opt_find(&priv_class, "framerate", NULL, 0,
AV_OPT_SEARCH_FAKE_OBJ)) {
av_dict_set(&o->g->format_opts, "framerate",
o->frame_rates[o->nb_frame_rates - 1].u.str, 0);
typedef struct VideoState {
SDL_Thread *read_tid;
- AVInputFormat *iformat;
+ const AVInputFormat *iformat;
int abort_request;
int force_refresh;
int paused;
} VideoState;
/* options specified by the user */
-static AVInputFormat *file_iformat;
+static const AVInputFormat *file_iformat;
static const char *input_filename;
static const char *window_title;
static int default_width = 640;
return 0;
}
-static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
+static VideoState *stream_open(const char *filename,
+ const AVInputFormat *iformat)
{
VideoState *is;
/* FFprobe context */
static const char *input_filename;
static const char *print_input_filename;
-static AVInputFormat *iformat = NULL;
+static const AVInputFormat *iformat = NULL;
static struct AVHashContext *hash;
#include "libavformat/avformat.h"
av_warn_unused_result
-int ff_alloc_input_device_context(struct AVFormatContext **avctx, struct AVInputFormat *iformat,
+int ff_alloc_input_device_context(struct AVFormatContext **avctx, const AVInputFormat *iformat,
const char *format);
#endif
#include "libavutil/opt.h"
#include "libavformat/avformat.h"
-int ff_alloc_input_device_context(AVFormatContext **avctx, AVInputFormat *iformat, const char *format)
+int ff_alloc_input_device_context(AVFormatContext **avctx, const AVInputFormat *iformat, const char *format)
{
AVFormatContext *s;
int ret = 0;
int *w, int *h, enum AVPixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
- AVInputFormat *iformat = NULL;
+ const AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx = NULL;
const AVCodec *codec;
AVCodecContext *codec_ctx = NULL;
static av_cold int movie_common_init(AVFilterContext *ctx)
{
MovieContext *movie = ctx->priv;
- AVInputFormat *iformat = NULL;
+ const AVInputFormat *iformat = NULL;
int64_t timestamp;
int nb_streams = 1, ret, i;
char default_streams[16], *stream_specs, *spec, *cursor;
* New public fields should be added right above.
*****************************************************************
*/
- /**
- * The ff_const59 define is not part of the public API and will
- * be removed without further warning.
- */
-#if FF_API_AVIOFORMAT
-#define ff_const59
-#else
-#define ff_const59 const
-#endif
/**
* size of private data so that it can be allocated in the wrapper
*/
*
* Demuxing only, set by avformat_open_input().
*/
- ff_const59 struct AVInputFormat *iformat;
+ const struct AVInputFormat *iformat;
/**
* The output container format.
*
* Muxing only, must be set by the caller before avformat_write_header().
*/
- ff_const59 struct AVOutputFormat *oformat;
+ const struct AVOutputFormat *oformat;
/**
* Format private data. This is an AVOptions-enabled struct
* @return >= 0 in case of success, a negative AVERROR code in case of
* failure
*/
-int avformat_alloc_output_context2(AVFormatContext **ctx, ff_const59 AVOutputFormat *oformat,
+int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat,
const char *format_name, const char *filename);
/**
/**
* Find AVInputFormat based on the short name of the input format.
*/
-ff_const59 AVInputFormat *av_find_input_format(const char *short_name);
+const AVInputFormat *av_find_input_format(const char *short_name);
/**
* Guess the file format.
* @param is_opened Whether the file is already opened; determines whether
* demuxers with or without AVFMT_NOFILE are probed.
*/
-ff_const59 AVInputFormat *av_probe_input_format(ff_const59 AVProbeData *pd, int is_opened);
+const AVInputFormat *av_probe_input_format(const AVProbeData *pd, int is_opened);
/**
* Guess the file format.
* If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended
* to retry with a larger probe buffer.
*/
-ff_const59 AVInputFormat *av_probe_input_format2(ff_const59 AVProbeData *pd, int is_opened, int *score_max);
+const AVInputFormat *av_probe_input_format2(const AVProbeData *pd,
+ int is_opened, int *score_max);
/**
* Guess the file format.
* demuxers with or without AVFMT_NOFILE are probed.
* @param score_ret The score of the best detection.
*/
-ff_const59 AVInputFormat *av_probe_input_format3(ff_const59 AVProbeData *pd, int is_opened, int *score_ret);
+const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
+ int is_opened, int *score_ret);
/**
* Probe a bytestream to determine the input format. Each time a probe returns
* the maximal score is AVPROBE_SCORE_MAX
* AVERROR code otherwise
*/
-int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
+int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
const char *url, void *logctx,
unsigned int offset, unsigned int max_probe_size);
/**
* Like av_probe_input_buffer2() but returns 0 on success
*/
-int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
+int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt,
const char *url, void *logctx,
unsigned int offset, unsigned int max_probe_size);
*
* @note If you want to use custom IO, preallocate the format context and set its pb field.
*/
-int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options);
+int avformat_open_input(AVFormatContext **ps, const char *url,
+ const AVInputFormat *fmt, AVDictionary **options);
#if FF_API_DEMUXER_OPEN
/**
* @param mime_type if non-NULL checks if mime_type matches with the
* MIME type of the registered formats
*/
-ff_const59 AVOutputFormat *av_guess_format(const char *short_name,
- const char *filename,
- const char *mime_type);
+const AVOutputFormat *av_guess_format(const char *short_name,
+ const char *filename,
+ const char *mime_type);
/**
* Guess the codec ID based upon muxer and filename.
*/
-enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name,
- const char *filename, const char *mime_type,
- enum AVMediaType type);
+enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name,
+ const char *filename, const char *mime_type,
+ enum AVMediaType type);
/**
* Get timing information for the data currently output.
uint8_t desc[256];
int score = AVPROBE_SCORE_EXTENSION, ret;
AVIStream *ast = st->priv_data;
- ff_const59 AVInputFormat *sub_demuxer;
+ const AVInputFormat *sub_demuxer;
AVRational time_base;
int size;
AVProbeData pd;
static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
{
DASHContext *c = s->priv_data;
- ff_const59 AVInputFormat *in_fmt = NULL;
+ const AVInputFormat *in_fmt = NULL;
AVDictionary *in_fmt_opts = NULL;
uint8_t *avio_ctx_buffer = NULL;
int ret = 0, i;
return NULL;
}
-static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oformat,
+static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat,
const char *filename)
{
FifoContext *fifo = avf->priv_data;
static int fifo_init(AVFormatContext *avf)
{
FifoContext *fifo = avf->priv_data;
- ff_const59 AVOutputFormat *oformat;
+ const AVOutputFormat *oformat;
int ret = 0;
if (fifo->recovery_wait_streamtime && !fifo->drop_pkts_on_overflow) {
return 0;
}
-ff_const59 AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
- const char *mime_type)
+const AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
+ const char *mime_type)
{
const AVOutputFormat *fmt = NULL;
AVOutputFormat *fmt_found = NULL;
return fmt_found;
}
-enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name,
+enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name,
const char *filename, const char *mime_type,
enum AVMediaType type)
{
if (av_match_name("segment", fmt->name) || av_match_name("ssegment", fmt->name)) {
- ff_const59 AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL);
+ const AVOutputFormat *fmt2 = av_guess_format(NULL, filename, NULL);
if (fmt2)
fmt = fmt2;
}
return AV_CODEC_ID_NONE;
}
-ff_const59 AVInputFormat *av_find_input_format(const char *short_name)
+const AVInputFormat *av_find_input_format(const char *short_name)
{
const AVInputFormat *fmt = NULL;
void *i = 0;
return NULL;
}
-ff_const59 AVInputFormat *av_probe_input_format3(ff_const59 AVProbeData *pd, int is_opened,
- int *score_ret)
+const AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
+ int is_opened, int *score_ret)
{
AVProbeData lpd = *pd;
const AVInputFormat *fmt1 = NULL;
- ff_const59 AVInputFormat *fmt = NULL;
+ const AVInputFormat *fmt = NULL;
int score, score_max = 0;
void *i = 0;
const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
}
if (score > score_max) {
score_max = score;
- fmt = (AVInputFormat*)fmt1;
+ fmt = fmt1;
} else if (score == score_max)
fmt = NULL;
}
return fmt;
}
-ff_const59 AVInputFormat *av_probe_input_format2(ff_const59 AVProbeData *pd, int is_opened, int *score_max)
+const AVInputFormat *av_probe_input_format2(const AVProbeData *pd,
+ int is_opened, int *score_max)
{
int score_ret;
- ff_const59 AVInputFormat *fmt = av_probe_input_format3(pd, is_opened, &score_ret);
+ const AVInputFormat *fmt = av_probe_input_format3(pd, is_opened, &score_ret);
if (score_ret > *score_max) {
*score_max = score_ret;
return fmt;
return NULL;
}
-ff_const59 AVInputFormat *av_probe_input_format(ff_const59 AVProbeData *pd, int is_opened)
+const AVInputFormat *av_probe_input_format(const AVProbeData *pd, int is_opened)
{
int score = 0;
return av_probe_input_format2(pd, is_opened, &score);
}
-int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
- const char *filename, void *logctx,
- unsigned int offset, unsigned int max_probe_size)
+int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
+ const char *filename, void *logctx,
+ unsigned int offset, unsigned int max_probe_size)
{
AVProbeData pd = { filename ? filename : "" };
uint8_t *buf = NULL;
return ret < 0 ? ret : score;
}
-int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
+int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt,
const char *filename, void *logctx,
unsigned int offset, unsigned int max_probe_size)
{
static int hds_write_header(AVFormatContext *s)
{
HDSContext *c = s->priv_data;
+ const AVOutputFormat *oformat;
int ret = 0, i;
- ff_const59 AVOutputFormat *oformat;
if (mkdir(s->url, 0777) == -1 && errno != EEXIST) {
av_log(s, AV_LOG_ERROR , "Failed to create directory %s\n", s->url);
/* Open the demuxer for each playlist */
for (i = 0; i < c->n_playlists; i++) {
struct playlist *pls = c->playlists[i];
+ const AVInputFormat *in_fmt = NULL;
char *url;
- ff_const59 AVInputFormat *in_fmt = NULL;
if (!(pls->ctx = avformat_alloc_context())) {
ret = AVERROR(ENOMEM);
unsigned var_stream_idx;
unsigned number;
int64_t sequence;
- ff_const59 AVOutputFormat *oformat;
- ff_const59 AVOutputFormat *vtt_oformat;
+ const AVOutputFormat *oformat;
+ const AVOutputFormat *vtt_oformat;
AVIOContext *out;
AVIOContext *out_single_file;
int packets_written;
{
int i, ret = 0, header_parsed = 0, langidx = 0;
VobSubDemuxContext *vobsub = s->priv_data;
+ const AVInputFormat *iformat;
size_t fname_len;
AVBPrint header;
int64_t delay = 0;
int stream_id = -1;
char id[64] = {0};
char alt[MAX_LINE_SIZE] = {0};
- ff_const59 AVInputFormat *iformat;
if (!vobsub->sub_name) {
char *ext;
}
-int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputFormat *oformat,
+int avformat_alloc_output_context2(AVFormatContext **avctx, const AVOutputFormat *oformat,
const char *format, const char *filename)
{
AVFormatContext *s = avformat_alloc_context();
AVDictionary *opts = NULL;
int len = strlen(p) * 6 / 8;
char *buf = av_mallocz(len);
- ff_const59 AVInputFormat *iformat;
+ const AVInputFormat *iformat;
if (!buf)
return AVERROR(ENOMEM);
{
AVFormatContext *rtpctx = NULL;
int ret;
- ff_const59 AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
+ const AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
uint8_t *rtpflags;
AVDictionary *opts = NULL;
{
MuxChain *chain = s->priv_data;
AVFormatContext *mpegts_ctx = NULL, *rtp_ctx = NULL;
- ff_const59 AVOutputFormat *mpegts_format = av_guess_format("mpegts", NULL, NULL);
- ff_const59 AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
+ const AVOutputFormat *mpegts_format = av_guess_format("mpegts", NULL, NULL);
+ const AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
int i, ret = AVERROR(ENOMEM);
AVStream *st;
AVDictionary *mpegts_muxer_options = NULL;
struct SAPState *sap = s->priv_data;
char host[1024], path[1024], url[1024];
uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
+ const AVInputFormat *infmt;
int port;
int ret, i;
- ff_const59 AVInputFormat* infmt;
if (!ff_network_init())
return AVERROR(EIO);
int segment_idx_wrap; ///< number after which the index wraps
int segment_idx_wrap_nb; ///< number of time the index has wraped
int segment_count; ///< number of segment files already written
- ff_const59 AVOutputFormat *oformat;
+ const AVOutputFormat *oformat;
AVFormatContext *avf;
char *format; ///< format to use for output segment files
AVDictionary *format_options;
{
SmoothStreamingContext *c = s->priv_data;
int ret = 0, i;
- ff_const59 AVOutputFormat *oformat;
+ const AVOutputFormat *oformat;
if (mkdir(s->url, 0777) == -1 && errno != EEXIST) {
av_log(s, AV_LOG_ERROR, "mkdir failed\n");
int avformat_open_input(AVFormatContext **ps, const char *filename,
- ff_const59 AVInputFormat *fmt, AVDictionary **options)
+ const AVInputFormat *fmt, AVDictionary **options)
{
AVFormatContext *s = *ps;
int i, ret = 0;
#ifndef FF_API_LAVF_MP4A_LATM
#define FF_API_LAVF_MP4A_LATM (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
-#ifndef FF_API_AVIOFORMAT
-#define FF_API_AVIOFORMAT (LIBAVFORMAT_VERSION_MAJOR < 59)
-#endif
#ifndef FF_API_DEMUXER_OPEN
#define FF_API_DEMUXER_OPEN (LIBAVFORMAT_VERSION_MAJOR < 59)
#endif
static int webm_chunk_init(AVFormatContext *s)
{
WebMChunkContext *wc = s->priv_data;
- ff_const59 AVOutputFormat *oformat;
+ const AVOutputFormat *oformat;
AVFormatContext *oc;
AVStream *st, *ost = s->streams[0];
AVDictionary *dict = NULL;