printf (" unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
static int roq_read_header(AVFormatContext *s,                           AVFormatParameters *ap){    RoqDemuxContext *roq = s->priv_data;    ByteIOContext *pb = &s->pb;    AVStream *st;    unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];    int i;    unsigned int chunk_size;    unsigned int chunk_type;    /* get the main header */    if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=         RoQ_CHUNK_PREAMBLE_SIZE)        return AVERROR_IO;    roq->framerate = LE_16(&preamble[6]);    roq->frame_pts_inc = 90000 / roq->framerate;    /* set the pts reference (1 pts = 1/90000) */    s->pts_num = 1;    s->pts_den = 90000;    /* init private context parameters */    roq->width = roq->height = roq->audio_channels = roq->video_pts =     roq->audio_frame_count = 0;    /* scan the first n chunks searching for A/V parameters */    for (i = 0; i < RoQ_CHUNKS_TO_SCAN; i++) {        if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=             RoQ_CHUNK_PREAMBLE_SIZE)            return AVERROR_IO;        chunk_type = LE_16(&preamble[0]);        chunk_size = LE_32(&preamble[2]);        switch (chunk_type) {        case RoQ_INFO:            /* fetch the width and height; reuse the preamble bytes */            if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=                 RoQ_CHUNK_PREAMBLE_SIZE)                return AVERROR_IO;            roq->width = LE_16(&preamble[0]);            roq->height = LE_16(&preamble[2]);            break;        case RoQ_QUAD_CODEBOOK:        case RoQ_QUAD_VQ:            /* ignore during this scan */            url_fseek(pb, chunk_size, SEEK_CUR);            break;        case RoQ_SOUND_MONO:            roq->audio_channels = 1;            url_fseek(pb, chunk_size, SEEK_CUR);            break;        case RoQ_SOUND_STEREO:            roq->audio_channels = 2;            url_fseek(pb, chunk_size, SEEK_CUR);            break;        default:            printf (" unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));            return AVERROR_INVALIDDATA;            break;        }        /* if all necessary parameters have been gathered, exit early */        if ((roq->width && roq->height) && roq->audio_channels)            break;    }    /* seek back to the first chunk */    url_fseek(pb, RoQ_CHUNK_PREAMBLE_SIZE, SEEK_SET);    /* initialize the decoders */    st = av_new_stream(s, 0);    if (!st)        return AVERROR_NOMEM;    roq->video_stream_index = st->index;    st->codec.codec_type = CODEC_TYPE_VIDEO;    st->codec.codec_id = CODEC_ID_ROQ;    st->codec.codec_tag = 0;  /* no fourcc */    st->codec.width = roq->width;    st->codec.height = roq->height;    if (roq->audio_channels) {        st = av_new_stream(s, 0);        if (!st)            return AVERROR_NOMEM;        roq->audio_stream_index = st->index;        st->codec.codec_type = CODEC_TYPE_AUDIO;        st->codec.codec_id = CODEC_ID_ROQ_DPCM;        st->codec.codec_tag = 0;  /* no tag */        st->codec.channels = roq->audio_channels;        st->codec.sample_rate = RoQ_AUDIO_SAMPLE_RATE;        st->codec.bits_per_sample = 16;        st->codec.bit_rate = st->codec.channels * st->codec.sample_rate *            st->codec.bits_per_sample;        st->codec.block_align = st->codec.channels * st->codec.bits_per_sample;    }    return 0;}