diff mbox series

[FFmpeg-devel,v2] mxf : allow using codecs RAWVIDEO and V210 (with more rgb format and correct stored width/height)

Message ID 20210811082241.22545-1-michael.krebs@hemeria-group.com
State New
Headers show
Series [FFmpeg-devel,v2] mxf : allow using codecs RAWVIDEO and V210 (with more rgb format and correct stored width/height) | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

KREBS Michael Aug. 11, 2021, 8:22 a.m. UTC
* Let older tags on the same place as originally
* Add new fate tests for rawvideo and v210 and update checksum for mxf tests
* Add more rgb format (to allow r210 raw format)
* Correct stored width and height when rawvideo or v210 encoder are used
---
 libavformat/mxf.c                       |  19 +++
 libavformat/mxf.h                       |   1 +
 libavformat/mxfenc.c                    | 188 +++++++++++++++++++-----
 tests/fate/lavf-container.mak           |   7 +
 tests/ref/fate/copy-trac4914            |   2 +-
 tests/ref/fate/mxf-d10-user-comments    |   2 +-
 tests/ref/fate/mxf-opatom-user-comments |   2 +-
 tests/ref/fate/mxf-reel_name            |   2 +-
 tests/ref/fate/mxf-user-comments        |   2 +-
 tests/ref/fate/time_base                |   2 +-
 tests/ref/lavf/mxf                      |   6 +-
 tests/ref/lavf/mxf_d10                  |   2 +-
 tests/ref/lavf/mxf_dv25                 |   2 +-
 tests/ref/lavf/mxf_dvcpro50             |   2 +-
 tests/ref/lavf/mxf_opatom               |   2 +-
 tests/ref/lavf/mxf_opatom_audio         |   2 +-
 tests/ref/lavf/mxf_rawvideo_uyvy422     |   3 +
 tests/ref/lavf/mxf_rawvideo_yuv420p     |   3 +
 tests/ref/lavf/mxf_rawvideo_yuv422p     |   3 +
 tests/ref/lavf/mxf_rawvideo_yuyv422     |   3 +
 tests/ref/lavf/mxf_v210                 |   3 +
 21 files changed, 204 insertions(+), 54 deletions(-)
 create mode 100644 tests/ref/lavf/mxf_rawvideo_uyvy422
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv420p
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuv422p
 create mode 100644 tests/ref/lavf/mxf_rawvideo_yuyv422
 create mode 100644 tests/ref/lavf/mxf_v210

Comments

Kieran O Leary Aug. 11, 2021, 8:26 a.m. UTC | #1
Woah, can't test this but it would be a brilliant addition to ffmpeg!

Best,

Kieran O'Leary
National Library of Ireland
KREBS Michael Aug. 11, 2021, 8:30 a.m. UTC | #2
Thank you. We need it in our organization so i think the best is to share it but i hope it will be accepted.


Michaël Krebs
Responsable Technique Logiciel

[1572337113342]

36 impasse Félix Nadar

16000 ANGOULEME
-----------------------------------

www.hemeria-group.com<https://webmail.nexeya.fr/owa/redir.aspx?C=GK_BqKCZef7LtPZnqnd_LGYr1NG9sz4Smy3iKIwO-pXqtJC7VgzXCA..&URL=http%3a%2f%2fwww.hemeria-group.com%2f>
P Afin de contribuer au respect de l'environnement, merci de n'imprimer ce courriel qu'en cas de nécessité.

Ce message et les fichiers pouvant être attachés sont confidentiels, réservés à l'usage unique des destinataires et n'engagent HEMERIA sous aucune forme que ce soit.
This email and any files transmitted with it are confidential, intented solely for the unique use of the recipients and don't commit HEMERIA.
diff mbox series

Patch

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 36d662b58c..748214a64f 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -81,6 +81,8 @@  const MXFCodecUL ff_mxf_codec_uls[] = {
 const MXFCodecUL ff_mxf_pixel_format_uls[] = {
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x01 }, 16, AV_PIX_FMT_UYVY422 },
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x02 }, 16, AV_PIX_FMT_YUYV422 },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x03 }, 16, AV_PIX_FMT_YUV422P },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x03,0x01,0x02 }, 16, AV_PIX_FMT_YUV420P },
     { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },  0,    AV_PIX_FMT_NONE },
 };
 
