static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size)

{

    RMContext *rm = s->priv_data;

    ByteIOContext *pb = &s->pb;

    StreamInfo *stream = rm->video_stream;

    int key_frame = stream->enc->coded_frame->key_frame;



    /* XXX: this is incorrect: should be a parameter */



    /* Well, I spent some time finding the meaning of these bits. I am

       not sure I understood everything, but it works !! */

#if 1

    write_packet_header(s, stream, size + 7, key_frame);

    /* bit 7: '1' if final packet of a frame converted in several packets */

    put_byte(pb, 0x81); 

    /* bit 7: '1' if I frame. bits 6..0 : sequence number in current

       frame starting from 1 */

    if (key_frame) {

        put_byte(pb, 0x81); 

    } else {

        put_byte(pb, 0x01); 

    }

    put_be16(pb, 0x4000 | (size)); /* total frame size */

    put_be16(pb, 0x4000 | (size));              /* offset from the start or the end */

#else

    /* full frame */

    write_packet_header(s, size + 6);

    put_byte(pb, 0xc0); 

    put_be16(pb, 0x4000 | size); /* total frame size */

    put_be16(pb, 0x4000 + packet_number * 126); /* position in stream */

#endif

    put_byte(pb, stream->nb_frames & 0xff); 

    

    put_buffer(pb, buf, size);

    put_flush_packet(pb);



    stream->nb_frames++;

    return 0;

}

static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size)

{

    RMContext *rm = s->priv_data;

    ByteIOContext *pb = &s->pb;

    StreamInfo *stream = rm->video_stream;

    int key_frame = stream->enc->coded_frame->key_frame;



    



    



#if 1

    write_packet_header(s, stream, size + 7, key_frame);

    

    put_byte(pb, 0x81); 

    



    if (key_frame) {

        put_byte(pb, 0x81); 

    } else {

        put_byte(pb, 0x01); 

    }

    put_be16(pb, 0x4000 | (size)); 

    put_be16(pb, 0x4000 | (size));              

#else

    

    write_packet_header(s, size + 6);

    put_byte(pb, 0xc0); 

    put_be16(pb, 0x4000 | size); 

    put_be16(pb, 0x4000 + packet_number * 126); 

#endif

    put_byte(pb, stream->nb_frames & 0xff); 

    

    put_buffer(pb, buf, size);

    put_flush_packet(pb);



    stream->nb_frames++;

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2)

{

    RMContext *rm = VAR_0->priv_data;

    ByteIOContext *pb = &VAR_0->pb;

    StreamInfo *stream = rm->video_stream;

    int VAR_3 = stream->enc->coded_frame->VAR_3;



    



    



#if 1

    write_packet_header(VAR_0, stream, VAR_2 + 7, VAR_3);

    

    put_byte(pb, 0x81); 

    



    if (VAR_3) {

        put_byte(pb, 0x81); 

    } else {

        put_byte(pb, 0x01); 

    }

    put_be16(pb, 0x4000 | (VAR_2)); 

    put_be16(pb, 0x4000 | (VAR_2));              

#else

    

    write_packet_header(VAR_0, VAR_2 + 6);

    put_byte(pb, 0xc0); 

    put_be16(pb, 0x4000 | VAR_2); 

    put_be16(pb, 0x4000 + packet_number * 126); 

#endif

    put_byte(pb, stream->nb_frames & 0xff); 

    

    put_buffer(pb, VAR_1, VAR_2);

    put_flush_packet(pb);



    stream->nb_frames++;

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, const uint8_t *VAR_1, int VAR_2)
{ RMContext *rm = VAR_0->priv_data; ByteIOContext *pb = &VAR_0->pb; StreamInfo *stream = rm->video_stream; int VAR_3 = stream->enc->coded_frame->VAR_3; #if 1
write_packet_header(VAR_0, stream, VAR_2 + 7, VAR_3); put_byte(pb, 0x81); if (VAR_3) { put_byte(pb, 0x81); } else { put_byte(pb, 0x01); } put_be16(pb, 0x4000 | (VAR_2)); put_be16(pb, 0x4000 | (VAR_2)); #else
write_packet_header(VAR_0, VAR_2 + 6); put_byte(pb, 0xc0); put_be16(pb, 0x4000 | VAR_2); put_be16(pb, 0x4000 + packet_number * 126); #endif
put_byte(pb, stream->nb_frames & 0xff); put_buffer(pb, VAR_1, VAR_2); put_flush_packet(pb); stream->nb_frames++; return 0; }