Mercurial > libavformat.hg
diff mxfdec.c @ 6198:8551432b011a libavformat
mxfdec: Improve parsing of the PixelLayout item
author | thardin |
---|---|
date | Wed, 30 Jun 2010 07:55:05 +0000 |
parents | 536e5527c1e0 |
children | ab29c8ff40d9 |
line wrap: on
line diff
--- a/mxfdec.c Mon Jun 28 21:02:16 2010 +0000 +++ b/mxfdec.c Wed Jun 30 07:55:05 2010 +0000 @@ -101,6 +101,7 @@ int linked_track_id; uint8_t *extradata; int extradata_size; + enum PixelFormat pix_fmt; } MXFDescriptor; typedef struct { @@ -520,25 +521,21 @@ static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor) { - int code; + int code, value, ofs = 0; + char layout[16] = {}; do { code = get_byte(pb); + value = get_byte(pb); dprintf(NULL, "pixel layout: code %#x\n", code); - switch (code) { - case 0x52: /* R */ - descriptor->bits_per_sample += get_byte(pb); - break; - case 0x47: /* G */ - descriptor->bits_per_sample += get_byte(pb); - break; - case 0x42: /* B */ - descriptor->bits_per_sample += get_byte(pb); - break; - default: - get_byte(pb); + + if (ofs < 16) { + layout[ofs++] = code; + layout[ofs++] = value; } } while (code != 0); /* SMPTE 377M E.2.46 */ + + ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt); } static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size, UID uid) @@ -801,7 +798,8 @@ st->codec->codec_id = container_ul->id; st->codec->width = descriptor->width; st->codec->height = descriptor->height; - st->codec->bits_per_coded_sample = descriptor->bits_per_sample; /* Uncompressed */ + if (st->codec->codec_id == CODEC_ID_RAWVIDEO) + st->codec->pix_fmt = descriptor->pix_fmt; st->need_parsing = AVSTREAM_PARSE_HEADERS; } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { container_ul = mxf_get_codec_ul(mxf_essence_container_uls, essence_container_ul);