[libbluray-devel] Crop RLE images inside library.

hpi1 git at videolan.org
Fri Nov 8 11:29:48 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Nov  8 11:59:24 2013 +0200| [2be7e8f9bb43ad64063f01f401e6823d5cf01699] | committer: hpi1

Crop RLE images inside library.
Simplifies player implementations.

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

 src/libbluray/decoders/graphics_controller.c |   18 ++++++++++--------
 src/libbluray/decoders/overlay.h             |    8 ++++----
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/libbluray/decoders/graphics_controller.c b/src/libbluray/decoders/graphics_controller.c
index 69ac2a3..e7ec2b7 100644
--- a/src/libbluray/decoders/graphics_controller.c
+++ b/src/libbluray/decoders/graphics_controller.c
@@ -575,6 +575,7 @@ static void _render_composition_object(GRAPHICS_CONTROLLER *gc,
                                        int palette_update_flag)
 {
     if (gc->overlay_proc) {
+        BD_PG_RLE_ELEM *cropped_img = NULL;
         BD_OVERLAY ov = {0};
         ov.cmd     = BD_OVERLAY_DRAW;
         ov.pts     = pts;
@@ -585,20 +586,21 @@ static void _render_composition_object(GRAPHICS_CONTROLLER *gc,
         ov.h       = object->height;
         ov.palette = palette->entry;
         ov.img     = object->img;
+
         if (cobj->crop_flag) {
-            ov.crop_x  = cobj->crop_x;
-            ov.crop_y  = cobj->crop_y;
-            ov.crop_w  = cobj->crop_w;
-            ov.crop_h  = cobj->crop_h;
-        }
-        if (ov.crop_h) {
-          ov.h = ov.crop_h;
-          ov.crop_h = 0;
+            if (cobj->crop_x || cobj->crop_y || cobj->crop_w != object->width) {
+                ov.img = cropped_img = rle_crop_object(object->img, object->width,
+                                                       cobj->crop_x, cobj->crop_y, cobj->crop_w, cobj->crop_h);
+            }
+            ov.w  = cobj->crop_w;
+            ov.h  = cobj->crop_h;
         }
 
         ov.palette_update_flag = palette_update_flag;
 
         gc->overlay_proc(gc->overlay_proc_handle, &ov);
+
+        bd_refcnt_dec(cropped_img);
     }
 }
 
diff --git a/src/libbluray/decoders/overlay.h b/src/libbluray/decoders/overlay.h
index 96dd958..aca16ce 100644
--- a/src/libbluray/decoders/overlay.h
+++ b/src/libbluray/decoders/overlay.h
@@ -75,10 +75,10 @@ typedef struct bd_overlay_s {
     const BD_PG_PALETTE_ENTRY * palette;
     const BD_PG_RLE_ELEM      * img;
 
-    uint16_t crop_x;
-    uint16_t crop_y;
-    uint16_t crop_w;
-    uint16_t crop_h;
+    uint16_t crop_x; /* deprecated: cropping is executed by libbluray */
+    uint16_t crop_y; /* deprecated: cropping is executed by libbluray */
+    uint16_t crop_w; /* deprecated: cropping is executed by libbluray */
+    uint16_t crop_h; /* deprecated: cropping is executed by libbluray */
 
     uint8_t palette_update_flag; /* only palette was changed */
 } BD_OVERLAY;



More information about the libbluray-devel mailing list