Move the memory allocation/deallocation routines to the common library

They are still used slightly differently in the encoder and decoder;
the decoder uses plain functions while the encoder uses one object
keeping track of the number of allocated bytes, and keeping track
of the requested alignment.
This commit is contained in:
Martin Storsjö
2015-01-30 10:44:04 +02:00
parent 869870e670
commit 2356eb1ff6
28 changed files with 148 additions and 297 deletions

View File

@@ -19,6 +19,7 @@
4CE443D918B722CD0017DF25 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CE443D818B722CD0017DF25 /* Foundation.framework */; }; 4CE443D918B722CD0017DF25 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CE443D818B722CD0017DF25 /* Foundation.framework */; };
53C1C9BC193F0FB000404D8F /* expand_pic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */; }; 53C1C9BC193F0FB000404D8F /* expand_pic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */; };
5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */; }; 5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */; };
5BD896BA1A7B839B00D32B7D /* memory_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BD896B91A7B839B00D32B7D /* memory_align.cpp */; };
5BDD15ED1A79027600B6CA2E /* mc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BDD15EC1A79027600B6CA2E /* mc.cpp */; }; 5BDD15ED1A79027600B6CA2E /* mc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5BDD15EC1A79027600B6CA2E /* mc.cpp */; };
F0B204F918FD23BF005DA23F /* copy_mb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0B204F818FD23BF005DA23F /* copy_mb.cpp */; }; F0B204F918FD23BF005DA23F /* copy_mb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0B204F818FD23BF005DA23F /* copy_mb.cpp */; };
F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */ = {isa = PBXBuildFile; fileRef = F556A8221906673900E156A8 /* arm_arch64_common_macro.S */; }; F556A8241906673900E156A8 /* arm_arch64_common_macro.S in Sources */ = {isa = PBXBuildFile; fileRef = F556A8221906673900E156A8 /* arm_arch64_common_macro.S */; };
@@ -70,6 +71,8 @@
53C1C9BB193F0FB000404D8F /* expand_pic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = expand_pic.cpp; sourceTree = "<group>"; }; 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = expand_pic.cpp; sourceTree = "<group>"; };
5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wels_common_defs.h; sourceTree = "<group>"; }; 5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wels_common_defs.h; sourceTree = "<group>"; };
5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common_tables.cpp; sourceTree = "<group>"; }; 5BA8F2BF19603F5F00011CE4 /* common_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common_tables.cpp; sourceTree = "<group>"; };
5BD896B81A7B837700D32B7D /* memory_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_align.h; sourceTree = "<group>"; };
5BD896B91A7B839B00D32B7D /* memory_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memory_align.cpp; sourceTree = "<group>"; };
5BDD15EB1A79026A00B6CA2E /* mc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc.h; sourceTree = "<group>"; }; 5BDD15EB1A79026A00B6CA2E /* mc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mc.h; sourceTree = "<group>"; };
5BDD15EC1A79027600B6CA2E /* mc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mc.cpp; sourceTree = "<group>"; }; 5BDD15EC1A79027600B6CA2E /* mc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mc.cpp; sourceTree = "<group>"; };
F0B204F718FD23B6005DA23F /* copy_mb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = copy_mb.h; sourceTree = "<group>"; }; F0B204F718FD23B6005DA23F /* copy_mb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = copy_mb.h; sourceTree = "<group>"; };
@@ -127,6 +130,7 @@
4C3406BE18D96EA600DFA14A /* macros.h */, 4C3406BE18D96EA600DFA14A /* macros.h */,
5BDD15EB1A79026A00B6CA2E /* mc.h */, 5BDD15EB1A79026A00B6CA2E /* mc.h */,
4C3406C018D96EA600DFA14A /* measure_time.h */, 4C3406C018D96EA600DFA14A /* measure_time.h */,
5BD896B81A7B837700D32B7D /* memory_align.h */,
4C3406C118D96EA600DFA14A /* typedefs.h */, 4C3406C118D96EA600DFA14A /* typedefs.h */,
5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */, 5BA8F2BE19603F3500011CE4 /* wels_common_defs.h */,
4C3406C218D96EA600DFA14A /* WelsThreadLib.h */, 4C3406C218D96EA600DFA14A /* WelsThreadLib.h */,
@@ -146,6 +150,7 @@
53C1C9BB193F0FB000404D8F /* expand_pic.cpp */, 53C1C9BB193F0FB000404D8F /* expand_pic.cpp */,
4C3406C618D96EA600DFA14A /* deblocking_common.cpp */, 4C3406C618D96EA600DFA14A /* deblocking_common.cpp */,
5BDD15EC1A79027600B6CA2E /* mc.cpp */, 5BDD15EC1A79027600B6CA2E /* mc.cpp */,
5BD896B91A7B839B00D32B7D /* memory_align.cpp */,
4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */, 4C3406C818D96EA600DFA14A /* WelsThreadLib.cpp */,
); );
path = src; path = src;
@@ -260,6 +265,7 @@
F5AC94FF193EB7D800F58154 /* deblocking_aarch64_neon.S in Sources */, F5AC94FF193EB7D800F58154 /* deblocking_aarch64_neon.S in Sources */,
4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */, 4C3406CE18D96EA600DFA14A /* crt_util_safe_x.cpp in Sources */,
F791965919D3BE2200F60C6B /* intra_pred_common.cpp in Sources */, F791965919D3BE2200F60C6B /* intra_pred_common.cpp in Sources */,
5BD896BA1A7B839B00D32B7D /* memory_align.cpp in Sources */,
4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */, 4C3406CF18D96EA600DFA14A /* deblocking_common.cpp in Sources */,
5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */, 5BA8F2C019603F5F00011CE4 /* common_tables.cpp in Sources */,
F791965419D3B89D00F60C6B /* intra_pred_common_aarch64_neon.S in Sources */, F791965419D3B89D00F60C6B /* intra_pred_common_aarch64_neon.S in Sources */,

