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
8819a320
Commit
8819a320
authored
Aug 24, 2021
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mca: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
8e3fab88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
mca.c
libavformat/mca.c
+12
-12
No files found.
libavformat/mca.c
View file @
8819a320
...
...
@@ -62,7 +62,7 @@ static int read_header(AVFormatContext *s)
avio_skip
(
s
->
pb
,
0x4
);
// skip the file magic
version
=
avio_rl16
(
s
->
pb
);
avio_skip
(
s
->
pb
,
0x2
);
// padding
par
->
ch
annels
=
avio_r8
(
s
->
pb
);
par
->
ch
_layout
.
nb_channels
=
avio_r8
(
s
->
pb
);
avio_skip
(
s
->
pb
,
0x1
);
// padding
m
->
block_size
=
avio_rl16
(
s
->
pb
);
nb_samples
=
avio_rl32
(
s
->
pb
);
...
...
@@ -85,7 +85,7 @@ static int read_header(AVFormatContext *s)
st
->
duration
=
nb_samples
;
// sanity checks
if
(
!
par
->
channels
||
par
->
sample_rate
<=
0
if
(
!
par
->
ch
_layout
.
nb_ch
annels
||
par
->
sample_rate
<=
0
||
loop_start
>
loop_end
||
m
->
block_count
<
1
)
return
AVERROR_INVALIDDATA
;
if
((
ret
=
av_dict_set_int
(
&
s
->
metadata
,
"loop_start"
,
...
...
@@ -96,8 +96,8 @@ static int read_header(AVFormatContext *s)
av_rescale
(
loop_end
,
AV_TIME_BASE
,
par
->
sample_rate
),
0
))
<
0
)
return
ret
;
if
((
32
+
4
+
m
->
block_size
)
>
(
INT_MAX
/
par
->
channels
)
||
(
32
+
4
+
m
->
block_size
)
*
par
->
channels
>
INT_MAX
-
8
)
if
((
32
+
4
+
m
->
block_size
)
>
(
INT_MAX
/
par
->
ch
_layout
.
nb_ch
annels
)
||
(
32
+
4
+
m
->
block_size
)
*
par
->
ch
_layout
.
nb_ch
annels
>
INT_MAX
-
8
)
return
AVERROR_INVALIDDATA
;
avpriv_set_pts_info
(
st
,
64
,
1
,
par
->
sample_rate
);
...
...
@@ -116,9 +116,9 @@ static int read_header(AVFormatContext *s)
}
}
else
if
(
version
==
5
)
{
// read data_start location from the header
if
(
0x30
*
par
->
channels
+
0x4
>
header_size
)
if
(
0x30
*
par
->
ch
_layout
.
nb_ch
annels
+
0x4
>
header_size
)
return
AVERROR_INVALIDDATA
;
data_offset
=
header_size
-
0x30
*
par
->
channels
-
0x4
;
data_offset
=
header_size
-
0x30
*
par
->
ch
_layout
.
nb_ch
annels
-
0x4
;
if
((
ret_size
=
avio_seek
(
s
->
pb
,
data_offset
,
SEEK_SET
))
<
0
)
return
ret_size
;
m
->
data_start
=
avio_rl32
(
s
->
pb
);
...
...
@@ -144,21 +144,21 @@ static int read_header(AVFormatContext *s)
}
// coefficient alignment = 0x30; metadata size = 0x14
if
(
0x30
*
par
->
channels
+
nb_metadata
*
0x14
>
header_size
)
if
(
0x30
*
par
->
ch
_layout
.
nb_ch
annels
+
nb_metadata
*
0x14
>
header_size
)
return
AVERROR_INVALIDDATA
;
coef_offset
=
header_size
-
0x30
*
par
->
channels
+
nb_metadata
*
0x14
;
header_size
-
0x30
*
par
->
ch
_layout
.
nb_ch
annels
+
nb_metadata
*
0x14
;
st
->
start_time
=
0
;
par
->
codec_id
=
AV_CODEC_ID_ADPCM_THP_LE
;
ret
=
ff_alloc_extradata
(
st
->
codecpar
,
32
*
par
->
channels
);
ret
=
ff_alloc_extradata
(
st
->
codecpar
,
32
*
par
->
ch
_layout
.
nb_ch
annels
);
if
(
ret
<
0
)
return
ret
;
if
((
ret_size
=
avio_seek
(
s
->
pb
,
coef_offset
,
SEEK_SET
))
<
0
)
return
ret_size
;
for
(
ch
=
0
;
ch
<
par
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
par
->
ch
_layout
.
nb_ch
annels
;
ch
++
)
{
if
((
ret
=
ffio_read_size
(
s
->
pb
,
par
->
extradata
+
ch
*
32
,
32
))
<
0
)
return
ret
;
// 0x30 (alignment) - 0x20 (actual size, 32) = 0x10 (padding)
...
...
@@ -187,7 +187,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if
(
m
->
current_block
>
m
->
block_count
)
return
AVERROR_EOF
;
if
((
ret
=
av_get_packet
(
s
->
pb
,
pkt
,
size
*
par
->
channels
))
<
0
)
if
((
ret
=
av_get_packet
(
s
->
pb
,
pkt
,
size
*
par
->
ch
_layout
.
nb_ch
annels
))
<
0
)
return
ret
;
pkt
->
duration
=
samples
;
pkt
->
stream_index
=
0
;
...
...
@@ -208,7 +208,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
if
(
timestamp
>=
m
->
block_count
)
timestamp
=
m
->
block_count
-
1
;
ret
=
avio_seek
(
s
->
pb
,
m
->
data_start
+
timestamp
*
m
->
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