summaryrefslogtreecommitdiff
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
parent18c007ba37b2c7dee5bd2f1a3eb3bfee9b6b3d26 (diff)
lavc: make avcodec_alloc_context3 officially public.
Deprecate avcodec_alloc_context/2.
-rw-r--r--cmdutils.c2
-rw-r--r--ffserver.c4
-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
-rw-r--r--libavformat/movenc.c2
-rw-r--r--libavformat/movenchint.c2
-rw-r--r--libavformat/utils.c2
11 files changed, 41 insertions, 17 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 943a77c82c..2124ca1439 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -63,7 +63,7 @@ void init_opts(void)
{
int i;
for (i = 0; i < AVMEDIA_TYPE_NB; i++)
- avcodec_opts[i] = avcodec_alloc_context2(i);
+ avcodec_opts[i] = avcodec_alloc_context3(NULL);
avformat_opts = avformat_alloc_context();
#if CONFIG_SWSCALE
sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, NULL, NULL, NULL);
diff --git a/ffserver.c b/ffserver.c
index a12d7082b6..1dc8a17f2f 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3468,7 +3468,7 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int cop
if (!fst)
return NULL;
if (copy) {
- fst->codec= avcodec_alloc_context();
+ fst->codec = avcodec_alloc_context3(NULL);
memcpy(fst->codec, codec, sizeof(AVCodecContext));
if (codec->extradata_size) {
fst->codec->extradata = av_malloc(codec->extradata_size);
@@ -3885,7 +3885,7 @@ static void add_codec(FFStream *stream, AVCodecContext *av)
st = av_mallocz(sizeof(AVStream));
if (!st)
return;
- st->codec = avcodec_alloc_context();
+ st->codec = avcodec_alloc_context3(NULL);
stream->streams[stream->nb_streams++] = st;
memcpy(st->codec, av, sizeof(AVCodecContext));
}
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
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0de7c4d44d..ae6f603e86 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2102,7 +2102,7 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
- track->enc = avcodec_alloc_context();
+ track->enc = avcodec_alloc_context3(NULL);
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
for (i = 0; i < s->nb_chapters; i++) {
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 615714627c..683d58b7c5 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -36,7 +36,7 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
track->tag = MKTAG('r','t','p',' ');
track->src_track = src_index;
- track->enc = avcodec_alloc_context();
+ track->enc = avcodec_alloc_context3(NULL);
if (!track->enc)
goto fail;
track->enc->codec_type = AVMEDIA_TYPE_DATA;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a3825a0c93..bbd1b2d07b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2668,7 +2668,7 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
return NULL;
}
- st->codec= avcodec_alloc_context();
+ st->codec = avcodec_alloc_context3(NULL);
if (s->iformat) {
/* no default bitrate if decoding */
st->codec->bit_rate = 0;