View File

@@ -20,7 +20,6 @@
4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467018BC5EAA0017DF25 /* fmo.cpp */; }; 4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467018BC5EAA0017DF25 /* fmo.cpp */; };
4CE4469418BC5EAB0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */; }; 4CE4469418BC5EAB0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */; };
4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */; }; 4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */; };
4CE4469718BC5EAB0017DF25 /* mem_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467418BC5EAA0017DF25 /* mem_align.cpp */; };
4CE4469818BC5EAB0017DF25 /* memmgr_nal_unit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */; }; 4CE4469818BC5EAB0017DF25 /* memmgr_nal_unit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */; };
4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */; }; 4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */; };
4CE4469A18BC5EAB0017DF25 /* parse_mb_syn_cavlc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */; }; 4CE4469A18BC5EAB0017DF25 /* parse_mb_syn_cavlc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */; };
@@ -71,7 +70,6 @@
4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; }; 4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = manage_dec_ref.h; sourceTree = "<group>"; }; 4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = manage_dec_ref.h; sourceTree = "<group>"; };
4CE4465518BC5EAA0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; }; 4CE4465518BC5EAA0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; };
4CE4465718BC5EAA0017DF25 /* mem_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem_align.h; sourceTree = "<group>"; };
4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memmgr_nal_unit.h; sourceTree = "<group>"; }; 4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memmgr_nal_unit.h; sourceTree = "<group>"; };
4CE4465918BC5EAA0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; }; 4CE4465918BC5EAA0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; };
4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_prefix.h; sourceTree = "<group>"; }; 4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_prefix.h; sourceTree = "<group>"; };
@@ -96,7 +94,6 @@
4CE4467018BC5EAA0017DF25 /* fmo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fmo.cpp; sourceTree = "<group>"; }; 4CE4467018BC5EAA0017DF25 /* fmo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fmo.cpp; sourceTree = "<group>"; };
4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; }; 4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; };
4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manage_dec_ref.cpp; sourceTree = "<group>"; }; 4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manage_dec_ref.cpp; sourceTree = "<group>"; };
4CE4467418BC5EAA0017DF25 /* mem_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mem_align.cpp; sourceTree = "<group>"; };
4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memmgr_nal_unit.cpp; sourceTree = "<group>"; }; 4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memmgr_nal_unit.cpp; sourceTree = "<group>"; };
4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; }; 4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; };
4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_mb_syn_cavlc.cpp; sourceTree = "<group>"; }; 4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_mb_syn_cavlc.cpp; sourceTree = "<group>"; };
@@ -211,7 +208,6 @@
4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */, 4CE4465318BC5EAA0017DF25 /* get_intra_predictor.h */,
4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */, 4CE4465418BC5EAA0017DF25 /* manage_dec_ref.h */,
4CE4465518BC5EAA0017DF25 /* mb_cache.h */, 4CE4465518BC5EAA0017DF25 /* mb_cache.h */,
4CE4465718BC5EAA0017DF25 /* mem_align.h */,
4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */, 4CE4465818BC5EAA0017DF25 /* memmgr_nal_unit.h */,
4CE4465918BC5EAA0017DF25 /* mv_pred.h */, 4CE4465918BC5EAA0017DF25 /* mv_pred.h */,
4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */, 4CE4465A18BC5EAA0017DF25 /* nal_prefix.h */,
@@ -247,7 +243,6 @@
4CE4467018BC5EAA0017DF25 /* fmo.cpp */, 4CE4467018BC5EAA0017DF25 /* fmo.cpp */,
4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */, 4CE4467118BC5EAA0017DF25 /* get_intra_predictor.cpp */,
4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */, 4CE4467218BC5EAA0017DF25 /* manage_dec_ref.cpp */,
4CE4467418BC5EAA0017DF25 /* mem_align.cpp */,
4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */, 4CE4467518BC5EAA0017DF25 /* memmgr_nal_unit.cpp */,
4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */, 4CE4467618BC5EAA0017DF25 /* mv_pred.cpp */,
4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */, 4CE4467718BC5EAA0017DF25 /* parse_mb_syn_cavlc.cpp */,
@@ -351,7 +346,6 @@
4CE4469F18BC5EAB0017DF25 /* welsDecoderExt.cpp in Sources */, 4CE4469F18BC5EAB0017DF25 /* welsDecoderExt.cpp in Sources */,
4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */, 4CE4469318BC5EAB0017DF25 /* fmo.cpp in Sources */,
4CE4469118BC5EAB0017DF25 /* decoder_data_tables.cpp in Sources */, 4CE4469118BC5EAB0017DF25 /* decoder_data_tables.cpp in Sources */,
4CE4469718BC5EAB0017DF25 /* mem_align.cpp in Sources */,
4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */, 4CE4469518BC5EAB0017DF25 /* manage_dec_ref.cpp in Sources */,
4CE4468A18BC5EAB0017DF25 /* au_parser.cpp in Sources */, 4CE4468A18BC5EAB0017DF25 /* au_parser.cpp in Sources */,
4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */, 4CE4469918BC5EAB0017DF25 /* mv_pred.cpp in Sources */,

