diff --git a/libavformat/isom.c b/libavformat/isom.c
index 04e3f3f0d01deb20046f723af88f37f49dc063ce..2042b65f48c17b3b4a80241b38f9843df5722e3f 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -348,7 +348,7 @@ int ff_mov_lang_to_iso639(unsigned code, char to[4])
     memset(to, 0, 4);
     /* is it the mangled iso code? */
     /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */
-    if (code > 138) {
+    if (code >= 0x400 && code != 0x7fff) {
         for (i = 2; i >= 0; i--) {
             to[i] = 0x60 + (code & 0x1f);
             code >>= 5;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 03a35047ac297951227f141e6121ce8fb708105b..c32d22ea8cd6100e4f0cb977ba734d49c0465ebe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -253,7 +253,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (parse)
         parse(c, pb, str_size, key);
     else {
-        if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
+        if (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff))) { // MAC Encoded
             mov_read_mac_string(c, pb, str_size, str, sizeof(str));
         } else {
             avio_read(pb, str, str_size);