| 53 | }; |
| 54 | |
| 55 | static int ircam_read_header(AVFormatContext *s) |
| 56 | { |
| 57 | uint32_t magic, sample_rate, channels, tag; |
| 58 | const AVCodecTag *tags; |
| 59 | int le = -1, i; |
| 60 | AVStream *st; |
| 61 | |
| 62 | magic = avio_rl32(s->pb); |
| 63 | for (i = 0; i < 7; i++) { |
| 64 | if (magic == table[i].magic) { |
| 65 | le = table[i].is_le; |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if (le == 1) { |
| 71 | sample_rate = lrintf(av_int2float(avio_rl32(s->pb))); |
| 72 | channels = avio_rl32(s->pb); |
| 73 | tag = avio_rl32(s->pb); |
| 74 | tags = ff_codec_ircam_le_tags; |
| 75 | } else if (le == 0) { |
| 76 | sample_rate = lrintf(av_int2float(avio_rb32(s->pb))); |
| 77 | channels = avio_rb32(s->pb); |
| 78 | tag = avio_rb32(s->pb); |
| 79 | tags = ff_codec_ircam_be_tags; |
| 80 | } else { |
| 81 | return AVERROR_INVALIDDATA; |
| 82 | } |
| 83 | |
| 84 | if (!channels || !sample_rate) |
| 85 | return AVERROR_INVALIDDATA; |
| 86 | |
| 87 | st = avformat_new_stream(s, NULL); |
| 88 | if (!st) |
| 89 | return AVERROR(ENOMEM); |
| 90 | |
| 91 | st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
| 92 | st->codecpar->ch_layout.nb_channels = channels; |
| 93 | if (st->codecpar->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) |
| 94 | return AVERROR(ENOSYS); |
| 95 | st->codecpar->sample_rate = sample_rate; |
| 96 | |
| 97 | st->codecpar->codec_id = ff_codec_get_id(tags, tag); |
| 98 | if (st->codecpar->codec_id == AV_CODEC_ID_NONE) { |
| 99 | av_log(s, AV_LOG_ERROR, "unknown tag %"PRIx32"\n", tag); |
| 100 | return AVERROR_INVALIDDATA; |
| 101 | } |
| 102 | |
| 103 | st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id); |
| 104 | st->codecpar->block_align = st->codecpar->bits_per_coded_sample * |
| 105 | st->codecpar->ch_layout.nb_channels / 8; |
| 106 | avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); |
| 107 | avio_skip(s->pb, 1008); |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | const FFInputFormat ff_ircam_demuxer = { |
nothing calls this directly
no test coverage detected