View File

@@ -25,7 +25,6 @@
4CE4471418BC605C0017DF25 /* encoder_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E318BC605C0017DF25 /* encoder_ext.cpp */; }; 4CE4471418BC605C0017DF25 /* encoder_ext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E318BC605C0017DF25 /* encoder_ext.cpp */; };
4CE4471618BC605C0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */; }; 4CE4471618BC605C0017DF25 /* get_intra_predictor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */; };
4CE4471818BC605C0017DF25 /* md.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E718BC605C0017DF25 /* md.cpp */; }; 4CE4471818BC605C0017DF25 /* md.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E718BC605C0017DF25 /* md.cpp */; };
4CE4471918BC605C0017DF25 /* memory_align.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E818BC605C0017DF25 /* memory_align.cpp */; };
4CE4471A18BC605C0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E918BC605C0017DF25 /* mv_pred.cpp */; }; 4CE4471A18BC605C0017DF25 /* mv_pred.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446E918BC605C0017DF25 /* mv_pred.cpp */; };
4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EA18BC605C0017DF25 /* nal_encap.cpp */; }; 4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EA18BC605C0017DF25 /* nal_encap.cpp */; };
4CE4471C18BC605C0017DF25 /* picture_handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EB18BC605C0017DF25 /* picture_handle.cpp */; }; 4CE4471C18BC605C0017DF25 /* picture_handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CE446EB18BC605C0017DF25 /* picture_handle.cpp */; };
@@ -93,7 +92,6 @@
4CE446B618BC605C0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; }; 4CE446B618BC605C0017DF25 /* get_intra_predictor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = get_intra_predictor.h; sourceTree = "<group>"; };
4CE446B718BC605C0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; }; 4CE446B718BC605C0017DF25 /* mb_cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mb_cache.h; sourceTree = "<group>"; };
4CE446B918BC605C0017DF25 /* md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md.h; sourceTree = "<group>"; }; 4CE446B918BC605C0017DF25 /* md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md.h; sourceTree = "<group>"; };
4CE446BA18BC605C0017DF25 /* memory_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory_align.h; sourceTree = "<group>"; };
4CE446BB18BC605C0017DF25 /* mt_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mt_defs.h; sourceTree = "<group>"; }; 4CE446BB18BC605C0017DF25 /* mt_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mt_defs.h; sourceTree = "<group>"; };
4CE446BC18BC605C0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; }; 4CE446BC18BC605C0017DF25 /* mv_pred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mv_pred.h; sourceTree = "<group>"; };
4CE446BD18BC605C0017DF25 /* nal_encap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_encap.h; sourceTree = "<group>"; }; 4CE446BD18BC605C0017DF25 /* nal_encap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nal_encap.h; sourceTree = "<group>"; };
@@ -134,7 +132,6 @@
4CE446E318BC605C0017DF25 /* encoder_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = encoder_ext.cpp; sourceTree = "<group>"; }; 4CE446E318BC605C0017DF25 /* encoder_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = encoder_ext.cpp; sourceTree = "<group>"; };
4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; }; 4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = get_intra_predictor.cpp; sourceTree = "<group>"; };
4CE446E718BC605C0017DF25 /* md.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = md.cpp; sourceTree = "<group>"; }; 4CE446E718BC605C0017DF25 /* md.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = md.cpp; sourceTree = "<group>"; };
4CE446E818BC605C0017DF25 /* memory_align.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memory_align.cpp; sourceTree = "<group>"; };
4CE446E918BC605C0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; }; 4CE446E918BC605C0017DF25 /* mv_pred.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mv_pred.cpp; sourceTree = "<group>"; };
4CE446EA18BC605C0017DF25 /* nal_encap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nal_encap.cpp; sourceTree = "<group>"; }; 4CE446EA18BC605C0017DF25 /* nal_encap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nal_encap.cpp; sourceTree = "<group>"; };
4CE446EB18BC605C0017DF25 /* picture_handle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = picture_handle.cpp; sourceTree = "<group>"; }; 4CE446EB18BC605C0017DF25 /* picture_handle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = picture_handle.cpp; sourceTree = "<group>"; };
@@ -274,7 +271,6 @@
4CE446B618BC605C0017DF25 /* get_intra_predictor.h */, 4CE446B618BC605C0017DF25 /* get_intra_predictor.h */,
4CE446B718BC605C0017DF25 /* mb_cache.h */, 4CE446B718BC605C0017DF25 /* mb_cache.h */,
4CE446B918BC605C0017DF25 /* md.h */, 4CE446B918BC605C0017DF25 /* md.h */,
4CE446BA18BC605C0017DF25 /* memory_align.h */,
4CE446BB18BC605C0017DF25 /* mt_defs.h */, 4CE446BB18BC605C0017DF25 /* mt_defs.h */,
4CE446BC18BC605C0017DF25 /* mv_pred.h */, 4CE446BC18BC605C0017DF25 /* mv_pred.h */,
4CE446BD18BC605C0017DF25 /* nal_encap.h */, 4CE446BD18BC605C0017DF25 /* nal_encap.h */,
@@ -325,7 +321,6 @@
4CE446E318BC605C0017DF25 /* encoder_ext.cpp */, 4CE446E318BC605C0017DF25 /* encoder_ext.cpp */,
4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */, 4CE446E518BC605C0017DF25 /* get_intra_predictor.cpp */,
4CE446E718BC605C0017DF25 /* md.cpp */, 4CE446E718BC605C0017DF25 /* md.cpp */,
4CE446E818BC605C0017DF25 /* memory_align.cpp */,
4CE446E918BC605C0017DF25 /* mv_pred.cpp */, 4CE446E918BC605C0017DF25 /* mv_pred.cpp */,
4CE446EA18BC605C0017DF25 /* nal_encap.cpp */, 4CE446EA18BC605C0017DF25 /* nal_encap.cpp */,
4CE446EB18BC605C0017DF25 /* picture_handle.cpp */, 4CE446EB18BC605C0017DF25 /* picture_handle.cpp */,
@@ -455,7 +450,6 @@
4CE4472918BC605C0017DF25 /* svc_set_mb_syn_cavlc.cpp in Sources */, 4CE4472918BC605C0017DF25 /* svc_set_mb_syn_cavlc.cpp in Sources */,
4CE4471818BC605C0017DF25 /* md.cpp in Sources */, 4CE4471818BC605C0017DF25 /* md.cpp in Sources */,
4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */, 4CE4471B18BC605C0017DF25 /* nal_encap.cpp in Sources */,
4CE4471918BC605C0017DF25 /* memory_align.cpp in Sources */,
4CE4472418BC605C0017DF25 /* svc_enc_slice_segment.cpp in Sources */, 4CE4472418BC605C0017DF25 /* svc_enc_slice_segment.cpp in Sources */,
4CE4472318BC605C0017DF25 /* svc_base_layer_md.cpp in Sources */, 4CE4472318BC605C0017DF25 /* svc_base_layer_md.cpp in Sources */,
4CB8F2B419235FC5005D6386 /* pixel_aarch64_neon.S in Sources */, 4CB8F2B419235FC5005D6386 /* pixel_aarch64_neon.S in Sources */,

