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
34093ba0
Commit
34093ba0
authored
Jan 06, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
g722enc: split encoding into separate functions for trellis vs. no trellis
parent
96219141
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
20 deletions
+33
-20
g722enc.c
libavcodec/g722enc.c
+33
-20
No files found.
libavcodec/g722enc.c
View file @
34093ba0
...
...
@@ -117,13 +117,12 @@ static inline int encode_low(const struct G722Band* state, int xlow)
return
(
diff
<
0
?
(
i
<
2
?
63
:
33
)
:
61
)
-
i
;
}
static
int
g722_encode_trellis
(
AVCodecContext
*
avctx
,
uint8_t
*
dst
,
int
buf_size
,
void
*
data
)
static
void
g722_encode_trellis
(
G722Context
*
c
,
int
trellis
,
uint8_t
*
dst
,
int
nb_samples
,
const
int16_t
*
samples
)
{
G722Context
*
c
=
avctx
->
priv_data
;
const
int16_t
*
samples
=
data
;
int
i
,
j
,
k
;
int
frontier
=
1
<<
avctx
->
trellis
;
int
frontier
=
1
<<
trellis
;
struct
TrellisNode
**
nodes
[
2
];
struct
TrellisNode
**
nodes_next
[
2
];
int
pathn
[
2
]
=
{
0
,
0
},
froze
=
-
1
;
...
...
@@ -139,7 +138,7 @@ static int g722_encode_trellis(AVCodecContext *avctx,
nodes
[
i
][
0
]
->
state
=
c
->
band
[
i
];
}
for
(
i
=
0
;
i
<
buf_size
;
i
++
)
{
for
(
i
=
0
;
i
<
nb_samples
>>
1
;
i
++
)
{
int
xlow
,
xhigh
;
struct
TrellisNode
*
next
[
2
];
int
heap_pos
[
2
]
=
{
0
,
0
};
...
...
@@ -271,8 +270,28 @@ static int g722_encode_trellis(AVCodecContext *avctx,
}
c
->
band
[
0
]
=
nodes
[
0
][
0
]
->
state
;
c
->
band
[
1
]
=
nodes
[
1
][
0
]
->
state
;
}
static
av_always_inline
void
encode_byte
(
G722Context
*
c
,
uint8_t
*
dst
,
const
int16_t
*
samples
)
{
int
xlow
,
xhigh
,
ilow
,
ihigh
;
filter_samples
(
c
,
samples
,
&
xlow
,
&
xhigh
);
ihigh
=
encode_high
(
&
c
->
band
[
1
],
xhigh
);
ilow
=
encode_low
(
&
c
->
band
[
0
],
xlow
);
ff_g722_update_high_predictor
(
&
c
->
band
[
1
],
c
->
band
[
1
].
scale_factor
*
ff_g722_high_inv_quant
[
ihigh
]
>>
10
,
ihigh
);
ff_g722_update_low_predictor
(
&
c
->
band
[
0
],
ilow
>>
2
);
*
dst
=
ihigh
<<
6
|
ilow
;
}
return
i
;
static
void
g722_encode_no_trellis
(
G722Context
*
c
,
uint8_t
*
dst
,
int
nb_samples
,
const
int16_t
*
samples
)
{
int
i
;
for
(
i
=
0
;
i
<
nb_samples
;
i
+=
2
)
encode_byte
(
c
,
dst
++
,
&
samples
[
i
]);
}
static
int
g722_encode_frame
(
AVCodecContext
*
avctx
,
...
...
@@ -280,22 +299,16 @@ static int g722_encode_frame(AVCodecContext *avctx,
{
G722Context
*
c
=
avctx
->
priv_data
;
const
int16_t
*
samples
=
data
;
int
i
;
int
nb_samples
;
nb_samples
=
buf_size
*
2
;
if
(
avctx
->
trellis
)
return
g722_encode_trellis
(
avctx
,
dst
,
buf_size
,
data
);
g722_encode_trellis
(
c
,
avctx
->
trellis
,
dst
,
nb_samples
,
samples
);
else
g722_encode_no_trellis
(
c
,
dst
,
nb_samples
,
samples
);
for
(
i
=
0
;
i
<
buf_size
;
i
++
)
{
int
xlow
,
xhigh
,
ihigh
,
ilow
;
filter_samples
(
c
,
&
samples
[
2
*
i
],
&
xlow
,
&
xhigh
);
ihigh
=
encode_high
(
&
c
->
band
[
1
],
xhigh
);
ilow
=
encode_low
(
&
c
->
band
[
0
],
xlow
);
ff_g722_update_high_predictor
(
&
c
->
band
[
1
],
c
->
band
[
1
].
scale_factor
*
ff_g722_high_inv_quant
[
ihigh
]
>>
10
,
ihigh
);
ff_g722_update_low_predictor
(
&
c
->
band
[
0
],
ilow
>>
2
);
*
dst
++
=
ihigh
<<
6
|
ilow
;
}
return
i
;
return
buf_size
;
}
AVCodec
ff_adpcm_g722_encoder
=
{
...
...
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