Totally untested patch for cropping in Jheora

"Benjamin M. Schwartz" <[email protected]>
Newsgroups gmane.comp.multimedia.ogg.theora.devel
Message-ID <[email protected]>
The attached patch attempts to implement Theora's cropping frame in
Cortado.  I make no claim that it is likely to work, as I have no clue how
to build and test Jheora/Cortado.  Please test.  Thank you.

I can at least confirm that CropImageFilter and FilteredImageSource were
present in JDK 1.1.

Performance impact in the absence of cropping should be negligible.  With
cropping, there might be a significant performance penalty.  I have no idea.

--Ben

_______________________________________________
theora-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/theora-dev
crop_patch.diff (text/plain, 1.1 KB)
--- src_com_fluendo_jheora_YUVBuffer.java	2009-10-17 01:23:40.000000000 -0400
+++ YUVBuffer2.java	2009-10-17 01:42:59.000000000 -0400
@@ -42,6 +42,11 @@
     private int pix_size;
     private boolean newPixels = true;
     private ColorModel colorModel = ColorModel.getRGBdefault();
+    private ImageProducer filteredThis;
+    private int crop_x;
+    private int crop_y;
+    private int crop_w;
+    private int crop_h;
 
     public void addConsumer(ImageConsumer ic) {
     }
@@ -92,7 +97,19 @@
     }
 
     public Object getObject(int x, int y, int width, int height) {
-        return this;
+        if (x == 0 && y == 0 && width == y_width && height == y_height) {
+            return this;
+        } else {
+            if (x != crop_x || y != crop_y || width != crop_w || height != crop_h) {
+                crop_x = x;
+                crop_y = y;
+                crop_w = width;
+                crop_h = height;
+                filteredThis = FilteredImageSource(this, 
+                               CropImageFilter(crop_x, crop_y, crop_w, crop_h));
+            }
+            return filteredThis;
+        }
     }
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkrZXDMACgkQUJT6e6HFtqSj6ACdEeNhWXDRWNLq3NG6EryikiFq
smcAn0Cd5WkHBUvCapaKDIyu7dBIVNg2
=M9gz
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.