Commit ebb83e2d authored by bnnm's avatar bnnm Committed by Paul B Mahol

avformat/msf: fix codec 4 (joint stereo ATRAC3) and align

Codec 4 (frame size 98) uses joint stereo per spec and examples.
Also removed an incorrect "align" var which wasn't used anyway (it was overwrittern).

Probably all/only .AT3 of frame size 98 are JS, too.
Signed-off-by: 's avatarbnnm <bananaman255@gmail.com>
parent ec33ade7
...@@ -42,7 +42,7 @@ static int msf_probe(AVProbeData *p) ...@@ -42,7 +42,7 @@ static int msf_probe(AVProbeData *p)
static int msf_read_header(AVFormatContext *s) static int msf_read_header(AVFormatContext *s)
{ {
unsigned codec, align, size; unsigned codec, size;
AVStream *st; AVStream *st;
int ret; int ret;
...@@ -61,10 +61,7 @@ static int msf_read_header(AVFormatContext *s) ...@@ -61,10 +61,7 @@ static int msf_read_header(AVFormatContext *s)
st->codecpar->sample_rate = avio_rb32(s->pb); st->codecpar->sample_rate = avio_rb32(s->pb);
if (st->codecpar->sample_rate <= 0) if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
align = avio_rb32(s->pb) ; // avio_rb32(s->pb); /* byte flags with encoder info */
if (align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
st->codecpar->block_align = align;
switch (codec) { switch (codec) {
case 0: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; break; case 0: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; break;
case 3: st->codecpar->block_align = 16 * st->codecpar->channels; case 3: st->codecpar->block_align = 16 * st->codecpar->channels;
...@@ -76,8 +73,10 @@ static int msf_read_header(AVFormatContext *s) ...@@ -76,8 +73,10 @@ static int msf_read_header(AVFormatContext *s)
if (ret < 0) if (ret < 0)
return ret; return ret;
memset(st->codecpar->extradata, 0, st->codecpar->extradata_size); memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
AV_WL16(st->codecpar->extradata, 1); AV_WL16(st->codecpar->extradata, 1); /* version */
AV_WL16(st->codecpar->extradata+4, 4096); AV_WL16(st->codecpar->extradata+2, 2048 * st->codecpar->channels); /* unknown size */
AV_WL16(st->codecpar->extradata+6, codec == 4 ? 1 : 0); /* joint stereo */
AV_WL16(st->codecpar->extradata+8, codec == 4 ? 1 : 0); /* joint stereo (repeat?) */
AV_WL16(st->codecpar->extradata+10, 1); AV_WL16(st->codecpar->extradata+10, 1);
st->codecpar->codec_id = AV_CODEC_ID_ATRAC3; break; st->codecpar->codec_id = AV_CODEC_ID_ATRAC3; break;
case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW; case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment