- /* check through the first 32 sectors for individual channels */
- for (i = 0; i < 32; i++) {
- if (get_buffer(pb, sector, RAW_CD_SECTOR_SIZE) != RAW_CD_SECTOR_SIZE)
- return AVERROR_IO;
-
-//printf("%02x %02x %02x %02x\n",sector[0x10],sector[0x11],sector[0x12],sector[0x13]);
-
- channel = sector[0x11];
- if (channel >= 32)
- return AVERROR_INVALIDDATA;
-
- switch (sector[0x12] & CDXA_TYPE_MASK) {
-
- case CDXA_TYPE_DATA:
- case CDXA_TYPE_VIDEO:
- /* check if this channel gets to be the dominant video channel */
- if (str->video_channel == -1) {
- /* qualify the magic number */
- if (LE_32(§or[0x18]) != STR_MAGIC)
- break;
- str->video_channel = channel;
- str->channels[channel].type = STR_VIDEO;
- str->channels[channel].width = LE_16(§or[0x28]);
- str->channels[channel].height = LE_16(§or[0x2A]);
-
- /* allocate a new AVStream */
- st = av_new_stream(s, 0);
- if (!st)
- return AVERROR_NOMEM;
- av_set_pts_info(st, 64, 1, 15);
-
- str->channels[channel].video_stream_index = st->index;
-
- st->codec->codec_type = CODEC_TYPE_VIDEO;
- st->codec->codec_id = CODEC_ID_MDEC;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = str->channels[channel].width;
- st->codec->height = str->channels[channel].height;
- }
- break;
-
- case CDXA_TYPE_AUDIO:
- /* check if this channel gets to be the dominant audio channel */
- if (str->audio_channel == -1) {
- int fmt;
- str->audio_channel = channel;
- str->channels[channel].type = STR_AUDIO;
- str->channels[channel].channels =
- (sector[0x13] & 0x01) ? 2 : 1;
- str->channels[channel].sample_rate =
- (sector[0x13] & 0x04) ? 18900 : 37800;
- str->channels[channel].bits =
- (sector[0x13] & 0x10) ? 8 : 4;
-
- /* allocate a new AVStream */
- st = av_new_stream(s, 0);
- if (!st)
- return AVERROR_NOMEM;
- av_set_pts_info(st, 64, 128, str->channels[channel].sample_rate);
-
- str->channels[channel].audio_stream_index = st->index;
-
- fmt = sector[0x13];
- st->codec->codec_type = CODEC_TYPE_AUDIO;
- st->codec->codec_id = CODEC_ID_ADPCM_XA;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->channels = (fmt&1)?2:1;
- st->codec->sample_rate = (fmt&4)?18900:37800;
- // st->codec->bit_rate = 0; //FIXME;
- st->codec->block_align = 128;
- }
- break;
-
- default:
- /* ignore */
- break;
- }