Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
aom-rav1e
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
aom-rav1e
Commits
0546636c
Commit
0546636c
authored
Feb 16, 2016
by
Marco Paniconi
Committed by
Gerrit Code Review
Feb 16, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge "vp9-resize: Fix an issue with external dynamic resize."
parents
425b1562
3cbc26f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
191 additions
and
71 deletions
+191
-71
test/resize_test.cc
test/resize_test.cc
+170
-62
vp9/common/vp9_alloccommon.c
vp9/common/vp9_alloccommon.c
+16
-9
vp9/common/vp9_alloccommon.h
vp9/common/vp9_alloccommon.h
+1
-0
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.c
+4
-0
No files found.
test/resize_test.cc
View file @
0546636c
...
...
@@ -90,74 +90,178 @@ struct FrameInfo {
unsigned
int
h
;
};
unsigned
int
ScaleForFrameNumber
(
unsigned
int
frame
,
unsigned
int
val
)
{
if
(
frame
<
10
)
return
val
;
if
(
frame
<
20
)
return
val
*
3
/
4
;
if
(
frame
<
30
)
return
val
/
2
;
if
(
frame
<
40
)
return
val
;
if
(
frame
<
50
)
return
val
*
3
/
4
;
if
(
frame
<
60
)
return
val
/
2
;
if
(
frame
<
70
)
return
val
*
3
/
4
;
if
(
frame
<
80
)
return
val
;
if
(
frame
<
90
)
return
val
*
3
/
4
;
if
(
frame
<
100
)
return
val
/
2
;
if
(
frame
<
110
)
return
val
*
3
/
4
;
if
(
frame
<
120
)
return
val
;
if
(
frame
<
130
)
return
val
*
3
/
4
;
if
(
frame
<
140
)
return
val
/
2
;
if
(
frame
<
150
)
return
val
*
3
/
4
;
if
(
frame
<
160
)
return
val
;
if
(
frame
<
170
)
return
val
/
2
;
if
(
frame
<
180
)
return
val
*
3
/
4
;
if
(
frame
<
190
)
return
val
;
if
(
frame
<
200
)
return
val
*
3
/
4
;
if
(
frame
<
210
)
return
val
/
2
;
if
(
frame
<
220
)
return
val
*
3
/
4
;
if
(
frame
<
230
)
return
val
;
if
(
frame
<
240
)
return
val
/
2
;
if
(
frame
<
250
)
return
val
*
3
/
4
;
return
val
;
void
ScaleForFrameNumber
(
unsigned
int
frame
,
unsigned
int
initial_w
,
unsigned
int
initial_h
,
unsigned
int
*
w
,
unsigned
int
*
h
,
int
flag_codec
)
{
if
(
frame
<
10
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
20
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
30
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
40
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
50
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
60
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
70
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
80
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
90
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
100
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
110
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
120
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
130
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
140
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
150
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
160
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
170
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
180
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
190
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
200
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
210
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
220
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
230
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
if
(
frame
<
240
)
{
*
w
=
initial_w
*
3
/
4
;
*
h
=
initial_h
*
3
/
4
;
return
;
}
if
(
frame
<
250
)
{
*
w
=
initial_w
/
2
;
*
h
=
initial_h
/
2
;
return
;
}
if
(
frame
<
260
)
{
*
w
=
initial_w
;
*
h
=
initial_h
;
return
;
}
// Go down very low.
if
(
frame
<
270
)
{
*
w
=
initial_w
/
4
;
*
h
=
initial_h
/
4
;
return
;
}
if
(
flag_codec
==
1
)
{
// Cases that only works for VP9.
// For VP9: Swap width and height of original.
if
(
frame
<
320
)
{
*
w
=
initial_h
;
*
h
=
initial_w
;
return
;
}
}
*
w
=
initial_w
;
*
h
=
initial_h
;
}
class
ResizingVideoSource
:
public
::
libvpx_test
::
DummyVideoSource
{
public:
ResizingVideoSource
()
{
SetSize
(
kInitialWidth
,
kInitialHeight
);
limit_
=
3
0
0
;
limit_
=
3
5
0
;
}
int
flag_codec_
;
virtual
~
ResizingVideoSource
()
{}
protected:
virtual
void
Next
()
{
++
frame_
;
SetSize
(
ScaleForFrameNumber
(
frame_
,
kInitialWidth
),
ScaleForFrameNumber
(
frame_
,
kInitialHeight
));
unsigned
int
width
;
unsigned
int
height
;
ScaleForFrameNumber
(
frame_
,
kInitialWidth
,
kInitialHeight
,
&
width
,
&
height
,
flag_codec_
);
SetSize
(
width
,
height
);
FillFrame
();
}
};
...
...
@@ -184,15 +288,17 @@ class ResizeTest : public ::libvpx_test::EncoderTest,
TEST_P
(
ResizeTest
,
TestExternalResizeWorks
)
{
ResizingVideoSource
video
;
video
.
flag_codec_
=
0
;
cfg_
.
g_lag_in_frames
=
0
;
ASSERT_NO_FATAL_FAILURE
(
RunLoop
(
&
video
));
for
(
std
::
vector
<
FrameInfo
>::
const_iterator
info
=
frame_info_list_
.
begin
();
info
!=
frame_info_list_
.
end
();
++
info
)
{
const
unsigned
int
frame
=
static_cast
<
unsigned
>
(
info
->
pts
);
const
unsigned
int
expected_w
=
ScaleForFrameNumber
(
frame
,
kInitialWidth
);
const
unsigned
int
expected_h
=
ScaleForFrameNumber
(
frame
,
kInitialHeight
);
unsigned
int
expected_w
;
unsigned
int
expected_h
;
ScaleForFrameNumber
(
frame
,
kInitialWidth
,
kInitialHeight
,
&
expected_w
,
&
expected_h
,
0
);
EXPECT_EQ
(
expected_w
,
info
->
w
)
<<
"Frame "
<<
frame
<<
" had unexpected width"
;
EXPECT_EQ
(
expected_h
,
info
->
h
)
...
...
@@ -386,6 +492,7 @@ class ResizeRealtimeTest : public ::libvpx_test::EncoderTest,
TEST_P
(
ResizeRealtimeTest
,
TestExternalResizeWorks
)
{
ResizingVideoSource
video
;
video
.
flag_codec_
=
1
;
DefaultConfig
();
// Disable internal resize for this test.
cfg_
.
rc_resize_allowed
=
0
;
...
...
@@ -395,9 +502,10 @@ TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) {
for
(
std
::
vector
<
FrameInfo
>::
const_iterator
info
=
frame_info_list_
.
begin
();
info
!=
frame_info_list_
.
end
();
++
info
)
{
const
unsigned
int
frame
=
static_cast
<
unsigned
>
(
info
->
pts
);
const
unsigned
int
expected_w
=
ScaleForFrameNumber
(
frame
,
kInitialWidth
);
const
unsigned
int
expected_h
=
ScaleForFrameNumber
(
frame
,
kInitialHeight
);
unsigned
int
expected_w
;
unsigned
int
expected_h
;
ScaleForFrameNumber
(
frame
,
kInitialWidth
,
kInitialHeight
,
&
expected_w
,
&
expected_h
,
1
);
EXPECT_EQ
(
expected_w
,
info
->
w
)
<<
"Frame "
<<
frame
<<
" had unexpected width"
;
EXPECT_EQ
(
expected_h
,
info
->
h
)
...
...
vp9/common/vp9_alloccommon.c
View file @
0546636c
...
...
@@ -119,6 +119,20 @@ void vp9_free_context_buffers(VP9_COMMON *cm) {
cm
->
lf
.
lfm
=
NULL
;
}
int
vp9_alloc_loop_filter
(
VP9_COMMON
*
cm
)
{
vpx_free
(
cm
->
lf
.
lfm
);
// Each lfm holds bit masks for all the 8x8 blocks in a 64x64 region. The
// stride and rows are rounded up / truncated to a multiple of 8.
cm
->
lf
.
lfm_stride
=
(
cm
->
mi_cols
+
(
MI_BLOCK_SIZE
-
1
))
>>
3
;
cm
->
lf
.
lfm
=
(
LOOP_FILTER_MASK
*
)
vpx_calloc
(
((
cm
->
mi_rows
+
(
MI_BLOCK_SIZE
-
1
))
>>
3
)
*
cm
->
lf
.
lfm_stride
,
sizeof
(
*
cm
->
lf
.
lfm
));
if
(
!
cm
->
lf
.
lfm
)
return
1
;
return
0
;
}
int
vp9_alloc_context_buffers
(
VP9_COMMON
*
cm
,
int
width
,
int
height
)
{
int
new_mi_size
;
...
...
@@ -151,15 +165,8 @@ int vp9_alloc_context_buffers(VP9_COMMON *cm, int width, int height) {
cm
->
above_context_alloc_cols
=
cm
->
mi_cols
;
}
vpx_free
(
cm
->
lf
.
lfm
);
// Each lfm holds bit masks for all the 8x8 blocks in a 64x64 region. The
// stride and rows are rounded up / truncated to a multiple of 8.
cm
->
lf
.
lfm_stride
=
(
cm
->
mi_cols
+
(
MI_BLOCK_SIZE
-
1
))
>>
3
;
cm
->
lf
.
lfm
=
(
LOOP_FILTER_MASK
*
)
vpx_calloc
(
((
cm
->
mi_rows
+
(
MI_BLOCK_SIZE
-
1
))
>>
3
)
*
cm
->
lf
.
lfm_stride
,
sizeof
(
*
cm
->
lf
.
lfm
));
if
(
!
cm
->
lf
.
lfm
)
goto
fail
;
if
(
vp9_alloc_loop_filter
(
cm
))
goto
fail
;
return
0
;
...
...
vp9/common/vp9_alloccommon.h
View file @
0546636c
...
...
@@ -23,6 +23,7 @@ struct BufferPool;
void
vp9_remove_common
(
struct
VP9Common
*
cm
);
int
vp9_alloc_loop_filter
(
struct
VP9Common
*
cm
);
int
vp9_alloc_context_buffers
(
struct
VP9Common
*
cm
,
int
width
,
int
height
);
void
vp9_init_context_buffers
(
struct
VP9Common
*
cm
);
void
vp9_free_context_buffers
(
struct
VP9Common
*
cm
);
...
...
vp9/encoder/vp9_encoder.c
View file @
0546636c
...
...
@@ -1538,8 +1538,12 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
realloc_segmentation_maps
(
cpi
);
cpi
->
initial_width
=
cpi
->
initial_height
=
0
;
cpi
->
external_resize
=
0
;
}
else
if
(
cm
->
mi_alloc_size
==
new_mi_size
&&
(
cpi
->
oxcf
.
width
>
last_w
||
cpi
->
oxcf
.
height
>
last_h
))
{
vp9_alloc_loop_filter
(
cm
);
}
}
update_frame_size
(
cpi
);
if
((
last_w
!=
cpi
->
oxcf
.
width
||
last_h
!=
cpi
->
oxcf
.
height
)
&&
...
...
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