summaryrefslogtreecommitdiff
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
authorPhilip de Nier <philipn@rd.bbc.co.uk>2012-02-28 14:16:39 +0000
committerLuca Barbato <lu_zero@gentoo.org>2012-07-10 13:51:04 +0200
commitfda891e108f53b1dd2d9801232c2893e45c072a1 (patch)
tree06d69f54eba16431ee67c574d19408eb11209c87 /libavformat/mxfdec.c
parentdfefede00e3ea03f2a1bdfcb1b6db11699229049 (diff)
mxfdec: set pixel format for cdci picture formats
The properties of the CDCI Descriptor are insufficient to specify the pixel format for uncompressed picture data. SMPTE 377-1 and RP224v10 have defined a set of picture coding labels to indicate what formatting was used. This patch uses 2 labels to detect UYVY422 or YUYV422 pixel formats. It defaults to UYVY422 for 8-bit 4:2:2 pictures to support files that were created before the coding labels were introduced ~2008 The codec pix_fmt default was changed from 0 (PIX_FMT_YUV420P) to -1 (PIX_FMT_NONE) Reviewed-by: Baptiste Coudurier <baptiste.coudurier@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 31585d7516..f24e25f5bc 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -134,6 +134,9 @@ typedef struct {
int height;
int channels;
int bits_per_sample;
+ unsigned int component_depth;
+ unsigned int horiz_subsampling;
+ unsigned int vert_subsampling;
UID *sub_descriptors_refs;
int sub_descriptors_count;
int linked_track_id;
@@ -789,6 +792,7 @@ static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFDescriptor *descriptor = arg;
+ descriptor->pix_fmt = PIX_FMT_NONE;
switch(tag) {
case 0x3F01:
descriptor->sub_descriptors_count = avio_rb32(pb);
@@ -819,6 +823,15 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
descriptor->aspect_ratio.num = avio_rb32(pb);
descriptor->aspect_ratio.den = avio_rb32(pb);
break;
+ case 0x3301:
+ descriptor->component_depth = avio_rb32(pb);
+ break;
+ case 0x3302:
+ descriptor->horiz_subsampling = avio_rb32(pb);
+ break;
+ case 0x3308:
+ descriptor->vert_subsampling = avio_rb32(pb);
+ break;
case 0x3D03:
descriptor->sample_rate.num = avio_rb32(pb);
descriptor->sample_rate.den = avio_rb32(pb);
@@ -1294,6 +1307,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
UID *essence_container_ul = NULL;
const MXFCodecUL *codec_ul = NULL;
const MXFCodecUL *container_ul = NULL;
+ const MXFCodecUL *pix_fmt_ul = NULL;
AVStream *st;
if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i], Track))) {
@@ -1427,8 +1441,23 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->codec->codec_id = container_ul->id;
st->codec->width = descriptor->width;
st->codec->height = descriptor->height;
- if (st->codec->codec_id == CODEC_ID_RAWVIDEO)
+ if (st->codec->codec_id == CODEC_ID_RAWVIDEO) {
st->codec->pix_fmt = descriptor->pix_fmt;
+ if (st->codec->pix_fmt == PIX_FMT_NONE) {
+ pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls,
+ &descriptor->essence_codec_ul);
+ st->codec->pix_fmt = pix_fmt_ul->id;
+ if (st->codec->pix_fmt == PIX_FMT_NONE) {
+ /* support files created before RP224v10 by defaulting to UYVY422
+ if subsampling is 4:2:2 and component depth is 8-bit */
+ if (descriptor->horiz_subsampling == 2 &&
+ descriptor->vert_subsampling == 1 &&
+ descriptor->component_depth == 8) {
+ st->codec->pix_fmt = PIX_FMT_UYVY422;
+ }
+ }
+ }
+ }
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);