@@ -165,6 +167,8 @@  static const struct {
     {AV_PIX_FMT_RGBA,    {'R', 8,  'G', 8,  'B', 8, 'A', 8                 }},
     {AV_PIX_FMT_PAL8,    {'P', 8                                           }},
     {AV_PIX_FMT_GRAY8,   {'A', 8                                           }},
+    {AV_PIX_FMT_GBRP10BE,{'F', 2,  'R', 10,  'G', 10, 'B', 10              }},
+    {AV_PIX_FMT_GBRP10LE,{'F', 2,  'r', 10,  'g', 10, 'b', 10              }},
 };
 
 static const int num_pixel_layouts = FF_ARRAY_ELEMS(ff_mxf_pixel_layouts);
@@ -183,6 +187,21 @@  int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *
     return -1;
 }
 
+int ff_mxf_find_pixel_layout(const char** pixel_layout, const enum AVPixelFormat pix_fmt)
+{
+    int x;
+    *pixel_layout = NULL;
+
+    for(x = 0; x < num_pixel_layouts; x++) {
+        if(ff_mxf_pixel_layouts[x].pix_fmt == pix_fmt) {
+            *pixel_layout = ff_mxf_pixel_layouts[x].data;
+            return 0;
+        }
+    }
+
+    return -1;
+}
+
 /**
  * See SMPTE 326M-2000 Section 7.2 Content package rate
  * MXFContentPackageRate->rate is bits b5..b0.
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index fe9c52732c..fa4a4eb0d2 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -114,6 +114,7 @@  extern const MXFCodecUL ff_mxf_color_trc_uls[];
 extern const MXFCodecUL ff_mxf_color_space_uls[];
 
 int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt);
+int ff_mxf_find_pixel_layout(const char** pixel_layout, const enum AVPixelFormat pix_fmt);
 int ff_mxf_get_content_package_rate(AVRational time_base);
 
 
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 5ec619675b..8b7f463ef8 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -127,6 +127,8 @@  enum ULIndex {
     INDEX_H264,
     INDEX_S436M,
     INDEX_PRORES,
+    INDEX_RAWVIDEO,
+    INDEX_V210
 };
 
 static const struct {
@@ -141,6 +143,8 @@  static const struct {
     { AV_CODEC_ID_JPEG2000,   INDEX_JPEG2000 },
     { AV_CODEC_ID_H264,       INDEX_H264 },
     { AV_CODEC_ID_PRORES,     INDEX_PRORES },
+    { AV_CODEC_ID_RAWVIDEO,   INDEX_RAWVIDEO },
+    { AV_CODEC_ID_V210,       INDEX_V210 },
     { AV_CODEC_ID_NONE }
 };
 
@@ -148,6 +152,7 @@  static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_aes3_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st);
+static void mxf_write_cdci_or_rgba_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st);
 static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st);
@@ -205,6 +210,16 @@  static const MXFContainerEssenceEntry mxf_essence_container_uls[] = {
       { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x15,0x01,0x17,0x00 },
       { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0d,0x04,0x01,0x02,0x02,0x03,0x06,0x03,0x00 },
       mxf_write_cdci_desc },
+    // RawVideo
+    { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, // MXF-GC Uncompressed Pictures
+      { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x15,0x01,0x05,0x00 }, // GC Picture Essence
+      { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, // Uncompressed
+      mxf_write_cdci_or_rgba_desc },
+    // V210
+    { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, // MXF-GC Uncompressed Pictures
+      { 0x06,0x0E,0x2B,0x34,0x01,0x02,0x01,0x01,0x0D,0x01,0x03,0x01,0x15,0x01,0x05,0x00 }, // GC Picture Essence
+      { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x01 }, // V210
+      mxf_write_cdci_desc },
     { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
       { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
       { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
@@ -346,6 +361,8 @@  static const MXFLocalTagPair mxf_local_tag_batch[] = {
     { 0x3304, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x03,0x00,0x00,0x00}}, /* Black Ref level */
     { 0x3305, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x04,0x00,0x00,0x00}}, /* White Ref level */
     { 0x3306, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x05,0x00,0x00,0x00}}, /* Color Range */
