static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,

                              AVFormatContext *s)

{

    AVIOContext *pb_buf;

    int i, ret, size;

    uint8_t *buf;



    for (i = 0; i < s->nb_streams; i++)

        if (s->flags & AVFMT_FLAG_BITEXACT) {

            return 0;

        }



    ret = avio_open_dyn_buf(&pb_buf);

    if (ret < 0)

        return ret;



    if (mov->mode & MODE_3GP) {

        mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist");

        mov_write_3gp_udta_tag(pb_buf, s, "titl", "title");

        mov_write_3gp_udta_tag(pb_buf, s, "auth", "author");

        mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre");

        mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment");

        mov_write_3gp_udta_tag(pb_buf, s, "albm", "album");

        mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");

        mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date");

    } else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4

        mov_write_string_metadata(s, pb_buf, "\251ART", "artist",      0);

        mov_write_string_metadata(s, pb_buf, "\251nam", "title",       0);

        mov_write_string_metadata(s, pb_buf, "\251aut", "author",      0);

        mov_write_string_metadata(s, pb_buf, "\251alb", "album",       0);

        mov_write_string_metadata(s, pb_buf, "\251day", "date",        0);

        mov_write_string_metadata(s, pb_buf, "\251swr", "encoder",     0);

        mov_write_string_metadata(s, pb_buf, "\251des", "comment",     0);

        mov_write_string_metadata(s, pb_buf, "\251gen", "genre",       0);

        mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright",   0);

    } else {

        /* iTunes meta data */

        mov_write_meta_tag(pb_buf, mov, s);

    }



    if (s->nb_chapters && !(mov->flags & FF_MOV_FLAG_DISABLE_CHPL))

        mov_write_chpl_tag(pb_buf, s);



    if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {

        avio_wb32(pb, size + 8);

        ffio_wfourcc(pb, "udta");

        avio_write(pb, buf, size);

    }

    av_free(buf);



    return 0;

}

static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,

                              AVFormatContext *s)

{

    AVIOContext *pb_buf;

    int i, ret, size;

    uint8_t *buf;



    for (i = 0; i < s->nb_streams; i++)

        if (s->flags & AVFMT_FLAG_BITEXACT) {

            return 0;

        }



    ret = avio_open_dyn_buf(&pb_buf);

    if (ret < 0)

        return ret;



    if (mov->mode & MODE_3GP) {

        mov_write_3gp_udta_tag(pb_buf, s, "perf", "artist");

        mov_write_3gp_udta_tag(pb_buf, s, "titl", "title");

        mov_write_3gp_udta_tag(pb_buf, s, "auth", "author");

        mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre");

        mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment");

        mov_write_3gp_udta_tag(pb_buf, s, "albm", "album");

        mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");

        mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date");

    } else if (mov->mode == MODE_MOV) { 

        mov_write_string_metadata(s, pb_buf, "\251ART", "artist",      0);

        mov_write_string_metadata(s, pb_buf, "\251nam", "title",       0);

        mov_write_string_metadata(s, pb_buf, "\251aut", "author",      0);

        mov_write_string_metadata(s, pb_buf, "\251alb", "album",       0);

        mov_write_string_metadata(s, pb_buf, "\251day", "date",        0);

        mov_write_string_metadata(s, pb_buf, "\251swr", "encoder",     0);

        mov_write_string_metadata(s, pb_buf, "\251des", "comment",     0);

        mov_write_string_metadata(s, pb_buf, "\251gen", "genre",       0);

        mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright",   0);

    } else {

        

        mov_write_meta_tag(pb_buf, mov, s);

    }



    if (s->nb_chapters && !(mov->flags & FF_MOV_FLAG_DISABLE_CHPL))

        mov_write_chpl_tag(pb_buf, s);



    if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {

        avio_wb32(pb, size + 8);

        ffio_wfourcc(pb, "udta");

        avio_write(pb, buf, size);

    }

    av_free(buf);



    return 0;

}

static int FUNC_0(AVIOContext *VAR_0, MOVMuxContext *VAR_1,

                              AVFormatContext *VAR_2)