View File

@@ -752,7 +752,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\..\decoder\core\inc\mem_align.h" RelativePath="..\..\..\common\inc\memory_align.h"
> >
</File> </File>
<File <File
@@ -909,7 +909,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\..\decoder\core\src\mem_align.cpp" RelativePath="..\..\..\common\src\memory_align.cpp"
> >
</File> </File>
<File <File

View File

@@ -384,7 +384,7 @@
Filter="h;hpp;hxx;hm;inl" Filter="h;hpp;hxx;hm;inl"
> >
<File <File
RelativePath="..\..\..\decoder\core\inc\mem_align.h" RelativePath="..\..\..\common\inc\mem_align.h"
> >
</File> </File>
<File <File

View File

@@ -394,7 +394,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\..\encoder\core\src\memory_align.cpp" RelativePath="..\..\..\common\src\memory_align.cpp"
> >
</File> </File>
<File <File
@@ -575,7 +575,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\..\encoder\core\inc\memory_align.h" RelativePath="..\..\..\common\inc\memory_align.h"
> >
</File> </File>
<File <File

View File

@@ -30,16 +30,26 @@
* *
*/ */
#if !defined(WELS_ENCODER_MEMORY_ALIGN_H__) #if !defined(WELS_COMMON_MEMORY_ALIGN_H__)
#define WELS_ENCODER_MEMORY_ALIGN_H__ #define WELS_COMMON_MEMORY_ALIGN_H__
#include "typedefs.h" #include "typedefs.h"
#include "as264_common.h"
// NOTE: please do not clean below lines even comment, turn on for potential memory leak verify and memory usage monitor etc.
//#define MEMORY_CHECK
#define MEMORY_MONITOR
#ifdef MEMORY_CHECK
#ifndef MEMORY_MONITOR
#define MEMORY_MONITOR
#endif//MEMORY_MONITOR
#endif//MEMORY_CHECK
#ifdef MEMORY_CHECK #ifdef MEMORY_CHECK
#include <stdio.h> #include <stdio.h>
#endif//MEMORY_CHECK #endif//MEMORY_CHECK
namespace WelsEnc { namespace WelsCommon {
class CMemoryAlign { class CMemoryAlign {
public: public:
@@ -63,13 +73,38 @@ uint32_t m_nCacheLineSize;
#ifdef MEMORY_MONITOR #ifdef MEMORY_MONITOR
uint32_t m_nMemoryUsageInBytes; uint32_t m_nMemoryUsageInBytes;
#endif//MEMORY_MONITOR #endif//MEMORY_MONITOR
#ifdef MEMORY_CHECK
FILE* m_fpMemChkPoint;
uint32_t m_nCountRequestNum;
#endif//MEMORY_CHECK
}; };
/*!
*************************************************************************************
* \brief malloc with zero filled utilization in Wels
*
* \param kuiSize size of memory block required
*
* \return allocated memory pointer exactly, failed in case of NULL return
*
* \note N/A
*************************************************************************************
*/
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
/*!
*************************************************************************************
* \brief free utilization in Wels
*
* \param pPtr data pointer to be free.
* i.e, uint8_t *pPtr = actual data to be free, argv = &pPtr.
*
* \return NONE
*
* \note N/A
*************************************************************************************
*/
void WelsFree (void* pPtr, const char* kpTag);
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }
} }
#endif//WELS_ENCODER_MEMORY_ALIGN_H__ #endif//WELS_COMMON_MEMORY_ALIGN_H__

