[MPlayer-dev-eng] Video output for RV280+Mesa3D
compn
tempn at twmi.rr.com
Fri Dec 5 12:48:26 CET 2008
On Fri, 5 Dec 2008 13:44:51 +0300 (MSK), malc wrote:
>
>The patch implements the most performant(at least on this mac mini) way to
>put YV12/I420/YUY2/UYVY data on screen. Constraints include:
>a) PPC
>b) Altivec presence
>c) Mesa3D + GLX_MESA_allocate_memory
>d) Horizontal resolution being multiple of 16
>
>The code also relies on SDL for operation.
interesting. like reimar says , benchmarks would be nice
also is it mac osx or linux on ppc ? :)
>+/*
>+ * AltiVec-enhanced yuv2yuvX
>+ *
>+ * Copyright (C) 2004 Romain Dolbeau <romain at dolbeau.org>
>+ * based on the equivalent C code in "postproc/swscale.c"
>+ * ...
>+ */
>+static uint32_t rv280_compute_hint (int w)
>+{
>+ union {
>+ struct {
>+ int stride : 16;
>+ int count : 8;
>+ int size : 5;
>+ int pad : 3;
>+ } hint;
>+ uint32_t val;
>+ } u;
>+
>+ u.hint.stride = 16;
>+ u.hint.count = 1;
>+ u.hint.size = w >> 4;
>+ u.hint.pad = 0;
>+ return u.val;
>+ /* return (u.hint.stride << 16) | (u.hint.count << 8) | (u.hint.size << 3); */
>+}
>+
>+/*
>+ * AltiVec-enhanced yuv2yuvX
>+ *
>+ * Copyright (C) 2004 Romain Dolbeau <romain at dolbeau.org>
>+ * based on the equivalent C code in "postproc/swscale.c"
>+ * ...
>+ */
>+static void rv280_yv12toyuy2_unscaled_altivec (
>+ State *s,
>+ uint8_t* src[],
>+ int srcStride[],
>+ uint8_t* dst,
>+ int dstStride
>+ )
>+{
>+ uint8_t *ysrc = src[0];
>+ uint8_t *usrc = src[1];
>+ uint8_t *vsrc = src[2];
>+ const int width = s->w;
>+ const int height = s->h;
>+ const int lumStride = srcStride[0];
>+ const int chromStride = srcStride[1];
>+ const vector unsigned char yperm = vec_lvsl(0, ysrc);
>+ register int y;
>+
>+ /* this code assume:
>+
>+ 1) dst is 16 bytes-aligned
>+ 2) dstStride is a multiple of 16
>+ 3) width is a multiple of 16
>+ 4) lum&chrom stride are multiple of 8
>+ */
>+
>+ for (y=0; y<height; y++) {
>+ int i;
>+
>+ vec_dstt (ysrc, s->hint_luma, 0);
>+ /* vec_dststt (dst, s->hint_dst, 3); */
>+ if (!(y & 1)) {
>+ vec_dstt (usrc, s->hint_chroma, 1);
>+ vec_dstt (vsrc, s->hint_chroma, 2);
>+ }
>+
>+ for (i = 0; i < width - 31; i+= 32) {
>+ const unsigned int j = i >> 1;
>+ vector unsigned char v_yA = vec_ld(i, ysrc);
>+ vector unsigned char v_yB = vec_ld(i + 16, ysrc);
>+ vector unsigned char v_yC = vec_ld(i + 32, ysrc);
>+ vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm);
>+ vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm);
>+ vector unsigned char v_uA = vec_ld(j, usrc);
>+ vector unsigned char v_uB = vec_ld(j + 16, usrc);
>+ vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
>+ vector unsigned char v_vA = vec_ld(j, vsrc);
>+ vector unsigned char v_vB = vec_ld(j + 16, vsrc);
>+ vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
>+ vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
>+ vector unsigned char v_uv_b = vec_mergel(v_u, v_v);
>+ vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
>+ vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
>+ vector unsigned char v_yuy2_2 = vec_mergeh(v_y2, v_uv_b);
>+ vector unsigned char v_yuy2_3 = vec_mergel(v_y2, v_uv_b);
>+ vec_st(v_yuy2_0, (i << 1), dst);
>+ vec_st(v_yuy2_1, (i << 1) + 16, dst);
>+ vec_st(v_yuy2_2, (i << 1) + 32, dst);
>+ vec_st(v_yuy2_3, (i << 1) + 48, dst);
>+ }
>+ if (i < width) {
>+ const unsigned int j = i >> 1;
>+ vector unsigned char v_y1 = vec_ld(i, ysrc);
>+ vector unsigned char v_u = vec_ld(j, usrc);
>+ vector unsigned char v_v = vec_ld(j, vsrc);
>+ vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
>+ vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
>+ vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
>+ vec_st(v_yuy2_0, (i << 1), dst);
>+ vec_st(v_yuy2_1, (i << 1) + 16, dst);
>+ }
>+ if (y & 1) {
>+ usrc += chromStride;
>+ vsrc += chromStride;
>+ }
>+ ysrc += lumStride;
>+ dst += dstStride;
>+ }
>+}
is this lgpl? it should go into swscale if its faster than current
swscale...
>+#define shift_key (event->key.keysym.mod==(KMOD_LSHIFT||KMOD_RSHIFT))
>+static void rv280_process_keydown (State *s, SDL_Event *event)
>+{
>+ int key = event->key.keysym.sym;
>+
>+ switch (key) {
>+ case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break;
>+ case SDLK_ESCAPE: mplayer_put_key(KEY_ESC);break;
>+ case SDLK_q: mplayer_put_key('q');break;
>+
>+ case SDLK_F1: mplayer_put_key(KEY_F+1);break;
>+ case SDLK_F2: mplayer_put_key(KEY_F+2);break;
>+ case SDLK_F3: mplayer_put_key(KEY_F+3);break;
>+ case SDLK_F4: mplayer_put_key(KEY_F+4);break;
>+ case SDLK_F5: mplayer_put_key(KEY_F+5);break;
>+ case SDLK_F6: mplayer_put_key(KEY_F+6);break;
>+ case SDLK_F7: mplayer_put_key(KEY_F+7);break;
>+ case SDLK_F8: mplayer_put_key(KEY_F+8);break;
>+ case SDLK_F9: mplayer_put_key(KEY_F+9);break;
>+ case SDLK_F10: mplayer_put_key(KEY_F+10);break;
>+ case SDLK_F11: mplayer_put_key(KEY_F+11);break;
>+ case SDLK_F12: mplayer_put_key(KEY_F+12);break;
>+
>+ case SDLK_h: mplayer_put_key('h');break;
>+ case SDLK_k: mplayer_put_key('k');break;
>+ case SDLK_j: mplayer_put_key('j');break;
>+ case SDLK_v: mplayer_put_key('v');break;
>+ case SDLK_o: mplayer_put_key('o');break;
>+ case SDLK_l: mplayer_put_key('l');break;
>+ case SDLK_f:
>+ vo_fs ^= 1;
>+ vo_fs_type = vo_wm_FULLSCREEN;
>+ vo_window = s->win;
>+ mDisplay = s->dpy;
>+ vo_x11_ewmh_fullscreen (_NET_WM_STATE_TOGGLE);
>+ break;
>+ case SDLK_SPACE: mplayer_put_key(' ');break;
>+ case SDLK_p: mplayer_put_key('p');break;
>+ case SDLK_7: mplayer_put_key(shift_key?'/':'7'); break;
>+ case SDLK_PLUS: mplayer_put_key(shift_key?'*':'+'); break;
>+ case SDLK_KP_PLUS: mplayer_put_key('+');break;
>+ case SDLK_MINUS:
>+ case SDLK_KP_MINUS: mplayer_put_key('-');break;
>+ case SDLK_TAB: mplayer_put_key('\t');break;
>+ case SDLK_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break;
>+ case SDLK_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
>+ case SDLK_UP: mplayer_put_key(KEY_UP);break;
>+ case SDLK_DOWN: mplayer_put_key(KEY_DOWN);break;
>+ case SDLK_LEFT: mplayer_put_key(KEY_LEFT);break;
>+ case SDLK_RIGHT: mplayer_put_key(KEY_RIGHT);break;
>+ case SDLK_LESS: mplayer_put_key(shift_key?'>':'<'); break;
>+ case SDLK_GREATER: mplayer_put_key('>'); break;
>+ case SDLK_ASTERISK:
>+ case SDLK_KP_MULTIPLY: mplayer_put_key('*'); break;
>+ case SDLK_SLASH:
>+ case SDLK_KP_DIVIDE: mplayer_put_key('/'); break;
>+ case SDLK_KP0: mplayer_put_key(KEY_KP0); break;
>+ case SDLK_KP1: mplayer_put_key(KEY_KP1); break;
>+ case SDLK_KP2: mplayer_put_key(KEY_KP2); break;
>+ case SDLK_KP3: mplayer_put_key(KEY_KP3); break;
>+ case SDLK_KP4: mplayer_put_key(KEY_KP4); break;
>+ case SDLK_KP5: mplayer_put_key(KEY_KP5); break;
>+ case SDLK_KP6: mplayer_put_key(KEY_KP6); break;
>+ case SDLK_KP7: mplayer_put_key(KEY_KP7); break;
>+ case SDLK_KP8: mplayer_put_key(KEY_KP8); break;
>+ case SDLK_KP9: mplayer_put_key(KEY_KP9); break;
>+ case SDLK_KP_PERIOD: mplayer_put_key(KEY_KPDEC); break;
>+ case SDLK_KP_ENTER: mplayer_put_key(KEY_KPENTER); break;
>+ case SDLK_c: SDL_ShowCursor (s->cursor_visible = !s->cursor_visible); break;
>+
>+ default: break;
>+ }
>+}
duplication from vo_sdl.c ?
-compn
More information about the MPlayer-dev-eng
mailing list