[FFmpeg-devel] [PATCH 3/4] mxfenc: write optional field dominance flag in picture description

Matthieu Bouron matthieu.bouron at gmail.com
Wed Jun 6 13:18:37 CEST 2012


On Sun, May 27, 2012 at 02:21:41PM +0200, Matthieu Bouron wrote:
> ---
> $title
> ---
>  libavformat/mxfenc.c   |   15 ++++++++++++++-
>  tests/ref/lavf/mxf     |    6 +++---
>  tests/ref/lavf/mxf_d10 |    2 +-
>  3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 1d11bae..fce8446 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -73,6 +73,7 @@ typedef struct {
>      const UID *codec_ul;
>      int order;               ///< interleaving order if dts are equal
>      int interlaced;          ///< whether picture is interlaced
> +    int field_dominance;     ///< tff=1, bff=2
>      int temporal_reordering;
>      AVRational aspect_ratio; ///< display aspect ratio
>      int closed_gop;          ///< gop is closed, used in mpeg-2 frame parsing
> @@ -285,6 +286,7 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
>      { 0x3208, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0B,0x00,0x00,0x00}}, /* Display Height */
>      { 0x320E, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x00,0x00,0x00}}, /* Aspect Ratio */
>      { 0x3201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}}, /* Picture Essence Coding */
> +    { 0x3212, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x03,0x01,0x06,0x00,0x00,0x00}}, /* Field Dominance (Opt) */
>      // CDCI Picture Essence Descriptor
>      { 0x3301, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x0A,0x00,0x00,0x00}}, /* Component Depth */
>      { 0x3302, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x05,0x00,0x00,0x00}}, /* Horizontal Subsampling */
> @@ -790,8 +792,11 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
>      int stored_height = (st->codec->height+15)/16*16;
>      int display_height;
>      int f1, f2;
> +    unsigned desc_size = size+8+8+8+8+8+8+5+16+sc->interlaced*4+12+20;
> +    if (sc->interlaced && sc->field_dominance)
> +        desc_size += 5;
>  
> -    mxf_write_generic_desc(s, st, key, size+8+8+8+8+8+8+5+16+sc->interlaced*4+12+20);
> +    mxf_write_generic_desc(s, st, key, desc_size);
>  
>      mxf_write_local_tag(pb, 4, 0x3203);
>      avio_wb32(pb, st->codec->width);
> @@ -853,6 +858,12 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
>  
>      mxf_write_local_tag(pb, 16, 0x3201);
>      avio_write(pb, *sc->codec_ul, 16);
> +
> +    if (sc->interlaced && sc->field_dominance) {
> +        mxf_write_local_tag(pb, 1, 0x3212);
> +        avio_w8(pb, sc->field_dominance);
> +    }
> +
>  }
>  
>  static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st)
> @@ -1329,6 +1340,8 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
>                  st->codec->level   = pkt->data[i+2] >> 4;
>              } else if (i + 5 < pkt->size && (pkt->data[i+1] & 0xf0) == 0x80) { // pict coding ext
>                  sc->interlaced = !(pkt->data[i+5] & 0x80); // progressive frame
> +                if (sc->interlaced)
> +                    sc->field_dominance = 1 + !(pkt->data[i+4] & 0x80); // top field first
>                  break;
>              }
>          } else if (c == 0x1b8) { // gop
> diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
> index f78fe38..51a488e 100644
> --- a/tests/ref/lavf/mxf
> +++ b/tests/ref/lavf/mxf
> @@ -1,9 +1,9 @@
> -785e38ddd2466046f30aa36399b8f8fa *./tests/data/lavf/lavf.mxf
> +4cc269e1d2066fac03a3d7466f011c8e *./tests/data/lavf/lavf.mxf
>  525881 ./tests/data/lavf/lavf.mxf
>  ./tests/data/lavf/lavf.mxf CRC=0x4ace0849
> -ccaa42c75e653f71604fd28c7c83722d *./tests/data/lavf/lavf.mxf
> +87eb6e0e51d31c8ffa414d02672edfa0 *./tests/data/lavf/lavf.mxf
>  537657 ./tests/data/lavf/lavf.mxf
>  ./tests/data/lavf/lavf.mxf CRC=0x9b928d6b
> -c78207030d57b48295b089916849d50d *./tests/data/lavf/lavf.mxf
> +52c5b74ecfdc48bd77d79a6bbe62d2de *./tests/data/lavf/lavf.mxf
>  525881 ./tests/data/lavf/lavf.mxf
>  ./tests/data/lavf/lavf.mxf CRC=0x4ace0849
> diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10
> index a10e845..efe861a 100644
> --- a/tests/ref/lavf/mxf_d10
> +++ b/tests/ref/lavf/mxf_d10
> @@ -1,3 +1,3 @@
> -0d72247067569901a2e351586ddc0b82 *./tests/data/lavf/lavf.mxf_d10
> +93237916962c1ecacc8ae3b9e97481fb *./tests/data/lavf/lavf.mxf_d10
>  5330989 ./tests/data/lavf/lavf.mxf_d10
>  ./tests/data/lavf/lavf.mxf_d10 CRC=0x4474d480
> -- 
> 1.7.10
> 

ping



More information about the ffmpeg-devel mailing list