+    // RGBA Picture Essence Descriptor
+    { 0x3401, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x06,0x00,0x00,0x00}}, /* Pixel Layout */
     // Generic Sound Essence Descriptor
     { 0x3D02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x04,0x02,0x03,0x01,0x04,0x00,0x00,0x00}}, /* Locked/Unlocked */
     { 0x3D03, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x01,0x01,0x01,0x00,0x00}}, /* Audio sampling rate */
@@ -1047,7 +1064,7 @@  static void mxf_write_multi_descriptor(AVFormatContext *s)
         mxf_write_uuid(pb, SubDescriptor, i);
 }
 
-static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID key)
+static int64_t mxf_write_file_desc(AVFormatContext *s, AVStream *st, const UID key)
 {
     MXFContext *mxf = s->priv_data;
     MXFStreamContext *sc = st->priv_data;
@@ -1090,6 +1107,7 @@  static const UID mxf_mpegvideo_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,
 static const UID mxf_wav_descriptor_key       = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 };
 static const UID mxf_aes3_descriptor_key      = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 };
 static const UID mxf_cdci_descriptor_key      = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x28,0x00 };
+static const UID mxf_rgba_descriptor_key      = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x29,0x00 };
 static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x42,0x00 };
 
 static const UID mxf_avc_subdescriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00 };
@@ -1104,7 +1122,9 @@  static inline uint32_t rescale_mastering_luma(AVRational q)
     return av_rescale(q.num, FF_MXF_MASTERING_LUMA_DEN, q.den);
 }
 
-static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key)
+typedef void (*generic_desc_extra_tags_func)(AVFormatContext *, AVStream *, const UID, MXFStreamContext *, AVIOContext *, void*);
+
+static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID key, generic_desc_extra_tags_func write_extra_tags_func, void* extra_tags_func_context)
 {
     MXFStreamContext *sc = st->priv_data;
     AVIOContext *pb = s->pb;
@@ -1115,7 +1135,7 @@  static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
     const MXFCodecUL *color_primaries_ul;
     const MXFCodecUL *color_trc_ul;
     const MXFCodecUL *color_space_ul;
-    int64_t pos = mxf_write_generic_desc(s, st, key);
+    int64_t pos = mxf_write_file_desc(s, st, key);
     uint8_t *side_data;
 
     color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries);
@@ -1128,6 +1148,12 @@  static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
         else if (st->codecpar->height == 720)
             stored_width = 1280;
     }
+    else if ((st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO)
+             || (st->codecpar->codec_id == AV_CODEC_ID_V210)) {
+        stored_width = st->codecpar->width;
+        stored_height = st->codecpar->height;
+    }
+
     if (!stored_width)
         stored_width = (st->codecpar->width+15)/16*16;
 
@@ -1194,41 +1220,8 @@  static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
         avio_wb32(pb, -((st->codecpar->height - display_height)&1));
     }
 
