[FFmpeg-devel] [PATCH 13/13] avformat/mxfenc: Write transfer characteristic

Tomas Härdin tjoppen at acc.umu.se
Tue May 8 14:00:51 EEST 2018


mån 2018-05-07 klockan 12:38 +0200 skrev Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> 
> +static int get_trc(UID ul, enum AVColorTransferCharacteristic trc)
> +{
> +    switch (trc){
> +    case AVCOL_TRC_GAMMA28   :
> +    case AVCOL_TRC_GAMMA22   :
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00}, 16);
> +        return 0;
> +    case AVCOL_TRC_BT709     :
> +    case AVCOL_TRC_SMPTE170M :
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00}, 16);
> +        return 0;
> +    case AVCOL_TRC_SMPTE240M :
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00}, 16);
> +        return 0;
> +    case AVCOL_TRC_BT1361_ECG:
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00}, 16);
> +        return 0;
> +    case AVCOL_TRC_LINEAR    :
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00}, 16);
> +        return 0;
> +    case AVCOL_TRC_SMPTE428  :
> +        memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00}, 16);
> +        return 0;
> +    default:
> +        return -1;
> +    }
> +}
> +
>  static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
>  {
>      MXFStreamContext *sc = st->priv_data;
> @@ -1152,6 +1181,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
>      int display_height;
>      int f1, f2;
>      unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6;
> +    UID transfer_ul = {0};
> +
>      if (sc->interlaced && sc->field_dominance)
>          desc_size += 5;
>      if (sc->signal_standard)
> @@ -1164,6 +1195,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
>          desc_size += 8 * 3;
>      if (s->oformat == &ff_mxf_d10_muxer)
>          desc_size += 8 + 8 + 8;
> +    if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0)
> +        desc_size += 20;
>  
>      mxf_write_generic_desc(s, st, key, desc_size);
>  
> @@ -1305,6 +1338,12 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
>      avio_wb32(pb, sc->aspect_ratio.num);
>      avio_wb32(pb, sc->aspect_ratio.den);
>  
> +    //Transfer characteristic
> +    if (transfer_ul[0]) {
> +        mxf_write_local_tag(pb, 16, 0x3210);
> +        avio_write(pb, transfer_ul, 16);
> +    };

Looks OK, but I didn't check the ULs for correctness

/Tomas


More information about the ffmpeg-devel mailing list