if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE))
if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt){    int size;    FFMContext *ffm = s->priv_data;    int duration;    switch(ffm->read_state) {    case READ_HEADER:        if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE))            return -EAGAIN;#if 0        printf("pos=%08Lx spos=%Lx, write_index=%Lx size=%Lx\n",               url_ftell(&s->pb), s->pb.pos, ffm->write_index, ffm->file_size);#endif        if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) != FRAME_HEADER_SIZE)            return -EAGAIN;#if 0        {            int i;            for(i=0;i<FRAME_HEADER_SIZE;i++)                printf("%02x ", ffm->header[i]);            printf("\n");        }#endif        ffm->read_state = READ_DATA;        /* fall thru */    case READ_DATA:        size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4];        if (!ffm_is_avail_data(s, size)) {            return -EAGAIN;        }        duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7];        av_new_packet(pkt, size);        pkt->stream_index = ffm->header[0];        if (ffm->header[1] & FLAG_KEY_FRAME)            pkt->flags |= PKT_FLAG_KEY;        ffm->read_state = READ_HEADER;        if (ffm_read_data(s, pkt->data, size, 0) != size) {            /* bad case: desynchronized packet. we cancel all the packet loading */            av_free_packet(pkt);            return -EAGAIN;        }        pkt->pts = ffm->pts;        pkt->duration = duration;        break;    }    return 0;}