-    // component depth
-    mxf_write_local_tag(s, 4, 0x3301);
-    avio_wb32(pb, sc->component_depth);
-
-    // horizontal subsampling
-    mxf_write_local_tag(s, 4, 0x3302);
-    avio_wb32(pb, sc->h_chroma_sub_sample);
-
-    // vertical subsampling
-    mxf_write_local_tag(s, 4, 0x3308);
-    avio_wb32(pb, sc->v_chroma_sub_sample);
-
-    // color siting
-    mxf_write_local_tag(s, 1, 0x3303);
-    avio_w8(pb, sc->color_siting);
-
-    // Padding Bits
-    mxf_write_local_tag(s, 2, 0x3307);
-    avio_wb16(pb, 0);
-
-    if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) {
-        int black = 0,
-            white = (1<<sc->component_depth) - 1,
-            color = (1<<sc->component_depth);
-        if (st->codecpar->color_range == AVCOL_RANGE_MPEG) {
-            black = 1   << (sc->component_depth - 4);
-            white = 235 << (sc->component_depth - 8);
-            color = (14 << (sc->component_depth - 4)) + 1;
-        }
-        mxf_write_local_tag(s, 4, 0x3304);
-        avio_wb32(pb, black);
-        mxf_write_local_tag(s, 4, 0x3305);
-        avio_wb32(pb, white);
-        mxf_write_local_tag(s, 4, 0x3306);
-        avio_wb32(pb, color);
+    if(write_extra_tags_func != NULL) {
+        (*write_extra_tags_func)(s, st, key, sc, pb, extra_tags_func_context);
     }
 
     if (sc->signal_standard) {
@@ -1328,6 +1321,51 @@  static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
     return pos;
 }
 
+static void mxf_write_extra_cdci_tags(AVFormatContext *s, AVStream *st, const UID key, MXFStreamContext *sc, AVIOContext *pb, void* extra_tags_func_context)
+{
+    // component depth
+    mxf_write_local_tag(s, 4, 0x3301);
+    avio_wb32(pb, sc->component_depth);
+
+    // horizontal subsampling
+    mxf_write_local_tag(s, 4, 0x3302);
+    avio_wb32(pb, sc->h_chroma_sub_sample);
+
+    // vertical subsampling
+    mxf_write_local_tag(s, 4, 0x3308);
+    avio_wb32(pb, sc->v_chroma_sub_sample);
+
+    // color siting
+    mxf_write_local_tag(s, 1, 0x3303);
+    avio_w8(pb, sc->color_siting);
+
+    // Padding Bits
+    mxf_write_local_tag(s, 2, 0x3307);
+    avio_wb16(pb, 0);
+
+    if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) {
+        int black = 0,
+            white = (1<<sc->component_depth) - 1,
+            color = (1<<sc->component_depth);
+        if (st->codecpar->color_range == AVCOL_RANGE_MPEG) {
+            black = 1   << (sc->component_depth - 4);
+            white = 235 << (sc->component_depth - 8);
+            color = (14 << (sc->component_depth - 4)) + 1;
+        }
+        mxf_write_local_tag(s, 4, 0x3304);
+        avio_wb32(pb, black);
+        mxf_write_local_tag(s, 4, 0x3305);
+        avio_wb32(pb, white);
+        mxf_write_local_tag(s, 4, 0x3306);
+        avio_wb32(pb, color);
+    }
+}
+
+static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key)
+{
+    return mxf_write_generic_desc(s, st, key, &mxf_write_extra_cdci_tags, NULL);
+}
+
 static void mxf_update_klv_size(AVIOContext *pb, int64_t pos)
 {
     int64_t cur_pos = avio_tell(pb);
@@ -1361,6 +1399,35 @@  static void mxf_write_avc_subdesc(AVFormatContext *s, AVStream *st)
     mxf_update_klv_size(s->pb, pos);
 }
 
+static void mxf_write_extra_rgba_tags(AVFormatContext *s, AVStream *st, const UID key, MXFStreamContext *sc, AVIOContext *pb, void* extra_tags_func_context)
+{
+    const char* pixelLayoutData = extra_tags_func_context;
+
+    // pixel layout
+    mxf_write_local_tag(s, 16, 0x3401);
+    avio_write(pb, pixelLayoutData, 16);
+}
+
+static void mxf_write_cdci_or_rgba_desc(AVFormatContext *s, AVStream *st)
+{
+    const char* pixelLayoutData = NULL;
+    int64_t pos;
+
+    if(ff_mxf_find_pixel_layout(&pixelLayoutData, st->codecpar->format) >= 0)
+    {
+        pos = mxf_write_generic_desc(s, st, mxf_rgba_descriptor_key, &mxf_write_extra_rgba_tags, (void*)pixelLayoutData);
+        mxf_update_klv_size(s->pb, pos);
+        return;
+    }
+
+    pos = mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key);
+    mxf_update_klv_size(s->pb, pos);
+
+    if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
+        mxf_write_avc_subdesc(s, st);
+    }
+}
+
 static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
 {
     int64_t pos = mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key);
