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
cdd0e0de
Commit
cdd0e0de
authored
Oct 19, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atrac3: use AVCodecContext.block_align instead of keeping a private copy
parent
64ebbb8f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
atrac3.c
libavcodec/atrac3.c
+13
-17
No files found.
libavcodec/atrac3.c
View file @
cdd0e0de
...
...
@@ -95,8 +95,6 @@ typedef struct ATRAC3Context {
int
samples_per_channel
;
int
samples_per_frame
;
int
bits_per_frame
;
int
bytes_per_frame
;
ChannelUnit
*
units
;
//@}
//@{
...
...
@@ -723,7 +721,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
if
(
q
->
coding_mode
==
JOINT_STEREO
)
{
/* channel coupling mode */
/* decode Sound Unit 1 */
init_get_bits
(
&
q
->
gb
,
databuf
,
q
->
bits_per_frame
);
init_get_bits
(
&
q
->
gb
,
databuf
,
avctx
->
block_align
*
8
);
ret
=
decode_channel_sound_unit
(
q
,
&
q
->
gb
,
q
->
units
,
out_samples
[
0
],
0
,
JOINT_STEREO
);
...
...
@@ -733,26 +731,26 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
/* Framedata of the su2 in the joint-stereo mode is encoded in
* reverse byte order so we need to swap it first. */
if
(
databuf
==
q
->
decoded_bytes_buffer
)
{
uint8_t
*
ptr2
=
q
->
decoded_bytes_buffer
+
q
->
bytes_per_frame
-
1
;
uint8_t
*
ptr2
=
q
->
decoded_bytes_buffer
+
avctx
->
block_align
-
1
;
ptr1
=
q
->
decoded_bytes_buffer
;
for
(
i
=
0
;
i
<
q
->
bytes_per_frame
/
2
;
i
++
,
ptr1
++
,
ptr2
--
)
for
(
i
=
0
;
i
<
avctx
->
block_align
/
2
;
i
++
,
ptr1
++
,
ptr2
--
)
FFSWAP
(
uint8_t
,
*
ptr1
,
*
ptr2
);
}
else
{
const
uint8_t
*
ptr2
=
databuf
+
q
->
bytes_per_frame
-
1
;
for
(
i
=
0
;
i
<
q
->
bytes_per_frame
;
i
++
)
const
uint8_t
*
ptr2
=
databuf
+
avctx
->
block_align
-
1
;
for
(
i
=
0
;
i
<
avctx
->
block_align
;
i
++
)
q
->
decoded_bytes_buffer
[
i
]
=
*
ptr2
--
;
}
/* Skip the sync codes (0xF8). */
ptr1
=
q
->
decoded_bytes_buffer
;
for
(
i
=
4
;
*
ptr1
==
0xF8
;
i
++
,
ptr1
++
)
{
if
(
i
>=
q
->
bytes_per_frame
)
if
(
i
>=
avctx
->
block_align
)
return
AVERROR_INVALIDDATA
;
}
/* set the bitstream reader at the start of the second Sound Unit*/
init_get_bits
(
&
q
->
gb
,
ptr1
,
q
->
bits_per_frame
);
init_get_bits
(
&
q
->
gb
,
ptr1
,
avctx
->
block_align
*
8
);
/* Fill the Weighting coeffs delay buffer */
memmove
(
q
->
weighting_delay
,
&
q
->
weighting_delay
[
2
],
4
*
sizeof
(
int
));
...
...
@@ -783,8 +781,8 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
for
(
i
=
0
;
i
<
avctx
->
channels
;
i
++
)
{
/* Set the bitstream reader at the start of a channel sound unit. */
init_get_bits
(
&
q
->
gb
,
databuf
+
i
*
q
->
bytes_per_frame
/
avctx
->
channels
,
q
->
bits_per_frame
/
avctx
->
channels
);
databuf
+
i
*
avctx
->
block_align
/
avctx
->
channels
,
avctx
->
block_align
*
8
/
avctx
->
channels
);
ret
=
decode_channel_sound_unit
(
q
,
&
q
->
gb
,
&
q
->
units
[
i
],
out_samples
[
i
],
i
,
q
->
coding_mode
);
...
...
@@ -861,8 +859,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
/* Take data from the AVCodecContext (RM container). */
q
->
sample_rate
=
avctx
->
sample_rate
;
q
->
bit_rate
=
avctx
->
bit_rate
;
q
->
bits_per_frame
=
avctx
->
block_align
*
8
;
q
->
bytes_per_frame
=
avctx
->
block_align
;
if
(
avctx
->
channels
<=
0
||
avctx
->
channels
>
2
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Channel configuration error!
\n
"
);
...
...
@@ -889,11 +885,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
q
->
coding_mode
=
q
->
coding_mode
?
JOINT_STEREO
:
STEREO
;
q
->
scrambled_stream
=
0
;
if
(
q
->
bytes_per_frame
!=
96
*
avctx
->
channels
*
q
->
frame_factor
&&
q
->
bytes_per_frame
!=
152
*
avctx
->
channels
*
q
->
frame_factor
&&
q
->
bytes_per_frame
!=
192
*
avctx
->
channels
*
q
->
frame_factor
)
{
if
(
avctx
->
block_align
!=
96
*
avctx
->
channels
*
q
->
frame_factor
&&
avctx
->
block_align
!=
152
*
avctx
->
channels
*
q
->
frame_factor
&&
avctx
->
block_align
!=
192
*
avctx
->
channels
*
q
->
frame_factor
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Unknown frame/channel/frame_factor "
"configuration %d/%d/%d
\n
"
,
q
->
bytes_per_frame
,
"configuration %d/%d/%d
\n
"
,
avctx
->
block_align
,
avctx
->
channels
,
q
->
frame_factor
);
return
AVERROR_INVALIDDATA
;
}
...
...
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