<div dir="ltr"><div>LGTM until we come up with a better method such as the one you have described in your patch.<br><br></div>Thank you,<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-06 Martin Storsjö <span dir="ltr"><<a href="mailto:martin@martin.st" target="_blank">martin@martin.st</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This avoids reuploading a full resolution 32 bpp surface for<br>
every frame while the subtitles are displayed.<br>
<br>
Ideally this information perhaps should be signalled from the vlc<br>
core in some way, but until then, this avoids excessive slowdowns<br>
with subtitles with the mediacodec direct rendering.<br>
---<br>
 modules/video_output/android/opaque.c | 25 +++++++++++++++++++++++++<br>
 1 file changed, 25 insertions(+)<br>
<br>
diff --git a/modules/video_output/android/opaque.c b/modules/video_output/android/opaque.c<br>
index 371d65f..4812e64 100644<br>
--- a/modules/video_output/android/opaque.c<br>
+++ b/modules/video_output/android/opaque.c<br>
@@ -30,6 +30,7 @@<br>
 #include <vlc_vout_display.h><br>
 #include <vlc_picture_pool.h><br>
 #include <vlc_filter.h><br>
+#include <vlc_md5.h><br>
<br>
 #include <dlfcn.h><br>
<br>
@@ -83,12 +84,36 @@ struct vout_display_sys_t<br>
     picture_t *subtitles_picture;<br>
<br>
     bool b_has_subpictures;<br>
+<br>
+    uint8_t hash[16];<br>
 };<br>
<br>
 static void DisplaySubpicture(vout_display_t *vd, subpicture_t *subpicture)<br>
 {<br>
     vout_display_sys_t *sys = vd->sys;<br>
<br>
+    struct md5_s hash;<br>
+    InitMD5(&hash);<br>
+    if (subpicture) {<br>
+        for (subpicture_region_t *r = subpicture->p_region; r != NULL; r = r->p_next) {<br>
+            AddMD5(&hash, &r->i_x, sizeof(r->i_x));<br>
+            AddMD5(&hash, &r->i_y, sizeof(r->i_y));<br>
+            AddMD5(&hash, &r->fmt.i_visible_width, sizeof(r->fmt.i_visible_width));<br>
+            AddMD5(&hash, &r->fmt.i_visible_height, sizeof(r->fmt.i_visible_height));<br>
+            AddMD5(&hash, &r->fmt.i_x_offset, sizeof(r->fmt.i_x_offset));<br>
+            AddMD5(&hash, &r->fmt.i_y_offset, sizeof(r->fmt.i_y_offset));<br>
+            const int pixels_offset = r->fmt.i_y_offset * r->p_picture->p->i_pitch +<br>
+                                      r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;<br>
+<br>
+            for (int y = 0; y < r->fmt.i_visible_height; y++)<br>
+                AddMD5(&hash, &r->p_picture->p->p_pixels[pixels_offset + y*r->p_picture->p->i_pitch], r->fmt.i_visible_width);<br>
+        }<br>
+    }<br>
+    EndMD5(&hash);<br>
+    if (!memcmp(hash.buf, sys->hash, 16))<br>
+        return;<br>
+    memcpy(sys->hash, hash.buf, 16);<br>
+<br>
     jobject jsurf = jni_LockAndGetSubtitlesSurface();<br>
     if (sys->window && jsurf != sys->jsurf)<br>
     {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.4 (Apple Git-47)<br>
<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Félix Abecassis<div><a href="http://felix.abecassis.me" target="_blank">http://felix.abecassis.me</a></div>
</div>