@@ -1385,7 +1452,7 @@  static void mxf_write_h264_desc(AVFormatContext *s, AVStream *st)
 
 static void mxf_write_s436m_anc_desc(AVFormatContext *s, AVStream *st)
 {
-    int64_t pos = mxf_write_generic_desc(s, st, mxf_s436m_anc_descriptor_key);
+    int64_t pos = mxf_write_file_desc(s, st, mxf_s436m_anc_descriptor_key);
     mxf_update_klv_size(s->pb, pos);
 }
 
@@ -1432,7 +1499,7 @@  static int64_t mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st,
     AVIOContext *pb = s->pb;
     MXFContext *mxf = s->priv_data;
     int show_warnings = !mxf->footer_partition_offset;
-    int64_t pos = mxf_write_generic_desc(s, st, key);
+    int64_t pos = mxf_write_file_desc(s, st, key);
 
     if (s->oformat == &ff_mxf_opatom_muxer) {
         mxf_write_local_tag(s, 8, 0x3002);
@@ -2348,6 +2415,42 @@  static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
     return 1;
 }
 
+static int mxf_parse_raw_frame(AVFormatContext *s, AVStream *st,
+                               AVPacket *pkt, MXFIndexEntry *e)
+{
+    MXFContext *mxf = s->priv_data;
+    MXFStreamContext *sc = st->priv_data;
+    const MXFCodecUL* uls = ff_mxf_pixel_format_uls;
+    const char* pixelLayoutData = NULL;
+    int format;
+
+    if (mxf->header_written)
+        return 1;
+
+    format = st->codecpar->format;
+
+    if(ff_mxf_find_pixel_layout(&pixelLayoutData, format) < 0)
+    {
+        while (uls->uid[0]) {
+            if (format == uls->id) {
+                sc->codec_ul = &uls->uid;
+                break;
+            }
+            uls++;
+        }
+
+        if (!uls->uid[0])
+        {
+            av_log(s, AV_LOG_ERROR, "no codec ul available for pixel format %s\n", av_get_pix_fmt_name(format));
+            return 0;
+        }
+    }
+
+    sc->frame_size = pkt->size;
+
+    return 1;
+}
+
 static const UID mxf_mpeg2_codec_uls[] = {
     { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x10,0x00 }, // MP-ML I-Frame
     { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, // MP-ML Long GOP
@@ -2929,6 +3032,11 @@  static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
             av_log(s, AV_LOG_ERROR, "could not get h264 profile\n");
             return -1;
         }
+    } else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
+        if (!mxf_parse_raw_frame(s, st, pkt, &ie)) {
+            av_log(s, AV_LOG_ERROR, "could not get raw profile\n");
+            return -1;
+        }
     }
 
     if (mxf->cbr_index) {
diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak
index 9e0eed4851..af61417576 100644
--- a/tests/fate/lavf-container.mak
+++ b/tests/fate/lavf-container.mak
@@ -9,6 +9,8 @@  FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG4,      PCM_ALAW,  MOV)                +
 FATE_LAVF_CONTAINER-$(call ENCDEC,  MPEG4,                 MOV)                += mp4
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG1VIDEO, MP2,       MPEG1SYSTEM MPEGPS) += mpg
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF)                += mxf mxf_dv25 mxf_dvcpro50
+FATE_LAVF_CONTAINER-$(call ENCDEC2, RAWVIDEO,   PCM_S16LE, MXF)                += mxf_rawvideo_uyvy422 mxf_rawvideo_yuyv422 mxf_rawvideo_yuv422p mxf_rawvideo_yuv420p
+FATE_LAVF_CONTAINER-$(call ENCDEC2, V210,       PCM_S16LE, MXF)                += mxf_v210
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF_D10 MXF)        += mxf_d10
 FATE_LAVF_CONTAINER-$(call ENCDEC2, DNXHD,      PCM_S16LE, MXF_OPATOM MXF)     += mxf_opatom mxf_opatom_audio
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG4,      MP2,       NUT)                += nut
@@ -45,6 +47,11 @@  fate-lavf-mxf: CMD = lavf_container_timecode "-ar 48000 -bf 2 -threads 1"
 fate-lavf-mxf_d10: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,pad=720:608:0:32 -c:v mpeg2video -g 0 -flags +ildct+low_delay -dc 10 -non_linear_quant 1 -intra_vlc 1 -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10"
 fate-lavf-mxf_dv25: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=4/3 -c:v dvvideo -pix_fmt yuv420p -b 25000k -top 0 -f mxf"
 fate-lavf-mxf_dvcpro50: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v dvvideo -pix_fmt yuv422p -b 50000k -top 0 -f mxf"
