static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)

{

    const char *hdlr, *descr = NULL, *hdlr_type = NULL;

    int64_t pos = avio_tell(pb);



    if (!track) { /* no media --> data handler */

        hdlr      = "dhlr";

        hdlr_type = "url ";

        descr     = "DataHandler";

    } else {

        hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";

        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {

            hdlr_type = "vide";

            descr     = "VideoHandler";

        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {

            hdlr_type = "soun";

            descr     = "SoundHandler";

        } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {

            if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl";

            else                                      hdlr_type = "text";

            descr = "SubtitleHandler";

        } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {

            hdlr_type = "hint";

            descr     = "HintHandler";

        }

    }



    avio_wb32(pb, 0); /* size */

    ffio_wfourcc(pb, "hdlr");

    avio_wb32(pb, 0); /* Version & flags */

    avio_write(pb, hdlr, 4); /* handler */

    ffio_wfourcc(pb, hdlr_type); /* handler type */

    avio_wb32(pb, 0); /* reserved */

    avio_wb32(pb, 0); /* reserved */

    avio_wb32(pb, 0); /* reserved */

    if (!track || track->mode == MODE_MOV)

        avio_w8(pb, strlen(descr)); /* pascal string */

    avio_write(pb, descr, strlen(descr)); /* handler description */

    if (track && track->mode != MODE_MOV)

        avio_w8(pb, 0); /* c string */

    return update_size(pb, pos);

}

static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)

{

    const char *hdlr, *descr = NULL, *hdlr_type = NULL;

    int64_t pos = avio_tell(pb);



    if (!track) { 

        hdlr      = "dhlr";

        hdlr_type = "url ";

        descr     = "DataHandler";

    } else {

        hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";

        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {

            hdlr_type = "vide";

            descr     = "VideoHandler";

        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {

            hdlr_type = "soun";

            descr     = "SoundHandler";

        } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {

            if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl";

            else                                      hdlr_type = "text";

            descr = "SubtitleHandler";

        } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {

            hdlr_type = "hint";

            descr     = "HintHandler";

        }

    }



    avio_wb32(pb, 0); 

    ffio_wfourcc(pb, "hdlr");

    avio_wb32(pb, 0); 

    avio_write(pb, hdlr, 4); 

    ffio_wfourcc(pb, hdlr_type); 

    avio_wb32(pb, 0); 

    avio_wb32(pb, 0); 

    avio_wb32(pb, 0); 

    if (!track || track->mode == MODE_MOV)

        avio_w8(pb, strlen(descr)); 

    avio_write(pb, descr, strlen(descr)); 

    if (track && track->mode != MODE_MOV)

        avio_w8(pb, 0); 

    return update_size(pb, pos);

}

static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)

{

    const char *VAR_2, *VAR_3 = NULL, *VAR_4 = NULL;

    int64_t pos = avio_tell(VAR_0);



    if (!VAR_1) { 

        VAR_2      = "dhlr";

        VAR_4 = "url ";

        VAR_3     = "DataHandler";

    } else {

        VAR_2 = (VAR_1->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";

        if (VAR_1->enc->codec_type == AVMEDIA_TYPE_VIDEO) {

            VAR_4 = "vide";

            VAR_3     = "VideoHandler";

        } else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO) {

            VAR_4 = "soun";

            VAR_3     = "SoundHandler";

        } else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {

            if (VAR_1->tag == MKTAG('t','x','3','g')) VAR_4 = "sbtl";

            else                                      VAR_4 = "text";

            VAR_3 = "SubtitleHandler";

        } else if (VAR_1->enc->codec_tag == MKTAG('r','t','p',' ')) {

            VAR_4 = "hint";

            VAR_3     = "HintHandler";

        }

    }



    avio_wb32(VAR_0, 0); 

    ffio_wfourcc(VAR_0, "VAR_2");

    avio_wb32(VAR_0, 0); 

    avio_write(VAR_0, VAR_2, 4); 

    ffio_wfourcc(VAR_0, VAR_4); 

    avio_wb32(VAR_0, 0); 

    avio_wb32(VAR_0, 0); 

    avio_wb32(VAR_0, 0); 

    if (!VAR_1 || VAR_1->mode == MODE_MOV)

        avio_w8(VAR_0, strlen(VAR_3)); 

    avio_write(VAR_0, VAR_3, strlen(VAR_3)); 

    if (VAR_1 && VAR_1->mode != MODE_MOV)

        avio_w8(VAR_0, 0); 

    return update_size(VAR_0, pos);

}

static int FUNC_0(AVIOContext *VAR_0, MOVTrack *VAR_1)
{ const char *VAR_2, *VAR_3 = NULL, *VAR_4 = NULL; int64_t pos = avio_tell(VAR_0); if (!VAR_1) { VAR_2      = "dhlr"; VAR_4 = "url "; VAR_3     = "DataHandler"; } else { VAR_2 = (VAR_1->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0"; if (VAR_1->enc->codec_type == AVMEDIA_TYPE_VIDEO) { VAR_4 = "vide"; VAR_3     = "VideoHandler"; } else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_AUDIO) { VAR_4 = "soun"; VAR_3     = "SoundHandler"; } else if (VAR_1->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (VAR_1->tag == MKTAG('t','x','3','g')) VAR_4 = "sbtl"; else                                      VAR_4 = "text"; VAR_3 = "SubtitleHandler"; } else if (VAR_1->enc->codec_tag == MKTAG('r','t','p',' ')) { VAR_4 = "hint"; VAR_3     = "HintHandler"; } } avio_wb32(VAR_0, 0); ffio_wfourcc(VAR_0, "VAR_2"); avio_wb32(VAR_0, 0); avio_write(VAR_0, VAR_2, 4); ffio_wfourcc(VAR_0, VAR_4); avio_wb32(VAR_0, 0); avio_wb32(VAR_0, 0); avio_wb32(VAR_0, 0); if (!VAR_1 || VAR_1->mode == MODE_MOV)
avio_w8(VAR_0, strlen(VAR_3)); avio_write(VAR_0, VAR_3, strlen(VAR_3)); if (VAR_1 && VAR_1->mode != MODE_MOV)
avio_w8(VAR_0, 0); return update_size(VAR_0, pos); }