[libbluray-devel] Changed demuxer PES buffer allocation size.
hpi1
git at videolan.org
Fri Jun 21 21:53:22 CEST 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Jun 21 22:12:06 2013 +0300| [d21c890891f28520ed9c0045a0de9ca76e11a306] | committer: hpi1
Changed demuxer PES buffer allocation size.
Drops memory requirements with typical preloaded menus by ~80% and TextST streams by ~99.6% (65MB -> 256kb).
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=d21c890891f28520ed9c0045a0de9ca76e11a306
---
src/libbluray/decoders/m2ts_demux.c | 5 +++--
src/libbluray/decoders/pes_buffer.c | 7 +------
src/libbluray/decoders/pes_buffer.h | 2 +-
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/libbluray/decoders/m2ts_demux.c b/src/libbluray/decoders/m2ts_demux.c
index 91fb4be..0e4fc26 100644
--- a/src/libbluray/decoders/m2ts_demux.c
+++ b/src/libbluray/decoders/m2ts_demux.c
@@ -132,7 +132,8 @@ static int _add_ts(PES_BUFFER *p, unsigned pusi, uint8_t *buf, unsigned len)
// realloc
if (p->size < p->len + len) {
p->size *= 2;
- p->buf = realloc(p->buf, p->size);
+ p->size = BD_MAX(p->size, BD_MAX(result, 0x100));
+ p->buf = realloc(p->buf, p->size);
}
// append
@@ -189,7 +190,7 @@ PES_BUFFER *m2ts_demux(M2TS_DEMUX *p, uint8_t *buf)
p->buf->len, p->pes_length);
pes_buffer_free(&p->buf);
}
- p->buf = pes_buffer_alloc(0xffff);
+ p->buf = pes_buffer_alloc();
}
if (!p->buf) {
diff --git a/src/libbluray/decoders/pes_buffer.c b/src/libbluray/decoders/pes_buffer.c
index 89e4337..66a2a32 100644
--- a/src/libbluray/decoders/pes_buffer.c
+++ b/src/libbluray/decoders/pes_buffer.c
@@ -24,15 +24,10 @@
#include <stdlib.h>
#include <string.h>
-PES_BUFFER *pes_buffer_alloc(int size)
+PES_BUFFER *pes_buffer_alloc(void)
{
PES_BUFFER *p = calloc(1, sizeof(*p));
- if (p) {
- p->size = size;
- p->buf = malloc(size);
- }
-
return p;
}
diff --git a/src/libbluray/decoders/pes_buffer.h b/src/libbluray/decoders/pes_buffer.h
index 02a727f..f766d5e 100644
--- a/src/libbluray/decoders/pes_buffer.h
+++ b/src/libbluray/decoders/pes_buffer.h
@@ -38,7 +38,7 @@ struct pes_buffer_s {
};
-BD_PRIVATE PES_BUFFER *pes_buffer_alloc(int size) BD_ATTR_MALLOC;
+BD_PRIVATE PES_BUFFER *pes_buffer_alloc(void) BD_ATTR_MALLOC;
BD_PRIVATE void pes_buffer_free(PES_BUFFER **); // free list of buffers
BD_PRIVATE void pes_buffer_append(PES_BUFFER **head, PES_BUFFER *buf); // append buf to list
More information about the libbluray-devel
mailing list