- /* 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:
- av_log(s, AV_LOG_ERROR, " 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 */