diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index 0bcf5dca2275e5aa3c60c82d1f683df1ba3a7a02..838f836516f868552a65c18e3d3f1a2c82bda564 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -153,7 +153,6 @@ static int decode_frame(AVCodecContext *avctx,
 
     bytestream2_init(&gbc, avpkt->data, avpkt->size);
     if (   bytestream2_get_bytes_left(&gbc) >= 552
-           && !check_header(gbc.buffer      , bytestream2_get_bytes_left(&gbc))
            &&  check_header(gbc.buffer + 512, bytestream2_get_bytes_left(&gbc) - 512)
        )
         bytestream2_skip(&gbc, 512);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 7cbba0b0027d16211e664c18bf30708cb3779b3f..c4c58f4d0922a1b6c4bc7f5534f0647a943ed2f3 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1575,7 +1575,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
     } else
         data = pkt->data;
 
-    if (codec->codec_id == AV_CODEC_ID_PRORES) {
+    if (codec->codec_id == AV_CODEC_ID_PRORES && size >= 8) {
         /* Matroska specification requires to remove the first QuickTime atom
          */
         size  -= 8;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b6821d447c92183101086cb67099b2f4804293de..9cad1ae06bdca3d7ca54e714426e447702374404 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1607,9 +1607,10 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
     default:                  avio_wb16(pb, 2);
     }
     switch (track->enc->colorspace) {
-    case AVCOL_TRC_BT709:     avio_wb16(pb, 1); break;
-    case AVCOL_PRI_SMPTE170M: avio_wb16(pb, 6); break;
-    case AVCOL_PRI_SMPTE240M: avio_wb16(pb, 7); break;
+    case AVCOL_SPC_BT709:     avio_wb16(pb, 1); break;
+    case AVCOL_SPC_BT470BG:
+    case AVCOL_SPC_SMPTE170M: avio_wb16(pb, 6); break;
+    case AVCOL_SPC_SMPTE240M: avio_wb16(pb, 7); break;
     default:                  avio_wb16(pb, 2);
     }