static int put_flac_codecpriv(AVFormatContext *s,

                              AVIOContext *pb, AVCodecContext *codec)

{

    int write_comment = (codec->channel_layout &&

                         !(codec->channel_layout & ~0x3ffffULL) &&

                         !ff_flac_is_native_layout(codec->channel_layout));

    int ret = ff_flac_write_header(pb, codec->extradata, codec->extradata_size,

                                   !write_comment);



    if (ret < 0)

        return ret;



    if (write_comment) {

        const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ?

                             "Lavf" : LIBAVFORMAT_IDENT;

        AVDictionary *dict = NULL;

        uint8_t buf[32], *data, *p;

        int len;



        snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);

        av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);



        len = ff_vorbiscomment_length(dict, vendor);

        data = av_malloc(len + 4);

        if (!data) {

            av_dict_free(&dict);

            return AVERROR(ENOMEM);

        }



        data[0] = 0x84;

        AV_WB24(data + 1, len);



        p = data + 4;

        ff_vorbiscomment_write(&p, &dict, vendor);



        avio_write(pb, data, len + 4);



        av_freep(&data);

        av_dict_free(&dict);

    }



    return 0;

}

static int put_flac_codecpriv(AVFormatContext *s,

                              AVIOContext *pb, AVCodecContext *codec)

{

    int write_comment = (codec->channel_layout &&

                         !(codec->channel_layout & ~0x3ffffULL) &&

                         !ff_flac_is_native_layout(codec->channel_layout));

    int ret = ff_flac_write_header(pb, codec->extradata, codec->extradata_size,

                                   !write_comment);



    if (ret < 0)

        return ret;



    if (write_comment) {

        const char *vendor = (s->flags & AVFMT_FLAG_BITEXACT) ?

                             "Lavf" : LIBAVFORMAT_IDENT;

        AVDictionary *dict = NULL;

        uint8_t buf[32], *data, *p;

        int len;



        snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);

        av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);



        len = ff_vorbiscomment_length(dict, vendor);

        data = av_malloc(len + 4);

        if (!data) {

            av_dict_free(&dict);

            return AVERROR(ENOMEM);

        }



        data[0] = 0x84;

        AV_WB24(data + 1, len);



        p = data + 4;

        ff_vorbiscomment_write(&p, &dict, vendor);



        avio_write(pb, data, len + 4);



        av_freep(&data);

        av_dict_free(&dict);

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0,

                              AVIOContext *VAR_1, AVCodecContext *VAR_2)

{

    int VAR_3 = (VAR_2->channel_layout &&

                         !(VAR_2->channel_layout & ~0x3ffffULL) &&

                         !ff_flac_is_native_layout(VAR_2->channel_layout));

    int VAR_4 = ff_flac_write_header(VAR_1, VAR_2->extradata, VAR_2->extradata_size,

                                   !VAR_3);



    if (VAR_4 < 0)

        return VAR_4;



    if (VAR_3) {

        const char *VAR_5 = (VAR_0->flags & AVFMT_FLAG_BITEXACT) ?

                             "Lavf" : LIBAVFORMAT_IDENT;

        AVDictionary *dict = NULL;

        uint8_t buf[32], *data, *p;

        int VAR_6;



        snprintf(buf, sizeof(buf), "0x%"PRIx64, VAR_2->channel_layout);

        av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);



        VAR_6 = ff_vorbiscomment_length(dict, VAR_5);

        data = av_malloc(VAR_6 + 4);

        if (!data) {

            av_dict_free(&dict);

            return AVERROR(ENOMEM);

        }



        data[0] = 0x84;

        AV_WB24(data + 1, VAR_6);



        p = data + 4;

        ff_vorbiscomment_write(&p, &dict, VAR_5);



        avio_write(VAR_1, data, VAR_6 + 4);



        av_freep(&data);

        av_dict_free(&dict);

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0,
AVIOContext *VAR_1, AVCodecContext *VAR_2)
{ int VAR_3 = (VAR_2->channel_layout &&
!(VAR_2->channel_layout & ~0x3ffffULL) &&
!ff_flac_is_native_layout(VAR_2->channel_layout)); int VAR_4 = ff_flac_write_header(VAR_1, VAR_2->extradata, VAR_2->extradata_size,
!VAR_3); if (VAR_4 < 0)
return VAR_4; if (VAR_3) { const char *VAR_5 = (VAR_0->flags & AVFMT_FLAG_BITEXACT) ?
"Lavf" : LIBAVFORMAT_IDENT; AVDictionary *dict = NULL; uint8_t buf[32], *data, *p; int VAR_6; snprintf(buf, sizeof(buf), "0x%"PRIx64, VAR_2->channel_layout); av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0); VAR_6 = ff_vorbiscomment_length(dict, VAR_5); data = av_malloc(VAR_6 + 4); if (!data) { av_dict_free(&dict); return AVERROR(ENOMEM); } data[0] = 0x84; AV_WB24(data + 1, VAR_6); p = data + 4; ff_vorbiscomment_write(&p, &dict, VAR_5); avio_write(VAR_1, data, VAR_6 + 4); av_freep(&data); av_dict_free(&dict); } return 0; }