diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 655488ca956528945006a5c07b8ceed02461c524..0354f03a479e9efa9109b5e3b5c0951c48fe8307 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -63,6 +63,9 @@
 #ifndef FF_API_URL_SPLIT
 #define FF_API_URL_SPLIT          (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
+#ifndef FF_API_ALLOC_FORMAT_CONTEXT
+#define FF_API_ALLOC_FORMAT_CONTEXT    (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
 
 /**
  * I return the LIBAVFORMAT_VERSION_INT constant.  You got
@@ -1071,7 +1074,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
                        int buf_size,
                        AVFormatParameters *ap);
 
-#if LIBAVFORMAT_VERSION_MAJOR < 53
+#if FF_API_ALLOC_FORMAT_CONTEXT
 /**
  * @deprecated Use avformat_alloc_context() instead.
  */
diff --git a/libavformat/options.c b/libavformat/options.c
index cba6436c299eede2dd03ec66d14dcff3621a11e5..27eb8da76adac55e376ca855d16a91b294497112 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -89,7 +89,7 @@ AVFormatContext *avformat_alloc_context(void)
     return ic;
 }
 
-#if LIBAVFORMAT_VERSION_MAJOR < 53
+#if FF_API_ALLOC_FORMAT_CONTEXT
 AVFormatContext *av_alloc_format_context(void)
 {
     return avformat_alloc_context();