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
837bbd19
Commit
837bbd19
authored
Nov 20, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adx: remove unneeded post-decode channel interleaving
instead interleave channels while decoding
parent
e2d1eace
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
39 deletions
+20
-39
adx.h
libavcodec/adx.h
+1
-0
adxdec.c
libavcodec/adxdec.c
+19
-39
No files found.
libavcodec/adx.h
View file @
837bbd19
...
@@ -36,6 +36,7 @@ typedef struct {
...
@@ -36,6 +36,7 @@ typedef struct {
}
ADXChannelState
;
}
ADXChannelState
;
typedef
struct
{
typedef
struct
{
int
channels
;
ADXChannelState
prev
[
2
];
ADXChannelState
prev
[
2
];
int
header_parsed
;
int
header_parsed
;
unsigned
char
dec_temp
[
18
*
2
];
unsigned
char
dec_temp
[
18
*
2
];
...
...
libavcodec/adxdec.c
View file @
837bbd19
...
@@ -45,8 +45,9 @@ static av_cold int adx_decode_init(AVCodecContext *avctx)
...
@@ -45,8 +45,9 @@ static av_cold int adx_decode_init(AVCodecContext *avctx)
* 2nd-order LPC filter applied to it to form the output signal for a single
* 2nd-order LPC filter applied to it to form the output signal for a single
* channel.
* channel.
*/
*/
static
void
adx_decode
(
int16_t
*
out
,
const
uint8_t
*
in
,
ADXChannelState
*
prev
)
static
void
adx_decode
(
ADXContext
*
c
,
int16_t
*
out
,
const
uint8_t
*
in
,
int
ch
)
{
{
ADXChannelState
*
prev
=
&
c
->
prev
[
ch
];
int
scale
=
AV_RB16
(
in
);
int
scale
=
AV_RB16
(
in
);
int
i
;
int
i
;
int
s0
,
s1
,
s2
,
d
;
int
s0
,
s1
,
s2
,
d
;
...
@@ -60,33 +61,21 @@ static void adx_decode(int16_t *out, const uint8_t *in, ADXChannelState *prev)
...
@@ -60,33 +61,21 @@ static void adx_decode(int16_t *out, const uint8_t *in, ADXChannelState *prev)
s0
=
(
BASEVOL
*
d
*
scale
+
SCALE1
*
s1
-
SCALE2
*
s2
)
>>
14
;
s0
=
(
BASEVOL
*
d
*
scale
+
SCALE1
*
s1
-
SCALE2
*
s2
)
>>
14
;
s2
=
s1
;
s2
=
s1
;
s1
=
av_clip_int16
(
s0
);
s1
=
av_clip_int16
(
s0
);
*
out
++
=
s1
;
*
out
=
s1
;
out
+=
c
->
channels
;
d
=
in
[
i
];
d
=
in
[
i
];
d
=
(
signed
char
)(
d
<<
4
)
>>
4
;
d
=
(
signed
char
)(
d
<<
4
)
>>
4
;
s0
=
(
BASEVOL
*
d
*
scale
+
SCALE1
*
s1
-
SCALE2
*
s2
)
>>
14
;
s0
=
(
BASEVOL
*
d
*
scale
+
SCALE1
*
s1
-
SCALE2
*
s2
)
>>
14
;
s2
=
s1
;
s2
=
s1
;
s1
=
av_clip_int16
(
s0
);
s1
=
av_clip_int16
(
s0
);
*
out
++
=
s1
;
*
out
=
s1
;
out
+=
c
->
channels
;
}
}
prev
->
s1
=
s1
;
prev
->
s1
=
s1
;
prev
->
s2
=
s2
;
prev
->
s2
=
s2
;
}
}
static
void
adx_decode_stereo
(
int16_t
*
out
,
const
uint8_t
*
in
,
ADXChannelState
*
prev
)
{
short
tmp
[
32
*
2
];
int
i
;
adx_decode
(
tmp
,
in
,
prev
);
adx_decode
(
tmp
+
32
,
in
+
18
,
prev
+
1
);
for
(
i
=
0
;
i
<
32
;
i
++
)
{
out
[
i
*
2
]
=
tmp
[
i
];
out
[
i
*
2
+
1
]
=
tmp
[
i
+
32
];
}
}
/**
/**
* Decode stream header.
* Decode stream header.
*
*
...
@@ -98,6 +87,7 @@ static void adx_decode_stereo(int16_t *out,const uint8_t *in,
...
@@ -98,6 +87,7 @@ static void adx_decode_stereo(int16_t *out,const uint8_t *in,
static
int
adx_decode_header
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
static
int
adx_decode_header
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
bufsize
)
int
bufsize
)
{
{
ADXContext
*
c
=
avctx
->
priv_data
;
int
offset
;
int
offset
;
if
(
buf
[
0
]
!=
0x80
)
if
(
buf
[
0
]
!=
0x80
)
...
@@ -106,7 +96,7 @@ static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
...
@@ -106,7 +96,7 @@ static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
if
(
bufsize
<
offset
||
memcmp
(
buf
+
offset
-
6
,
"(c)CRI"
,
6
))
if
(
bufsize
<
offset
||
memcmp
(
buf
+
offset
-
6
,
"(c)CRI"
,
6
))
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
avctx
->
channels
=
buf
[
7
];
c
->
channels
=
avctx
->
channels
=
buf
[
7
];
if
(
avctx
->
channels
>
2
)
if
(
avctx
->
channels
>
2
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
avctx
->
sample_rate
=
AV_RB32
(
buf
+
8
);
avctx
->
sample_rate
=
AV_RB32
(
buf
+
8
);
...
@@ -149,29 +139,19 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
...
@@ -149,29 +139,19 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
memcpy
(
c
->
dec_temp
+
c
->
in_temp
,
buf
,
copysize
);
memcpy
(
c
->
dec_temp
+
c
->
in_temp
,
buf
,
copysize
);
rest
-=
copysize
;
rest
-=
copysize
;
buf
+=
copysize
;
buf
+=
copysize
;
if
(
avctx
->
channels
==
1
)
{
adx_decode
(
c
,
samples
,
c
->
dec_temp
,
0
);
adx_decode
(
samples
,
c
->
dec_temp
,
c
->
prev
);
if
(
avctx
->
channels
==
2
)
samples
+=
32
;
adx_decode
(
c
,
samples
+
1
,
c
->
dec_temp
+
18
,
1
);
}
else
{
samples
+=
32
*
c
->
channels
;
adx_decode_stereo
(
samples
,
c
->
dec_temp
,
c
->
prev
);
samples
+=
32
*
2
;
}
}
}
if
(
avctx
->
channels
==
1
)
{
while
(
rest
>=
18
*
c
->
channels
)
{
while
(
rest
>=
18
)
{
adx_decode
(
c
,
samples
,
buf
,
0
);
adx_decode
(
samples
,
buf
,
c
->
prev
);
if
(
c
->
channels
==
2
)
rest
-=
18
;
adx_decode
(
c
,
samples
+
1
,
buf
+
18
,
1
);
buf
+=
18
;
rest
-=
18
*
c
->
channels
;
samples
+=
32
;
buf
+=
18
*
c
->
channels
;
}
samples
+=
32
*
c
->
channels
;
}
else
{
while
(
rest
>=
18
*
2
)
{
adx_decode_stereo
(
samples
,
buf
,
c
->
prev
);
rest
-=
18
*
2
;
buf
+=
18
*
2
;
samples
+=
32
*
2
;
}
}
}
c
->
in_temp
=
rest
;
c
->
in_temp
=
rest
;
...
...
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