Lines Matching +refs:s +refs:par +refs:s

55 static int rsd_read_header(AVFormatContext *s)  in rsd_read_header()  argument
57 AVIOContext *pb = s->pb; in rsd_read_header()
59 AVCodecParameters *par; in rsd_read_header() local
60 AVStream *st = avformat_new_stream(s, NULL); in rsd_read_header()
68 par = st->codecpar; in rsd_read_header()
69 par->codec_type = AVMEDIA_TYPE_AUDIO; in rsd_read_header()
70 par->codec_tag = avio_rl32(pb); in rsd_read_header()
71 par->codec_id = ff_codec_get_id(rsd_tags, par->codec_tag); in rsd_read_header()
72 if (!par->codec_id) { in rsd_read_header()
73 const char *tag_buf = av_fourcc2str(par->codec_tag); in rsd_read_header()
75 if (par->codec_tag == rsd_unsupported_tags[i]) { in rsd_read_header()
76 avpriv_request_sample(s, "Codec tag: %s", tag_buf); in rsd_read_header()
80 av_log(s, AV_LOG_ERROR, "Unknown codec tag: %s\n", tag_buf); in rsd_read_header()
84 par->channels = avio_rl32(pb); in rsd_read_header()
85 if (par->channels <= 0 || par->channels > INT_MAX / 36) { in rsd_read_header()
86 av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", par->channels); in rsd_read_header()
91 par->sample_rate = avio_rl32(pb); in rsd_read_header()
92 if (!par->sample_rate) in rsd_read_header()
97 switch (par->codec_id) { in rsd_read_header()
99 par->block_align = 2048; in rsd_read_header()
100 if ((ret = ff_alloc_extradata(par, 34)) < 0) in rsd_read_header()
102 memset(par->extradata, 0, 34); in rsd_read_header()
105 par->block_align = 16 * par->channels; in rsd_read_header()
107 st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); in rsd_read_header()
110 par->block_align = 20 * par->channels; in rsd_read_header()
112 st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); in rsd_read_header()
118 par->bits_per_coded_sample = 4; in rsd_read_header()
119 par->block_align = 36 * par->channels; in rsd_read_header()
121 st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); in rsd_read_header()
129 if ((ret = ff_get_extradata(s, par, s->pb, 32)) < 0) in rsd_read_header()
132 st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start); in rsd_read_header()
135 par->block_align = 8 * par->channels; in rsd_read_header()
136 avio_skip(s->pb, 0x1A4 - avio_tell(s->pb)); in rsd_read_header()
138 if ((ret = ff_alloc_extradata(st->codecpar, 32 * par->channels)) < 0) in rsd_read_header()
141 for (i = 0; i < par->channels; i++) { in rsd_read_header()
142 avio_read(s->pb, st->codecpar->extradata + 32 * i, 32); in rsd_read_header()
143 avio_skip(s->pb, 8); in rsd_read_header()
146 st->duration = (avio_size(pb) - start) / (8 * par->channels) * 14; in rsd_read_header()
154 st->duration = (avio_size(pb) - start) / 2 / par->channels; in rsd_read_header()
159 if (par->codec_id == AV_CODEC_ID_XMA2) { in rsd_read_header()
164 avpriv_set_pts_info(st, 64, 1, par->sample_rate); in rsd_read_header()
169 static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt) in rsd_read_packet() argument
171 AVCodecParameters *par = s->streams[0]->codecpar; in rsd_read_packet() local
175 if (avio_feof(s->pb)) in rsd_read_packet()
178 pos = avio_tell(s->pb); in rsd_read_packet()
179 if (par->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD || in rsd_read_packet()
180 par->codec_id == AV_CODEC_ID_ADPCM_PSX || in rsd_read_packet()
181 par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || in rsd_read_packet()
182 par->codec_id == AV_CODEC_ID_XMA2) { in rsd_read_packet()
183 ret = av_get_packet(s->pb, pkt, par->block_align); in rsd_read_packet()
184 } else if (par->codec_tag == MKTAG('W','A','D','P') && in rsd_read_packet()
185 par->channels > 1) { in rsd_read_packet()
188 ret = av_new_packet(pkt, par->block_align); in rsd_read_packet()
192 for (ch = 0; ch < par->channels; ch++) { in rsd_read_packet()
193 pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb); in rsd_read_packet()
194 pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb); in rsd_read_packet()
199 ret = av_get_packet(s->pb, pkt, size); in rsd_read_packet()
202 if (par->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1) in rsd_read_packet()