+fate-lavf-mxf_rawvideo_uyvy422: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v rawvideo -pix_fmt uyvy422 -b 50000k -top 0 -f mxf"
+fate-lavf-mxf_rawvideo_yuyv422: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v rawvideo -pix_fmt yuyv422 -b 50000k -top 0 -f mxf"
+fate-lavf-mxf_rawvideo_yuv422p: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v rawvideo -pix_fmt yuv422p -b 50000k -top 0 -f mxf"
+fate-lavf-mxf_rawvideo_yuv420p: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v rawvideo -pix_fmt yuv420p -b 50000k -top 0 -f mxf"
+fate-lavf-mxf_v210: CMD = lavf_container "-ar 48000 -ac 2" "-r 25 -vf scale=720:576,setdar=16/9 -c:v v210 -pix_fmt yuv422p10le -b 50000k -top 0 -f mxf"
 fate-lavf-mxf_opatom: CMD = lavf_container "" "-s 1920x1080 -c:v dnxhd -pix_fmt yuv422p -vb 36M -f mxf_opatom -map 0"
 fate-lavf-mxf_opatom_audio: CMD = lavf_container "-ar 48000 -ac 1" "-f mxf_opatom -mxf_audio_edit_rate 25 -map 1"
 fate-lavf-smjpeg:  CMD = lavf_container "" "-f smjpeg"
diff --git a/tests/ref/fate/copy-trac4914 b/tests/ref/fate/copy-trac4914
index 743dc8c055..72a81c4e21 100644
--- a/tests/ref/fate/copy-trac4914
+++ b/tests/ref/fate/copy-trac4914
@@ -1,4 +1,4 @@ 
-f5150fb82c1bb5a90906fce93dcc3f76 *tests/data/fate/copy-trac4914.mxf
+438f4fea5b4956e324e0ce61329d42fe *tests/data/fate/copy-trac4914.mxf
 561721 tests/data/fate/copy-trac4914.mxf
 #tb 0: 1001/30000
 #media_type 0: video
diff --git a/tests/ref/fate/mxf-d10-user-comments b/tests/ref/fate/mxf-d10-user-comments
index 64a2dec463..01469c28a0 100644
--- a/tests/ref/fate/mxf-d10-user-comments
+++ b/tests/ref/fate/mxf-d10-user-comments
@@ -1,4 +1,4 @@ 
-6dc13ae283257e898e069e5041ac8435 *tests/data/fate/mxf-d10-user-comments.mxf_d10
+904042310dbc0ec7a0763bc543a19d14 *tests/data/fate/mxf-d10-user-comments.mxf_d10
 3782189 tests/data/fate/mxf-d10-user-comments.mxf_d10
 #extradata 0:       34, 0x716b05c4
 #tb 0: 1/25
