changeset 681:b3869ffff47a libavcodec

avcodec_alloc_context()
author michaelni
date Thu, 19 Sep 2002 09:13:43 +0000
parents 79393a88c6e4
children 8be211ca9db9
files avcodec.h utils.c
diffstat 2 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Wed Sep 18 18:30:31 2002 +0000
+++ b/avcodec.h	Thu Sep 19 09:13:43 2002 +0000
@@ -5,8 +5,8 @@
 
 #define LIBAVCODEC_VERSION_INT 0x000406
 #define LIBAVCODEC_VERSION     "0.4.6"
-#define LIBAVCODEC_BUILD       4623
-#define LIBAVCODEC_BUILD_STR   "4623"
+#define LIBAVCODEC_BUILD       4624
+#define LIBAVCODEC_BUILD_STR   "4624"
 
 enum CodecID {
     CODEC_ID_NONE, 
@@ -100,8 +100,10 @@
 
 #define FF_MAX_B_FRAMES 4
 
-/* encoding support */
-/* note not everything is supported yet */
+/* encoding support
+   these flags can be passed in AVCodecContext.flags before initing 
+   Note: note not everything is supported yet 
+*/
 
 #define CODEC_FLAG_HQ     0x0001 /* high quality (non real time) encoding */
 #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
@@ -514,6 +516,7 @@
 AVCodec *avcodec_find_decoder_by_name(const char *name);
 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
 
+AVCodecContext *avcodec_alloc_context();
 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, 
                          int *frame_size_ptr,
--- a/utils.c	Wed Sep 18 18:30:31 2002 +0000
+++ b/utils.c	Thu Sep 19 09:13:43 2002 +0000
@@ -49,6 +49,27 @@
     format->next = NULL;
 }
 
+void avcodec_get_context_defaults(AVCodecContext *s){
+    s->qmin= 2;
+    s->qmax= 31;
+    s->rc_eq= "tex^qComp";
+    s->qcompress= 0.5;
+}
+
+/**
+ * allocates a AVCodecContext and set it to defaults.
+ * this can be deallocated by simply calling free() 
+ */
+AVCodecContext *avcodec_alloc_context(){
+    AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext));
+    
+    if(avctx==NULL) return NULL;
+    
+    avcodec_get_context_defaults(avctx);
+    
+    return avctx;
+}
+
 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
 {
     int ret;