View File

@@ -35,7 +35,13 @@
#include "memory_align.h" #include "memory_align.h"
#include "macros.h" #include "macros.h"
namespace WelsEnc { namespace WelsCommon {
#ifdef MEMORY_CHECK
static FILE* fpMemChkPoint;
static uint32_t nCountRequestNum;
#endif
CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize) CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize)
#ifdef MEMORY_MONITOR #ifdef MEMORY_MONITOR
@@ -46,24 +52,66 @@ CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize)
m_nCacheLineSize = 0x10; m_nCacheLineSize = 0x10;
else else
m_nCacheLineSize = kuiCacheLineSize; m_nCacheLineSize = kuiCacheLineSize;
#ifdef MEMORY_CHECK
m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "wt+");
m_nCountRequestNum = 0;
#endif//MEMORY_CHECK
} }
CMemoryAlign::~CMemoryAlign() { CMemoryAlign::~CMemoryAlign() {
#ifdef MEMORY_MONITOR #ifdef MEMORY_MONITOR
assert (m_nMemoryUsageInBytes == 0); assert (m_nMemoryUsageInBytes == 0);
#endif//MEMORY_MONITOR #endif//MEMORY_MONITOR
}
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAlign) {
const int32_t kiSizeOfVoidPointer = sizeof (void**);
const int32_t kiSizeOfInt = sizeof (int32_t);
const int32_t kiAlignedBytes = kiAlign - 1;
const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
const int32_t kiActualRequestedSize = kiTrialRequestedSize;
const uint32_t kiPayloadSize = kuiSize;
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
#ifdef MEMORY_CHECK #ifdef MEMORY_CHECK
fclose (m_fpMemChkPoint); if (fpMemChkPoint == NULL) {
m_fpMemChkPoint = NULL; m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+");
m_nCountRequestNum = 0;
}
m_nCountRequestNum = 0; if (fpMemChkPoint != NULL) {
#endif//MEMORY_CHECK if (kpTag != NULL)
fprintf (fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d - %s\n",
(void*)pBuf, kiActualRequestedSize, kuiSize, nCountRequestNum++, kpTag);
else
fprintf (fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d \n", (void*)pBuf,
kiActualRequestedSize, kuiSize, nCountRequestNum++);
fflush (fpMemChkPoint);
}
#endif
uint8_t* pAlignedBuffer;
if (NULL == pBuf)
return NULL;
pAlignedBuffer = pBuf + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
pAlignedBuffer -= ((uintptr_t) pAlignedBuffer & kiAlignedBytes);
* ((void**) (pAlignedBuffer - kiSizeOfVoidPointer)) = pBuf;
* ((int32_t*) (pAlignedBuffer - (kiSizeOfVoidPointer + kiSizeOfInt))) = kiPayloadSize;
return pAlignedBuffer;
}
void WelsFree (void* pPointer, const char* kpTag) {
if (pPointer) {
#ifdef MEMORY_CHECK
if (m_fpMemChkPoint != NULL) {
if (kpTag != NULL)
fprintf (fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag,
kiMemoryLength);
else
fprintf (fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1)));
fflush (fpMemChkPoint);
}
#endif
free (* (((void**) pPointer) - 1));
}
} }
void* CMemoryAlign::WelsMallocz (const uint32_t kuiSize, const char* kpTag) { void* CMemoryAlign::WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
@@ -78,40 +126,15 @@ void* CMemoryAlign::WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
} }
void* CMemoryAlign::WelsMalloc (const uint32_t kuiSize, const char* kpTag) { void* CMemoryAlign::WelsMalloc (const uint32_t kuiSize, const char* kpTag) {
const int32_t kiSizeOfVoidPointer = sizeof (void**); void* pPointer = WelsCommon::WelsMalloc (kuiSize, kpTag, m_nCacheLineSize);
const int32_t kiSizeOfInt = sizeof (int32_t);
const int32_t kiAlignedBytes = m_nCacheLineSize - 1;
const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
const int32_t kiActualRequestedSize = kiTrialRequestedSize;
const uint32_t kiPayloadSize = kuiSize;
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
#ifdef MEMORY_CHECK
if (m_fpMemChkPoint != NULL) {
if (kpTag != NULL)
fprintf (m_fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d - %s\n",
(void*)pBuf, kiActualRequestedSize, kuiSize, m_nCountRequestNum++, kpTag);
else
fprintf (m_fpMemChkPoint, "WelsMalloc(), 0x%x : actual uiSize:\t%d\tbytes, input uiSize: %d bytes, %d \n", (void*)pBuf,
kiActualRequestedSize, kuiSize, m_nCountRequestNum++);
fflush (m_fpMemChkPoint);
}
#endif
uint8_t* pAlignedBuffer;
if (NULL == pBuf)
return NULL;
pAlignedBuffer = pBuf + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
pAlignedBuffer -= ((uintptr_t) pAlignedBuffer & kiAlignedBytes);
* ((void**) (pAlignedBuffer - kiSizeOfVoidPointer)) = pBuf;
* ((int32_t*) (pAlignedBuffer - (kiSizeOfVoidPointer + kiSizeOfInt))) = kiPayloadSize;
#ifdef MEMORY_MONITOR #ifdef MEMORY_MONITOR
m_nMemoryUsageInBytes += kiActualRequestedSize; if (pPointer != NULL) {
const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof (
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
m_nMemoryUsageInBytes += kiMemoryLength;
}
#endif//MEMORY_MONITOR #endif//MEMORY_MONITOR
return pPointer;
return pAlignedBuffer;
} }
void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) { void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) {
@@ -121,18 +144,17 @@ void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) {
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t); int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
m_nMemoryUsageInBytes -= kiMemoryLength; m_nMemoryUsageInBytes -= kiMemoryLength;
#endif//MEMORY_MONITOR #endif//MEMORY_MONITOR
#ifdef MEMORY_CHECK
if (m_fpMemChkPoint != NULL) {
if (kpTag != NULL)
fprintf (m_fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag,
kiMemoryLength);
else
fprintf (m_fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1)));
fflush (m_fpMemChkPoint);
}
#endif
free (* (((void**) pPointer) - 1));
} }
WelsCommon::WelsFree (pPointer, kpTag);
}
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
void* pPointer = WelsMalloc (kuiSize, kpTag, 16);
if (NULL == pPointer) {
return NULL;
}
memset (pPointer, 0, kuiSize);
return pPointer;
} }
const uint32_t CMemoryAlign::WelsGetCacheLineSize() const { const uint32_t CMemoryAlign::WelsGetCacheLineSize() const {
@@ -143,4 +165,4 @@ const uint32_t CMemoryAlign::WelsGetMemoryUsage() const {
return m_nMemoryUsageInBytes; return m_nMemoryUsageInBytes;
} }
} // end of namespace WelsEnc } // end of namespace WelsCommon