diff --git a/tests/ref/fate/mxf-opatom-user-comments b/tests/ref/fate/mxf-opatom-user-comments
index ec4fdff425..2272eb7692 100644
--- a/tests/ref/fate/mxf-opatom-user-comments
+++ b/tests/ref/fate/mxf-opatom-user-comments
@@ -1 +1 @@ 
-8475bebf3448a972ae89ba59309fd7d6
+0e498d6c36a8b3e37aa9ecb64496d3b6
diff --git a/tests/ref/fate/mxf-reel_name b/tests/ref/fate/mxf-reel_name
index d50f0f6990..b0728b7fe3 100644
--- a/tests/ref/fate/mxf-reel_name
+++ b/tests/ref/fate/mxf-reel_name
@@ -1 +1 @@ 
-ce49a0361d3f79106e1952d387eace51
+560f4451dd6b38f78cf86f231e48eff6
diff --git a/tests/ref/fate/mxf-user-comments b/tests/ref/fate/mxf-user-comments
index 5fcdc5806a..f6fa46cc97 100644
--- a/tests/ref/fate/mxf-user-comments
+++ b/tests/ref/fate/mxf-user-comments
@@ -1 +1 @@ 
-956f653cd75e1a319569caec9df81b4f
+9d3ba341971578da259ddb59009a0852
diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base
index 28815d0828..658684b037 100644
--- a/tests/ref/fate/time_base
+++ b/tests/ref/fate/time_base
@@ -1 +1 @@ 
-78ac0348027b75d73acb8bea14e67a59
+8e36415635c2524ca26d543ee36e7234
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 21bf2be513..d364d38155 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,9 +1,9 @@ 
-8938d5c4a396ff1b24d10d4f917ae1c9 *tests/data/lavf/lavf.mxf
+7d02fc2e7745c07a52eeaebb24c6e79f *tests/data/lavf/lavf.mxf
 526393 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x8dddfaab
-93ea2cfdf5dda7fffdc0d2fdcfb6a9a4 *tests/data/lavf/lavf.mxf
+48f6b83fba88c6eac8ffd80a7fd24bdb *tests/data/lavf/lavf.mxf
 561721 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x96ff1b48
-87bdf844ae34bcc758e44419e80177a0 *tests/data/lavf/lavf.mxf
+6810c86109c5e6a139ff1b3c47f4a274 *tests/data/lavf/lavf.mxf
 526393 tests/data/lavf/lavf.mxf
 tests/data/lavf/lavf.mxf CRC=0x8dddfaab
diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10
index 47ef244cb1..d6bf06b510 100644
--- a/tests/ref/lavf/mxf_d10
+++ b/tests/ref/lavf/mxf_d10
@@ -1,3 +1,3 @@ 
-7f16902e28718c2a92bc082400a1c6ee *tests/data/lavf/lavf.mxf_d10
+ecec1e36b3ddc9dd686df429674680b6 *tests/data/lavf/lavf.mxf_d10
 5332013 tests/data/lavf/lavf.mxf_d10
 tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
diff --git a/tests/ref/lavf/mxf_dv25 b/tests/ref/lavf/mxf_dv25
index 92509cf1f4..fa3b4da61c 100644
--- a/tests/ref/lavf/mxf_dv25
+++ b/tests/ref/lavf/mxf_dv25
@@ -1,3 +1,3 @@ 
-106e33eb1634595623f0334e92204b65 *tests/data/lavf/lavf.mxf_dv25
+e05459f1a7fae9765a6b3035fdbae7ef *tests/data/lavf/lavf.mxf_dv25
 3834413 tests/data/lavf/lavf.mxf_dv25
 tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
diff --git a/tests/ref/lavf/mxf_dvcpro50 b/tests/ref/lavf/mxf_dvcpro50
index 2d569b0553..a94e74dab0 100644
--- a/tests/ref/lavf/mxf_dvcpro50
+++ b/tests/ref/lavf/mxf_dvcpro50
@@ -1,3 +1,3 @@ 
-3d5a303c22666996700f0e8f6e4cb938 *tests/data/lavf/lavf.mxf_dvcpro50
+02bdd6731f7e520aa8c9c67c8db53bc3 *tests/data/lavf/lavf.mxf_dvcpro50
 7431213 tests/data/lavf/lavf.mxf_dvcpro50
 tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
diff --git a/tests/ref/lavf/mxf_opatom b/tests/ref/lavf/mxf_opatom
index 61e755550b..2a0c6bd38a 100644
--- a/tests/ref/lavf/mxf_opatom
+++ b/tests/ref/lavf/mxf_opatom
@@ -1,3 +1,3 @@ 
-5d235c127ace64b1f4fe6c79a7ca8be6 *tests/data/lavf/lavf.mxf_opatom
+5659524f7c407daaed778345b0adefe5 *tests/data/lavf/lavf.mxf_opatom
 4717625 tests/data/lavf/lavf.mxf_opatom
 tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
