#if FF_API_FORMAT_GET_SET
MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
-MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration)
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
return 0;
}
+int ff_add_attached_pic(AVFormatContext *s, AVStream *st0, AVIOContext *pb,
+ AVBufferRef **buf, int size)
+{
+ AVStream *st = st0;
+ AVPacket *pkt;
+ int ret;
+
+ if (!st && !(st = avformat_new_stream(s, NULL)))
+ return AVERROR(ENOMEM);
+ pkt = &st->attached_pic;
+ if (buf) {
+ av_assert1(*buf);
+ av_packet_unref(pkt);
+ pkt->buf = *buf;
+ pkt->data = (*buf)->data;
+ pkt->size = (*buf)->size - AV_INPUT_BUFFER_PADDING_SIZE;
+ *buf = NULL;
+ } else {
+ ret = av_get_packet(pb, pkt, size);
+ if (ret < 0)
+ goto fail;
+ }
+ st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+
+ pkt->stream_index = st->index;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+
+ return 0;
+fail:
+ if (!st0)
+ ff_free_stream(s, st);
+ return ret;
+}
+
static int update_stream_avctx(AVFormatContext *s)
{
int i, ret;
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;
presentation_delayed = 1;
if (pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
- st->pts_wrap_bits < 63 && pkt->dts > INT64_MIN + (1LL << (st->pts_wrap_bits - 1)) &&
+ st->pts_wrap_bits < 63 && pkt->dts > INT64_MIN + (1LL << st->pts_wrap_bits) &&
pkt->dts - (1LL << (st->pts_wrap_bits - 1)) > pkt->pts) {
if (is_relative(st->cur_dts) || pkt->dts - (1LL<<(st->pts_wrap_bits - 1)) > st->cur_dts) {
pkt->dts -= 1LL << st->pts_wrap_bits;
/* update flags */
if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA || ff_is_intra_only(st->codecpar->codec_id))
pkt->flags |= AV_PKT_FLAG_KEY;
-#if FF_API_CONVERGENCE_DURATION
-FF_DISABLE_DEPRECATION_WARNINGS
- if (pc)
- pkt->convergence_duration = pc->convergence_duration;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
}
/**
wanted_timestamp, flags);
}
+int avformat_index_get_entries_count(const AVStream *st)
+{
+ return st->internal->nb_index_entries;
+}
+
+const AVIndexEntry *avformat_index_get_entry(const AVStream *st, int idx)
+{
+ if (idx < 0 || idx >= st->internal->nb_index_entries)
+ return NULL;
+
+ return &st->internal->index_entries[idx];
+}
+
+const AVIndexEntry *avformat_index_get_entry_from_timestamp(const AVStream *st,
+ int64_t wanted_timestamp,
+ int flags)
+{
+ int idx = ff_index_search_timestamp(st->internal->index_entries,
+ st->internal->nb_index_entries,
+ wanted_timestamp, flags);
+
+ if (idx < 0)
+ return NULL;
+
+ return &st->internal->index_entries[idx];
+}
+
static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
{
if (ic->codec_whitelist)
av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0);
- /* Ensure that subtitle_header is properly set. */
- if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE
- && codec && !avctx->codec) {
- if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
- av_log(ic, AV_LOG_WARNING,
- "Failed to open codec in %s\n",__FUNCTION__);
- }
-
// Try to just open decoders, in case this is enough to get parameters.
- if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) {
+ // Also ensure that subtitle_header is properly set.
+ if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0 ||
+ st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (codec && !avctx->codec)
if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
av_log(ic, AV_LOG_WARNING,
}
}
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
- av_freep(&dst->recommended_encoder_configuration);
- if (src->recommended_encoder_configuration) {
- const char *conf_str = src->recommended_encoder_configuration;
- dst->recommended_encoder_configuration = av_strdup(conf_str);
- if (!dst->recommended_encoder_configuration)
- return AVERROR(ENOMEM);
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
return 0;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
av_freep(&st->priv_data);
-#if FF_API_LAVF_FFSERVER
-FF_DISABLE_DEPRECATION_WARNINGS
- av_freep(&st->recommended_encoder_configuration);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
av_freep(pst);
}
AVProgram *av_new_program(AVFormatContext *ac, int id)
{
AVProgram *program = NULL;
- int i;
+ int i, ret;
av_log(ac, AV_LOG_TRACE, "new_program: id=0x%04x\n", id);
program = av_mallocz(sizeof(AVProgram));
if (!program)
return NULL;
- dynarray_add(&ac->programs, &ac->nb_programs, program);
+ ret = av_dynarray_add_nofree(&ac->programs, &ac->nb_programs, program);
+ if (ret < 0) {
+ av_free(program);
+ return NULL;
+ }
program->discard = AVDISCARD_NONE;
program->pmt_version = -1;
program->id = id;
int64_t start, int64_t end, const char *title)
{
AVChapter *chapter = NULL;
- int i;
+ int i, ret;
if (end != AV_NOPTS_VALUE && start > end) {
av_log(s, AV_LOG_ERROR, "Chapter end time %"PRId64" before start %"PRId64"\n", end, start);
chapter = av_mallocz(sizeof(AVChapter));
if (!chapter)
return NULL;
- dynarray_add(&s->chapters, &s->nb_chapters, chapter);
+ ret = av_dynarray_add_nofree(&s->chapters, &s->nb_chapters, chapter);
+ if (ret < 0) {
+ av_free(chapter);
+ return NULL;
+ }
}
av_dict_set(&chapter->metadata, "title", title, 0);
chapter->id = id;
return 1;
}
-#if FF_API_OLD_BSF
-FF_DISABLE_DEPRECATION_WARNINGS
-int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
- AVBitStreamFilterContext *bsfc)
-{
- int ret = 0;
- while (bsfc) {
- AVPacket new_pkt = *pkt;
- int a = av_bitstream_filter_filter(bsfc, codec, NULL,
- &new_pkt.data, &new_pkt.size,
- pkt->data, pkt->size,
- pkt->flags & AV_PKT_FLAG_KEY);
- if (a == 0 && new_pkt.size == 0 && new_pkt.side_data_elems == 0) {
- av_packet_unref(pkt);
- memset(pkt, 0, sizeof(*pkt));
- return 0;
- }
- if(a == 0 && new_pkt.data != pkt->data) {
- uint8_t *t = av_malloc(new_pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow
- if (t) {
- memcpy(t, new_pkt.data, new_pkt.size);
- memset(t + new_pkt.size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
- new_pkt.data = t;
- new_pkt.buf = NULL;
- a = 1;
- } else {
- a = AVERROR(ENOMEM);
- }
- }
- if (a > 0) {
- new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
- av_buffer_default_free, NULL, 0);
- if (new_pkt.buf) {
- pkt->side_data = NULL;
- pkt->side_data_elems = 0;
- av_packet_unref(pkt);
- } else {
- av_freep(&new_pkt.data);
- a = AVERROR(ENOMEM);
- }
- }
- if (a < 0) {
- av_log(codec, AV_LOG_ERROR,
- "Failed to open bitstream filter %s for stream %d with codec %s",
- bsfc->filter->name, pkt->stream_index,
- codec->codec ? codec->codec->name : "copy");
- ret = a;
- break;
- }
- *pkt = new_pkt;
-
- bsfc = bsfc->next;
- }
- return ret;
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options)
{
if (!s->oformat)
enc_ctx->time_base = dec_ctx->time_base;
}
- if (ost->avg_frame_rate.num)
- enc_ctx->time_base = av_inv_q(ost->avg_frame_rate);
-
av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den,
enc_ctx->time_base.num, enc_ctx->time_base.den, INT_MAX);