[x265] [PATCH] NALWrite : do not use malloc, realloc and free
Gopu Govindaswamy
gopu at multicorewareinc.com
Wed Sep 18 10:34:19 CEST 2013
# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1379493217 -19800
# Node ID 1f4dfa794ad9ca5333671dc600d5fcd8efddeb25
# Parent 25182c943bfab1fde922c2b7f8f1b05a1c4b0fd6
NALWrite : do not use malloc, realloc and free
malloc and free replaced with X265_MALLOC and X265_FREE
diff -r 25182c943bfa -r 1f4dfa794ad9 source/Lib/TLibEncoder/NALwrite.cpp
--- a/source/Lib/TLibEncoder/NALwrite.cpp Wed Sep 18 13:29:18 2013 +0530
+++ b/source/Lib/TLibEncoder/NALwrite.cpp Wed Sep 18 14:03:37 2013 +0530
@@ -64,8 +64,6 @@
bsNALUHeader.write(nalu.m_temporalId + 1, 3); // nuh_temporal_id_plus1
packetSize += bsNALUHeader.getByteStreamLength();
- out = (uint8_t *) malloc(packetSize);
- ::memcpy(out, bsNALUHeader.getByteStream(), packetSize);
/* write out rsbp_byte's, inserting any required
* emulation_prevention_three_byte's */
@@ -118,8 +116,10 @@
}
}
UInt i = packetSize;
- out = (uint8_t *) realloc (out, (rbsp.end() - rbsp.begin()) + 4 );
- memcpy(out + packetSize, &(*rbsp.begin()), rbsp.end() - rbsp.begin());
+ UInt offset = rbsp.end() - rbsp.begin();
+ out = (uint8_t *) X265_MALLOC(uint8_t, packetSize + offset + 4 );
+ ::memcpy(out, bsNALUHeader.getByteStream(), packetSize);
+ ::memcpy(out + packetSize, &(*rbsp.begin()), rbsp.end() - rbsp.begin());
packetSize += rbsp.end() - rbsp.begin();
/* 7.4.1.1
diff -r 25182c943bfa -r 1f4dfa794ad9 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Wed Sep 18 13:29:18 2013 +0530
+++ b/source/encoder/encoder.cpp Wed Sep 18 14:03:37 2013 +0530
@@ -487,7 +487,7 @@
m_nals[nalcount].i_type = nalu.m_nalUnitType;
m_nals[nalcount].i_payload = size;
nalcount++;
- free(nalu.m_nalUnitData);
+ X265_FREE(nalu.m_nalUnitData);
}
/* Setup payload pointers, now that we're done adding content to m_packetData */
More information about the x265-devel
mailing list