-#if FF_API_FORMAT_PARAMETERS
-static AVDictionary *convert_format_parameters(AVFormatParameters *ap)
-{
- char buf[1024];
- AVDictionary *opts = NULL;
-
- if (!ap)
- return NULL;
-
- AV_NOWARN_DEPRECATED(
- if (ap->time_base.num) {
- snprintf(buf, sizeof(buf), "%d/%d", ap->time_base.den, ap->time_base.num);
- av_dict_set(&opts, "framerate", buf, 0);
- }
- if (ap->sample_rate) {
- snprintf(buf, sizeof(buf), "%d", ap->sample_rate);
- av_dict_set(&opts, "sample_rate", buf, 0);
- }
- if (ap->channels) {
- snprintf(buf, sizeof(buf), "%d", ap->channels);
- av_dict_set(&opts, "channels", buf, 0);
- }
- if (ap->width || ap->height) {
- snprintf(buf, sizeof(buf), "%dx%d", ap->width, ap->height);
- av_dict_set(&opts, "video_size", buf, 0);
- }
- if (ap->pix_fmt != PIX_FMT_NONE) {
- av_dict_set(&opts, "pixel_format", av_get_pix_fmt_name(ap->pix_fmt), 0);
- }
- if (ap->channel) {
- snprintf(buf, sizeof(buf), "%d", ap->channel);
- av_dict_set(&opts, "channel", buf, 0);
- }
- if (ap->standard) {
- av_dict_set(&opts, "standard", ap->standard, 0);
- }
- if (ap->mpeg2ts_compute_pcr) {
- av_dict_set(&opts, "mpeg2ts_compute_pcr", "1", 0);
- }
- if (ap->initial_pause) {
- av_dict_set(&opts, "initial_pause", "1", 0);
- }
- )
- return opts;
-}
-
-/**
- * Open a media file from an IO stream. 'fmt' must be specified.
- */
-int av_open_input_stream(AVFormatContext **ic_ptr,
- AVIOContext *pb, const char *filename,
- AVInputFormat *fmt, AVFormatParameters *ap)
-{
- int err;
- AVDictionary *opts;
- AVFormatContext *ic;
- AVFormatParameters default_ap;
-
- if(!ap){
- ap=&default_ap;
- memset(ap, 0, sizeof(default_ap));
- }
- opts = convert_format_parameters(ap);
-
- AV_NOWARN_DEPRECATED(
- if(!ap->prealloced_context)
- *ic_ptr = ic = avformat_alloc_context();
- else
- ic = *ic_ptr;
- )
- if (!ic) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
- if (pb && fmt && fmt->flags & AVFMT_NOFILE)
- av_log(ic, AV_LOG_WARNING, "Custom AVIOContext makes no sense and "
- "will be ignored with AVFMT_NOFILE format.\n");
- else
- ic->pb = pb;
-
- if ((err = avformat_open_input(&ic, filename, fmt, &opts)) < 0)
- goto fail;
- ic->pb = ic->pb ? ic->pb : pb; // don't leak custom pb if it wasn't set above
-
-fail:
- *ic_ptr = ic;
- av_dict_free(&opts);
- return err;
-}
-#endif
-
-int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap){