annotate mxf.c @ 6476:f06908662125 libavformat

Handle G.722 in RTP, and all the exceptions mandated in RFC 3551
author mstorsjo
date Wed, 15 Sep 2010 17:35:39 +0000
parents 8551432b011a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
1 /*
3734
3b3b45af4a92 Factorize common code out of the mxf demuxer.
michael
parents: 3699
diff changeset
2 * MXF
4251
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 3829
diff changeset
3 * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
15 * Lesser General Public License for more details.
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
16 *
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1354
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
1186
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
20 */
fbdd53c2a12d MXF demuxer
bcoudurier
parents:
diff changeset
21
3734
3b3b45af4a92 Factorize common code out of the mxf demuxer.
michael
parents: 3699
diff changeset
22 #include "mxf.h"
1779
de2cf54eb68f mxf aes decryption support, patch by Reimar, simplified to only look for first crypto context, will be extended once we get files with multiple cryptocontext, and hope that they won't have broken container ul
bcoudurier
parents: 1655
diff changeset
23
3743
68414dc4c4d1 Ok-ed parts from patch by zhentan feng.
cehoyos
parents: 3734
diff changeset
24 /**
68414dc4c4d1 Ok-ed parts from patch by zhentan feng.
cehoyos
parents: 3734
diff changeset
25 * SMPTE RP224 http://www.smpte-ra.org/mdd/index.html
68414dc4c4d1 Ok-ed parts from patch by zhentan feng.
cehoyos
parents: 3734
diff changeset
26 */
4404
7cf3b77ad6ff reuse MXFCodecUL for data def and simplify
bcoudurier
parents: 4403
diff changeset
27 const MXFCodecUL ff_mxf_data_definition_uls[] = {
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 4404
diff changeset
28 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x01,0x00,0x00,0x00 }, 13, AVMEDIA_TYPE_VIDEO },
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 4404
diff changeset
29 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x02,0x00,0x00,0x00 }, 13, AVMEDIA_TYPE_AUDIO },
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 4404
diff changeset
30 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AVMEDIA_TYPE_DATA },
1341
884baacb7f7e use a data definition uls table to fetch codec type
bcoudurier
parents: 1340
diff changeset
31 };
1190
03c0b0e61e5b demuxer reworked, more accurate parsing, prepare handling of other operational patterns, streaming demuxing, simplified codec detection
bcoudurier
parents: 1189
diff changeset
32
3734
3b3b45af4a92 Factorize common code out of the mxf demuxer.
michael
parents: 3699
diff changeset
33 const MXFCodecUL ff_mxf_codec_uls[] = {
1190
03c0b0e61e5b demuxer reworked, more accurate parsing, prepare handling of other operational patterns, streaming demuxing, simplified codec detection
bcoudurier
parents: 1189
diff changeset
34 /* PictureEssenceCoding */
2949
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
35 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP@ML Long GoP */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
36 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* D-10 50Mbps PAL */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
37 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP@HL Long GoP */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
38 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* 422P@HL I-Frame */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
39 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, 14, CODEC_ID_MPEG4 }, /* XDCAM proxy_pal030926.mxf */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
40 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13, CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
41 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, CODEC_ID_JPEG2000 }, /* JPEG2000 Codestream */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
42 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_RAWVIDEO }, /* Uncompressed */
4403
39f6b190c772 remove implicit header inclusions from mxf.h
bcoudurier
parents: 4251
diff changeset
43 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 }, 14, CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
1190
03c0b0e61e5b demuxer reworked, more accurate parsing, prepare handling of other operational patterns, streaming demuxing, simplified codec detection
bcoudurier
parents: 1189
diff changeset
44 /* SoundEssenceCompression */
2949
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
45 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE }, /* Uncompressed */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
46 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE },
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
47 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16BE }, /* From Omneon MXF file */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
48 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, 15, CODEC_ID_PCM_ALAW }, /* XDCAM Proxy C0023S01.mxf */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
49 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 },
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
50 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
51 //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */
c433c2607194 simplify and detect better non frame wrapped mappings
bcoudurier
parents: 2948
diff changeset
52 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
1190
03c0b0e61e5b demuxer reworked, more accurate parsing, prepare handling of other operational patterns, streaming demuxing, simplified codec detection
bcoudurier
parents: 1189
diff changeset
53 };
6198
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
54
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
55 const MXFPixelLayout ff_mxf_pixel_layouts[] = {
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
56 /**
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
57 * See SMPTE 377M E.2.46
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
58 *
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
59 * Note: Only RGB, palette based and "abnormal" YUV pixel formats like 4:2:2:4 go here.
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
60 * For regular YUV, use CDCIPictureEssenceDescriptor.
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
61 *
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
62 * Note: Do not use these for encoding descriptors for little-endian formats until we
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
63 * get samples or official word from SMPTE on how/if those can be encoded.
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
64 */
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
65 {PIX_FMT_ABGR, {'A', 8, 'B', 8, 'G', 8, 'R', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
66 {PIX_FMT_ARGB, {'A', 8, 'R', 8, 'G', 8, 'B', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
67 {PIX_FMT_BGR24, {'B', 8, 'G', 8, 'R', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
68 {PIX_FMT_BGRA, {'B', 8, 'G', 8, 'R', 8, 'A', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
69 {PIX_FMT_RGB24, {'R', 8, 'G', 8, 'B', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
70 {PIX_FMT_RGB444BE,{'F', 4, 'R', 4, 'G', 4, 'B', 4 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
71 {PIX_FMT_RGB48BE, {'R', 8, 'r', 8, 'G', 8, 'g', 8, 'B', 8, 'b', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
72 {PIX_FMT_RGB48BE, {'R', 16, 'G', 16, 'B', 16 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
73 {PIX_FMT_RGB48LE, {'r', 8, 'R', 8, 'g', 8, 'G', 8, 'b', 8, 'B', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
74 {PIX_FMT_RGB555BE,{'F', 1, 'R', 5, 'G', 5, 'B', 5 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
75 {PIX_FMT_RGB565BE,{'R', 5, 'G', 6, 'B', 5 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
76 {PIX_FMT_RGBA, {'R', 8, 'G', 8, 'B', 8, 'A', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
77 {PIX_FMT_PAL8, {'P', 8 }},
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
78 };
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
79
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
80 static const int num_pixel_layouts = sizeof(ff_mxf_pixel_layouts) / sizeof(*ff_mxf_pixel_layouts);
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
81
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
82 int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum PixelFormat *pix_fmt)
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
83 {
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
84 int x;
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
85
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
86 for(x = 0; x < num_pixel_layouts; x++) {
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
87 if (!memcmp(pixel_layout, ff_mxf_pixel_layouts[x].data, 16)) {
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
88 *pix_fmt = ff_mxf_pixel_layouts[x].pix_fmt;
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
89 return 0;
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
90 }
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
91 }
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
92
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
93 return -1;
8551432b011a mxfdec: Improve parsing of the PixelLayout item
thardin
parents: 5910
diff changeset
94 }