static int sol_read_header(AVFormatContext *s) { unsigned int magic,tag; AVIOContext *pb = s->pb; unsigned int id, channels, rate, type; enum AVCodecID codec; AVStream *st; /* check ".snd" header */ magic = avio_rl16(pb); tag = avio_rl32(pb); if (tag != MKTAG('S', 'O', 'L', 0)) return -1; rate = avio_rl16(pb); type = avio_r8(pb); avio_skip(pb, 4); /* size */ if (magic != 0x0B8D) avio_r8(pb); /* newer SOLs contain padding byte */ codec = sol_codec_id(magic, type); channels = sol_channels(magic, type); if (codec == AV_CODEC_ID_SOL_DPCM) id = sol_codec_type(magic, type); else id = 0; /* now we are ready: build format streams */ st = avformat_new_stream(s, NULL); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = id; st->codec->codec_id = codec; st->codec->channels = channels; st->codec->channel_layout = channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; st->codec->sample_rate = rate; avpriv_set_pts_info(st, 64, 1, rate); return 0; }
static int sol_read_header(AVFormatContext *s, AVFormatParameters *ap) { int size; unsigned int magic,tag; AVIOContext *pb = s->pb; unsigned int id, channels, rate, type; enum CodecID codec; AVStream *st; /* check ".snd" header */ magic = avio_rl16(pb); tag = avio_rl32(pb); if (tag != MKTAG('S', 'O', 'L', 0)) return -1; rate = avio_rl16(pb); type = avio_r8(pb); size = avio_rl32(pb); if (magic != 0x0B8D) avio_r8(pb); /* newer SOLs contain padding byte */ codec = sol_codec_id(magic, type); channels = sol_channels(magic, type); if (codec == CODEC_ID_SOL_DPCM) id = sol_codec_type(magic, type); else id = 0; /* now we are ready: build format streams */ st = av_new_stream(s, 0); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = id; st->codec->codec_id = codec; st->codec->channels = channels; st->codec->sample_rate = rate; av_set_pts_info(st, 64, 1, rate); return 0; }