1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avformat/mov: factorize setting little endian PCM streams

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2022-06-19 23:25:51 +02:00
parent 2a3640de84
commit cd83383f4d

View File

@ -1544,35 +1544,38 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void set_last_stream_little_endian(AVFormatContext *fc)
{
AVStream *st;
int little_endian;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if (fc->nb_streams < 1)
return;
st = fc->streams[fc->nb_streams-1];
little_endian = avio_rb16(pb) & 0xFF;
av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codecpar->codec_id) {
case AV_CODEC_ID_PCM_S24BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
break;
case AV_CODEC_ID_PCM_S32BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
break;
case AV_CODEC_ID_PCM_F32BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
break;
case AV_CODEC_ID_PCM_F64BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
break;
default:
break;
}
switch (st->codecpar->codec_id) {
case AV_CODEC_ID_PCM_S24BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
break;
case AV_CODEC_ID_PCM_S32BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
break;
case AV_CODEC_ID_PCM_F32BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
break;
case AV_CODEC_ID_PCM_F64BE:
st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
break;
default:
break;
}
}
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int little_endian = avio_rb16(pb) & 0xFF;
av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian);
if (little_endian == 1)
set_last_stream_little_endian(c->fc);
return 0;
}