Use a single allocation for a video fragment

This commit is contained in:
Cameron Gutman 2014-08-24 11:44:29 -07:00
parent e438445219
commit cb148c7139

View File

@ -39,7 +39,6 @@ static void cleanupAvcFrameState(void) {
while (nalChainHead != NULL) { while (nalChainHead != NULL) {
lastEntry = nalChainHead; lastEntry = nalChainHead;
nalChainHead = lastEntry->next; nalChainHead = lastEntry->next;
free(lastEntry->data);
free(lastEntry); free(lastEntry);
} }
@ -58,7 +57,6 @@ void destroyVideoDepacketizer(void) {
entry = LbqDestroyLinkedBlockingQueue(&decodeUnitQueue); entry = LbqDestroyLinkedBlockingQueue(&decodeUnitQueue);
while (entry != NULL) { while (entry != NULL) {
nextEntry = entry->flink; nextEntry = entry->flink;
free(entry->data);
free(entry); free(entry);
entry = nextEntry; entry = nextEntry;
} }
@ -168,7 +166,6 @@ void freeDecodeUnit(PDECODE_UNIT decodeUnit) {
while (decodeUnit->bufferList != NULL) { while (decodeUnit->bufferList != NULL) {
lastEntry = decodeUnit->bufferList; lastEntry = decodeUnit->bufferList;
decodeUnit->bufferList = lastEntry->next; decodeUnit->bufferList = lastEntry->next;
free(lastEntry->data);
free(lastEntry); free(lastEntry);
} }
@ -176,15 +173,11 @@ void freeDecodeUnit(PDECODE_UNIT decodeUnit) {
} }
static void queueFragment(char *data, int offset, int length) { static void queueFragment(char *data, int offset, int length) {
PLENTRY entry = (PLENTRY) malloc(sizeof(*entry)); PLENTRY entry = (PLENTRY) malloc(sizeof(*entry) + length);
if (entry != NULL) { if (entry != NULL) {
entry->next = NULL; entry->next = NULL;
entry->length = length; entry->length = length;
entry->data = (char*) malloc(entry->length); entry->data = (char*) (entry + 1);
if (entry->data == NULL) {
free(entry);
return;
}
memcpy(entry->data, &data[offset], entry->length); memcpy(entry->data, &data[offset], entry->length);