View File

@@ -8,6 +8,7 @@ COMMON_CPP_SRCS=\
$(COMMON_SRCDIR)/src/expand_pic.cpp\ $(COMMON_SRCDIR)/src/expand_pic.cpp\
$(COMMON_SRCDIR)/src/intra_pred_common.cpp\ $(COMMON_SRCDIR)/src/intra_pred_common.cpp\
$(COMMON_SRCDIR)/src/mc.cpp\ $(COMMON_SRCDIR)/src/mc.cpp\
$(COMMON_SRCDIR)/src/memory_align.cpp\
$(COMMON_SRCDIR)/src/sad_common.cpp\ $(COMMON_SRCDIR)/src/sad_common.cpp\
$(COMMON_SRCDIR)/src/utils.cpp\ $(COMMON_SRCDIR)/src/utils.cpp\
$(COMMON_SRCDIR)/src/welsCodecTrace.cpp\ $(COMMON_SRCDIR)/src/welsCodecTrace.cpp\

View File

@@ -1,90 +0,0 @@
/*!
* \copy
* Copyright (c) 2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* memory alignment utilization
*/
#ifndef WELS_MEM_ALIGN_H__
#define WELS_MEM_ALIGN_H__
#include <stdlib.h>
#include <string.h>
#include "utils.h"
namespace WelsDec {
#ifdef __cplusplus
extern "C" {
#endif//__cplusplus
/*!
*************************************************************************************
* \brief malloc with zero filled utilization in Wels
*
* \param kuiSize size of memory block required
*
* \return allocated memory pointer exactly, failed in case of NULL return
*
* \note N/A
*************************************************************************************
*/
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
/*!
*************************************************************************************
* \brief free utilization in Wels
*
* \param pPtr data pointer to be free.
* i.e, uint8_t *pPtr = actual data to be free, argv = &pPtr.
*
* \return NONE
*
* \note N/A
*************************************************************************************
*/
void WelsFree (void* pPtr, const char* kpTag);
#define WELS_SAFE_FREE(pPtr, pTag) if (pPtr) { WelsFree(pPtr, pTag); pPtr = NULL; }
/*
* memory operation routines
*/
#ifdef __cplusplus
}
#endif//__cplusplus
} // namespace WelsDec
#endif //WELS_MEM_ALIGN_H__

