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
14b41e06
Commit
14b41e06
authored
Mar 23, 2016
by
Rostislav Pehlivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vc2enc: macro out slice size rounding
Signed-off-by:
Rostislav Pehlivanov
<
atomnuker@gmail.com
>
parent
8dbffda0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
vc2enc.c
libavcodec/vc2enc.c
+9
-6
No files found.
libavcodec/vc2enc.c
View file @
14b41e06
...
...
@@ -36,6 +36,9 @@
* (COEF_LUT_TAB*MAX_QUANT_INDEX) since the sign is appended during encoding */
#define COEF_LUT_TAB 2048
/* The limited size resolution of each slice forces us to do this */
#define SSIZE_ROUND(b) (FFALIGN((b), s->size_scaler) + 4 + s->prefix_bytes)
/* Decides the cutoff point in # of slices to distribute the leftover bytes */
#define SLICE_REDIST_TOTAL 150
...
...
@@ -688,7 +691,7 @@ static int rate_control(AVCodecContext *avctx, void *arg)
bits_last
=
bits
;
}
slice_dat
->
quant_idx
=
av_clip
(
quant
,
0
,
s
->
q_ceil
-
1
);
slice_dat
->
bytes
=
FFALIGN
((
bits
>>
3
),
s
->
size_scaler
)
+
4
+
s
->
prefix_bytes
;
slice_dat
->
bytes
=
SSIZE_ROUND
(
bits
>>
3
)
;
slice_dat
->
bytes_left
=
s
->
slice_max_bytes
-
slice_dat
->
bytes
;
return
0
;
}
...
...
@@ -748,7 +751,7 @@ static int calc_slice_sizes(VC2EncContext *s)
prev_bytes
=
args
->
bytes
;
new_idx
=
FFMAX
(
args
->
quant_idx
-
1
,
0
);
bits
=
count_hq_slice
(
args
,
new_idx
);
bytes
=
FFALIGN
((
bits
>>
3
),
s
->
size_scaler
)
+
4
+
s
->
prefix_bytes
;
bytes
=
SSIZE_ROUND
(
bits
>>
3
)
;
diff
=
bytes
-
prev_bytes
;
if
((
bytes_left
-
diff
)
>
0
)
{
args
->
quant_idx
=
new_idx
;
...
...
@@ -1016,16 +1019,16 @@ static av_cold int vc2_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
/* Rate control */
max_frame_bytes
=
(
av_rescale
(
r_bitrate
,
s
->
avctx
->
time_base
.
num
,
s
->
avctx
->
time_base
.
den
)
>>
3
)
-
header_size
;
s
->
slice_max_bytes
=
av_rescale
(
max_frame_bytes
,
1
,
s
->
num_x
*
s
->
num_y
);
/* Find an appropriate size scaler */
while
(
sig_size
>
255
)
{
s
->
slice_max_bytes
=
FFALIGN
(
av_rescale
(
max_frame_bytes
,
1
,
s
->
num_x
*
s
->
num_y
),
s
->
size_scaler
);
s
->
slice_max_bytes
+=
4
+
s
->
prefix_bytes
;
sig_size
=
s
->
slice_max_bytes
/
s
->
size_scaler
;
/* Signalled slize size */
int
r_size
=
SSIZE_ROUND
(
s
->
slice_max_bytes
);
sig_size
=
r_size
/
s
->
size_scaler
;
/* Signalled slize size */
s
->
size_scaler
<<=
1
;
}
s
->
slice_max_bytes
=
SSIZE_ROUND
(
s
->
slice_max_bytes
);
s
->
slice_min_bytes
=
s
->
slice_max_bytes
-
s
->
slice_max_bytes
*
(
s
->
tolerance
/
100
.
0
f
);
ret
=
encode_frame
(
s
,
avpkt
,
frame
,
aux_data
,
header_size
,
s
->
interlaced
);
...
...
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