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
85f760fe
Commit
85f760fe
authored
Apr 14, 2016
by
Alexandra Hájková
Committed by
Diego Biurrun
Nov 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
twinvq: Convert to the new bitstream reader
parent
0bea79af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
twinvq_data.h
libavcodec/twinvq_data.h
+1
-1
twinvqdec.c
libavcodec/twinvqdec.c
+21
-21
No files found.
libavcodec/twinvq_data.h
View file @
85f760fe
...
...
@@ -130,7 +130,7 @@ static const uint16_t bark_tab_s44_128[] = {
/**
* TwinVQ codebooks. They are coded in a struct so we can use code such as
*
* float val = tab.fcb0808l[
get_bits(gb
, 12)];
* float val = tab.fcb0808l[
bitstream_read(bc
, 12)];
*
* without risking a segfault on malformed files.
*/
...
...
libavcodec/twinvqdec.c
View file @
85f760fe
...
...
@@ -23,8 +23,9 @@
#include <stdint.h>
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "
get_bits
.h"
#include "
bitstream
.h"
#include "internal.h"
#include "twinvq.h"
#include "twinvq_data.h"
...
...
@@ -235,7 +236,7 @@ static void dec_bark_env(TwinVQContext *tctx, const uint8_t *in, int use_hist,
}
}
static
void
read_cb_data
(
TwinVQContext
*
tctx
,
GetBitContext
*
gb
,
static
void
read_cb_data
(
TwinVQContext
*
tctx
,
BitstreamContext
*
bc
,
uint8_t
*
dst
,
enum
TwinVQFrameType
ftype
)
{
int
i
;
...
...
@@ -243,8 +244,8 @@ static void read_cb_data(TwinVQContext *tctx, GetBitContext *gb,
for
(
i
=
0
;
i
<
tctx
->
n_div
[
ftype
];
i
++
)
{
int
bs_second_part
=
(
i
>=
tctx
->
bits_main_spec_change
[
ftype
]);
*
dst
++
=
get_bits
(
gb
,
tctx
->
bits_main_spec
[
0
][
ftype
][
bs_second_part
]);
*
dst
++
=
get_bits
(
gb
,
tctx
->
bits_main_spec
[
1
][
ftype
][
bs_second_part
]);
*
dst
++
=
bitstream_read
(
bc
,
tctx
->
bits_main_spec
[
0
][
ftype
][
bs_second_part
]);
*
dst
++
=
bitstream_read
(
bc
,
tctx
->
bits_main_spec
[
1
][
ftype
][
bs_second_part
]);
}
}
...
...
@@ -255,13 +256,13 @@ static int twinvq_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
const
TwinVQModeTab
*
mtab
=
tctx
->
mtab
;
int
channels
=
tctx
->
avctx
->
channels
;
int
sub
;
GetBitContext
gb
;
BitstreamContext
bc
;
int
i
,
j
,
k
;
init_get_bits
(
&
gb
,
buf
,
buf_size
*
8
);
skip_bits
(
&
gb
,
get_bits
(
&
gb
,
8
));
bitstream_init
(
&
bc
,
buf
,
buf_size
*
8
);
bitstream_skip
(
&
bc
,
bitstream_read
(
&
bc
,
8
));
bits
->
window_type
=
get_bits
(
&
gb
,
TWINVQ_WINDOW_TYPE_BITS
);
bits
->
window_type
=
bitstream_read
(
&
bc
,
TWINVQ_WINDOW_TYPE_BITS
);
if
(
bits
->
window_type
>
8
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid window type, broken sample?
\n
"
);
...
...
@@ -272,43 +273,42 @@ static int twinvq_read_bitstream(AVCodecContext *avctx, TwinVQContext *tctx,
sub
=
mtab
->
fmode
[
bits
->
ftype
].
sub
;
read_cb_data
(
tctx
,
&
gb
,
bits
->
main_coeffs
,
bits
->
ftype
);
read_cb_data
(
tctx
,
&
bc
,
bits
->
main_coeffs
,
bits
->
ftype
);
for
(
i
=
0
;
i
<
channels
;
i
++
)
for
(
j
=
0
;
j
<
sub
;
j
++
)
for
(
k
=
0
;
k
<
mtab
->
fmode
[
bits
->
ftype
].
bark_n_coef
;
k
++
)
bits
->
bark1
[
i
][
j
][
k
]
=
get_bits
(
&
gb
,
mtab
->
fmode
[
bits
->
ftype
].
bark_n_bit
);
bitstream_read
(
&
bc
,
mtab
->
fmode
[
bits
->
ftype
].
bark_n_bit
);
for
(
i
=
0
;
i
<
channels
;
i
++
)
for
(
j
=
0
;
j
<
sub
;
j
++
)
bits
->
bark_use_hist
[
i
][
j
]
=
get_bits1
(
&
gb
);
bits
->
bark_use_hist
[
i
][
j
]
=
bitstream_read_bit
(
&
bc
);
if
(
bits
->
ftype
==
TWINVQ_FT_LONG
)
{
for
(
i
=
0
;
i
<
channels
;
i
++
)
bits
->
gain_bits
[
i
]
=
get_bits
(
&
gb
,
TWINVQ_GAIN_BITS
);
bits
->
gain_bits
[
i
]
=
bitstream_read
(
&
bc
,
TWINVQ_GAIN_BITS
);
}
else
{
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
bits
->
gain_bits
[
i
]
=
get_bits
(
&
gb
,
TWINVQ_GAIN_BITS
);
bits
->
gain_bits
[
i
]
=
bitstream_read
(
&
bc
,
TWINVQ_GAIN_BITS
);
for
(
j
=
0
;
j
<
sub
;
j
++
)
bits
->
sub_gain_bits
[
i
*
sub
+
j
]
=
get_bits
(
&
gb
,
TWINVQ_SUB_GAIN_BITS
);
bits
->
sub_gain_bits
[
i
*
sub
+
j
]
=
bitstream_read
(
&
bc
,
TWINVQ_SUB_GAIN_BITS
);
}
}
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
bits
->
lpc_hist_idx
[
i
]
=
get_bits
(
&
gb
,
mtab
->
lsp_bit0
);
bits
->
lpc_idx1
[
i
]
=
get_bits
(
&
gb
,
mtab
->
lsp_bit1
);
bits
->
lpc_hist_idx
[
i
]
=
bitstream_read
(
&
bc
,
mtab
->
lsp_bit0
);
bits
->
lpc_idx1
[
i
]
=
bitstream_read
(
&
bc
,
mtab
->
lsp_bit1
);
for
(
j
=
0
;
j
<
mtab
->
lsp_split
;
j
++
)
bits
->
lpc_idx2
[
i
][
j
]
=
get_bits
(
&
gb
,
mtab
->
lsp_bit2
);
bits
->
lpc_idx2
[
i
][
j
]
=
bitstream_read
(
&
bc
,
mtab
->
lsp_bit2
);
}
if
(
bits
->
ftype
==
TWINVQ_FT_LONG
)
{
read_cb_data
(
tctx
,
&
gb
,
bits
->
ppc_coeffs
,
3
);
read_cb_data
(
tctx
,
&
bc
,
bits
->
ppc_coeffs
,
3
);
for
(
i
=
0
;
i
<
channels
;
i
++
)
{
bits
->
p_coef
[
i
]
=
get_bits
(
&
gb
,
mtab
->
ppc_period_bit
);
bits
->
g_coef
[
i
]
=
get_bits
(
&
gb
,
mtab
->
pgain_bit
);
bits
->
p_coef
[
i
]
=
bitstream_read
(
&
bc
,
mtab
->
ppc_period_bit
);
bits
->
g_coef
[
i
]
=
bitstream_read
(
&
bc
,
mtab
->
pgain_bit
);
}
}
...
...
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