{

    AVIOContext *pb_buf;

    int VAR_3, VAR_4, VAR_5;

    uint8_t *buf;



    for (VAR_3 = 0; VAR_3 < VAR_2->nb_streams; VAR_3++)

        if (VAR_2->flags & AVFMT_FLAG_BITEXACT) {

            return 0;

        }



    VAR_4 = avio_open_dyn_buf(&pb_buf);

    if (VAR_4 < 0)

        return VAR_4;



    if (VAR_1->mode & MODE_3GP) {

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "perf", "artist");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "titl", "title");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "auth", "author");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "gnre", "genre");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "dscp", "comment");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "albm", "album");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "cprt", "copyright");

        mov_write_3gp_udta_tag(pb_buf, VAR_2, "yrrc", "date");

    } else if (VAR_1->mode == MODE_MOV) { 

        mov_write_string_metadata(VAR_2, pb_buf, "\251ART", "artist",      0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251nam", "title",       0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251aut", "author",      0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251alb", "album",       0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251day", "date",        0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251swr", "encoder",     0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251des", "comment",     0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251gen", "genre",       0);

        mov_write_string_metadata(VAR_2, pb_buf, "\251cpy", "copyright",   0);

    } else {

        

        mov_write_meta_tag(pb_buf, VAR_1, VAR_2);

    }



    if (VAR_2->nb_chapters && !(VAR_1->flags & FF_MOV_FLAG_DISABLE_CHPL))

        mov_write_chpl_tag(pb_buf, VAR_2);



    if ((VAR_5 = avio_close_dyn_buf(pb_buf, &buf)) > 0) {

        avio_wb32(VAR_0, VAR_5 + 8);

        ffio_wfourcc(VAR_0, "udta");

        avio_write(VAR_0, buf, VAR_5);

    }

    av_free(buf);



    return 0;

}

static int FUNC_0(AVIOContext *VAR_0, MOVMuxContext *VAR_1,
AVFormatContext *VAR_2)
{ AVIOContext *pb_buf; int VAR_3, VAR_4, VAR_5; uint8_t *buf; for (VAR_3 = 0; VAR_3 < VAR_2->nb_streams; VAR_3++) if (VAR_2->flags & AVFMT_FLAG_BITEXACT) { return 0; } VAR_4 = avio_open_dyn_buf(&pb_buf); if (VAR_4 < 0)
return VAR_4; if (VAR_1->mode & MODE_3GP) { mov_write_3gp_udta_tag(pb_buf, VAR_2, "perf", "artist"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "titl", "title"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "auth", "author"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "gnre", "genre"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "dscp", "comment"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "albm", "album"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "cprt", "copyright"); mov_write_3gp_udta_tag(pb_buf, VAR_2, "yrrc", "date"); } else if (VAR_1->mode == MODE_MOV) { mov_write_string_metadata(VAR_2, pb_buf, "\251ART", "artist",      0); mov_write_string_metadata(VAR_2, pb_buf, "\251nam", "title",       0); mov_write_string_metadata(VAR_2, pb_buf, "\251aut", "author",      0); mov_write_string_metadata(VAR_2, pb_buf, "\251alb", "album",       0); mov_write_string_metadata(VAR_2, pb_buf, "\251day", "date",        0); mov_write_string_metadata(VAR_2, pb_buf, "\251swr", "encoder",     0); mov_write_string_metadata(VAR_2, pb_buf, "\251des", "comment",     0); mov_write_string_metadata(VAR_2, pb_buf, "\251gen", "genre",       0); mov_write_string_metadata(VAR_2, pb_buf, "\251cpy", "copyright",   0); } else { mov_write_meta_tag(pb_buf, VAR_1, VAR_2); } if (VAR_2->nb_chapters && !(VAR_1->flags & FF_MOV_FLAG_DISABLE_CHPL))
mov_write_chpl_tag(pb_buf, VAR_2); if ((VAR_5 = avio_close_dyn_buf(pb_buf, &buf)) > 0) { avio_wb32(VAR_0, VAR_5 + 8); ffio_wfourcc(VAR_0, "udta"); avio_write(VAR_0, buf, VAR_5); } av_free(buf); return 0; }