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

                              MOVTrack *track, AVStream *st)

{

    int64_t pos = avio_tell(pb);

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

    ffio_wfourcc(pb, "trak");

    mov_write_tkhd_tag(pb, track, st);

    if (supports_edts(mov))

        mov_write_edts_tag(pb, track);  // PSP Movies and several other cases require edts box

    if (track->tref_tag)

        mov_write_tref_tag(pb, track);

    mov_write_mdia_tag(pb, track);

    if (track->mode == MODE_PSP)

        mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box

    if (track->tag == MKTAG('r','t','p',' '))

        mov_write_udta_sdp(pb, track);

    if (track->mode == MODE_MOV) {

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

            double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);

            if (st->sample_aspect_ratio.num && 1.0 != sample_aspect_ratio) {

                mov_write_tapt_tag(pb, track);

            }

        }

        if (is_clcp_track(track)) {

            mov_write_tapt_tag(pb, track);

        }

    }

    return update_size(pb, pos);

}

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

                              MOVTrack *track, AVStream *st)

{

    int64_t pos = avio_tell(pb);

    avio_wb32(pb, 0); 

    ffio_wfourcc(pb, "trak");

    mov_write_tkhd_tag(pb, track, st);

    if (supports_edts(mov))

        mov_write_edts_tag(pb, track);  

    if (track->tref_tag)

        mov_write_tref_tag(pb, track);

    mov_write_mdia_tag(pb, track);

    if (track->mode == MODE_PSP)

        mov_write_uuid_tag_psp(pb, track); 

    if (track->tag == MKTAG('r','t','p',' '))

        mov_write_udta_sdp(pb, track);

    if (track->mode == MODE_MOV) {

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

            double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);

            if (st->sample_aspect_ratio.num && 1.0 != sample_aspect_ratio) {

                mov_write_tapt_tag(pb, track);

            }

        }

        if (is_clcp_track(track)) {

            mov_write_tapt_tag(pb, track);

        }

    }

    return update_size(pb, pos);

}

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

                              MOVTrack *VAR_2, AVStream *VAR_3)

{

    int64_t pos = avio_tell(VAR_0);

    avio_wb32(VAR_0, 0); 

    ffio_wfourcc(VAR_0, "trak");

    mov_write_tkhd_tag(VAR_0, VAR_2, VAR_3);

    if (supports_edts(VAR_1))

        mov_write_edts_tag(VAR_0, VAR_2);  

    if (VAR_2->tref_tag)

        mov_write_tref_tag(VAR_0, VAR_2);

    mov_write_mdia_tag(VAR_0, VAR_2);

    if (VAR_2->mode == MODE_PSP)

        mov_write_uuid_tag_psp(VAR_0, VAR_2); 

    if (VAR_2->tag == MKTAG('r','t','p',' '))

        mov_write_udta_sdp(VAR_0, VAR_2);

    if (VAR_2->mode == MODE_MOV) {

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

            double VAR_4 = av_q2d(VAR_3->VAR_4);

            if (VAR_3->VAR_4.num && 1.0 != VAR_4) {

                mov_write_tapt_tag(VAR_0, VAR_2);

            }

        }

        if (is_clcp_track(VAR_2)) {

            mov_write_tapt_tag(VAR_0, VAR_2);

        }

    }

    return update_size(VAR_0, pos);

}

static int FUNC_0(AVIOContext *VAR_0, MOVMuxContext *VAR_1,
MOVTrack *VAR_2, AVStream *VAR_3)
{ int64_t pos = avio_tell(VAR_0); avio_wb32(VAR_0, 0); ffio_wfourcc(VAR_0, "trak"); mov_write_tkhd_tag(VAR_0, VAR_2, VAR_3); if (supports_edts(VAR_1))
mov_write_edts_tag(VAR_0, VAR_2); if (VAR_2->tref_tag)
mov_write_tref_tag(VAR_0, VAR_2); mov_write_mdia_tag(VAR_0, VAR_2); if (VAR_2->mode == MODE_PSP)
mov_write_uuid_tag_psp(VAR_0, VAR_2); if (VAR_2->tag == MKTAG('r','t','p',' '))
mov_write_udta_sdp(VAR_0, VAR_2); if (VAR_2->mode == MODE_MOV) { if (VAR_2->enc->codec_type == AVMEDIA_TYPE_VIDEO) { double VAR_4 = av_q2d(VAR_3->VAR_4); if (VAR_3->VAR_4.num && 1.0 != VAR_4) { mov_write_tapt_tag(VAR_0, VAR_2); } } if (is_clcp_track(VAR_2)) { mov_write_tapt_tag(VAR_0, VAR_2); } } return update_size(VAR_0, pos); }