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

Baptiste Coudurier baptiste.coudurier at gmail.com
Tue Feb 28 19:36:16 CET 2012


On 02/28/2012 06:16 AM, Philip de Nier wrote:
> ---
>   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);

This one I'm hesitating. The problem is that setting sample aspect ratio to these values will break
the rule width/height == dar/par which is expected in many places.
I believe sample aspect ratio should follow the rule and another field like clean aperture should be 
exported.
Furthermore, this assume the source is analog and not digital.
Michael ?

-- 
Baptiste COUDURIER
Key fingerprint          8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                           http://www.ffmpeg.org


More information about the ffmpeg-devel mailing list