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
84f957e6
Commit
84f957e6
authored
May 13, 2019
by
Anton Khirnov
Committed by
James Almer
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsfdec: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
ca467f2a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
25 deletions
+34
-25
dsfdec.c
libavformat/dsfdec.c
+34
-25
No files found.
libavformat/dsfdec.c
View file @
84f957e6
...
@@ -38,15 +38,15 @@ static int dsf_probe(const AVProbeData *p)
...
@@ -38,15 +38,15 @@ static int dsf_probe(const AVProbeData *p)
return
AVPROBE_SCORE_MAX
;
return
AVPROBE_SCORE_MAX
;
}
}
static
const
uint64_
t
dsf_channel_layout
[]
=
{
static
const
AVChannelLayou
t
dsf_channel_layout
[]
=
{
0
,
{
.
order
=
AV_CHANNEL_ORDER_UNSPEC
}
,
AV_CH_LAYOUT_MONO
,
AV_CH
ANNEL
_LAYOUT_MONO
,
AV_CH_LAYOUT_STEREO
,
AV_CH
ANNEL
_LAYOUT_STEREO
,
AV_CH_LAYOUT_SURROUND
,
AV_CH
ANNEL
_LAYOUT_SURROUND
,
AV_CH_LAYOUT_QUAD
,
AV_CH
ANNEL
_LAYOUT_QUAD
,
AV_CH_LAYOUT_4POINT0
,
AV_CH
ANNEL
_LAYOUT_4POINT0
,
AV_CH_LAYOUT_5POINT0_BACK
,
AV_CH
ANNEL
_LAYOUT_5POINT0_BACK
,
AV_CH_LAYOUT_5POINT1_BACK
,
AV_CH
ANNEL
_LAYOUT_5POINT1_BACK
,
};
};
static
void
read_id3
(
AVFormatContext
*
s
,
uint64_t
id3pos
)
static
void
read_id3
(
AVFormatContext
*
s
,
uint64_t
id3pos
)
...
@@ -70,6 +70,7 @@ static int dsf_read_header(AVFormatContext *s)
...
@@ -70,6 +70,7 @@ static int dsf_read_header(AVFormatContext *s)
AVStream
*
st
;
AVStream
*
st
;
uint64_t
id3pos
;
uint64_t
id3pos
;
unsigned
int
channel_type
;
unsigned
int
channel_type
;
int
channels
;
avio_skip
(
pb
,
4
);
avio_skip
(
pb
,
4
);
if
(
avio_rl64
(
pb
)
!=
28
)
if
(
avio_rl64
(
pb
)
!=
28
)
...
@@ -104,15 +105,21 @@ static int dsf_read_header(AVFormatContext *s)
...
@@ -104,15 +105,21 @@ static int dsf_read_header(AVFormatContext *s)
channel_type
=
avio_rl32
(
pb
);
channel_type
=
avio_rl32
(
pb
);
if
(
channel_type
<
FF_ARRAY_ELEMS
(
dsf_channel_layout
))
if
(
channel_type
<
FF_ARRAY_ELEMS
(
dsf_channel_layout
))
st
->
codecpar
->
ch
annel
_layout
=
dsf_channel_layout
[
channel_type
];
st
->
codecpar
->
ch_layout
=
dsf_channel_layout
[
channel_type
];
if
(
!
st
->
codecpar
->
ch
annel_layout
)
if
(
!
st
->
codecpar
->
ch
_layout
.
nb_channels
)
avpriv_request_sample
(
s
,
"channel type %i"
,
channel_type
);
avpriv_request_sample
(
s
,
"channel type %i"
,
channel_type
);
st
->
codecpar
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
codecpar
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
codecpar
->
channels
=
avio_rl32
(
pb
);
channels
=
avio_rl32
(
pb
);
if
(
!
st
->
codecpar
->
ch_layout
.
nb_channels
)
{
st
->
codecpar
->
ch_layout
.
nb_channels
=
channels
;
}
else
if
(
channels
!=
st
->
codecpar
->
ch_layout
.
nb_channels
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Channel count mismatch
\n
"
);
return
AVERROR
(
EINVAL
);
}
st
->
codecpar
->
sample_rate
=
avio_rl32
(
pb
)
/
8
;
st
->
codecpar
->
sample_rate
=
avio_rl32
(
pb
)
/
8
;
if
(
st
->
codecpar
->
channels
<=
0
)
if
(
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
<=
0
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
switch
(
avio_rl32
(
pb
))
{
switch
(
avio_rl32
(
pb
))
{
...
@@ -123,14 +130,15 @@ static int dsf_read_header(AVFormatContext *s)
...
@@ -123,14 +130,15 @@ static int dsf_read_header(AVFormatContext *s)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
dsf
->
audio_size
=
avio_rl64
(
pb
)
/
8
*
st
->
codecpar
->
channels
;
dsf
->
audio_size
=
avio_rl64
(
pb
)
/
8
*
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
;
st
->
codecpar
->
block_align
=
avio_rl32
(
pb
);
st
->
codecpar
->
block_align
=
avio_rl32
(
pb
);
if
(
st
->
codecpar
->
block_align
>
INT_MAX
/
st
->
codecpar
->
channels
||
st
->
codecpar
->
block_align
<=
0
)
{
if
(
st
->
codecpar
->
block_align
>
INT_MAX
/
st
->
codecpar
->
ch_layout
.
nb_channels
||
st
->
codecpar
->
block_align
<=
0
)
{
avpriv_request_sample
(
s
,
"block_align invalid"
);
avpriv_request_sample
(
s
,
"block_align invalid"
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
}
}
st
->
codecpar
->
block_align
*=
st
->
codecpar
->
channels
;
st
->
codecpar
->
block_align
*=
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
;
st
->
codecpar
->
bit_rate
=
st
->
codecpar
->
channels
*
8LL
*
st
->
codecpar
->
sample_rate
;
st
->
codecpar
->
bit_rate
=
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
*
8LL
*
st
->
codecpar
->
sample_rate
;
avpriv_set_pts_info
(
st
,
64
,
1
,
st
->
codecpar
->
sample_rate
);
avpriv_set_pts_info
(
st
,
64
,
1
,
st
->
codecpar
->
sample_rate
);
avio_skip
(
pb
,
4
);
avio_skip
(
pb
,
4
);
...
@@ -152,6 +160,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -152,6 +160,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
AVStream
*
st
=
s
->
streams
[
0
];
AVStream
*
st
=
s
->
streams
[
0
];
int64_t
pos
=
avio_tell
(
pb
);
int64_t
pos
=
avio_tell
(
pb
);
int
channels
=
st
->
codecpar
->
ch_layout
.
nb_channels
;
int
ret
;
int
ret
;
if
(
pos
>=
dsf
->
data_end
)
if
(
pos
>=
dsf
->
data_end
)
...
@@ -173,19 +182,19 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -173,19 +182,19 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
if
((
ret
=
av_new_packet
(
pkt
,
packet_size
))
<
0
)
if
((
ret
=
av_new_packet
(
pkt
,
packet_size
))
<
0
)
return
ret
;
return
ret
;
dst
=
pkt
->
data
;
dst
=
pkt
->
data
;
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
;
ch
++
)
{
ret
=
avio_read
(
pb
,
dst
,
packet_size
/
st
->
codecpar
->
channels
);
ret
=
avio_read
(
pb
,
dst
,
packet_size
/
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
);
if
(
ret
<
packet_size
/
st
->
codecpar
->
channels
)
if
(
ret
<
packet_size
/
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
)
return
AVERROR_EOF
;
return
AVERROR_EOF
;
dst
+=
ret
;
dst
+=
ret
;
avio_skip
(
pb
,
skip_size
/
st
->
codecpar
->
channels
);
avio_skip
(
pb
,
skip_size
/
st
->
codecpar
->
ch
_layout
.
nb_ch
annels
);
}
}
pkt
->
pos
=
pos
;
pkt
->
pos
=
pos
;
pkt
->
stream_index
=
0
;
pkt
->
stream_index
=
0
;
pkt
->
pts
=
(
pos
-
si
->
data_offset
)
/
st
->
codecpar
->
channels
;
pkt
->
pts
=
(
pos
-
si
->
data_offset
)
/
channels
;
pkt
->
duration
=
packet_size
/
st
->
codecpar
->
channels
;
pkt
->
duration
=
packet_size
/
channels
;
return
0
;
return
0
;
}
}
}
}
...
@@ -194,8 +203,8 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -194,8 +203,8 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
return
ret
;
return
ret
;
pkt
->
stream_index
=
0
;
pkt
->
stream_index
=
0
;
pkt
->
pts
=
(
pos
-
si
->
data_offset
)
/
st
->
codecpar
->
channels
;
pkt
->
pts
=
(
pos
-
si
->
data_offset
)
/
channels
;
pkt
->
duration
=
st
->
codecpar
->
block_align
/
st
->
codecpar
->
channels
;
pkt
->
duration
=
st
->
codecpar
->
block_align
/
channels
;
return
0
;
return
0
;
}
}
...
...
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