[vlc-devel] [PATCH] android: Only reupload subtitle surfaces if they have changed
Martin Storsjö
martin at martin.st
Thu Feb 6 13:26:14 CET 2014
This avoids reuploading a full resolution 32 bpp surface for
every frame while the subtitles are displayed.
Ideally this information perhaps should be signalled from the vlc
core in some way, but until then, this avoids excessive slowdowns
with subtitles with the mediacodec direct rendering.
---
modules/video_output/android/opaque.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/modules/video_output/android/opaque.c b/modules/video_output/android/opaque.c
index 371d65f..4812e64 100644
--- a/modules/video_output/android/opaque.c
+++ b/modules/video_output/android/opaque.c
@@ -30,6 +30,7 @@
#include <vlc_vout_display.h>
#include <vlc_picture_pool.h>
#include <vlc_filter.h>
+#include <vlc_md5.h>
#include <dlfcn.h>
@@ -83,12 +84,36 @@ struct vout_display_sys_t
picture_t *subtitles_picture;
bool b_has_subpictures;
+
+ uint8_t hash[16];
};
static void DisplaySubpicture(vout_display_t *vd, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
+ struct md5_s hash;
+ InitMD5(&hash);
+ if (subpicture) {
+ for (subpicture_region_t *r = subpicture->p_region; r != NULL; r = r->p_next) {
+ AddMD5(&hash, &r->i_x, sizeof(r->i_x));
+ AddMD5(&hash, &r->i_y, sizeof(r->i_y));
+ AddMD5(&hash, &r->fmt.i_visible_width, sizeof(r->fmt.i_visible_width));
+ AddMD5(&hash, &r->fmt.i_visible_height, sizeof(r->fmt.i_visible_height));
+ AddMD5(&hash, &r->fmt.i_x_offset, sizeof(r->fmt.i_x_offset));
+ AddMD5(&hash, &r->fmt.i_y_offset, sizeof(r->fmt.i_y_offset));
+ const int pixels_offset = r->fmt.i_y_offset * r->p_picture->p->i_pitch +
+ r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;
+
+ for (int y = 0; y < r->fmt.i_visible_height; y++)
+ AddMD5(&hash, &r->p_picture->p->p_pixels[pixels_offset + y*r->p_picture->p->i_pitch], r->fmt.i_visible_width);
+ }
+ }
+ EndMD5(&hash);
+ if (!memcmp(hash.buf, sys->hash, 16))
+ return;
+ memcpy(sys->hash, hash.buf, 16);
+
jobject jsurf = jni_LockAndGetSubtitlesSurface();
if (sys->window && jsurf != sys->jsurf)
{
--
1.8.3.4 (Apple Git-47)
More information about the vlc-devel
mailing list