diff options
Diffstat (limited to 'libavcodec/options.c')
-rw-r--r-- | libavcodec/options.c | 71 |
1 files changed, 65 insertions, 6 deletions
diff --git a/libavcodec/options.c b/libavcodec/options.c index abbca0bf24..ef598d5871 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -2,20 +2,20 @@ * Copyright (c) 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -75,14 +75,28 @@ static const AVClass av_codec_context_class = { .child_class_next = codec_child_class_next, }; +#if FF_API_ALLOC_CONTEXT +void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ + AVCodec c= {0}; + c.type= codec_type; + avcodec_get_context_defaults3(s, &c); +} +#endif + int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ + int flags=0; memset(s, 0, sizeof(AVCodecContext)); s->av_class = &av_codec_context_class; s->codec_type = codec ? codec->type : AVMEDIA_TYPE_UNKNOWN; - s->codec = codec; - av_opt_set_defaults(s); + if(s->codec_type == AVMEDIA_TYPE_AUDIO) + flags= AV_OPT_FLAG_AUDIO_PARAM; + else if(s->codec_type == AVMEDIA_TYPE_VIDEO) + flags= AV_OPT_FLAG_VIDEO_PARAM; + else if(s->codec_type == AVMEDIA_TYPE_SUBTITLE) + flags= AV_OPT_FLAG_SUBTITLE_PARAM; + av_opt_set_defaults2(s, flags, flags); s->time_base = (AVRational){0,1}; s->get_buffer = avcodec_default_get_buffer; @@ -93,6 +107,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ s->sample_aspect_ratio = (AVRational){0,1}; s->pix_fmt = PIX_FMT_NONE; s->sample_fmt = AV_SAMPLE_FMT_NONE; + s->timecode_frame_start = -1; s->reget_buffer = avcodec_default_reget_buffer; s->reordered_opaque = AV_NOPTS_VALUE; @@ -133,6 +148,26 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec){ return avctx; } +#if FF_API_ALLOC_CONTEXT +AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){ + AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); + + if(avctx==NULL) return NULL; + + avcodec_get_context_defaults2(avctx, codec_type); + + return avctx; +} + +void avcodec_get_context_defaults(AVCodecContext *s){ + avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); +} + +AVCodecContext *avcodec_alloc_context(void){ + return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); +} +#endif + int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) { if (avcodec_is_open(dest)) { // check that the dest context is uninitialized @@ -194,3 +229,27 @@ const AVClass *avcodec_get_class(void) { return &av_codec_context_class; } + +#define FOFFSET(x) offsetof(AVFrame,x) + +static const AVOption frame_options[]={ +{"best_effort_timestamp", "", FOFFSET(best_effort_timestamp), AV_OPT_TYPE_INT64, {.dbl = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, 0}, +{"pkt_pos", "", FOFFSET(pkt_pos), AV_OPT_TYPE_INT64, {.dbl = -1 }, INT64_MIN, INT64_MAX, 0}, +{"sample_aspect_ratio", "", FOFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0}, +{"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0}, +{"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, 0}, +{"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.dbl = -1 }, 0, INT_MAX, 0}, +{NULL}, +}; + +static const AVClass av_frame_class = { + .class_name = "AVFrame", + .item_name = NULL, + .option = frame_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +const AVClass *avcodec_get_frame_class(void) +{ + return &av_frame_class; +} |