View File

@@ -44,7 +44,7 @@
#include "memmgr_nal_unit.h" #include "memmgr_nal_unit.h"
#include "decoder_core.h" #include "decoder_core.h"
#include "bit_stream.h" #include "bit_stream.h"
#include "mem_align.h" #include "memory_align.h"
namespace WelsDec { namespace WelsDec {
/*! /*!

View File

@@ -51,7 +51,7 @@
#include "expand_pic.h" #include "expand_pic.h"
#include "decode_slice.h" #include "decode_slice.h"
#include "error_concealment.h" #include "error_concealment.h"
#include "mem_align.h" #include "memory_align.h"
namespace WelsDec { namespace WelsDec {

View File

@@ -40,7 +40,7 @@
#include "expand_pic.h" #include "expand_pic.h"
#include "decoder.h" #include "decoder.h"
#include "decode_mb_aux.h" #include "decode_mb_aux.h"
#include "mem_align.h" #include "memory_align.h"
#include "error_concealment.h" #include "error_concealment.h"
namespace WelsDec { namespace WelsDec {

View File

@@ -39,7 +39,7 @@
*/ */
#include "fmo.h" #include "fmo.h"
#include "mem_align.h" #include "memory_align.h"
namespace WelsDec { namespace WelsDec {

View File

@@ -1,100 +0,0 @@
/*!
* \copy
* Copyright (c) 2013, Cisco Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "mem_align.h"
namespace WelsDec {
//#define MEMORY_CHECK
#ifdef MEMORY_CHECK
WelsFileHandle* pMemCheckMalloc = NULL;
WelsFileHandle* pMemCheckFree = NULL;
int32_t iCountMalloc = 0;
#endif
//
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag) {
const int32_t kiSizeVoidPtr = sizeof (void**);
const int32_t kiSizeInt = sizeof (int32_t);
const int32_t kiAlignBytes = 15;
uint8_t* pBuf = (uint8_t*) malloc (kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
uint8_t* pAlignBuf;
#ifdef MEMORY_CHECK
if (pMemCheckMalloc == NULL) {
pMemCheckMalloc = WelsFopen ("mem_check_malloc.txt", "at+");
pMemCheckFree = WelsFopen ("mem_check_free.txt", "at+");
}
if (kpTag != NULL) {
if (pMemCheckMalloc != NULL) {
fprintf (pMemCheckMalloc, "0x%x, size: %d , malloc %s\n", (void*)pBuf,
(kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt), kpTag);
}
if (pMemCheckMalloc != NULL) {
fflush (pMemCheckMalloc);
}
}
#endif
if (NULL == pBuf)
return NULL;
// to fill zero values
memset (pBuf, 0, kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
pAlignBuf = pBuf + kiAlignBytes + kiSizeVoidPtr + kiSizeInt;
pAlignBuf -= (uintptr_t) pAlignBuf & kiAlignBytes;
* ((void**) (pAlignBuf - kiSizeVoidPtr)) = pBuf;
* ((int32_t*) (pAlignBuf - (kiSizeVoidPtr + kiSizeInt))) = kuiSize;
return (pAlignBuf);
}
/////////////////////////////////////////////////////////////////////////////
void WelsFree (void* pPtr, const char* kpTag) {
if (pPtr) {
#ifdef MEMORY_CHECK
if (NULL != pMemCheckFree && kpTag != NULL) {
fprintf (pMemCheckFree, "0x%x, free %s\n", (void*) (* (((void**) pPtr) - 1)), kpTag);
fflush (pMemCheckFree);
}
#endif
free (* (((void**) pPtr) - 1));
}
}
/////////////////////////////////////////////////////////////////////////////
} // namespace WelsDec

View File

@@ -39,7 +39,7 @@
* *
*****************************************************************************/ *****************************************************************************/
#include "memmgr_nal_unit.h" #include "memmgr_nal_unit.h"
#include "mem_align.h" #include "memory_align.h"
namespace WelsDec { namespace WelsDec {

View File

@@ -40,7 +40,7 @@
#include "pic_queue.h" #include "pic_queue.h"
#include "decoder_context.h" #include "decoder_context.h"
#include "codec_def.h" #include "codec_def.h"
#include "mem_align.h" #include "memory_align.h"
namespace WelsDec { namespace WelsDec {

View File

@@ -44,7 +44,7 @@
#include "welsCodecTrace.h" #include "welsCodecTrace.h"
#include "codec_def.h" #include "codec_def.h"
#include "typedefs.h" #include "typedefs.h"
#include "mem_align.h" #include "memory_align.h"
#include "utils.h" #include "utils.h"
#include "version.h" #include "version.h"

View File

@@ -13,7 +13,6 @@ DECODER_CPP_SRCS=\
$(DECODER_SRCDIR)/core/src/fmo.cpp\ $(DECODER_SRCDIR)/core/src/fmo.cpp\
$(DECODER_SRCDIR)/core/src/get_intra_predictor.cpp\ $(DECODER_SRCDIR)/core/src/get_intra_predictor.cpp\
$(DECODER_SRCDIR)/core/src/manage_dec_ref.cpp\ $(DECODER_SRCDIR)/core/src/manage_dec_ref.cpp\
$(DECODER_SRCDIR)/core/src/mem_align.cpp\
$(DECODER_SRCDIR)/core/src/memmgr_nal_unit.cpp\ $(DECODER_SRCDIR)/core/src/memmgr_nal_unit.cpp\
$(DECODER_SRCDIR)/core/src/mv_pred.cpp\ $(DECODER_SRCDIR)/core/src/mv_pred.cpp\
$(DECODER_SRCDIR)/core/src/parse_mb_syn_cabac.cpp\ $(DECODER_SRCDIR)/core/src/parse_mb_syn_cabac.cpp\

View File

@@ -139,16 +139,5 @@ $(TargetPath)
#endif//MB_TYPES_CHECK #endif//MB_TYPES_CHECK
#endif//MB_TYPES_INFO_OUTPUT #endif//MB_TYPES_INFO_OUTPUT
// NOTE: please do not clean below lines even comment, turn on for potential memory leak verify and memory usage monitor etc.
//#define MEMORY_CHECK
#define MEMORY_MONITOR
#ifdef MEMORY_CHECK
#ifndef MEMORY_MONITOR
#define MEMORY_MONITOR
#endif//MEMORY_MONITOR
#endif//MEMORY_CHECK
#endif // AS264_COMMON_H_ #endif // AS264_COMMON_H_

View File

@@ -48,6 +48,8 @@
#include "codec_app_def.h" #include "codec_app_def.h"
#include "set_mb_syn_cabac.h" #include "set_mb_syn_cabac.h"
using namespace WelsCommon;
namespace WelsEnc { namespace WelsEnc {

View File

@@ -9,7 +9,6 @@ ENCODER_CPP_SRCS=\
$(ENCODER_SRCDIR)/core/src/encoder_ext.cpp\ $(ENCODER_SRCDIR)/core/src/encoder_ext.cpp\
$(ENCODER_SRCDIR)/core/src/get_intra_predictor.cpp\ $(ENCODER_SRCDIR)/core/src/get_intra_predictor.cpp\
$(ENCODER_SRCDIR)/core/src/md.cpp\ $(ENCODER_SRCDIR)/core/src/md.cpp\
$(ENCODER_SRCDIR)/core/src/memory_align.cpp\
$(ENCODER_SRCDIR)/core/src/mv_pred.cpp\ $(ENCODER_SRCDIR)/core/src/mv_pred.cpp\
$(ENCODER_SRCDIR)/core/src/nal_encap.cpp\ $(ENCODER_SRCDIR)/core/src/nal_encap.cpp\
$(ENCODER_SRCDIR)/core/src/picture_handle.cpp\ $(ENCODER_SRCDIR)/core/src/picture_handle.cpp\

View File

@@ -1,7 +1,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "codec_def.h" #include "codec_def.h"
#include "expand_pic.h" #include "expand_pic.h"
#include "mem_align.h" #include "memory_align.h"
#include "decoder_context.h" #include "decoder_context.h"
#include "cpu.h" #include "cpu.h"
#include "cpu_core.h" #include "cpu_core.h"

View File

@@ -4,7 +4,7 @@
#include "codec_app_def.h" #include "codec_app_def.h"
#include "codec_api.h" #include "codec_api.h"
#include "wels_common_basis.h" #include "wels_common_basis.h"
#include "mem_align.h" #include "memory_align.h"
#include "ls_defines.h" #include "ls_defines.h"
using namespace WelsDec; using namespace WelsDec;

View File

@@ -1,7 +1,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "wels_common_basis.h" #include "wels_common_basis.h"
#include "mem_align.h" #include "memory_align.h"
#include "error_concealment.h" #include "error_concealment.h"
#include "ls_defines.h" #include "ls_defines.h"
#include "cpu.h" #include "cpu.h"

View File

@@ -1,7 +1,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "wels_common_basis.h" #include "wels_common_basis.h"
#include "mem_align.h" #include "memory_align.h"
#include "mv_pred.h" #include "mv_pred.h"
#include "ls_defines.h" #include "ls_defines.h"

View File

@@ -3,8 +3,8 @@
#include "memory_align.h" #include "memory_align.h"
#include "utils/DataGenerator.h" #include "utils/DataGenerator.h"
using namespace WelsEnc;
#include "encode_mb_aux.h" #include "encode_mb_aux.h"
using namespace WelsEnc;
ALIGNED_DECLARE (const int16_t, g_kiQuantInterFFCompare[104][8], 16) = { ALIGNED_DECLARE (const int16_t, g_kiQuantInterFFCompare[104][8], 16) = {
/* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 }, /* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 },

View File

@@ -1,7 +1,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "memory_align.h" #include "memory_align.h"
using namespace WelsEnc; using namespace WelsCommon;
//Tests of WelsGetCacheLineSize Begin //Tests of WelsGetCacheLineSize Begin
TEST (MemoryAlignTest, GetCacheLineSize_LoopWithin16K) { TEST (MemoryAlignTest, GetCacheLineSize_LoopWithin16K) {