[libbluray-devel] Improve readability of PES buffer handling code

hpi1 git at videolan.org
Thu Sep 4 10:14:44 CEST 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Sep  4 11:04:04 2014 +0300| [ab334c2258519c4a1935c3ca5f304c323372a23c] | committer: hpi1

Improve readability of PES buffer handling code

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=ab334c2258519c4a1935c3ca5f304c323372a23c
---

 src/libbluray/decoders/graphics_processor.c |    4 ++--
 src/libbluray/decoders/pes_buffer.c         |   10 ++++++++++
 src/libbluray/decoders/pes_buffer.h         |    2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/decoders/graphics_processor.c b/src/libbluray/decoders/graphics_processor.c
index 479ccaa..d3ccbf9 100644
--- a/src/libbluray/decoders/graphics_processor.c
+++ b/src/libbluray/decoders/graphics_processor.c
@@ -552,7 +552,7 @@ static int graphics_processor_decode_pes(PG_DISPLAY_SET **s, PES_BUFFER **p, int
 
         if ((*p)->len <= 2) {
             BD_DEBUG(DBG_DECODE, "segment too short, skipping (%d bytes)\n", (*p)->len);
-            pes_buffer_remove(p, *p);
+            pes_buffer_next(p);
             continue;
         }
 
@@ -563,7 +563,7 @@ static int graphics_processor_decode_pes(PG_DISPLAY_SET **s, PES_BUFFER **p, int
 
         _decode_segment(*s, *p);
 
-        pes_buffer_remove(p, *p);
+        pes_buffer_next(p);
 
         if ((*s)->complete) {
             return 1;
diff --git a/src/libbluray/decoders/pes_buffer.c b/src/libbluray/decoders/pes_buffer.c
index 66a2a32..aaa4788 100644
--- a/src/libbluray/decoders/pes_buffer.c
+++ b/src/libbluray/decoders/pes_buffer.c
@@ -89,3 +89,13 @@ void pes_buffer_remove(PES_BUFFER **head, PES_BUFFER *p)
         }
     }
 }
+
+void pes_buffer_next(PES_BUFFER **head)
+{
+    if (head && *head) {
+        PES_BUFFER *p = *head;
+        *head = (*head)->next;
+        p->next = NULL;
+        pes_buffer_free(&p);
+    }
+}
diff --git a/src/libbluray/decoders/pes_buffer.h b/src/libbluray/decoders/pes_buffer.h
index 2904420..f18d133 100644
--- a/src/libbluray/decoders/pes_buffer.h
+++ b/src/libbluray/decoders/pes_buffer.h
@@ -44,4 +44,6 @@ 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
 BD_PRIVATE void        pes_buffer_remove(PES_BUFFER **head, PES_BUFFER *buf); // remove buf from list and free it
 
+BD_PRIVATE void        pes_buffer_next(PES_BUFFER **head); // free first buffer and advance head to next buffer
+
 #endif // _PES_BUFFER_H_



More information about the libbluray-devel mailing list