diff --git a/tests/ref/lavf/mxf_opatom_audio b/tests/ref/lavf/mxf_opatom_audio
index 97362e7aa4..b6b03b8f0e 100644
--- a/tests/ref/lavf/mxf_opatom_audio
+++ b/tests/ref/lavf/mxf_opatom_audio
@@ -1,3 +1,3 @@ 
-c356a3fdd49a1e015961678e837c12bb *tests/data/lavf/lavf.mxf_opatom_audio
+7da9e57a0310ad4e073f9a1f4de4c378 *tests/data/lavf/lavf.mxf_opatom_audio
 102969 tests/data/lavf/lavf.mxf_opatom_audio
 tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
diff --git a/tests/ref/lavf/mxf_rawvideo_uyvy422 b/tests/ref/lavf/mxf_rawvideo_uyvy422
new file mode 100644
index 0000000000..ca74e191f3
--- /dev/null
+++ b/tests/ref/lavf/mxf_rawvideo_uyvy422
@@ -0,0 +1,3 @@ 
+21fadfdb0188edca474bbde73c630e30 *tests/data/lavf/lavf.mxf_rawvideo_uyvy422
+20974649 tests/data/lavf/lavf.mxf_rawvideo_uyvy422
+tests/data/lavf/lavf.mxf_rawvideo_uyvy422 CRC=0x35946b93
diff --git a/tests/ref/lavf/mxf_rawvideo_yuv420p b/tests/ref/lavf/mxf_rawvideo_yuv420p
new file mode 100644
index 0000000000..512056391c
--- /dev/null
+++ b/tests/ref/lavf/mxf_rawvideo_yuv420p
@@ -0,0 +1,3 @@ 
+6e6c6a6bea63aac1622ab0008aaf89b5 *tests/data/lavf/lavf.mxf_rawvideo_yuv420p
+15790649 tests/data/lavf/lavf.mxf_rawvideo_yuv420p
+tests/data/lavf/lavf.mxf_rawvideo_yuv420p CRC=0x15c6bb97
diff --git a/tests/ref/lavf/mxf_rawvideo_yuv422p b/tests/ref/lavf/mxf_rawvideo_yuv422p
new file mode 100644
index 0000000000..1a5d239e14
--- /dev/null
+++ b/tests/ref/lavf/mxf_rawvideo_yuv422p
@@ -0,0 +1,3 @@ 
+f534813596e2800f5cdd76560eec4186 *tests/data/lavf/lavf.mxf_rawvideo_yuv422p
+20974649 tests/data/lavf/lavf.mxf_rawvideo_yuv422p
+tests/data/lavf/lavf.mxf_rawvideo_yuv422p CRC=0xd7cc6b93
diff --git a/tests/ref/lavf/mxf_rawvideo_yuyv422 b/tests/ref/lavf/mxf_rawvideo_yuyv422
new file mode 100644
index 0000000000..7fd25d3e9f
--- /dev/null
+++ b/tests/ref/lavf/mxf_rawvideo_yuyv422
@@ -0,0 +1,3 @@ 
+57fe7476e6ec8f5a349579b9233de25a *tests/data/lavf/lavf.mxf_rawvideo_yuyv422
+20974649 tests/data/lavf/lavf.mxf_rawvideo_yuyv422
+tests/data/lavf/lavf.mxf_rawvideo_yuyv422 CRC=0x60866b93
diff --git a/tests/ref/lavf/mxf_v210 b/tests/ref/lavf/mxf_v210
new file mode 100644
index 0000000000..c23418e406
--- /dev/null
+++ b/tests/ref/lavf/mxf_v210
@@ -0,0 +1,3 @@ 
+a96bd5ed2f15acbbbbebdd3d332dae73 *tests/data/lavf/lavf.mxf_v210
+27886649 tests/data/lavf/lavf.mxf_v210
+tests/data/lavf/lavf.mxf_v210 CRC=0x27a8f8cb