• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/options.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
00003  *
00004  * This file is part of Libav.
00005  *
00006  * Libav is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * Libav is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with Libav; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 #include "avformat.h"
00021 #include "avio_internal.h"
00022 #include "libavutil/opt.h"
00023 
00029 static const char* format_to_name(void* ptr)
00030 {
00031     AVFormatContext* fc = (AVFormatContext*) ptr;
00032     if(fc->iformat) return fc->iformat->name;
00033     else if(fc->oformat) return fc->oformat->name;
00034     else return "NULL";
00035 }
00036 
00037 static void *format_child_next(void *obj, void *prev)
00038 {
00039     AVFormatContext *s = obj;
00040     if (!prev && s->priv_data &&
00041         ((s->iformat && s->iformat->priv_class) ||
00042           s->oformat && s->oformat->priv_class))
00043         return s->priv_data;
00044 #if !FF_API_OLD_AVIO
00045     if (s->pb && s->pb->av_class && prev != s->pb)
00046         return s->pb;
00047 #endif
00048     return NULL;
00049 }
00050 
00051 static const AVClass *format_child_class_next(const AVClass *prev)
00052 {
00053     AVInputFormat  *ifmt = NULL;
00054     AVOutputFormat *ofmt = NULL;
00055 
00056     if (!prev)
00057 #if !FF_API_OLD_AVIO
00058         return &ffio_url_class;
00059 #else
00060     prev = (void *)&ifmt; // Dummy pointer;
00061 #endif
00062 
00063     while ((ifmt = av_iformat_next(ifmt)))
00064         if (ifmt->priv_class == prev)
00065             break;
00066 
00067     if (!ifmt)
00068         while ((ofmt = av_oformat_next(ofmt)))
00069             if (ofmt->priv_class == prev)
00070                 break;
00071     if (!ofmt)
00072         while (ifmt = av_iformat_next(ifmt))
00073             if (ifmt->priv_class)
00074                 return ifmt->priv_class;
00075 
00076     while (ofmt = av_oformat_next(ofmt))
00077         if (ofmt->priv_class)
00078             return ofmt->priv_class;
00079 
00080     return NULL;
00081 }
00082 
00083 #define OFFSET(x) offsetof(AVFormatContext,x)
00084 #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
00085 //these names are too long to be readable
00086 #define E AV_OPT_FLAG_ENCODING_PARAM
00087 #define D AV_OPT_FLAG_DECODING_PARAM
00088 
00089 static const AVOption options[]={
00090 {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D},
00091 #if FF_API_MUXRATE
00092 {"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
00093 #endif
00094 {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E},
00095 {"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"},
00096 {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"},
00097 {"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"},
00098 {"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"},
00099 {"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
00100 {"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
00101 #if FF_API_FLAG_RTP_HINT
00102 {"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"},
00103 #endif
00104 {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
00105 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
00106 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
00107 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
00108 {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
00109 {"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"},
00110 {"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"},
00111 {"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D},
00112 {"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D},
00113 /* this is a crutch for avconv, since it cannot deal with identically named options in different contexts.
00114  * to be removed when avconv is fixed */
00115 {"f_err_detect", "set error detection flags (deprecated; use err_detect, save via avconv)", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
00116 {"err_detect", "set error detection flags", OFFSET(error_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
00117 {"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, D, "err_detect"},
00118 {"bitstream", "detect bitstream specification deviations", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, D, "err_detect"},
00119 {"buffer", "detect improper bitstream length", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, D, "err_detect"},
00120 {"explode", "abort decoding on minor error detection", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, D, "err_detect"},
00121 {NULL},
00122 };
00123 
00124 #undef E
00125 #undef D
00126 #undef DEFAULT
00127 
00128 static const AVClass av_format_context_class = {
00129     .class_name     = "AVFormatContext",
00130     .item_name      = format_to_name,
00131     .option         = options,
00132     .version        = LIBAVUTIL_VERSION_INT,
00133     .child_next     = format_child_next,
00134     .child_class_next = format_child_class_next,
00135 };
00136 
00137 static void avformat_get_context_defaults(AVFormatContext *s)
00138 {
00139     memset(s, 0, sizeof(AVFormatContext));
00140 
00141     s->av_class = &av_format_context_class;
00142 
00143     av_opt_set_defaults(s);
00144 }
00145 
00146 AVFormatContext *avformat_alloc_context(void)
00147 {
00148     AVFormatContext *ic;
00149     ic = av_malloc(sizeof(AVFormatContext));
00150     if (!ic) return ic;
00151     avformat_get_context_defaults(ic);
00152     return ic;
00153 }
00154 
00155 const AVClass *avformat_get_class(void)
00156 {
00157     return &av_format_context_class;
00158 }
Generated on Thu Jan 24 2013 17:08:53 for Libav by doxygen 1.7.1