aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-02 04:18:04 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-02 04:18:04 +0200
commitd4b98d475f8abf9f05ebe91b3fce341aa4b902ee (patch)
treebc452a41fbc304d19ee058da006e9760cb160d6a /libavformat/utils.c
parent8d8962ca3e95b1ce86ab505498e7cd3ec89fa996 (diff)
parent1a9f9f81b1244b952126bb65bc741b04d3534f81 (diff)
downloadffmpeg-d4b98d475f8abf9f05ebe91b3fce341aa4b902ee.tar.gz
Merge commit '1a9f9f8' into oldabi
* commit '1a9f9f8': (98 commits) Do not drop packets with no valid ->pos set as e.g. DV-in-AVI produces. FFMPEG: support demuxer specific options. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> AVIDEC: use_odmc demuxer specific option. (mostly an exmaple for demuxer specific options) Signed-off-by: Michael Niedermayer <michaelni@gmx.at> LAVFAPI: demuxer specific options. (someone please add doxy) Signed-off-by: Michael Niedermayer <michaelni@gmx.at> output_example: use avformat_alloc_output_context() Signed-off-by: Michael Niedermayer <michaelni@gmx.at> LAVFAPI: avformat_alloc_output_context() / simplify usage of muxers. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> LAVF API: remove AVOutputFormat.set_parameters() the field is unused. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> CrystalHD: Add auto-detection of packed b-frame bug. lavc: remove disabled avcodec_decode_video() code Read the album_artist, grouping and lyrics metadata. In libx264 wrapper, change wpredp to a codec specific option. AMV: disable DR1 and don't override EMU_EDGE lavf: inspect more frames for fps when container time base is coarse Fix races in default av_log handler flashsv2enc: regression test. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> vorbis: Replace sized int_fast integer types with plain int/unsigned. Remove disabled non-optimized code variants. bswap.h: Remove disabled code. Remove some disabled printf debug cruft. Replace more disabled printf() calls by av_dlog(). ... Conflicts: libavcodec/options.c libavcodec/qpeg.c libavfilter/avfilter.h libavformat/avformat.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c73
1 files changed, 66 insertions, 7 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index ffb114d5e9..f99adab712 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -496,6 +496,10 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
err = AVERROR(ENOMEM);
goto fail;
}
+ if (fmt->priv_class) {
+ *(const AVClass**)ic->priv_data= fmt->priv_class;
+ av_opt_set_defaults(ic->priv_data);
+ }
} else {
ic->priv_data = NULL;
}
@@ -504,13 +508,13 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
if (ic->pb)
ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC);
- if (ic->iformat->read_header) {
+ if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && ic->iformat->read_header) {
err = ic->iformat->read_header(ic, ap);
if (err < 0)
goto fail;
}
- if (pb && !ic->data_offset)
+ if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && pb && !ic->data_offset)
ic->data_offset = avio_tell(ic->pb);
#if FF_API_OLD_METADATA
@@ -541,6 +545,22 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
return err;
}
+int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap){
+ int err;
+
+ if (ic->iformat->read_header) {
+ err = ic->iformat->read_header(ic, ap);
+ if (err < 0)
+ return err;
+ }
+
+ if (ic->pb && !ic->data_offset)
+ ic->data_offset = avio_tell(ic->pb);
+
+ return 0;
+}
+
+
/** size of probe buffer, for guessing file type from file contents */
#define PROBE_BUF_MIN 2048
#define PROBE_BUF_MAX (1<<20)
@@ -2807,14 +2827,53 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
} else
s->priv_data = NULL;
- if (s->oformat->set_parameters) {
- ret = s->oformat->set_parameters(s, ap);
- if (ret < 0)
- return ret;
- }
return 0;
}
+AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename){
+ AVFormatContext *s= avformat_alloc_context();
+ if(!s)
+ goto nomem;
+
+ if(!oformat){
+ if (format) {
+ oformat = av_guess_format(format, NULL, NULL);
+ if (!oformat) {
+ av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
+ goto error;
+ }
+ } else {
+ oformat = av_guess_format(NULL, filename, NULL);
+ if (!oformat) {
+ av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
+ filename);
+ goto error;
+ }
+ }
+ }
+
+ s->oformat= oformat;
+ if (s->oformat->priv_data_size > 0) {
+ s->priv_data = av_mallocz(s->oformat->priv_data_size);
+ if (!s->priv_data)
+ goto nomem;
+ if (s->oformat->priv_class) {
+ *(const AVClass**)s->priv_data= s->oformat->priv_class;
+ av_opt_set_defaults(s->priv_data);
+ }
+ } else
+ s->priv_data = NULL;
+
+ if(filename)
+ av_strlcpy(s->filename, filename, sizeof(s->filename));
+ return s;
+nomem:
+ av_log(s, AV_LOG_ERROR, "Out of memory\n");
+error:
+ avformat_free_context(s);
+ return NULL;
+}
+
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
{
const AVCodecTag *avctag;