[FFmpeg-devel] [PATCH 6/7] mxfdec: set sample aspect ratio for uncomp rec601

Philip de Nier philipn at rd.bbc.co.uk
Tue Feb 28 15:16:40 CET 2012


---
 libavformat/mxfdec.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3af970d..563eb8f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -897,6 +897,8 @@ static const MXFCodecUL mxf_sound_essence_container_uls[] = {
     { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },  0,      CODEC_ID_NONE },
 };
 
+static UID mxf_unc_rec601_ul = { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x05,0x01,0x00 };
+
 static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segments, MXFIndexTableSegment ***sorted_segments)
 {
     int i, j, nb_segments = 0;
@@ -1424,6 +1426,20 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
                     }
                 }
             }
+            if ((st->codec->codec_id == CODEC_ID_RAWVIDEO || st->codec->codec_id == CODEC_ID_V210) &&
+                mxf_match_uid(mxf_unc_rec601_ul, *essence_container_ul, 15) && descriptor->width == 720) {
+                if (material_track->edit_rate.num == 25 && material_track->edit_rate.den == 1) {
+                    if (descriptor->aspect_ratio.num == 4 && descriptor->aspect_ratio.den == 3)
+                    st->codec->sample_aspect_ratio = (AVRational){59, 54};
+                    else if (descriptor->aspect_ratio.num == 16 && descriptor->aspect_ratio.den == 9)
+                    st->codec->sample_aspect_ratio = (AVRational){118, 81};
+                } else if (material_track->edit_rate.num == 30000 && material_track->edit_rate.den == 1001) {
+                    if (descriptor->aspect_ratio.num == 4 && descriptor->aspect_ratio.den == 3)
+                        st->codec->sample_aspect_ratio = (AVRational){10, 11};
+                    else if (descriptor->aspect_ratio.num == 16 && descriptor->aspect_ratio.den == 9)
+                        st->codec->sample_aspect_ratio = (AVRational){40, 33};
+                }
+            }
             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);
-- 
1.7.3.4



More information about the ffmpeg-devel mailing list