Commit 29301573 authored by Michael Niedermayer's avatar Michael Niedermayer

add avcodec_get_context_defaults2() / avcodec_alloc_context2() which take...

add avcodec_get_context_defaults2() / avcodec_alloc_context2() which take CodecType as an additional parameter
also mark them as NOT part of the public API yet, so we can change their argument to CodecID if we decide to do so

Originally committed as revision 8283 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2d0aefd6
...@@ -2631,6 +2631,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); ...@@ -2631,6 +2631,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
*/ */
void avcodec_get_context_defaults(AVCodecContext *s); void avcodec_get_context_defaults(AVCodecContext *s);
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
* we WILL change its arguments and name a few times! */
void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
/** /**
* Allocates an AVCodecContext and sets its fields to default values. The * Allocates an AVCodecContext and sets its fields to default values. The
* resulting struct can be deallocated by simply calling av_free(). * resulting struct can be deallocated by simply calling av_free().
...@@ -2640,6 +2644,10 @@ void avcodec_get_context_defaults(AVCodecContext *s); ...@@ -2640,6 +2644,10 @@ void avcodec_get_context_defaults(AVCodecContext *s);
*/ */
AVCodecContext *avcodec_alloc_context(void); AVCodecContext *avcodec_alloc_context(void);
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
* we WILL change its arguments and name a few times! */
AVCodecContext *avcodec_alloc_context2(enum CodecType);
/** /**
* Sets the fields of the given AVFrame to default values. * Sets the fields of the given AVFrame to default values.
* *
......
...@@ -731,12 +731,19 @@ static const AVOption options[]={ ...@@ -731,12 +731,19 @@ static const AVOption options[]={
static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options }; static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
void avcodec_get_context_defaults(AVCodecContext *s){ void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType codec_type){
int flags=0;
memset(s, 0, sizeof(AVCodecContext)); memset(s, 0, sizeof(AVCodecContext));
s->av_class= &av_codec_context_class; s->av_class= &av_codec_context_class;
av_opt_set_defaults(s); if(codec_type == CODEC_TYPE_AUDIO)
flags= AV_OPT_FLAG_AUDIO_PARAM;
else if(codec_type == CODEC_TYPE_VIDEO)
flags= AV_OPT_FLAG_VIDEO_PARAM;
else if(codec_type == CODEC_TYPE_SUBTITLE)
flags= AV_OPT_FLAG_SUBTITLE_PARAM;
av_opt_set_defaults2(s, flags, flags);
s->rc_eq= "tex^qComp"; s->rc_eq= "tex^qComp";
s->time_base= (AVRational){0,1}; s->time_base= (AVRational){0,1};
...@@ -752,16 +759,24 @@ void avcodec_get_context_defaults(AVCodecContext *s){ ...@@ -752,16 +759,24 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->reget_buffer= avcodec_default_reget_buffer; s->reget_buffer= avcodec_default_reget_buffer;
} }
AVCodecContext *avcodec_alloc_context(void){ AVCodecContext *avcodec_alloc_context2(enum CodecType codec_type){
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
if(avctx==NULL) return NULL; if(avctx==NULL) return NULL;
avcodec_get_context_defaults(avctx); avcodec_get_context_defaults2(avctx, codec_type);
return avctx; return avctx;
} }
void avcodec_get_context_defaults(AVCodecContext *s){
avcodec_get_context_defaults2(s, CODEC_TYPE_UNKNOWN);
}
AVCodecContext *avcodec_alloc_context(void){
return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
}
void avcodec_get_frame_defaults(AVFrame *pic){ void avcodec_get_frame_defaults(AVFrame *pic){
memset(pic, 0, sizeof(AVFrame)); memset(pic, 0, sizeof(AVFrame));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment