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
b2c56301
Commit
b2c56301
authored
Apr 10, 2016
by
Alexandra Hájková
Committed by
Anton Khirnov
Nov 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsm: Convert to the new bitstream reader
Signed-off-by:
Anton Khirnov
<
anton@khirnov.net
>
parent
2188d539
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
26 deletions
+28
-26
gsmdec.c
libavcodec/gsmdec.c
+6
-5
gsmdec_template.c
libavcodec/gsmdec_template.c
+17
-17
msgsmdec.c
libavcodec/msgsmdec.c
+5
-4
No files found.
libavcodec/gsmdec.c
View file @
b2c56301
...
...
@@ -25,8 +25,9 @@
*/
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "
get_bits
.h"
#include "
bitstream
.h"
#include "internal.h"
#include "msgsmdec.h"
...
...
@@ -67,7 +68,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
{
AVFrame
*
frame
=
data
;
int
res
;
GetBitContext
gb
;
BitstreamContext
bc
;
const
uint8_t
*
buf
=
avpkt
->
data
;
int
buf_size
=
avpkt
->
size
;
int16_t
*
samples
;
...
...
@@ -87,10 +88,10 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
switch
(
avctx
->
codec_id
)
{
case
AV_CODEC_ID_GSM
:
init_get_bits
(
&
gb
,
buf
,
buf_size
*
8
);
if
(
get_bits
(
&
gb
,
4
)
!=
0xd
)
bitstream_init
(
&
bc
,
buf
,
buf_size
*
8
);
if
(
bitstream_read
(
&
bc
,
4
)
!=
0xd
)
av_log
(
avctx
,
AV_LOG_WARNING
,
"Missing GSM magic!
\n
"
);
res
=
gsm_decode_block
(
avctx
,
samples
,
&
gb
,
GSM_13000
);
res
=
gsm_decode_block
(
avctx
,
samples
,
&
bc
,
GSM_13000
);
if
(
res
<
0
)
return
res
;
break
;
...
...
libavcodec/gsmdec_template.c
View file @
b2c56301
...
...
@@ -24,17 +24,17 @@
* GSM decoder
*/
#include "
get_bits
.h"
#include "
bitstream
.h"
#include "gsm.h"
#include "gsmdec_data.h"
static
void
apcm_dequant_add
(
GetBitContext
*
gb
,
int16_t
*
dst
,
const
int
*
frame_bits
)
static
void
apcm_dequant_add
(
BitstreamContext
*
bc
,
int16_t
*
dst
,
const
int
*
frame_bits
)
{
int
i
,
val
;
int
maxidx
=
get_bits
(
gb
,
6
);
int
maxidx
=
bitstream_read
(
bc
,
6
);
const
int16_t
*
tab
=
ff_gsm_dequant_tab
[
maxidx
];
for
(
i
=
0
;
i
<
13
;
i
++
)
{
val
=
get_bits
(
gb
,
frame_bits
[
i
]);
val
=
bitstream_read
(
bc
,
frame_bits
[
i
]);
dst
[
3
*
i
]
+=
tab
[
ff_gsm_requant_tab
[
frame_bits
[
i
]][
val
]];
}
}
...
...
@@ -120,28 +120,28 @@ static int postprocess(int16_t *data, int msr)
}
static
int
gsm_decode_block
(
AVCodecContext
*
avctx
,
int16_t
*
samples
,
GetBitContext
*
gb
,
int
mode
)
BitstreamContext
*
bc
,
int
mode
)
{
GSMContext
*
ctx
=
avctx
->
priv_data
;
int
i
;
int16_t
*
ref_dst
=
ctx
->
ref_buf
+
120
;
int
*
lar
=
ctx
->
lar
[
ctx
->
lar_idx
];
lar
[
0
]
=
decode_log_area
(
get_bits
(
gb
,
6
),
13107
,
1
<<
15
);
lar
[
1
]
=
decode_log_area
(
get_bits
(
gb
,
6
),
13107
,
1
<<
15
);
lar
[
2
]
=
decode_log_area
(
get_bits
(
gb
,
5
),
13107
,
(
1
<<
14
)
+
2048
*
2
);
lar
[
3
]
=
decode_log_area
(
get_bits
(
gb
,
5
),
13107
,
(
1
<<
14
)
-
2560
*
2
);
lar
[
4
]
=
decode_log_area
(
get_bits
(
gb
,
4
),
19223
,
(
1
<<
13
)
+
94
*
2
);
lar
[
5
]
=
decode_log_area
(
get_bits
(
gb
,
4
),
17476
,
(
1
<<
13
)
-
1792
*
2
);
lar
[
6
]
=
decode_log_area
(
get_bits
(
gb
,
3
),
31454
,
(
1
<<
12
)
-
341
*
2
);
lar
[
7
]
=
decode_log_area
(
get_bits
(
gb
,
3
),
29708
,
(
1
<<
12
)
-
1144
*
2
);
lar
[
0
]
=
decode_log_area
(
bitstream_read
(
bc
,
6
),
13107
,
1
<<
15
);
lar
[
1
]
=
decode_log_area
(
bitstream_read
(
bc
,
6
),
13107
,
1
<<
15
);
lar
[
2
]
=
decode_log_area
(
bitstream_read
(
bc
,
5
),
13107
,
(
1
<<
14
)
+
2048
*
2
);
lar
[
3
]
=
decode_log_area
(
bitstream_read
(
bc
,
5
),
13107
,
(
1
<<
14
)
-
2560
*
2
);
lar
[
4
]
=
decode_log_area
(
bitstream_read
(
bc
,
4
),
19223
,
(
1
<<
13
)
+
94
*
2
);
lar
[
5
]
=
decode_log_area
(
bitstream_read
(
bc
,
4
),
17476
,
(
1
<<
13
)
-
1792
*
2
);
lar
[
6
]
=
decode_log_area
(
bitstream_read
(
bc
,
3
),
31454
,
(
1
<<
12
)
-
341
*
2
);
lar
[
7
]
=
decode_log_area
(
bitstream_read
(
bc
,
3
),
29708
,
(
1
<<
12
)
-
1144
*
2
);
for
(
i
=
0
;
i
<
4
;
i
++
)
{
int
lag
=
get_bits
(
gb
,
7
);
int
gain_idx
=
get_bits
(
gb
,
2
);
int
offset
=
get_bits
(
gb
,
2
);
int
lag
=
bitstream_read
(
bc
,
7
);
int
gain_idx
=
bitstream_read
(
bc
,
2
);
int
offset
=
bitstream_read
(
bc
,
2
);
lag
=
av_clip
(
lag
,
40
,
120
);
long_term_synth
(
ref_dst
,
lag
,
gain_idx
);
apcm_dequant_add
(
gb
,
ref_dst
+
offset
,
ff_gsm_apcm_bits
[
mode
][
i
]);
apcm_dequant_add
(
bc
,
ref_dst
+
offset
,
ff_gsm_apcm_bits
[
mode
][
i
]);
ref_dst
+=
40
;
}
memcpy
(
ctx
->
ref_buf
,
ctx
->
ref_buf
+
160
,
120
*
sizeof
(
*
ctx
->
ref_buf
));
...
...
libavcodec/msgsmdec.c
View file @
b2c56301
...
...
@@ -21,6 +21,7 @@
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "bitstream.h"
#include "gsm.h"
#include "msgsmdec.h"
...
...
@@ -30,10 +31,10 @@ int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
const
uint8_t
*
buf
,
int
mode
)
{
int
res
;
GetBitContext
gb
;
init_get_bits
(
&
gb
,
buf
,
GSM_MS_BLOCK_SIZE
*
8
);
res
=
gsm_decode_block
(
avctx
,
samples
,
&
gb
,
mode
);
BitstreamContext
bc
;
bitstream_init
(
&
bc
,
buf
,
GSM_MS_BLOCK_SIZE
*
8
);
res
=
gsm_decode_block
(
avctx
,
samples
,
&
bc
,
mode
);
if
(
res
<
0
)
return
res
;
return
gsm_decode_block
(
avctx
,
samples
+
GSM_FRAME_SIZE
,
&
gb
,
mode
);
return
gsm_decode_block
(
avctx
,
samples
+
GSM_FRAME_SIZE
,
&
bc
,
mode
);
}
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