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

Tomas Härdin tomas.hardin at codemill.se
Fri Mar 2 17:06:24 CET 2012


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

Why not derive SAR from essence_container_ul? See RP224. This way we
support other EditRates. Ah, and see av_cmp_q().

On Tue, 2012-02-28 at 10:36 -0800, Baptiste Coudurier wrote:
> 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.

What DAR? AVStream and AVCodecContext only have sample_aspect_ratio, and
the rawvideo decoder doesn't set it.
st->sample_aspect_ratio should probably be set too, but lavf/utils.c
probably already fixes that.

While we're on the subject, let me core dump regarding display
resolution stuff:

> another field like clean aperture should be exported.

Yes, also known as DisplayWidth/Height/XOffset/YOffset in MXF, kinda.
MXF and MOV don't use the same coordinate system for this information.

Consider D-10 (aka IMX) which we want displayed as 16:9. Essence is
720x608 with SAR = 152:135 (DAR = 4:3). MOV vs MXF wrt dealing with VBI
lines and improper essence aspect:

MOV:
 clap is raster size, meaning post-SAR, yoffset relative to center.
 1024x576, yoffset = 16, pasp = 64:45.

MXF:
 DisplayWidth/Height are pre-SAR and per-field, relative to the sampled
rectangle.
 720x288, DisplayYOffset = 16, AspectRatio = 16:9.

This means either muxer/demuxer pair or both of them (all four
muxers/demuxers) need to transform their coordinates to some common
system. These values can then be put into/read from AVRationals in
AVStream.

There's other aspects to this, but I'll stop for now.

-------------------
Future feature idea
-------------------

IMX50 is a pretty simple use case for this. IMO ffplay shouldn't display
the VBI lines, and the picture should be displayed with the container's
DAR. We could perhaps have a button for disregarding the container
information if the user wants to see the essence's POV (VBI lines, 4:3
DAR etc.).

Ooh, and a fun little tidbit: P2 AVC-Intra 50 16:9 cameras have essence
SAR = 3:4 instead of 4:3 (DAR = 1:1).

/Tomas



More information about the ffmpeg-devel mailing list