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
8664682d
Commit
8664682d
authored
Sep 22, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cosmetics: indentation
parent
7b7a74a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
94 deletions
+94
-94
tta.c
libavcodec/tta.c
+94
-94
No files found.
libavcodec/tta.c
View file @
8664682d
...
@@ -284,116 +284,116 @@ static int tta_decode_frame(AVCodecContext *avctx,
...
@@ -284,116 +284,116 @@ static int tta_decode_frame(AVCodecContext *avctx,
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
init_get_bits
(
&
s
->
gb
,
buf
,
buf_size
*
8
);
// FIXME: seeking
// FIXME: seeking
s
->
total_frames
--
;
s
->
total_frames
--
;
if
(
!
s
->
total_frames
&&
s
->
last_frame_length
)
if
(
!
s
->
total_frames
&&
s
->
last_frame_length
)
framelen
=
s
->
last_frame_length
;
framelen
=
s
->
last_frame_length
;
if
(
*
data_size
<
(
framelen
*
s
->
channels
*
2
))
{
if
(
*
data_size
<
(
framelen
*
s
->
channels
*
2
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Output buffer size is too small.
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Output buffer size is too small.
\n
"
);
return
-
1
;
return
-
1
;
}
}
// init per channel states
for
(
i
=
0
;
i
<
s
->
channels
;
i
++
)
{
s
->
ch_ctx
[
i
].
predictor
=
0
;
ttafilter_init
(
&
s
->
ch_ctx
[
i
].
filter
,
ttafilter_configs
[
s
->
bps
-
1
][
0
],
ttafilter_configs
[
s
->
bps
-
1
][
1
]);
rice_init
(
&
s
->
ch_ctx
[
i
].
rice
,
10
,
10
);
}
// init per channel states
for
(
p
=
s
->
decode_buffer
;
p
<
s
->
decode_buffer
+
(
framelen
*
s
->
channels
);
p
++
)
{
for
(
i
=
0
;
i
<
s
->
channels
;
i
++
)
{
int32_t
*
predictor
=
&
s
->
ch_ctx
[
cur_chan
].
predictor
;
s
->
ch_ctx
[
i
].
predictor
=
0
;
TTAFilter
*
filter
=
&
s
->
ch_ctx
[
cur_chan
].
filter
;
ttafilter_init
(
&
s
->
ch_ctx
[
i
].
filter
,
ttafilter_configs
[
s
->
bps
-
1
][
0
],
ttafilter_configs
[
s
->
bps
-
1
][
1
]);
TTARice
*
rice
=
&
s
->
ch_ctx
[
cur_chan
].
rice
;
rice_init
(
&
s
->
ch_ctx
[
i
].
rice
,
10
,
10
);
uint32_t
unary
,
depth
,
k
;
int32_t
value
;
unary
=
tta_get_unary
(
&
s
->
gb
);
if
(
unary
==
0
)
{
depth
=
0
;
k
=
rice
->
k0
;
}
else
{
depth
=
1
;
k
=
rice
->
k1
;
unary
--
;
}
}
for
(
p
=
s
->
decode_buffer
;
p
<
s
->
decode_buffer
+
(
framelen
*
s
->
channels
);
p
++
)
{
if
(
get_bits_left
(
&
s
->
gb
)
<
k
)
int32_t
*
predictor
=
&
s
->
ch_ctx
[
cur_chan
].
predictor
;
return
-
1
;
TTAFilter
*
filter
=
&
s
->
ch_ctx
[
cur_chan
].
filter
;
TTARice
*
rice
=
&
s
->
ch_ctx
[
cur_chan
].
rice
;
uint32_t
unary
,
depth
,
k
;
int32_t
value
;
unary
=
tta_get_unary
(
&
s
->
gb
);
if
(
unary
==
0
)
{
depth
=
0
;
k
=
rice
->
k0
;
}
else
{
depth
=
1
;
k
=
rice
->
k1
;
unary
--
;
}
if
(
get_bits_left
(
&
s
->
gb
)
<
k
)
if
(
k
)
{
if
(
k
>
MIN_CACHE_BITS
)
return
-
1
;
return
-
1
;
value
=
(
unary
<<
k
)
+
get_bits
(
&
s
->
gb
,
k
);
}
else
value
=
unary
;
// FIXME: copy paste from original
switch
(
depth
)
{
case
1
:
rice
->
sum1
+=
value
-
(
rice
->
sum1
>>
4
);
if
(
rice
->
k1
>
0
&&
rice
->
sum1
<
shift_16
[
rice
->
k1
])
rice
->
k1
--
;
else
if
(
rice
->
sum1
>
shift_16
[
rice
->
k1
+
1
])
rice
->
k1
++
;
value
+=
shift_1
[
rice
->
k0
];
default:
rice
->
sum0
+=
value
-
(
rice
->
sum0
>>
4
);
if
(
rice
->
k0
>
0
&&
rice
->
sum0
<
shift_16
[
rice
->
k0
])
rice
->
k0
--
;
else
if
(
rice
->
sum0
>
shift_16
[
rice
->
k0
+
1
])
rice
->
k0
++
;
}
if
(
k
)
{
// extract coded value
if
(
k
>
MIN_CACHE_BITS
)
return
-
1
;
value
=
(
unary
<<
k
)
+
get_bits
(
&
s
->
gb
,
k
);
}
else
value
=
unary
;
// FIXME: copy paste from original
switch
(
depth
)
{
case
1
:
rice
->
sum1
+=
value
-
(
rice
->
sum1
>>
4
);
if
(
rice
->
k1
>
0
&&
rice
->
sum1
<
shift_16
[
rice
->
k1
])
rice
->
k1
--
;
else
if
(
rice
->
sum1
>
shift_16
[
rice
->
k1
+
1
])
rice
->
k1
++
;
value
+=
shift_1
[
rice
->
k0
];
default:
rice
->
sum0
+=
value
-
(
rice
->
sum0
>>
4
);
if
(
rice
->
k0
>
0
&&
rice
->
sum0
<
shift_16
[
rice
->
k0
])
rice
->
k0
--
;
else
if
(
rice
->
sum0
>
shift_16
[
rice
->
k0
+
1
])
rice
->
k0
++
;
}
// extract coded value
#define UNFOLD(x) (((x)&1) ? (++(x)>>1) : (-(x)>>1))
#define UNFOLD(x) (((x)&1) ? (++(x)>>1) : (-(x)>>1))
*
p
=
UNFOLD
(
value
);
*
p
=
UNFOLD
(
value
);
// run hybrid filter
// run hybrid filter
ttafilter_process
(
filter
,
p
,
0
);
ttafilter_process
(
filter
,
p
,
0
);
// fixed order prediction
// fixed order prediction
#define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k)
#define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k)
switch
(
s
->
bps
)
{
switch
(
s
->
bps
)
{
case
1
:
*
p
+=
PRED
(
*
predictor
,
4
);
break
;
case
1
:
*
p
+=
PRED
(
*
predictor
,
4
);
break
;
case
2
:
case
2
:
case
3
:
*
p
+=
PRED
(
*
predictor
,
5
);
break
;
case
3
:
*
p
+=
PRED
(
*
predictor
,
5
);
break
;
case
4
:
*
p
+=
*
predictor
;
break
;
case
4
:
*
p
+=
*
predictor
;
break
;
}
}
*
predictor
=
*
p
;
*
predictor
=
*
p
;
// flip channels
// flip channels
if
(
cur_chan
<
(
s
->
channels
-
1
))
if
(
cur_chan
<
(
s
->
channels
-
1
))
cur_chan
++
;
cur_chan
++
;
else
{
else
{
// decorrelate in case of stereo integer
// decorrelate in case of stereo integer
if
(
s
->
channels
>
1
)
{
if
(
s
->
channels
>
1
)
{
int32_t
*
r
=
p
-
1
;
int32_t
*
r
=
p
-
1
;
for
(
*
p
+=
*
r
/
2
;
r
>
p
-
s
->
channels
;
r
--
)
for
(
*
p
+=
*
r
/
2
;
r
>
p
-
s
->
channels
;
r
--
)
*
r
=
*
(
r
+
1
)
-
*
r
;
*
r
=
*
(
r
+
1
)
-
*
r
;
}
cur_chan
=
0
;
}
}
cur_chan
=
0
;
}
}
}
if
(
get_bits_left
(
&
s
->
gb
)
<
32
)
if
(
get_bits_left
(
&
s
->
gb
)
<
32
)
return
-
1
;
return
-
1
;
skip_bits
(
&
s
->
gb
,
32
);
// frame crc
skip_bits
(
&
s
->
gb
,
32
);
// frame crc
// convert to output buffer
// convert to output buffer
switch
(
s
->
bps
)
{
switch
(
s
->
bps
)
{
case
2
:
{
case
2
:
{
uint16_t
*
samples
=
data
;
uint16_t
*
samples
=
data
;
for
(
p
=
s
->
decode_buffer
;
p
<
s
->
decode_buffer
+
(
framelen
*
s
->
channels
);
p
++
)
{
for
(
p
=
s
->
decode_buffer
;
p
<
s
->
decode_buffer
+
(
framelen
*
s
->
channels
);
p
++
)
{
*
samples
++
=
*
p
;
*
samples
++
=
*
p
;
}
*
data_size
=
(
uint8_t
*
)
samples
-
(
uint8_t
*
)
data
;
break
;
}
}
default:
*
data_size
=
(
uint8_t
*
)
samples
-
(
uint8_t
*
)
data
;
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Error, only 16bit samples supported!
\n
"
)
;
break
;
}
}
default:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Error, only 16bit samples supported!
\n
"
);
}
return
buf_size
;
return
buf_size
;
}
}
...
...
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