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
a14d4c07
Commit
a14d4c07
authored
Mar 23, 2016
by
Rostislav Pehlivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vc2enc: simplify calc_slice_sizes()
Signed-off-by:
Rostislav Pehlivanov
<
atomnuker@gmail.com
>
parent
a010e36f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
19 deletions
+13
-19
vc2enc.c
libavcodec/vc2enc.c
+13
-19
No files found.
libavcodec/vc2enc.c
View file @
a14d4c07
...
@@ -116,7 +116,6 @@ typedef struct SliceArgs {
...
@@ -116,7 +116,6 @@ typedef struct SliceArgs {
int
quant_idx
;
int
quant_idx
;
int
bits_ceil
;
int
bits_ceil
;
int
bits_floor
;
int
bits_floor
;
int
bytes_left
;
int
bytes
;
int
bytes
;
}
SliceArgs
;
}
SliceArgs
;
...
@@ -692,13 +691,12 @@ static int rate_control(AVCodecContext *avctx, void *arg)
...
@@ -692,13 +691,12 @@ static int rate_control(AVCodecContext *avctx, void *arg)
}
}
slice_dat
->
quant_idx
=
av_clip
(
quant
,
0
,
s
->
q_ceil
-
1
);
slice_dat
->
quant_idx
=
av_clip
(
quant
,
0
,
s
->
q_ceil
-
1
);
slice_dat
->
bytes
=
SSIZE_ROUND
(
bits
>>
3
);
slice_dat
->
bytes
=
SSIZE_ROUND
(
bits
>>
3
);
slice_dat
->
bytes_left
=
s
->
slice_max_bytes
-
slice_dat
->
bytes
;
return
0
;
return
0
;
}
}
static
int
calc_slice_sizes
(
VC2EncContext
*
s
)
static
int
calc_slice_sizes
(
VC2EncContext
*
s
)
{
{
int
i
,
slice_x
,
slice_y
,
bytes_left
=
0
;
int
i
,
j
,
slice_x
,
slice_y
,
bytes_left
=
0
;
int
bytes_top
[
SLICE_REDIST_TOTAL
]
=
{
0
};
int
bytes_top
[
SLICE_REDIST_TOTAL
]
=
{
0
};
int64_t
total_bytes_needed
=
0
;
int64_t
total_bytes_needed
=
0
;
int
slice_redist_range
=
FFMIN
(
SLICE_REDIST_TOTAL
,
s
->
num_x
*
s
->
num_y
);
int
slice_redist_range
=
FFMIN
(
SLICE_REDIST_TOTAL
,
s
->
num_x
*
s
->
num_y
);
...
@@ -723,16 +721,14 @@ static int calc_slice_sizes(VC2EncContext *s)
...
@@ -723,16 +721,14 @@ static int calc_slice_sizes(VC2EncContext *s)
s
->
avctx
->
execute
(
s
->
avctx
,
rate_control
,
enc_args
,
NULL
,
s
->
num_x
*
s
->
num_y
,
s
->
avctx
->
execute
(
s
->
avctx
,
rate_control
,
enc_args
,
NULL
,
s
->
num_x
*
s
->
num_y
,
sizeof
(
SliceArgs
));
sizeof
(
SliceArgs
));
for
(
slice_y
=
0
;
slice_y
<
s
->
num_y
;
slice_y
++
)
{
for
(
i
=
0
;
i
<
s
->
num_x
*
s
->
num_y
;
i
++
)
{
for
(
slice_x
=
0
;
slice_x
<
s
->
num_x
;
slice_x
++
)
{
SliceArgs
*
args
=
&
enc_args
[
i
];
SliceArgs
*
args
=
&
enc_args
[
s
->
num_x
*
slice_y
+
slice_x
];
bytes_left
+=
s
->
slice_max_bytes
-
args
->
bytes
;
bytes_left
+=
args
->
bytes_left
;
for
(
j
=
0
;
j
<
slice_redist_range
;
j
++
)
{
for
(
i
=
0
;
i
<
slice_redist_range
;
i
++
)
{
if
(
args
->
bytes
>
bytes_top
[
j
])
{
if
(
args
->
bytes
>
bytes_top
[
i
])
{
bytes_top
[
j
]
=
args
->
bytes
;
bytes_top
[
i
]
=
args
->
bytes
;
top_loc
[
j
]
=
args
;
top_loc
[
i
]
=
args
;
break
;
break
;
}
}
}
}
}
}
}
...
@@ -764,12 +760,10 @@ static int calc_slice_sizes(VC2EncContext *s)
...
@@ -764,12 +760,10 @@ static int calc_slice_sizes(VC2EncContext *s)
break
;
break
;
}
}
for
(
slice_y
=
0
;
slice_y
<
s
->
num_y
;
slice_y
++
)
{
for
(
i
=
0
;
i
<
s
->
num_x
*
s
->
num_y
;
i
++
)
{
for
(
slice_x
=
0
;
slice_x
<
s
->
num_x
;
slice_x
++
)
{
SliceArgs
*
args
=
&
enc_args
[
i
];
SliceArgs
*
args
=
&
enc_args
[
s
->
num_x
*
slice_y
+
slice_x
];
total_bytes_needed
+=
args
->
bytes
;
total_bytes_needed
+=
args
->
bytes
;
s
->
q_avg
=
(
s
->
q_avg
+
args
->
quant_idx
)
/
2
;
s
->
q_avg
=
(
s
->
q_avg
+
args
->
quant_idx
)
/
2
;
}
}
}
return
total_bytes_needed
;
return
total_bytes_needed
;
...
...
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