Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
88340b17
Commit
88340b17
authored
Jan 31, 2014
by
Dmitry Kovalev
Committed by
Gerrit Code Review
Jan 31, 2014
Browse files
Merge "Combining fb_idx_ref_cnt[] and yv12_fb[] arrays."
parents
a8a2f229
63320634
Changes
7
Hide whitespace changes
Inline
Side-by-side
vp9/common/vp9_alloccommon.c
View file @
88340b17
...
...
@@ -34,7 +34,7 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) {
int
i
;
for
(
i
=
0
;
i
<
FRAME_BUFFERS
;
i
++
)
vp9_free_frame_buffer
(
&
cm
->
yv12_fb
[
i
]
);
vp9_free_frame_buffer
(
&
cm
->
frame_bufs
[
i
].
buf
);
vp9_free_frame_buffer
(
&
cm
->
post_proc_buffer
);
...
...
@@ -140,18 +140,18 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
vp9_free_frame_buffers
(
cm
);
for
(
i
=
0
;
i
<
FRAME_BUFFERS
;
i
++
)
{
cm
->
f
b_idx_ref_cnt
[
i
]
=
0
;
if
(
vp9_alloc_frame_buffer
(
&
cm
->
yv12_fb
[
i
]
,
width
,
height
,
ss_x
,
ss_y
,
VP9_ENC_BORDER_IN_PIXELS
)
<
0
)
cm
->
f
rame_bufs
[
i
].
ref_count
=
0
;
if
(
vp9_alloc_frame_buffer
(
&
cm
->
frame_bufs
[
i
].
buf
,
width
,
height
,
ss_x
,
ss_y
,
VP9_ENC_BORDER_IN_PIXELS
)
<
0
)
goto
fail
;
}
cm
->
new_fb_idx
=
FRAME_BUFFERS
-
1
;
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
=
1
;
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
=
1
;
for
(
i
=
0
;
i
<
REF_FRAMES
;
i
++
)
{
cm
->
ref_frame_map
[
i
]
=
i
;
cm
->
f
b_idx_ref_cnt
[
i
]
=
1
;
cm
->
f
rame_bufs
[
i
].
ref_count
=
1
;
}
if
(
vp9_alloc_frame_buffer
(
&
cm
->
post_proc_buffer
,
width
,
height
,
ss_x
,
ss_y
,
...
...
vp9/common/vp9_onyxc_int.h
View file @
88340b17
...
...
@@ -91,6 +91,12 @@ typedef enum {
REFERENCE_MODES
=
3
,
}
REFERENCE_MODE
;
typedef
struct
{
int
ref_count
;
YV12_BUFFER_CONFIG
buf
;
}
RefCntBuffer
;
typedef
struct
VP9Common
{
struct
vpx_internal_error_info
error
;
...
...
@@ -117,8 +123,8 @@ typedef struct VP9Common {
YV12_BUFFER_CONFIG
*
frame_to_show
;
YV12_BUFFER_CONFIG
yv12_fb
[
FRAME_BUFFERS
];
int
fb_idx_ref_cnt
[
FRAME_BUFFERS
];
/* reference counts */
RefCntBuffer
frame_bufs
[
FRAME_BUFFERS
];
int
ref_frame_map
[
REF_FRAMES
];
/* maps fb_idx to reference slot */
// TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and
...
...
@@ -220,29 +226,29 @@ typedef struct VP9Common {
}
VP9_COMMON
;
static
YV12_BUFFER_CONFIG
*
get_frame_new_buffer
(
VP9_COMMON
*
cm
)
{
return
&
cm
->
yv12_fb
[
cm
->
new_fb_idx
];
return
&
cm
->
frame_bufs
[
cm
->
new_fb_idx
]
.
buf
;
}
static
int
get_free_fb
(
VP9_COMMON
*
cm
)
{
int
i
;
for
(
i
=
0
;
i
<
FRAME_BUFFERS
;
i
++
)
if
(
cm
->
f
b_idx_ref_cnt
[
i
]
==
0
)
if
(
cm
->
f
rame_bufs
[
i
].
ref_count
==
0
)
break
;
assert
(
i
<
FRAME_BUFFERS
);
cm
->
f
b_idx_ref_cnt
[
i
]
=
1
;
cm
->
f
rame_bufs
[
i
].
ref_count
=
1
;
return
i
;
}
static
void
ref_cnt_fb
(
int
*
buf
,
int
*
idx
,
int
new_idx
)
{
static
void
ref_cnt_fb
(
RefCntBuffer
*
buf
s
,
int
*
idx
,
int
new_idx
)
{
const
int
ref_index
=
*
idx
;
if
(
ref_index
>=
0
&&
buf
[
ref_index
]
>
0
)
buf
[
ref_index
]
--
;
if
(
ref_index
>=
0
&&
buf
s
[
ref_index
]
.
ref_count
>
0
)
buf
s
[
ref_index
]
.
ref_count
--
;
*
idx
=
new_idx
;
buf
[
new_idx
]
++
;
buf
s
[
new_idx
]
.
ref_count
++
;
}
static
int
mi_cols_aligned_to_sb
(
int
n_mis
)
{
...
...
vp9/decoder/vp9_decodeframe.c
View file @
88340b17
...
...
@@ -1115,7 +1115,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
if
(
cm
->
show_existing_frame
)
{
// Show an existing frame directly.
int
frame_to_show
=
cm
->
ref_frame_map
[
vp9_rb_read_literal
(
rb
,
3
)];
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
&
cm
->
new_fb_idx
,
frame_to_show
);
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
new_fb_idx
,
frame_to_show
);
pbi
->
refresh_frame_flags
=
0
;
cm
->
lf
.
filter_level
=
0
;
cm
->
show_frame
=
1
;
...
...
@@ -1175,7 +1175,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
const
int
ref
=
vp9_rb_read_literal
(
rb
,
REF_FRAMES_LOG2
);
const
int
idx
=
cm
->
ref_frame_map
[
ref
];
cm
->
frame_refs
[
i
].
idx
=
idx
;
cm
->
frame_refs
[
i
].
buf
=
&
cm
->
yv12_fb
[
idx
];
cm
->
frame_refs
[
i
].
buf
=
&
cm
->
frame_bufs
[
idx
]
.
buf
;
cm
->
ref_frame_sign_bias
[
LAST_FRAME
+
i
]
=
vp9_rb_read_bit
(
rb
);
}
...
...
vp9/decoder/vp9_onyxd_if.c
View file @
88340b17
...
...
@@ -194,7 +194,8 @@ void vp9_remove_decompressor(VP9D_PTR ptr) {
vpx_free
(
pbi
);
}
static
int
equal_dimensions
(
YV12_BUFFER_CONFIG
*
a
,
YV12_BUFFER_CONFIG
*
b
)
{
static
int
equal_dimensions
(
const
YV12_BUFFER_CONFIG
*
a
,
const
YV12_BUFFER_CONFIG
*
b
)
{
return
a
->
y_height
==
b
->
y_height
&&
a
->
y_width
==
b
->
y_width
&&
a
->
uv_height
==
b
->
uv_height
&&
a
->
uv_width
==
b
->
uv_width
;
}
...
...
@@ -211,7 +212,8 @@ vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr,
* later commit that adds VP9-specific controls for this functionality.
*/
if
(
ref_frame_flag
==
VP9_LAST_FLAG
)
{
YV12_BUFFER_CONFIG
*
cfg
=
&
cm
->
yv12_fb
[
cm
->
ref_frame_map
[
0
]];
const
YV12_BUFFER_CONFIG
*
const
cfg
=
&
cm
->
frame_bufs
[
cm
->
ref_frame_map
[
0
]].
buf
;
if
(
!
equal_dimensions
(
cfg
,
sd
))
vpx_internal_error
(
&
cm
->
error
,
VPX_CODEC_ERROR
,
"Incorrect buffer dimensions"
);
...
...
@@ -257,13 +259,13 @@ vpx_codec_err_t vp9_set_reference_dec(VP9D_PTR ptr, VP9_REFFRAME ref_frame_flag,
// Find an empty frame buffer.
const
int
free_fb
=
get_free_fb
(
cm
);
// Decrease
fb_idx_
ref_cnt since it will be increased again in
// Decrease ref_c
ou
nt since it will be increased again in
// ref_cnt_fb() below.
cm
->
f
b_idx_ref_cnt
[
free_fb
]
--
;
cm
->
f
rame_bufs
[
free_fb
].
ref_count
--
;
// Manage the reference counters and copy image.
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_fb_ptr
,
free_fb
);
ref_buf
->
buf
=
&
cm
->
yv12_fb
[
*
ref_fb_ptr
];
ref_cnt_fb
(
cm
->
f
rame_bufs
,
ref_fb_ptr
,
free_fb
);
ref_buf
->
buf
=
&
cm
->
frame_bufs
[
*
ref_fb_ptr
]
.
buf
;
vp8_yv12_copy_frame
(
sd
,
ref_buf
->
buf
);
}
...
...
@@ -278,7 +280,7 @@ int vp9_get_reference_dec(VP9D_PTR ptr, int index, YV12_BUFFER_CONFIG **fb) {
if
(
index
<
0
||
index
>=
REF_FRAMES
)
return
-
1
;
*
fb
=
&
cm
->
yv12_fb
[
cm
->
ref_frame_map
[
index
]];
*
fb
=
&
cm
->
frame_bufs
[
cm
->
ref_frame_map
[
index
]]
.
buf
;
return
0
;
}
...
...
@@ -289,13 +291,13 @@ static void swap_frame_buffers(VP9D_COMP *pbi) {
for
(
mask
=
pbi
->
refresh_frame_flags
;
mask
;
mask
>>=
1
)
{
if
(
mask
&
1
)
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
&
cm
->
ref_frame_map
[
ref_index
],
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
ref_index
],
cm
->
new_fb_idx
);
++
ref_index
;
}
cm
->
frame_to_show
=
get_frame_new_buffer
(
cm
);
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
--
;
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
--
;
// Invalidate these references until the next frame starts.
for
(
ref_index
=
0
;
ref_index
<
3
;
ref_index
++
)
...
...
@@ -351,8 +353,8 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
if
(
cm
->
frame_refs
[
0
].
idx
!=
INT_MAX
)
cm
->
frame_refs
[
0
].
buf
->
corrupted
=
1
;
if
(
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
>
0
)
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
--
;
if
(
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
>
0
)
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
--
;
return
-
1
;
}
...
...
@@ -364,8 +366,8 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
if
(
retcode
<
0
)
{
cm
->
error
.
error_code
=
VPX_CODEC_ERROR
;
cm
->
error
.
setjmp
=
0
;
if
(
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
>
0
)
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
--
;
if
(
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
>
0
)
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
--
;
return
retcode
;
}
...
...
vp9/encoder/vp9_onyx_if.c
View file @
88340b17
...
...
@@ -2197,7 +2197,7 @@ int vp9_get_reference_enc(VP9_PTR ptr, int index, YV12_BUFFER_CONFIG **fb) {
if
(
index
<
0
||
index
>=
REF_FRAMES
)
return
-
1
;
*
fb
=
&
cm
->
yv12_fb
[
cm
->
ref_frame_map
[
index
]];
*
fb
=
&
cm
->
frame_bufs
[
cm
->
ref_frame_map
[
index
]]
.
buf
;
return
0
;
}
...
...
@@ -2489,9 +2489,9 @@ static void update_reference_frames(VP9_COMP * const cpi) {
// At this point the new frame has been encoded.
// If any buffer copy / swapping is signaled it should be done here.
if
(
cm
->
frame_type
==
KEY_FRAME
)
{
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
cpi
->
gld_fb_idx
],
cm
->
new_fb_idx
);
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
cpi
->
alt_fb_idx
],
cm
->
new_fb_idx
);
}
#if CONFIG_MULTIPLE_ARF
...
...
@@ -2512,7 +2512,7 @@ static void update_reference_frames(VP9_COMP * const cpi) {
*/
int
tmp
;
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
cpi
->
alt_fb_idx
],
cm
->
new_fb_idx
);
tmp
=
cpi
->
alt_fb_idx
;
...
...
@@ -2526,18 +2526,18 @@ static void update_reference_frames(VP9_COMP * const cpi) {
arf_idx
=
cpi
->
arf_buffer_idx
[
cpi
->
sequence_number
+
1
];
}
#endif
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
arf_idx
],
cm
->
new_fb_idx
);
}
if
(
cpi
->
refresh_golden_frame
)
{
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
cpi
->
gld_fb_idx
],
cm
->
new_fb_idx
);
}
}
if
(
cpi
->
refresh_last_frame
)
{
ref_cnt_fb
(
cm
->
f
b_idx_ref_cnt
,
ref_cnt_fb
(
cm
->
f
rame_bufs
,
&
cm
->
ref_frame_map
[
cpi
->
lst_fb_idx
],
cm
->
new_fb_idx
);
}
}
...
...
@@ -2575,20 +2575,20 @@ static void scale_references(VP9_COMP *cpi) {
for
(
ref_frame
=
LAST_FRAME
;
ref_frame
<=
ALTREF_FRAME
;
++
ref_frame
)
{
const
int
idx
=
cm
->
ref_frame_map
[
get_ref_frame_idx
(
cpi
,
ref_frame
)];
YV12_BUFFER_CONFIG
*
ref
=
&
cm
->
yv12_fb
[
idx
];
YV12_BUFFER_CONFIG
*
const
ref
=
&
cm
->
frame_bufs
[
idx
]
.
buf
;
if
(
ref
->
y_crop_width
!=
cm
->
width
||
ref
->
y_crop_height
!=
cm
->
height
)
{
const
int
new_fb
=
get_free_fb
(
cm
);
vp9_realloc_frame_buffer
(
&
cm
->
yv12_fb
[
new_fb
],
vp9_realloc_frame_buffer
(
&
cm
->
frame_bufs
[
new_fb
]
.
buf
,
cm
->
width
,
cm
->
height
,
cm
->
subsampling_x
,
cm
->
subsampling_y
,
VP9_ENC_BORDER_IN_PIXELS
);
scale_and_extend_frame
(
ref
,
&
cm
->
yv12_fb
[
new_fb
]);
scale_and_extend_frame
(
ref
,
&
cm
->
frame_bufs
[
new_fb
]
.
buf
);
cpi
->
scaled_ref_idx
[
ref_frame
-
1
]
=
new_fb
;
}
else
{
cpi
->
scaled_ref_idx
[
ref_frame
-
1
]
=
idx
;
cm
->
f
b_
idx
_
ref_cnt
[
idx
]
++
;
cm
->
f
rame_bufs
[
idx
].
ref_c
ou
nt
++
;
}
}
}
...
...
@@ -2598,7 +2598,7 @@ static void release_scaled_references(VP9_COMP *cpi) {
int
i
;
for
(
i
=
0
;
i
<
3
;
i
++
)
cm
->
f
b_idx_ref_cnt
[
cpi
->
scaled_ref_idx
[
i
]]
--
;
cm
->
f
rame_bufs
[
cpi
->
scaled_ref_idx
[
i
]]
.
ref_count
--
;
}
static
void
full_to_model_count
(
unsigned
int
*
model_count
,
...
...
@@ -3567,7 +3567,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
/* find a free buffer for the new frame, releasing the reference previously
* held.
*/
cm
->
f
b_idx_ref_cnt
[
cm
->
new_fb_idx
]
--
;
cm
->
f
rame_bufs
[
cm
->
new_fb_idx
]
.
ref_count
--
;
cm
->
new_fb_idx
=
get_free_fb
(
cm
);
#if CONFIG_MULTIPLE_ARF
...
...
@@ -3591,8 +3591,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
for
(
ref_frame
=
LAST_FRAME
;
ref_frame
<=
ALTREF_FRAME
;
++
ref_frame
)
{
const
int
idx
=
cm
->
ref_frame_map
[
get_ref_frame_idx
(
cpi
,
ref_frame
)];
YV12_BUFFER_CONFIG
*
const
buf
=
&
cm
->
yv12_fb
[
idx
];
YV12_BUFFER_CONFIG
*
const
buf
=
&
cm
->
frame_bufs
[
idx
].
buf
;
RefBuffer
*
const
ref_buf
=
&
cm
->
frame_refs
[
ref_frame
-
1
];
ref_buf
->
buf
=
buf
;
ref_buf
->
idx
=
idx
;
...
...
vp9/encoder/vp9_onyx_int.h
View file @
88340b17
...
...
@@ -733,7 +733,8 @@ static int get_ref_frame_idx(const VP9_COMP *cpi,
static
YV12_BUFFER_CONFIG
*
get_ref_frame_buffer
(
VP9_COMP
*
cpi
,
MV_REFERENCE_FRAME
ref_frame
)
{
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
return
&
cm
->
yv12_fb
[
cm
->
ref_frame_map
[
get_ref_frame_idx
(
cpi
,
ref_frame
)]];
return
&
cm
->
frame_bufs
[
cm
->
ref_frame_map
[
get_ref_frame_idx
(
cpi
,
ref_frame
)]].
buf
;
}
void
vp9_encode_frame
(
VP9_COMP
*
cpi
);
...
...
vp9/encoder/vp9_rdopt.c
View file @
88340b17
...
...
@@ -2331,7 +2331,7 @@ const YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi,
const
VP9_COMMON
*
const
cm
=
&
cpi
->
common
;
const
int
ref_idx
=
cm
->
ref_frame_map
[
get_ref_frame_idx
(
cpi
,
ref_frame
)];
const
int
scaled_idx
=
cpi
->
scaled_ref_idx
[
ref_frame
-
1
];
return
(
scaled_idx
!=
ref_idx
)
?
&
cm
->
yv12_fb
[
scaled_idx
]
:
NULL
;
return
(
scaled_idx
!=
ref_idx
)
?
&
cm
->
frame_bufs
[
scaled_idx
]
.
buf
:
NULL
;
}
static
INLINE
int
get_switchable_rate
(
const
MACROBLOCK
*
x
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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