summaryrefslogtreecommitdiffstats
path: root/media/tools
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 22:27:07 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 22:27:07 +0000
commita579df59a4ef88e4116df0dd544464cbe2573a89 (patch)
tree7705dee65a2143588593310d578edb18a88166e2 /media/tools
parent72a31b4cffaaf6a60500b31323ba7fba6793a074 (diff)
downloadchromium_src-a579df59a4ef88e4116df0dd544464cbe2573a89.zip
chromium_src-a579df59a4ef88e4116df0dd544464cbe2573a89.tar.gz
chromium_src-a579df59a4ef88e4116df0dd544464cbe2573a89.tar.bz2
gles2: fix stride support
Review URL: http://codereview.chromium.org/626009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r--media/tools/player_x11/gles_video_renderer.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/media/tools/player_x11/gles_video_renderer.cc b/media/tools/player_x11/gles_video_renderer.cc
index c552a58..084b119 100644
--- a/media/tools/player_x11/gles_video_renderer.cc
+++ b/media/tools/player_x11/gles_video_renderer.cc
@@ -164,10 +164,33 @@ void GlesVideoRenderer::Paint() {
frame_in.format == media::VideoSurface::YV16) ?
frame_in.height : frame_in.height / 2;
glActiveTexture(GL_TEXTURE0 + i);
- // No GL_UNPACK_ROW_LENGTH in GLES2.
- // glPixelStorei(GL_UNPACK_ROW_LENGTH, frame_in.strides[i]);
+ // GLES2 supports a fixed set of unpack alignments that should match most
+ // of the time what ffmpeg outputs.
+ // TODO(piman): check if it is more efficient to prefer higher
+ // alignments.
+ unsigned int stride = frame_in.strides[i];
+ uint8* data = frame_in.data[i];
+ if (stride == width) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ } else if (stride == ((width + 1) & ~1)) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ } else if (stride == ((width + 3) & ~3)) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ } else if (stride == ((width + 7) & ~7)) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
+ } else {
+ // Otherwise do it line-by-line.
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0,
+ GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
+ for (unsigned int y = 0; y < height; ++y) {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, y, width, 1,
+ GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
+ data += stride;
+ }
+ continue;
+ }
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0,
- GL_LUMINANCE, GL_UNSIGNED_BYTE, frame_in.data[i]);
+ GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
}
video_frame->Unlock();
} else {