diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f4b2569d1182eff937278a22746e69c4d6ca1c3a..781cd298bf5ceed3a0f937a3c288ff699329aee4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -69,6 +69,9 @@
 #ifndef FF_API_USE_LPC
 #define FF_API_USE_LPC          (LIBAVCODEC_VERSION_MAJOR < 53)
 #endif
+#ifndef FF_API_SET_STRING_OLD
+#define FF_API_SET_STRING_OLD   (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
 
 #define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
 #define AV_TIME_BASE            1000000
diff --git a/libavcodec/opt.c b/libavcodec/opt.c
index fed9ae9930128ec8854c9a0987f347f3097e6875..ffa422ec93ddf1f4802f9d41744c20892d56f77c 100644
--- a/libavcodec/opt.c
+++ b/libavcodec/opt.c
@@ -65,7 +65,7 @@ FF_SYMVER(void, av_opt_set_defaults2, (void *s, int mask, int flags), "LIBAVCODE
 }
 #endif
 
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SET_STRING_OLD
 const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc){
     const AVOption *o;
     if (av_set_string3(obj, name, val, alloc, &o) < 0)
diff --git a/libavcodec/opt.h b/libavcodec/opt.h
index b6e6f59ea436e6dfe7d74f06a3179268ebbd6d3e..95147595b7fb8f5d3909d5b580fd92b5b1d61e17 100644
--- a/libavcodec/opt.h
+++ b/libavcodec/opt.h
@@ -31,7 +31,7 @@
 #include "avcodec.h"
 #include "libavutil/opt.h"
 
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SET_STRING_OLD
 /**
  * @see av_set_string2()
  */