Commit ee43c95c authored by fbarchard@google.com's avatar fbarchard@google.com

fix memory leaks in *ToI420 functions.

BUG=352
TESTED=drmemory out\debug\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter=**ToI420_Opt
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/21289004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1060 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 0c600525
...@@ -965,9 +965,6 @@ int RGB24ToI420(const uint8* src_rgb24, int src_stride_rgb24, ...@@ -965,9 +965,6 @@ int RGB24ToI420(const uint8* src_rgb24, int src_stride_rgb24,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
ARGBToYRow_C; ARGBToYRow_C;
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif #endif
if (!src_rgb24 || !dst_y || !dst_u || !dst_v || if (!src_rgb24 || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
...@@ -1024,36 +1021,44 @@ int RGB24ToI420(const uint8* src_rgb24, int src_stride_rgb24, ...@@ -1024,36 +1021,44 @@ int RGB24ToI420(const uint8* src_rgb24, int src_stride_rgb24,
#endif // HAS_ARGBTOUVROW_SSSE3 #endif // HAS_ARGBTOUVROW_SSSE3
#endif // HAS_RGB24TOYROW_NEON #endif // HAS_RGB24TOYROW_NEON
for (y = 0; y < height - 1; y += 2) { {
#if !defined(HAS_RGB24TOYROW_NEON)
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_RGB24TOYROW_NEON) #if defined(HAS_RGB24TOYROW_NEON)
RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width); RGB24ToUVRow(src_rgb24, src_stride_rgb24, dst_u, dst_v, width);
RGB24ToYRow(src_rgb24, dst_y, width); RGB24ToYRow(src_rgb24, dst_y, width);
RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width); RGB24ToYRow(src_rgb24 + src_stride_rgb24, dst_y + dst_stride_y, width);
#else #else
RGB24ToARGBRow(src_rgb24, row, width); RGB24ToARGBRow(src_rgb24, row, width);
RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width); RGB24ToARGBRow(src_rgb24 + src_stride_rgb24, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif #endif
src_rgb24 += src_stride_rgb24 * 2; src_rgb24 += src_stride_rgb24 * 2;
dst_y += dst_stride_y * 2; dst_y += dst_stride_y * 2;
dst_u += dst_stride_u; dst_u += dst_stride_u;
dst_v += dst_stride_v; dst_v += dst_stride_v;
} }
if (height & 1) { if (height & 1) {
#if defined(HAS_RGB24TOYROW_NEON) #if defined(HAS_RGB24TOYROW_NEON)
RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width); RGB24ToUVRow(src_rgb24, 0, dst_u, dst_v, width);
RGB24ToYRow(src_rgb24, dst_y, width); RGB24ToYRow(src_rgb24, dst_y, width);
#else #else
RGB24ToARGBRow(src_rgb24, row, width); RGB24ToARGBRow(src_rgb24, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width); ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
#endif #endif
} }
#if !defined(HAS_RGB24TOYROW_NEON) #if !defined(HAS_RGB24TOYROW_NEON)
free_aligned_buffer_64(row); free_aligned_buffer_64(row);
#endif #endif
}
return 0; return 0;
} }
...@@ -1077,9 +1082,6 @@ int RAWToI420(const uint8* src_raw, int src_stride_raw, ...@@ -1077,9 +1082,6 @@ int RAWToI420(const uint8* src_raw, int src_stride_raw,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
ARGBToYRow_C; ARGBToYRow_C;
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif #endif
if (!src_raw || !dst_y || !dst_u || !dst_v || if (!src_raw || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
...@@ -1136,36 +1138,42 @@ int RAWToI420(const uint8* src_raw, int src_stride_raw, ...@@ -1136,36 +1138,42 @@ int RAWToI420(const uint8* src_raw, int src_stride_raw,
#endif // HAS_ARGBTOUVROW_SSSE3 #endif // HAS_ARGBTOUVROW_SSSE3
#endif // HAS_RAWTOYROW_NEON #endif // HAS_RAWTOYROW_NEON
for (y = 0; y < height - 1; y += 2) { {
#if defined(HAS_RAWTOYROW_NEON) // Allocate 2 rows of ARGB.
RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width); const int kRowSize = (width * 4 + 15) & ~15;
RAWToYRow(src_raw, dst_y, width); align_buffer_64(row, kRowSize * 2);
RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width);
#else for (y = 0; y < height - 1; y += 2) {
RAWToARGBRow(src_raw, row, width); #if defined(HAS_RAWTOYROW_NEON)
RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width); RAWToUVRow(src_raw, src_stride_raw, dst_u, dst_v, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); RAWToYRow(src_raw, dst_y, width);
ARGBToYRow(row, dst_y, width); RAWToYRow(src_raw + src_stride_raw, dst_y + dst_stride_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); #else
#endif RAWToARGBRow(src_raw, row, width);
src_raw += src_stride_raw * 2; RAWToARGBRow(src_raw + src_stride_raw, row + kRowSize, width);
dst_y += dst_stride_y * 2; ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
dst_u += dst_stride_u; ARGBToYRow(row, dst_y, width);
dst_v += dst_stride_v; ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
} #endif
if (height & 1) { src_raw += src_stride_raw * 2;
#if defined(HAS_RAWTOYROW_NEON) dst_y += dst_stride_y * 2;
RAWToUVRow(src_raw, 0, dst_u, dst_v, width); dst_u += dst_stride_u;
RAWToYRow(src_raw, dst_y, width); dst_v += dst_stride_v;
#else }
RAWToARGBRow(src_raw, row, width); if (height & 1) {
ARGBToUVRow(row, 0, dst_u, dst_v, width); #if defined(HAS_RAWTOYROW_NEON)
ARGBToYRow(row, dst_y, width); RAWToUVRow(src_raw, 0, dst_u, dst_v, width);
#endif RAWToYRow(src_raw, dst_y, width);
#else
RAWToARGBRow(src_raw, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width);
#endif
}
#if !defined(HAS_RAWTOYROW_NEON)
free_aligned_buffer_64(row);
#endif
} }
#if !defined(HAS_RAWTOYROW_NEON)
free_aligned_buffer_64(row);
#endif
return 0; return 0;
} }
...@@ -1189,9 +1197,6 @@ int RGB565ToI420(const uint8* src_rgb565, int src_stride_rgb565, ...@@ -1189,9 +1197,6 @@ int RGB565ToI420(const uint8* src_rgb565, int src_stride_rgb565,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
ARGBToYRow_C; ARGBToYRow_C;
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif #endif
if (!src_rgb565 || !dst_y || !dst_u || !dst_v || if (!src_rgb565 || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
...@@ -1248,36 +1253,44 @@ int RGB565ToI420(const uint8* src_rgb565, int src_stride_rgb565, ...@@ -1248,36 +1253,44 @@ int RGB565ToI420(const uint8* src_rgb565, int src_stride_rgb565,
#endif // HAS_ARGBTOUVROW_SSSE3 #endif // HAS_ARGBTOUVROW_SSSE3
#endif // HAS_RGB565TOYROW_NEON #endif // HAS_RGB565TOYROW_NEON
for (y = 0; y < height - 1; y += 2) { {
#if !defined(HAS_RGB565TOYROW_NEON)
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_RGB565TOYROW_NEON) #if defined(HAS_RGB565TOYROW_NEON)
RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width); RGB565ToUVRow(src_rgb565, src_stride_rgb565, dst_u, dst_v, width);
RGB565ToYRow(src_rgb565, dst_y, width); RGB565ToYRow(src_rgb565, dst_y, width);
RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width); RGB565ToYRow(src_rgb565 + src_stride_rgb565, dst_y + dst_stride_y, width);
#else #else
RGB565ToARGBRow(src_rgb565, row, width); RGB565ToARGBRow(src_rgb565, row, width);
RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, width); RGB565ToARGBRow(src_rgb565 + src_stride_rgb565, row + kRowSize, width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif #endif
src_rgb565 += src_stride_rgb565 * 2; src_rgb565 += src_stride_rgb565 * 2;
dst_y += dst_stride_y * 2; dst_y += dst_stride_y * 2;
dst_u += dst_stride_u; dst_u += dst_stride_u;
dst_v += dst_stride_v; dst_v += dst_stride_v;
} }
if (height & 1) { if (height & 1) {
#if defined(HAS_RGB565TOYROW_NEON) #if defined(HAS_RGB565TOYROW_NEON)
RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width); RGB565ToUVRow(src_rgb565, 0, dst_u, dst_v, width);
RGB565ToYRow(src_rgb565, dst_y, width); RGB565ToYRow(src_rgb565, dst_y, width);
#else #else
RGB565ToARGBRow(src_rgb565, row, width); RGB565ToARGBRow(src_rgb565, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width); ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
#endif #endif
} }
#if !defined(HAS_RGB565TOYROW_NEON) #if !defined(HAS_RGB565TOYROW_NEON)
free_aligned_buffer_64(row); free_aligned_buffer_64(row);
#endif #endif
}
return 0; return 0;
} }
...@@ -1301,9 +1314,6 @@ int ARGB1555ToI420(const uint8* src_argb1555, int src_stride_argb1555, ...@@ -1301,9 +1314,6 @@ int ARGB1555ToI420(const uint8* src_argb1555, int src_stride_argb1555,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
ARGBToYRow_C; ARGBToYRow_C;
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif #endif
if (!src_argb1555 || !dst_y || !dst_u || !dst_v || if (!src_argb1555 || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
...@@ -1360,38 +1370,45 @@ int ARGB1555ToI420(const uint8* src_argb1555, int src_stride_argb1555, ...@@ -1360,38 +1370,45 @@ int ARGB1555ToI420(const uint8* src_argb1555, int src_stride_argb1555,
#endif // HAS_ARGBTOUVROW_SSSE3 #endif // HAS_ARGBTOUVROW_SSSE3
#endif // HAS_ARGB1555TOYROW_NEON #endif // HAS_ARGB1555TOYROW_NEON
for (y = 0; y < height - 1; y += 2) { {
#if !defined(HAS_ARGB1555TOYROW_NEON)
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_ARGB1555TOYROW_NEON) #if defined(HAS_ARGB1555TOYROW_NEON)
ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width); ARGB1555ToUVRow(src_argb1555, src_stride_argb1555, dst_u, dst_v, width);
ARGB1555ToYRow(src_argb1555, dst_y, width); ARGB1555ToYRow(src_argb1555, dst_y, width);
ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y, ARGB1555ToYRow(src_argb1555 + src_stride_argb1555, dst_y + dst_stride_y,
width); width);
#else #else
ARGB1555ToARGBRow(src_argb1555, row, width); ARGB1555ToARGBRow(src_argb1555, row, width);
ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, row + kRowSize, ARGB1555ToARGBRow(src_argb1555 + src_stride_argb1555, row + kRowSize,
width); width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif #endif
src_argb1555 += src_stride_argb1555 * 2; src_argb1555 += src_stride_argb1555 * 2;
dst_y += dst_stride_y * 2; dst_y += dst_stride_y * 2;
dst_u += dst_stride_u; dst_u += dst_stride_u;
dst_v += dst_stride_v; dst_v += dst_stride_v;
} }
if (height & 1) { if (height & 1) {
#if defined(HAS_ARGB1555TOYROW_NEON) #if defined(HAS_ARGB1555TOYROW_NEON)
ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width); ARGB1555ToUVRow(src_argb1555, 0, dst_u, dst_v, width);
ARGB1555ToYRow(src_argb1555, dst_y, width); ARGB1555ToYRow(src_argb1555, dst_y, width);
#else #else
ARGB1555ToARGBRow(src_argb1555, row, width); ARGB1555ToARGBRow(src_argb1555, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width); ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
#endif #endif
} }
#if !defined(HAS_ARGB1555TOYROW_NEON) #if !defined(HAS_ARGB1555TOYROW_NEON)
free_aligned_buffer_64(row); free_aligned_buffer_64(row);
#endif #endif
}
return 0; return 0;
} }
...@@ -1415,9 +1432,6 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444, ...@@ -1415,9 +1432,6 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444,
uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C; uint8* dst_u, uint8* dst_v, int width) = ARGBToUVRow_C;
void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) = void (*ARGBToYRow)(const uint8* src_argb, uint8* dst_y, int pix) =
ARGBToYRow_C; ARGBToYRow_C;
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif #endif
if (!src_argb4444 || !dst_y || !dst_u || !dst_v || if (!src_argb4444 || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
...@@ -1474,38 +1488,46 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444, ...@@ -1474,38 +1488,46 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444,
#endif // HAS_ARGBTOUVROW_SSSE3 #endif // HAS_ARGBTOUVROW_SSSE3
#endif // HAS_ARGB4444TOYROW_NEON #endif // HAS_ARGB4444TOYROW_NEON
for (y = 0; y < height - 1; y += 2) { {
#if !defined(HAS_ARGB4444TOYROW_NEON)
// Allocate 2 rows of ARGB.
const int kRowSize = (width * 4 + 15) & ~15;
align_buffer_64(row, kRowSize * 2);
#endif
for (y = 0; y < height - 1; y += 2) {
#if defined(HAS_ARGB4444TOYROW_NEON) #if defined(HAS_ARGB4444TOYROW_NEON)
ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width); ARGB4444ToUVRow(src_argb4444, src_stride_argb4444, dst_u, dst_v, width);
ARGB4444ToYRow(src_argb4444, dst_y, width); ARGB4444ToYRow(src_argb4444, dst_y, width);
ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y, ARGB4444ToYRow(src_argb4444 + src_stride_argb4444, dst_y + dst_stride_y,
width); width);
#else #else
ARGB4444ToARGBRow(src_argb4444, row, width); ARGB4444ToARGBRow(src_argb4444, row, width);
ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, row + kRowSize, ARGB4444ToARGBRow(src_argb4444 + src_stride_argb4444, row + kRowSize,
width); width);
ARGBToUVRow(row, kRowSize, dst_u, dst_v, width); ARGBToUVRow(row, kRowSize, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width); ARGBToYRow(row + kRowSize, dst_y + dst_stride_y, width);
#endif #endif
src_argb4444 += src_stride_argb4444 * 2; src_argb4444 += src_stride_argb4444 * 2;
dst_y += dst_stride_y * 2; dst_y += dst_stride_y * 2;
dst_u += dst_stride_u; dst_u += dst_stride_u;
dst_v += dst_stride_v; dst_v += dst_stride_v;
} }
if (height & 1) { if (height & 1) {
#if defined(HAS_ARGB4444TOYROW_NEON) #if defined(HAS_ARGB4444TOYROW_NEON)
ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width); ARGB4444ToUVRow(src_argb4444, 0, dst_u, dst_v, width);
ARGB4444ToYRow(src_argb4444, dst_y, width); ARGB4444ToYRow(src_argb4444, dst_y, width);
#else #else
ARGB4444ToARGBRow(src_argb4444, row, width); ARGB4444ToARGBRow(src_argb4444, row, width);
ARGBToUVRow(row, 0, dst_u, dst_v, width); ARGBToUVRow(row, 0, dst_u, dst_v, width);
ARGBToYRow(row, dst_y, width); ARGBToYRow(row, dst_y, width);
#endif #endif
} }
#if !defined(HAS_ARGB4444TOYROW_NEON) #if !defined(HAS_ARGB4444TOYROW_NEON)
free_aligned_buffer_64(row); free_aligned_buffer_64(row);
#endif #endif
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment