aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-06-18 13:40:48 +0200
committerAnton Khirnov <anton@khirnov.net>2011-07-10 17:09:28 +0200
commit71a861cf4010ab835fab383a250f27903eb61a34 (patch)
tree5af1c2668613d3cd606b9803f34ac68c22152228 /libavcodec
parent18c007ba37b2c7dee5bd2f1a3eb3bfee9b6b3d26 (diff)
downloadffmpeg-71a861cf4010ab835fab383a250f27903eb61a34.tar.gz
lavc: make avcodec_alloc_context3 officially public.
Deprecate avcodec_alloc_context/2.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/api-example.c8
-rw-r--r--libavcodec/avcodec.h27
-rw-r--r--libavcodec/motion-test.c2
-rw-r--r--libavcodec/mpegvideo_enc.c2
-rw-r--r--libavcodec/options.c4
-rw-r--r--libavcodec/version.h3
6 files changed, 35 insertions, 11 deletions
diff --git a/libavcodec/api-example.c b/libavcodec/api-example.c
index 1792d60d77..ec71b0d031 100644
--- a/libavcodec/api-example.c
+++ b/libavcodec/api-example.c
@@ -65,7 +65,7 @@ static void audio_encode_example(const char *filename)
exit(1);
}
- c= avcodec_alloc_context();
+ c = avcodec_alloc_context3(codec);
/* put sample parameters */
c->bit_rate = 64000;
@@ -135,7 +135,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
exit(1);
}
- c= avcodec_alloc_context();
+ c = avcodec_alloc_context3(codec);
/* open it */
if (avcodec_open(c, codec) < 0) {
@@ -216,7 +216,7 @@ static void video_encode_example(const char *filename)
exit(1);
}
- c= avcodec_alloc_context();
+ c = avcodec_alloc_context3(codec);
picture= avcodec_alloc_frame();
/* put sample parameters */
@@ -347,7 +347,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
exit(1);
}
- c= avcodec_alloc_context();
+ c = avcodec_alloc_context3(codec);
picture= avcodec_alloc_frame();
if(codec->capabilities&CODEC_CAP_TRUNCATED)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7c7a0c6a97..3f016807ab 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3529,21 +3529,38 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
* we WILL change its arguments and name a few times! */
int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
+#if FF_API_ALLOC_CONTEXT
/**
* Allocate an AVCodecContext and set its fields to default values. The
* resulting struct can be deallocated by simply calling av_free().
*
* @return An AVCodecContext filled with default values or NULL on failure.
* @see avcodec_get_context_defaults
+ *
+ * @deprecated use avcodec_alloc_context3()
*/
+attribute_deprecated
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! */
+attribute_deprecated
AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
+#endif
-/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
- * we WILL change its arguments and name a few times! */
+/**
+ * Allocate an AVCodecContext and set its fields to default values. The
+ * resulting struct can be deallocated by simply calling av_free().
+ *
+ * @param codec if non-NULL, allocate private data and initialize defaults
+ * for the given codec. It is illegal to then call avcodec_open()
+ * with a different codec.
+ *
+ * @return An AVCodecContext filled with default values or NULL on failure.
+ * @see avcodec_get_context_defaults
+ *
+ * @deprecated use avcodec_alloc_context3()
+ */
AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
/**
@@ -3553,7 +3570,7 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
* can use this AVCodecContext to decode/encode video/audio data.
*
* @param dest target codec context, should be initialized with
- * avcodec_alloc_context(), but otherwise uninitialized
+ * avcodec_alloc_context3(), but otherwise uninitialized
* @param src source codec context
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
*/
@@ -3640,7 +3657,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
* if (!codec)
* exit(1);
*
- * context = avcodec_alloc_context();
+ * context = avcodec_alloc_context3(codec);
*
* if (avcodec_open(context, codec) < 0)
* exit(1);
@@ -3649,7 +3666,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
* @param avctx The context which will be set up to use the given codec.
* @param codec The codec to use within the context.
* @return zero on success, a negative value on error
- * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
+ * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
*
* @deprecated use avcodec_open2
*/
diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c
index b88917c988..7ac5cc7d4a 100644
--- a/libavcodec/motion-test.c
+++ b/libavcodec/motion-test.c
@@ -144,7 +144,7 @@ int main(int argc, char **argv)
printf("ffmpeg motion test\n");
- ctx = avcodec_alloc_context();
+ ctx = avcodec_alloc_context3(NULL);
ctx->dsp_mask = AV_CPU_FLAG_FORCE;
dsputil_init(&cctx, ctx);
for (c = 0; c < flags_size; c++) {
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f298993c0c..68bd080960 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -944,7 +944,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
static int estimate_best_b_count(MpegEncContext *s){
AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
- AVCodecContext *c= avcodec_alloc_context();
+ AVCodecContext *c = avcodec_alloc_context3(NULL);
AVFrame input[FF_MAX_B_FRAMES+2];
const int scale= s->avctx->brd_scale;
int i, j, out_size, p_lambda, b_lambda, lambda2;
diff --git a/libavcodec/options.c b/libavcodec/options.c
index a876ce0404..1e7fe522ea 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -540,6 +540,7 @@ 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));
@@ -549,14 +550,17 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
return avctx;
}
+#endif
void avcodec_get_context_defaults(AVCodecContext *s){
avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN);
}
+#if FF_API_ALLOC_CONTEXT
AVCodecContext *avcodec_alloc_context(void){
return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
}
+#endif
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7e4c02d91e..32b2bb314c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -68,6 +68,9 @@
#ifndef FF_API_GET_PIX_FMT_NAME
#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_ALLOC_CONTEXT
+#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
#ifndef FF_API_AVCODEC_OPEN
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54)
#endif