Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
libvpx
Commits
254889cd
Commit
254889cd
authored
13 years ago
by
Yunqing Wang
Committed by
Gerrit Code Review
13 years ago
Browse files
Options
Download
Plain Diff
Merge "Allow aligning the raw image buffer"
parents
aa7335e6
be5bbc96
v1.14.0-linphone
1.4.X
eider
experimental
feature/update_to_v1.9.0-linphone
feature/uwp_nuget
forest
frame_parallel
highbitdepth
indianrunnerduck
javanwhistlingduck
khakicampbell
linphone
linphone-android
linphone-old
longtailedduck
m29-baseline
m31-baseline
m49-2623
m52-2743
m54-2840
m56-2924
m66-3359
m68-3440
mandarinduck
mcw
mcw2
nextgen
nextgenv2
pcs-2013
playground
sandbox/Jingning/experimental
sandbox/Jingning/transcode
sandbox/Jingning/vpx
sandbox/aconverse@google.com/ansbench
sandbox/debargha/playground
sandbox/hkuang/frame_parallel
sandbox/hkuang@google.com/decode
sandbox/jimbankoski@google.com/proposed-aom
sandbox/jingning@google.com/decoder_test_suite
sandbox/jingning@google.com/experimental
sandbox/jkoleszar/new-rtcd
sandbox/jkoleszar/reuse-modemv
sandbox/jzern@google.com/test
sandbox/wangch@google.com/vp9
sandbox/yaowu@google.com/mergeaom
stable-vp9-decoder
v1.12.0-linphone
v1.6.1_linphone
v1.7.0-linphone
v1.9.0-linphone
vp9-preview
v1.9.0
v1.9.0-rc1
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.0
v1.4.0
v1.3.0
v1.2.0
v1.1.0
v1.0.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vpx/src/vpx_image.c
+48
-5
vpx/src/vpx_image.c
vpx/vpx_image.h
+2
-1
vpx/vpx_image.h
with
50 additions
and
6 deletions
vpx/src/vpx_image.c
+
48
−
5
View file @
254889cd
...
@@ -13,10 +13,42 @@
...
@@ -13,10 +13,42 @@
#include
<string.h>
#include
<string.h>
#include
"vpx/vpx_image.h"
#include
"vpx/vpx_image.h"
#define ADDRESS_STORAGE_SIZE sizeof(size_t)
/*returns an addr aligned to the byte boundary specified by align*/
#define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
/* Memalign code is copied from vpx_mem.c */
static
void
*
img_buf_memalign
(
size_t
align
,
size_t
size
)
{
void
*
addr
,
*
x
=
NULL
;
addr
=
malloc
(
size
+
align
-
1
+
ADDRESS_STORAGE_SIZE
);
if
(
addr
)
{
x
=
align_addr
((
unsigned
char
*
)
addr
+
ADDRESS_STORAGE_SIZE
,
(
int
)
align
);
/* save the actual malloc address */
((
size_t
*
)
x
)[
-
1
]
=
(
size_t
)
addr
;
}
return
x
;
}
static
void
img_buf_free
(
void
*
memblk
)
{
if
(
memblk
)
{
void
*
addr
=
(
void
*
)(((
size_t
*
)
memblk
)[
-
1
]);
free
(
addr
);
}
}
static
vpx_image_t
*
img_alloc_helper
(
vpx_image_t
*
img
,
static
vpx_image_t
*
img_alloc_helper
(
vpx_image_t
*
img
,
vpx_img_fmt_t
fmt
,
vpx_img_fmt_t
fmt
,
unsigned
int
d_w
,
unsigned
int
d_w
,
unsigned
int
d_h
,
unsigned
int
d_h
,
unsigned
int
buf_align
,
unsigned
int
stride_align
,
unsigned
int
stride_align
,
unsigned
char
*
img_data
)
unsigned
char
*
img_data
)
{
{
...
@@ -24,6 +56,14 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
...
@@ -24,6 +56,14 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
unsigned
int
h
,
w
,
s
,
xcs
,
ycs
,
bps
;
unsigned
int
h
,
w
,
s
,
xcs
,
ycs
,
bps
;
int
align
;
int
align
;
/* Treat align==0 like align==1 */
if
(
!
buf_align
)
buf_align
=
1
;
/* Validate alignment (must be power of 2) */
if
(
buf_align
&
(
buf_align
-
1
))
goto
fail
;
/* Treat align==0 like align==1 */
/* Treat align==0 like align==1 */
if
(
!
stride_align
)
if
(
!
stride_align
)
stride_align
=
1
;
stride_align
=
1
;
...
@@ -119,7 +159,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
...
@@ -119,7 +159,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img,
if
(
!
img_data
)
if
(
!
img_data
)
{
{
img
->
img_data
=
malloc
((
fmt
&
VPX_IMG_FMT_PLANAR
)
?
h
*
w
*
bps
/
8
:
h
*
s
);
img
->
img_data
=
img_buf_memalign
(
buf_align
,
((
fmt
&
VPX_IMG_FMT_PLANAR
)
?
h
*
s
*
bps
/
8
:
h
*
s
));
img
->
img_data_owner
=
1
;
img
->
img_data_owner
=
1
;
}
}
...
@@ -150,9 +191,9 @@ vpx_image_t *vpx_img_alloc(vpx_image_t *img,
...
@@ -150,9 +191,9 @@ vpx_image_t *vpx_img_alloc(vpx_image_t *img,
vpx_img_fmt_t
fmt
,
vpx_img_fmt_t
fmt
,
unsigned
int
d_w
,
unsigned
int
d_w
,
unsigned
int
d_h
,
unsigned
int
d_h
,
unsigned
int
stride_
align
)
unsigned
int
align
)
{
{
return
img_alloc_helper
(
img
,
fmt
,
d_w
,
d_h
,
stride_
align
,
NULL
);
return
img_alloc_helper
(
img
,
fmt
,
d_w
,
d_h
,
align
,
align
,
NULL
);
}
}
vpx_image_t
*
vpx_img_wrap
(
vpx_image_t
*
img
,
vpx_image_t
*
vpx_img_wrap
(
vpx_image_t
*
img
,
...
@@ -162,7 +203,9 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img,
...
@@ -162,7 +203,9 @@ vpx_image_t *vpx_img_wrap(vpx_image_t *img,
unsigned
int
stride_align
,
unsigned
int
stride_align
,
unsigned
char
*
img_data
)
unsigned
char
*
img_data
)
{
{
return
img_alloc_helper
(
img
,
fmt
,
d_w
,
d_h
,
stride_align
,
img_data
);
/* By setting buf_align = 1, we don't change buffer alignment in this
* function. */
return
img_alloc_helper
(
img
,
fmt
,
d_w
,
d_h
,
1
,
stride_align
,
img_data
);
}
}
int
vpx_img_set_rect
(
vpx_image_t
*
img
,
int
vpx_img_set_rect
(
vpx_image_t
*
img
,
...
@@ -254,7 +297,7 @@ void vpx_img_free(vpx_image_t *img)
...
@@ -254,7 +297,7 @@ void vpx_img_free(vpx_image_t *img)
if
(
img
)
if
(
img
)
{
{
if
(
img
->
img_data
&&
img
->
img_data_owner
)
if
(
img
->
img_data
&&
img
->
img_data_owner
)
free
(
img
->
img_data
);
img_buf_
free
(
img
->
img_data
);
if
(
img
->
self_allocd
)
if
(
img
->
self_allocd
)
free
(
img
);
free
(
img
);
...
...
This diff is collapsed.
Click to expand it.
vpx/vpx_image.h
+
2
−
1
View file @
254889cd
...
@@ -160,7 +160,8 @@ extern "C" {
...
@@ -160,7 +160,8 @@ extern "C" {
* \param[in] fmt Format for the image
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of each row in the image.
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image(stride).
*
*
* \return Returns a pointer to the initialized image descriptor. If the img
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* parameter is non-null, the value of the img parameter will be
...
...
This diff is collapsed.
Click to expand it.
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!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets