static void ffm_write_data(AVFormatContext *s,

                           const uint8_t *buf, int size,

                           int64_t pts, int header)

{

    FFMContext *ffm = s->priv_data;

    int len;



    if (header && ffm->frame_offset == 0) {

        ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE;

        ffm->pts = pts;

    }



    /* write as many packets as needed */

    while (size > 0) {

        len = ffm->packet_end - ffm->packet_ptr;

        if (len > size)

            len = size;

        memcpy(ffm->packet_ptr, buf, len);



        ffm->packet_ptr += len;

        buf += len;

        size -= len;

        if (ffm->packet_ptr >= ffm->packet_end) {

            /* special case : no pts in packet : we leave the current one */

            if (ffm->pts == 0)

                ffm->pts = pts;



            flush_packet(s);

        }

    }

}

static void ffm_write_data(AVFormatContext *s,

                           const uint8_t *buf, int size,

                           int64_t pts, int header)

{

    FFMContext *ffm = s->priv_data;

    int len;



    if (header && ffm->frame_offset == 0) {

        ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE;

        ffm->pts = pts;

    }



    

    while (size > 0) {

        len = ffm->packet_end - ffm->packet_ptr;

        if (len > size)

            len = size;

        memcpy(ffm->packet_ptr, buf, len);



        ffm->packet_ptr += len;

        buf += len;

        size -= len;

        if (ffm->packet_ptr >= ffm->packet_end) {

            

            if (ffm->pts == 0)

                ffm->pts = pts;



            flush_packet(s);

        }

    }

}

static void FUNC_0(AVFormatContext *VAR_0,

                           const uint8_t *VAR_1, int VAR_2,

                           int64_t VAR_3, int VAR_4)

{

    FFMContext *ffm = VAR_0->priv_data;

    int VAR_5;



    if (VAR_4 && ffm->frame_offset == 0) {

        ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE;

        ffm->VAR_3 = VAR_3;

    }



    

    while (VAR_2 > 0) {

        VAR_5 = ffm->packet_end - ffm->packet_ptr;

        if (VAR_5 > VAR_2)

            VAR_5 = VAR_2;

        memcpy(ffm->packet_ptr, VAR_1, VAR_5);



        ffm->packet_ptr += VAR_5;

        VAR_1 += VAR_5;

        VAR_2 -= VAR_5;

        if (ffm->packet_ptr >= ffm->packet_end) {

            

            if (ffm->VAR_3 == 0)

                ffm->VAR_3 = VAR_3;



            flush_packet(VAR_0);

        }

    }

}

static void FUNC_0(AVFormatContext *VAR_0,
const uint8_t *VAR_1, int VAR_2,
int64_t VAR_3, int VAR_4)
{ FFMContext *ffm = VAR_0->priv_data; int VAR_5; if (VAR_4 && ffm->frame_offset == 0) { ffm->frame_offset = ffm->packet_ptr - ffm->packet + FFM_HEADER_SIZE; ffm->VAR_3 = VAR_3; } while (VAR_2 > 0) { VAR_5 = ffm->packet_end - ffm->packet_ptr; if (VAR_5 > VAR_2)
VAR_5 = VAR_2; memcpy(ffm->packet_ptr, VAR_1, VAR_5); ffm->packet_ptr += VAR_5; VAR_1 += VAR_5; VAR_2 -= VAR_5; if (ffm->packet_ptr >= ffm->packet_end) { if (ffm->VAR_3 == 0)
ffm->VAR_3 = VAR_3; flush_packet(VAR_0); } } }