printf ("  unknown RoQ chunk (%04X)\n", chunk_type);
av_log(s, AV_LOG_ERROR, "  unknown RoQ chunk (%04X)\n", chunk_type);
static int roq_read_packet(AVFormatContext *s,                           AVPacket *pkt){    RoqDemuxContext *roq = s->priv_data;    ByteIOContext *pb = &s->pb;    int ret = 0;    unsigned int chunk_size;    unsigned int chunk_type;    unsigned int codebook_size;    unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];    int packet_read = 0;    offset_t codebook_offset;    while (!packet_read) {        if (url_feof(&s->pb))            return -EIO;        /* get the next chunk preamble */        if ((ret = get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=             RoQ_CHUNK_PREAMBLE_SIZE)            return -EIO;        chunk_type = LE_16(&preamble[0]);        chunk_size = LE_32(&preamble[2]);        switch (chunk_type) {        case RoQ_INFO:            /* don't care about this chunk anymore */            url_fseek(pb, RoQ_CHUNK_PREAMBLE_SIZE, SEEK_CUR);            break;        case RoQ_QUAD_CODEBOOK:            /* packet needs to contain both this codebook and next VQ chunk */            codebook_offset = url_ftell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;            codebook_size = chunk_size;            url_fseek(pb, codebook_size, SEEK_CUR);            if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=                 RoQ_CHUNK_PREAMBLE_SIZE)                return -EIO;            chunk_size = LE_32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +                 codebook_size;            /* rewind */            url_fseek(pb, codebook_offset, SEEK_SET);            /* load up the packet */            if (av_new_packet(pkt, chunk_size))                return -EIO;            pkt->stream_index = roq->video_stream_index;            pkt->pts = roq->video_pts;            ret = get_buffer(pb, pkt->data, chunk_size);            if (ret != chunk_size)                ret = -EIO;            roq->video_pts += roq->frame_pts_inc;            packet_read = 1;            break;        case RoQ_SOUND_MONO:        case RoQ_SOUND_STEREO:        case RoQ_QUAD_VQ:            /* load up the packet */            if (av_new_packet(pkt, chunk_size + RoQ_CHUNK_PREAMBLE_SIZE))                return -EIO;            /* copy over preamble */            memcpy(pkt->data, preamble, RoQ_CHUNK_PREAMBLE_SIZE);            if (chunk_type == RoQ_QUAD_VQ) {                pkt->stream_index = roq->video_stream_index;                pkt->pts = roq->video_pts;                roq->video_pts += roq->frame_pts_inc;            } else {                pkt->stream_index = roq->audio_stream_index;                pkt->pts = roq->audio_frame_count;                pkt->pts *= 90000;                pkt->pts /= RoQ_AUDIO_SAMPLE_RATE;                roq->audio_frame_count += (chunk_size / roq->audio_channels);            }            ret = get_buffer(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,                chunk_size);            if (ret != chunk_size)                ret = -EIO;            packet_read = 1;            break;        default:            printf ("  unknown RoQ chunk (%04X)\n", chunk_type);            return AVERROR_INVALIDDATA;            break;        }    }    return ret;}