lavc: deprecate avcodec_get_context_defaults3()
This function is supposed to "reset" a codec context to a clean state so that it can be opened again. The only reason it exists is to allow using AVStream.codec as a decoding context (after it was already opened/used/closed by avformat_find_stream_info()). Since that behaviour is now deprecated, there is no reason for this function to exist anymore.
This commit is contained in:
		@@ -3619,7 +3619,6 @@ void avcodec_register_all(void);
 | 
				
			|||||||
 *              important mainly for encoders, e.g. libx264).
 | 
					 *              important mainly for encoders, e.g. libx264).
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @return An AVCodecContext filled with default values or NULL on failure.
 | 
					 * @return An AVCodecContext filled with default values or NULL on failure.
 | 
				
			||||||
 * @see avcodec_get_context_defaults
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
 | 
					AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -3629,16 +3628,14 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
void avcodec_free_context(AVCodecContext **avctx);
 | 
					void avcodec_free_context(AVCodecContext **avctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if FF_API_GET_CONTEXT_DEFAULTS
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Set the fields of the given AVCodecContext to default values corresponding
 | 
					 * @deprecated This function should not be used, as closing and opening a codec
 | 
				
			||||||
 * to the given codec (defaults may be codec-dependent).
 | 
					 * context multiple time is not supported. A new codec context should be
 | 
				
			||||||
 *
 | 
					 * allocated for each new use.
 | 
				
			||||||
 * Do not call this function if a non-NULL codec has been passed
 | 
					 | 
				
			||||||
 * to avcodec_alloc_context3() that allocated this AVCodecContext.
 | 
					 | 
				
			||||||
 * If codec is non-NULL, it is illegal to call avcodec_open2() with a
 | 
					 | 
				
			||||||
 * different codec on this AVCodecContext.
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
 | 
					int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Get the AVClass for AVCodecContext. It can be used in combination with
 | 
					 * Get the AVClass for AVCodecContext. It can be used in combination with
 | 
				
			||||||
@@ -3741,9 +3738,8 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 | 
				
			|||||||
 * @param avctx The context to initialize.
 | 
					 * @param avctx The context to initialize.
 | 
				
			||||||
 * @param codec The codec to open this context for. If a non-NULL codec has been
 | 
					 * @param codec The codec to open this context for. If a non-NULL codec has been
 | 
				
			||||||
 *              previously passed to avcodec_alloc_context3() or
 | 
					 *              previously passed to avcodec_alloc_context3() or
 | 
				
			||||||
 *              avcodec_get_context_defaults3() for this context, then this
 | 
					 *              for this context, then this parameter MUST be either NULL or
 | 
				
			||||||
 *              parameter MUST be either NULL or equal to the previously passed
 | 
					 *              equal to the previously passed codec.
 | 
				
			||||||
 *              codec.
 | 
					 | 
				
			||||||
 * @param options A dictionary filled with AVCodecContext and codec-private options.
 | 
					 * @param options A dictionary filled with AVCodecContext and codec-private options.
 | 
				
			||||||
 *                On return this object will be filled with options that were not found.
 | 
					 *                On return this object will be filled with options that were not found.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -3758,9 +3754,8 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op
 | 
				
			|||||||
 * (but not the AVCodecContext itself).
 | 
					 * (but not the AVCodecContext itself).
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Calling this function on an AVCodecContext that hasn't been opened will free
 | 
					 * Calling this function on an AVCodecContext that hasn't been opened will free
 | 
				
			||||||
 * the codec-specific data allocated in avcodec_alloc_context3() /
 | 
					 * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
 | 
				
			||||||
 * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
 | 
					 * codec. Subsequent calls will do nothing.
 | 
				
			||||||
 * do nothing.
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int avcodec_close(AVCodecContext *avctx);
 | 
					int avcodec_close(AVCodecContext *avctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,7 @@ static const AVClass av_codec_context_class = {
 | 
				
			|||||||
    .child_class_next        = codec_child_class_next,
 | 
					    .child_class_next        = codec_child_class_next,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
 | 
					static int init_context_defaults(AVCodecContext *s, const AVCodec *codec)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    memset(s, 0, sizeof(AVCodecContext));
 | 
					    memset(s, 0, sizeof(AVCodecContext));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -125,6 +125,13 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if FF_API_GET_CONTEXT_DEFAULTS
 | 
				
			||||||
 | 
					int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return init_context_defaults(s, codec);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
 | 
					AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
 | 
					    AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
 | 
				
			||||||
@@ -132,7 +139,7 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
 | 
				
			|||||||
    if (!avctx)
 | 
					    if (!avctx)
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(avcodec_get_context_defaults3(avctx, codec) < 0){
 | 
					    if (init_context_defaults(avctx, codec) < 0) {
 | 
				
			||||||
        av_free(avctx);
 | 
					        av_free(avctx);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -203,5 +203,8 @@
 | 
				
			|||||||
#ifndef FF_API_COPY_CONTEXT
 | 
					#ifndef FF_API_COPY_CONTEXT
 | 
				
			||||||
#define FF_API_COPY_CONTEXT     (LIBAVCODEC_VERSION_MAJOR < 59)
 | 
					#define FF_API_COPY_CONTEXT     (LIBAVCODEC_VERSION_MAJOR < 59)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef FF_API_GET_CONTEXT_DEFAULTS
 | 
				
			||||||
 | 
					#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* AVCODEC_VERSION_H */
 | 
					#endif /* AVCODEC_VERSION_H */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user