Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
8af33cb3
Commit
8af33cb3
authored
Oct 14, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atrac3: decode mono directly to the output buffer
parent
c4a6fde3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
atrac3.c
libavcodec/atrac3.c
+11
-14
No files found.
libavcodec/atrac3.c
View file @
8af33cb3
...
...
@@ -719,7 +719,8 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
* @param databuf the input data
*/
static
int
decodeFrame
(
ATRAC3Context
*
q
,
const
uint8_t
*
databuf
)
static
int
decodeFrame
(
ATRAC3Context
*
q
,
const
uint8_t
*
databuf
,
float
*
out_samples
)
{
int
result
,
i
;
float
*
p1
,
*
p2
,
*
p3
,
*
p4
;
...
...
@@ -731,7 +732,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
/* decode Sound Unit 1 */
init_get_bits
(
&
q
->
gb
,
databuf
,
q
->
bits_per_frame
);
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
q
->
pUnits
,
q
->
outS
amples
,
0
,
JOINT_STEREO
);
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
q
->
pUnits
,
out_s
amples
,
0
,
JOINT_STEREO
);
if
(
result
!=
0
)
return
(
result
);
...
...
@@ -772,14 +773,14 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
}
/* Decode Sound Unit 2. */
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
&
q
->
pUnits
[
1
],
&
q
->
outS
amples
[
1024
],
1
,
JOINT_STEREO
);
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
&
q
->
pUnits
[
1
],
&
out_s
amples
[
1024
],
1
,
JOINT_STEREO
);
if
(
result
!=
0
)
return
(
result
);
/* Reconstruct the channel coefficients. */
reverseMatrixing
(
q
->
outSamples
,
&
q
->
outS
amples
[
1024
],
q
->
matrix_coeff_index_prev
,
q
->
matrix_coeff_index_now
);
reverseMatrixing
(
out_samples
,
&
out_s
amples
[
1024
],
q
->
matrix_coeff_index_prev
,
q
->
matrix_coeff_index_now
);
channelWeighting
(
q
->
outSamples
,
&
q
->
outS
amples
[
1024
],
q
->
weighting_delay
);
channelWeighting
(
out_samples
,
&
out_s
amples
[
1024
],
q
->
weighting_delay
);
}
else
{
/* normal stereo mode or mono */
...
...
@@ -789,14 +790,14 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
/* Set the bitstream reader at the start of a channel sound unit. */
init_get_bits
(
&
q
->
gb
,
databuf
+
((
i
*
q
->
bytes_per_frame
)
/
q
->
channels
),
(
q
->
bits_per_frame
)
/
q
->
channels
);
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
&
q
->
pUnits
[
i
],
&
q
->
outS
amples
[
i
*
1024
],
i
,
q
->
codingMode
);
result
=
decodeChannelSoundUnit
(
q
,
&
q
->
gb
,
&
q
->
pUnits
[
i
],
&
out_s
amples
[
i
*
1024
],
i
,
q
->
codingMode
);
if
(
result
!=
0
)
return
(
result
);
}
}
/* Apply the iQMF synthesis filter. */
p1
=
q
->
outS
amples
;
p1
=
out_s
amples
;
for
(
i
=
0
;
i
<
q
->
channels
;
i
++
)
{
p2
=
p1
+
256
;
p3
=
p2
+
256
;
...
...
@@ -842,19 +843,15 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
databuf
=
buf
;
}
result
=
decodeFrame
(
q
,
databuf
);
result
=
decodeFrame
(
q
,
databuf
,
q
->
channels
==
2
?
q
->
outSamples
:
samples
);
if
(
result
!=
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Frame decoding error!
\n
"
);
return
-
1
;
}
if
(
q
->
channels
==
1
)
{
/* mono */
for
(
i
=
0
;
i
<
1024
;
i
++
)
samples
[
i
]
=
q
->
outSamples
[
i
];
}
else
{
/* stereo */
/* interleave */
if
(
q
->
channels
==
2
)
{
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
samples
[
i
*
2
]
=
q
->
outSamples
[
i
];
samples
[
i
*
2
+
1
]
=
q
->
outSamples
[
1024
+
i
];
...
...
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