Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
658102a8
Commit
658102a8
authored
May 13, 2019
by
Anton Khirnov
Committed by
James Almer
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
brstm: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
8269fbcb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
brstm.c
libavformat/brstm.c
+22
-21
No files found.
libavformat/brstm.c
View file @
658102a8
...
...
@@ -209,8 +209,8 @@ static int read_header(AVFormatContext *s)
loop
=
avio_r8
(
s
->
pb
);
// loop flag
st
->
codecpar
->
codec_id
=
codec
;
st
->
codecpar
->
channels
=
avio_r8
(
s
->
pb
);
if
(
!
st
->
codecpar
->
channels
)
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
=
avio_r8
(
s
->
pb
);
if
(
!
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
)
return
AVERROR_INVALIDDATA
;
avio_skip
(
s
->
pb
,
1
);
// padding
...
...
@@ -246,14 +246,14 @@ static int read_header(AVFormatContext *s)
}
b
->
block_size
=
read32
(
s
);
if
(
b
->
block_size
>
UINT32_MAX
/
st
->
codecpar
->
channels
)
if
(
b
->
block_size
>
UINT32_MAX
/
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
)
return
AVERROR_INVALIDDATA
;
b
->
samples_per_block
=
read32
(
s
);
b
->
last_block_used_bytes
=
read32
(
s
);
b
->
last_block_samples
=
read32
(
s
);
b
->
last_block_size
=
read32
(
s
);
if
(
b
->
last_block_size
>
UINT32_MAX
/
st
->
codecpar
->
channels
)
if
(
b
->
last_block_size
>
UINT32_MAX
/
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
)
return
AVERROR_INVALIDDATA
;
if
(
b
->
last_block_used_bytes
>
b
->
last_block_size
)
return
AVERROR_INVALIDDATA
;
...
...
@@ -266,24 +266,24 @@ static int read_header(AVFormatContext *s)
if
(
!
bfstm
)
toffset
=
read32
(
s
)
+
16LL
;
else
toffset
=
toffset
+
read32
(
s
)
+
st
->
codecpar
->
channels
*
8
-
8
;
toffset
=
toffset
+
read32
(
s
)
+
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
*
8
-
8
;
if
(
toffset
>
size
)
return
AVERROR_INVALIDDATA
;
if
(
!
bfstm
)
{
avio_skip
(
s
->
pb
,
pos
+
toffset
-
avio_tell
(
s
->
pb
)
-
8LL
*
(
st
->
codecpar
->
channels
+
1
));
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
channels
;
ch
++
)
{
avio_skip
(
s
->
pb
,
pos
+
toffset
-
avio_tell
(
s
->
pb
)
-
8LL
*
(
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
+
1
));
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
;
ch
++
)
{
avio_skip
(
s
->
pb
,
4
);
b
->
offsets
[
ch
].
channel
=
ch
;
b
->
offsets
[
ch
].
offset
=
read32
(
s
);
}
qsort
(
b
->
offsets
,
st
->
codecpar
->
channels
,
sizeof
(
*
b
->
offsets
),
sort_offsets
);
qsort
(
b
->
offsets
,
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
,
sizeof
(
*
b
->
offsets
),
sort_offsets
);
}
avio_skip
(
s
->
pb
,
pos
+
toffset
-
avio_tell
(
s
->
pb
));
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
;
ch
++
)
{
if
(
!
bfstm
)
avio_skip
(
s
->
pb
,
pos
+
16LL
+
b
->
offsets
[
ch
].
offset
-
avio_tell
(
s
->
pb
));
...
...
@@ -313,7 +313,7 @@ static int read_header(AVFormatContext *s)
codec
!=
AV_CODEC_ID_ADPCM_THP_LE
)
goto
skip
;
asize
=
b
->
block_count
*
st
->
codecpar
->
channels
*
4
;
asize
=
b
->
block_count
*
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
*
4
;
if
(
size
<
asize
)
return
AVERROR_INVALIDDATA
;
if
(
b
->
adpc
)
{
...
...
@@ -369,6 +369,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecParameters
*
par
=
s
->
streams
[
0
]
->
codecpar
;
BRSTMDemuxContext
*
b
=
s
->
priv_data
;
uint32_t
samples
,
size
,
skip
=
0
;
int
channels
=
par
->
ch_layout
.
nb_channels
;
int
ret
,
i
;
if
(
avio_feof
(
s
->
pb
))
...
...
@@ -404,24 +405,24 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
if
(
size
>
(
INT_MAX
-
32
-
4
)
||
(
32
+
4
+
size
)
>
(
INT_MAX
/
par
->
channels
)
||
(
32
+
4
+
size
)
*
par
->
channels
>
INT_MAX
-
8
)
(
32
+
4
+
size
)
>
(
INT_MAX
/
channels
)
||
(
32
+
4
+
size
)
*
channels
>
INT_MAX
-
8
)
return
AVERROR_INVALIDDATA
;
if
((
ret
=
av_new_packet
(
pkt
,
8
+
(
32
+
4
+
size
)
*
par
->
channels
))
<
0
)
if
((
ret
=
av_new_packet
(
pkt
,
8
+
(
32
+
4
+
size
)
*
channels
))
<
0
)
return
ret
;
dst
=
pkt
->
data
;
if
(
par
->
codec_id
==
AV_CODEC_ID_ADPCM_THP_LE
)
{
bytestream_put_le32
(
&
dst
,
size
*
par
->
channels
);
bytestream_put_le32
(
&
dst
,
size
*
channels
);
bytestream_put_le32
(
&
dst
,
samples
);
}
else
{
bytestream_put_be32
(
&
dst
,
size
*
par
->
channels
);
bytestream_put_be32
(
&
dst
,
size
*
channels
);
bytestream_put_be32
(
&
dst
,
samples
);
}
bytestream_put_buffer
(
&
dst
,
b
->
table
,
32
*
par
->
channels
);
bytestream_put_buffer
(
&
dst
,
b
->
adpc
+
4
*
par
->
channels
*
(
b
->
current_block
-
1
),
4
*
par
->
channels
);
bytestream_put_buffer
(
&
dst
,
b
->
table
,
32
*
channels
);
bytestream_put_buffer
(
&
dst
,
b
->
adpc
+
4
*
channels
*
(
b
->
current_block
-
1
),
4
*
channels
);
for
(
i
=
0
;
i
<
par
->
channels
;
i
++
)
{
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
ret
=
avio_read
(
s
->
pb
,
dst
,
size
);
dst
+=
size
;
avio_skip
(
s
->
pb
,
skip
);
...
...
@@ -431,7 +432,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt
->
duration
=
samples
;
}
else
{
size
*=
par
->
channels
;
size
*=
channels
;
ret
=
av_get_packet
(
s
->
pb
,
pkt
,
size
);
}
...
...
@@ -456,7 +457,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
if
(
timestamp
>=
b
->
block_count
)
timestamp
=
b
->
block_count
-
1
;
ret
=
avio_seek
(
s
->
pb
,
b
->
data_start
+
timestamp
*
b
->
block_size
*
st
->
codecpar
->
channels
,
SEEK_SET
);
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
,
SEEK_SET
);
if
(
ret
<
0
)
return
ret
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment