static int ffm_write_packet(AVFormatContext *s, int stream_index,

                            UINT8 *buf, int size, int force_pts)

{

    AVStream *st = s->streams[stream_index];

    FFMStream *fst = st->priv_data;

    INT64 pts;

    UINT8 header[FRAME_HEADER_SIZE];

    int duration;



    if (st->codec.codec_type == CODEC_TYPE_AUDIO) {

        duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);

    } else {

        duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);

    }



    pts = fst->pts;

    /* packet size & key_frame */

    header[0] = stream_index;

    header[1] = 0;

    if (st->codec.coded_picture->key_frame)

        header[1] |= FLAG_KEY_FRAME;

    header[2] = (size >> 16) & 0xff;

    header[3] = (size >> 8) & 0xff;

    header[4] = size & 0xff;

    header[5] = (duration >> 16) & 0xff;

    header[6] = (duration >> 8) & 0xff;

    header[7] = duration & 0xff;

    ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);

    ffm_write_data(s, buf, size, pts, 0);



    fst->pts += duration;

    return 0;

}

static int ffm_write_packet(AVFormatContext *s, int stream_index,

                            UINT8 *buf, int size, int force_pts)

{

    AVStream *st = s->streams[stream_index];

    FFMStream *fst = st->priv_data;

    INT64 pts;

    UINT8 header[FRAME_HEADER_SIZE];

    int duration;



    if (st->codec.codec_type == CODEC_TYPE_AUDIO) {

        duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);

    } else {

        duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);

    }



    pts = fst->pts;

    

    header[0] = stream_index;

    header[1] = 0;

    if (st->codec.coded_picture->key_frame)

        header[1] |= FLAG_KEY_FRAME;

    header[2] = (size >> 16) & 0xff;

    header[3] = (size >> 8) & 0xff;

    header[4] = size & 0xff;

    header[5] = (duration >> 16) & 0xff;

    header[6] = (duration >> 8) & 0xff;

    header[7] = duration & 0xff;

    ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);

    ffm_write_data(s, buf, size, pts, 0);



    fst->pts += duration;

    return 0;

}

    if (st->codec.coded_picture->key_frame)
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,

                            UINT8 *VAR_2, int VAR_3, int VAR_4)

{

    AVStream *st = VAR_0->streams[VAR_1];

    FFMStream *fst = st->priv_data;

    INT64 pts;

    UINT8 header[FRAME_HEADER_SIZE];

    int VAR_5;



    if (st->codec.codec_type == CODEC_TYPE_AUDIO) {

        VAR_5 = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);

    } else {

        VAR_5 = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);

    }



    pts = fst->pts;

    

    header[0] = VAR_1;

    header[1] = 0;

    if (st->codec.coded_picture->key_frame)

        header[1] |= FLAG_KEY_FRAME;

    header[2] = (VAR_3 >> 16) & 0xff;

    header[3] = (VAR_3 >> 8) & 0xff;

    header[4] = VAR_3 & 0xff;

    header[5] = (VAR_5 >> 16) & 0xff;

    header[6] = (VAR_5 >> 8) & 0xff;

    header[7] = VAR_5 & 0xff;

    ffm_write_data(VAR_0, header, FRAME_HEADER_SIZE, pts, 1);

    ffm_write_data(VAR_0, VAR_2, VAR_3, pts, 0);



    fst->pts += VAR_5;

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
UINT8 *VAR_2, int VAR_3, int VAR_4)
{ AVStream *st = VAR_0->streams[VAR_1]; FFMStream *fst = st->priv_data; INT64 pts; UINT8 header[FRAME_HEADER_SIZE]; int VAR_5; if (st->codec.codec_type == CODEC_TYPE_AUDIO) { VAR_5 = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); } else { VAR_5 = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate); } pts = fst->pts; header[0] = VAR_1; header[1] = 0; if (st->codec.coded_picture->key_frame)
header[1] |= FLAG_KEY_FRAME; header[2] = (VAR_3 >> 16) & 0xff; header[3] = (VAR_3 >> 8) & 0xff; header[4] = VAR_3 & 0xff; header[5] = (VAR_5 >> 16) & 0xff; header[6] = (VAR_5 >> 8) & 0xff; header[7] = VAR_5 & 0xff; ffm_write_data(VAR_0, header, FRAME_HEADER_SIZE, pts, 1); ffm_write_data(VAR_0, VAR_2, VAR_3, pts, 0); fst->pts += VAR_5; return 0; }