author | sandman <sandman> | 2002-08-04 20:23:19 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-04 20:23:19 (UTC) |
commit | 57bd412cf973805fbe69ecfa8f168ad2e28311a9 (patch) (side-by-side diff) | |
tree | 78d7bab924023bdf33a437447bb31fff52b51c32 | |
parent | 7bf26dd95a7bd434edc8dd5e001d8ac490f67dc3 (diff) | |
download | opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.zip opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.tar.gz opie-57bd412cf973805fbe69ecfa8f168ad2e28311a9.tar.bz2 |
- Removed the mlib and mmx yuv2rgb converters
- Added an optimized (non-scaling !) arm4l yuv2rgb (taken from bbplay)
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_arm.c | 174 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S | 192 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_mlib.c | 313 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb_mmx.c | 1047 |
7 files changed, 375 insertions, 1363 deletions
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index 79337c2..bd52869 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c @@ -341,14 +341,12 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); }else{ frame->frame.pitches[0] = 8*((width + 3) / 4); - frame->frame.pitches[1] = 8*((width + 3) / 4); - frame->frame.pitches[2] = 8*((width + 3) / 4); frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, (void **)&frame->chunk[0]); frame->chunk[1] = NULL; frame->chunk[2] = NULL; } diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index d8cacd0..fee9242 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro @@ -7,13 +7,13 @@ HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ frame.h lib.h xinevideowidget.h \ alphablend.h yuv2rgb.h SOURCES = main.cpp \ playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ - alphablend.c yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c + alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S TARGET = opieplayer2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lpthread -lopie -lxine -lxineutils MOC_DIR=qpeobj OBJECTS_DIR=qpeobj diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.c b/noncore/multimedia/opieplayer2/yuv2rgb.c index d1d6627..22bb4cb 100644 --- a/noncore/multimedia/opieplayer2/yuv2rgb.c +++ b/noncore/multimedia/opieplayer2/yuv2rgb.c @@ -3134,12 +3134,20 @@ yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, yuv2rgb_init_mlib (this); if (this->yuv2rgb_fun != NULL) printf ("yuv2rgb: using medialib for colorspace transform\n"); } #endif +#ifdef __arm__ + if (this->yuv2rgb_fun == NULL) { + yuv2rgb_init_arm ( this ); + + if(this->yuv2rgb_fun != NULL) + printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); + } +#endif if (this->yuv2rgb_fun == NULL) { printf ("yuv2rgb: no accelerated colorspace conversion found\n"); yuv2rgb_c_init (this); } /* diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_arm.c b/noncore/multimedia/opieplayer2/yuv2rgb_arm.c new file mode 100644 index 0000000..699ee48 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/yuv2rgb_arm.c @@ -0,0 +1,174 @@ +/* + * yuv2rgb_arm.c + * Copyright (C) 2000-2001 Project OPIE. + * All Rights Reserved. + * + * Author: Robert Griebl <sandman@handhelds.org> + * + * This file is part of OpiePlayer2. + * + * OpiePlayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * OpiePlayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef __arm__ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> + +#include "yuv2rgb.h" +#include <xine/xineutils.h> + +#define RGB(i) \ + U = pu[i]; \ + V = pv[i]; \ + r = this->table_rV[V]; \ + g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]); \ + b = this->table_bU[U]; + +#define DST1(i) \ + Y = py_1[2*i]; \ + dst_1[2*i] = r[Y] + g[Y] + b[Y]; \ + Y = py_1[2*i+1]; \ + dst_1[2*i+1] = r[Y] + g[Y] + b[Y]; + + +struct dummy { + uint8_t *yuv [3]; + int stride [3]; +}; + +extern void convert_yuv420_rgb565(struct dummy *picture, unsigned char *results, int w, int h) ; + + +static void arm_rgb16 (yuv2rgb_t *this, uint8_t * _dst, + uint8_t * _py, uint8_t * _pu, uint8_t * _pv) +{ + if ( !this-> do_scale ) { + struct dummy d; + d. yuv [0] = _py; + d. yuv [1] = _pu; + d. yuv [2] = _pv; + d. stride [0] = this-> y_stride; + d. stride [1] = d. stride [2] = this-> uv_stride; + +// printf( "calling arm (%dx%d)\n", this-> dest_width, this-> dest_height ); + + convert_yuv420_rgb565 ( &d, _dst, this->dest_width, this->dest_height ); + +// printf ( "arm done\n" ); + } + else { + int U, V, Y; + uint8_t * py_1, * py_2, * pu, * pv; + uint16_t * r, * g, * b; + uint16_t * dst_1, * dst_2; + int width, height, dst_height; + int dy; + + scale_line_func_t scale_line = this->scale_line; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + dy = 0; + dst_height = this->dest_height; + + for (height = 0;; ) { + dst_1 = (uint16_t*)_dst; + py_1 = this->y_buffer; + pu = this->u_buffer; + pv = this->v_buffer; + + width = this->dest_width >> 3; + + do { + RGB(0); + DST1(0); + + RGB(1); + DST1(1); + + RGB(2); + DST1(2); + + RGB(3); + DST1(3); + + pu += 4; + pv += 4; + py_1 += 8; + dst_1 += 8; + } while (--width); + + dy += this->step_dy; + _dst += this->rgb_stride; + + while (--dst_height > 0 && dy < 32768) { + + xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); + + dy += this->step_dy; + _dst += this->rgb_stride; + } + + if (dst_height <= 0) + break; + + do { + dy -= 32768; + _py += this->y_stride; + + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + if (height & 1) { + _pu += this->uv_stride; + _pv += this->uv_stride; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + + } + height++; + } while( dy>=32768); + } + } +} + + + +void yuv2rgb_init_arm (yuv2rgb_factory_t *this) { + + if (this->swapped) + return; /*no swapped pixel output upto now*/ + + switch (this->mode) { + case MODE_16_RGB: + this->yuv2rgb_fun = arm_rgb16; + break; + } +} + + + +#endif diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S b/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S new file mode 100644 index 0000000..f4a3395 --- a/dev/null +++ b/noncore/multimedia/opieplayer2/yuv2rgb_arm4l.S @@ -0,0 +1,192 @@ +/* WARNING : this function only works when stride_U == stride_V (I use some hacks to + not have to do too many computations at line's end)... + + C-like prototype : + void convert_yuv420_rgb565(AVPicture *picture, unsigned char *results, int w, int h) ; + +*/ + +#ifdef __arm__ + + .text + .align + + .global convert_yuv420_rgb565 +convert_yuv420_rgb565: + stmdb sp!, { r4 - r12, lr } @ all callee saved regs + ldr r7, [r0, #0] @ Y ptr + ldr r9, [r0, #4] @ U ptr + ldr r10, [r0, #8] @ V ptr + subs r10, r10, r9 @ V ptr - U ptr + ldr r8, [r0, #12] + add r8, r8, r7 @ Y + stride_Y + ldr r4, [r0, #12] @ Stride_Y + mov r4, r4, lsl #1 + sub r4, r4, r2 @ (2 * Stride_Y) - width + ldr r5, [r0, #16] @ Stride_U + sub r5, r5, r2, lsr #1 @ Stride_U - (width / 2) + ldr r6, [r0, #20] @ Stride_V + sub r6, r6, r2, lsr #1 @ Stride_V - (width / 2) + add r0, r1, r2, lsl #1 @ RGB + 1 + stmdb sp!, { r0-r10 } + @ Stack description : + @ (sp+ 0) RGB + one line + @ (sp+ 4) RGB + @ (sp+ 8) width (save) + @ (sp+12) height + @ (sp+16) (2 * stride_Y) - width + @ (sp+20) stride_U - (width / 2) + @ (sp+24) stride_V - (width / 2) !!! UNUSED !!! + @ (sp+28) Y ptr + @ (sp+32) Y ptr + one line + @ (sp+36) U ptr + @ (sp+40) V - U + mov lr, r2 @ Initialize the width counter + add r0, pc, #(const_storage-.-8) @ r0 = base pointer to the constants array + ldr r8, [r0, #(4*4)] @ r8 = multy +yuv_loop: + add r0, pc, #(const_storage-.-8) @ r0 = base pointer to the constants array + ldr r10, [sp, #28] @ r10 = Y + ldr r1, [sp, #36] @ r1 = U + ldrb r9, [r10, #0] @ r9 = *Y + ldrb r11, [r1] @ r11 = *U + add r1, r1, #1 @ r1 = U++ + ldr r2, [sp, #40] @ r2 = V - U + str r1, [sp, #36] @ store U++ + add r2, r1, r2 @ r2 = V+1 + ldrb r12, [r2, #-1] @ r12 = *V + sub r11, r11, #128 @ r11 = *U - 128 + sub r12, r12, #128 @ r12 = *V - 128 + ldr r1, [r0, #(4*0)] @ r1 = crv + mov r7, #32768 @ r7 = 32768 (for additions in MLA) + ldr r2, [r0, #(4*3)] @ r2 = -cgv + mla r6, r1, r12, r7 @ r6 = nonyc_r = crv * (*V - 128) + 32768 + ldr r3, [r0, #(4*1)] @ r3 = cbu + mla r4, r2, r12, r7 @ r4 = - cgv * (*V - 128) + 32768 + sub r9, r9, #16 @ r9 = *Y - 16 + mla r5, r3, r11, r7 @ r5 = nonyc_b = cbu * (*U - 128) + 32768 + ldr r0, [r0, #(4*2)] @ r0 = -cgu + mla r7, r8, r9, r6 @ r7 = (*Y - 16) * multy + nonyc_r + add r10, r10, #2 @ r10 = Y + 2 + mla r4, r0, r11, r4 @ r4 = nonyc_g = - cgu * (*U - 128) + r4 = - cgu * (*U - 128) - cgv * (*V - 128) + 32768 + add r0, pc, #(rb_clip-.-8) @ r0 contains the pointer to the R and B clipping array + mla r12, r8, r9, r5 @ r12 = (*Y - 16) * multy + nonyc_b + ldrb r7, [r0, r7, asr #(16+3)] @ r7 = R composant + mla r1, r8, r9, r4 @ r1 = (*Y - 16) * multy + nonyc_g + ldrb r9, [r10, #-1] @ r9 = *(Y+1) + str r10, [sp, #28] @ save Y + 2 + ldrb r12, [r0, r12, asr #(16+3)] @ r12 = B composant (and the start of the RGB word) + add r11, pc, #(g_clip-.-8) @ r11 now contains the pointer to the G clipping array + ldrb r1, [r11, r1, asr #(16+2)] @ r1 contains the G part of the RGB triplet + sub r9, r9, #16 @ r9 = *(Y+1) - 16 + mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet + add r12, r12, r7, lsl #11 @ r12 = .GB ... + mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet + add r12, r12, r1, lsl #5 @ r12 = RGB ... (ie the first pixel (half-word) is done) + mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet + ldrb r10, [r0, r10, asr #(16+3)] @ r10 = R composant + ldrb r7, [r0, r7, asr #(16+3)] @ r7 = B composant + ldr r1, [sp, #32] @ r1 = Ynext + ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant + ldrb r9, [r1] @ r9 = *Ynext + add r12, r12, r2, lsl #(5+16) @ r12 = RGB .G. + sub r9, r9, #16 @ r9 = *Ynext - 16 + mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet + add r12, r12, r7, lsl #(0+16) @ r12 = RGB .GB + mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet + add r12, r12, r10, lsl #(11+16) @ r12 = RGB RGB + ldr r3, [sp, #4] @ r3 = RGB + mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet + str r12, [r3] @ store the rgb pixel at *RGB + add r3, r3, #4 @ r3 = RGB++ (ie next double-pixel) + str r3, [sp, #4] @ store the RGB pointer + ldrb r9, [r1, #1] @ r9 = *(Ynext+1) + add r1, r1, #2 @ r1 = Ynext + 2 + sub r9, r9, #16 @ r9 = *(Ynext+1) - 16 + ldrb r12, [r0, r7, asr #(16+3)] @ r12 = ..B ... + ldrb r10, [r0, r10, asr #(16+3)] @ r10 = B composant + mla r7, r8, r9, r5 @ r7 is the Blue part of the RGB triplet + add r12, r12, r10, lsl #11 @ r12 = R.B ... + ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant + mla r10, r8, r9, r6 @ r10 is the Red part of the RGB triplet + add r12, r12, r2, lsl #5 @ r12 = RGB ... + mla r2, r8, r9, r4 @ r2 is the Green part of the RGB triplet + ldrb r7, [r0, r7, asr #(16+3)] @ r7 = B composant + str r1, [sp, #32] @ store the increased Ynext pointer + add r12, r12, r7, lsl #(16+0) @ r12 = RGB ..B + ldrb r10, [r0, r10, asr #(16+3)] @ r10 = R composant + ldr r3, [sp, #0] @ r3 = RGBnext pointer + add r12, r12, r10, lsl #(16+11) @ r12 = RGB R.B + ldrb r2, [r11, r2, asr #(16+2)] @ r2 = G composant + add r3, r3, #4 @ r3 = next pixel on the RGBnext line + add r12, r12, r2, lsl #(16+5) @ r12 = RGB RGB + str r12, [r3, #-4] @ store the next pixel + str r3, [sp, #0] @ store the increased 'next line' pixel pointer + subs lr, lr, #2 @ decrement the line counter + bne yuv_loop @ and restart if not at the end of the line + + ldr r0, [sp, #8] @ r0 = saved width + ldr r1, [sp, #0] @ r1 = RGBnext pointer + mov lr, r0 @ lr = saved width (to restart the line counter) + str r1, [sp, #4] @ current RGBnext pointer is next iteration RGB pointer + add r1, r1, r0, lsl #1 @ r1 = update RGBnext to next line + str r1, [sp, #0] @ store updated RGBnext pointer + + ldr r3, [sp, #16] @ r3 = (2 * stride_Y) - width + ldr r4, [sp, #28] @ r4 = Y ptr + ldr r5, [sp, #32] @ r5 = Ynext ptr + add r4, r4, r3 @ r4 = Y ptr for the next two lines + add r5, r5, r3 @ r5 = Ynext ptr for the next two lines + str r4, [sp, #28] @ store updated Y pointer + str r5, [sp, #32] @ store update Ynext pointer + + ldr r1, [sp, #20] @ r1 = stride_U - (width / 2) + ldr r2, [sp, #36] @ r2 = U ptr + + ldr r6, [sp, #12] @ get height counter + + add r2, r2, r1 @ update U ptr + str r2, [sp, #36] @ store updated U ptr (and update 'V' at the same time :-) ) + + subs r6, r6, #2 + str r6, [sp, #12] + bne yuv_loop + + @ Exit cleanly :-) + add sp, sp, #(11*4) @ remove all custom things from stack + ldmia sp!, { r4 - r12, pc } @ restore callee saved regs and return + + +const_storage: + @ In order : crv, cbu, - cgu, - cgv, multy + .word 0x00019895, 0x00020469, 0xffff9bb5, 0xffff2fe1, 0x00012A15 +rb_clip_dummy: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +rb_clip: + .byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f + .byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f + .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f + .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f + .byte 0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f +g_clip_dummy: + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +g_clip: + .byte 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f + .byte 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f + .byte 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f + .byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + .byte 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f + +#endif diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c b/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c deleted file mode 100644 index 908b439..0000000 --- a/noncore/multimedia/opieplayer2/yuv2rgb_mlib.c +++ b/dev/null @@ -1,313 +0,0 @@ -/* - * yuv2rgb_mlib.c - * Copyright (C) 2000-2001 Silicon Integrated System Corp. - * All Rights Reserved. - * - * Author: Juergen Keil <jk@tools.de> - * - * This file is part of xine, a free unix video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#if HAVE_MLIB - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <inttypes.h> -#include <mlib_video.h> - -#include "attributes.h" -#include "yuv2rgb.h" - - -static void scale_line (uint8_t *source, uint8_t *dest, - int width, int step) { - - unsigned p1; - unsigned p2; - int dx; - - p1 = *source++; - p2 = *source++; - dx = 0; - - while (width) { - - /* - printf ("scale_line, width = %d\n", width); - printf ("scale_line, dx = %d, p1 = %d, p2 = %d\n", dx, p1, p2); - */ - - *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; - - dx += step; - while (dx > 32768) { - dx -= 32768; - p1 = p2; - p2 = *source++; - } - - dest ++; - width --; - } -} - - - -static void mlib_yuv420_rgb24 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv) -{ - int dst_height; - int dy; - mlib_status mlib_stat; - - if (this->do_scale) { - dy = 0; - dst_height = this->dest_height; - - for (;;) { - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - pu += this->uv_stride; - - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - pv += this->uv_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - py += this->y_stride; - scale_line (py, this->y_buffer + this->dest_width, - this->dest_width, this->step_dx); - py += this->y_stride; - - mlib_stat = mlib_VideoColorYUV2RGB420(image, - this->y_buffer, - this->u_buffer, - this->v_buffer, - this->dest_width & ~1, 2, - this->rgb_stride, - this->dest_width, - this->dest_width >> 1); - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*6); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*3); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - } - } else { - mlib_stat = mlib_VideoColorYUV2RGB420(image, py, pu, pv, - this->source_width, - this->source_height, - this->rgb_stride, - this->y_stride, - this->uv_stride); - } -} - -static void mlib_yuv420_argb32 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv) -{ - int dst_height; - int dy; - mlib_status mlib_stat; - - if (this->do_scale) { - dy = 0; - dst_height = this->dest_height; - - for (;;) { - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - pu += this->uv_stride; - - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - pv += this->uv_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - py += this->y_stride; - scale_line (py, this->y_buffer + this->dest_width, - this->dest_width, this->step_dx); - py += this->y_stride; - - mlib_stat = mlib_VideoColorYUV2ARGB420(image, - this->y_buffer, - this->u_buffer, - this->v_buffer, - this->dest_width & ~1, 2, - this->rgb_stride, - this->dest_width, - this->dest_width >> 1); - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - } - } else { - mlib_stat = mlib_VideoColorYUV2ARGB420(image, py, pu, pv, - this->source_width, - this->source_height, - this->rgb_stride, - this->y_stride, - this->uv_stride); - } -} - -static void mlib_yuv420_abgr32 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv) -{ - int dst_height; - int dy; - mlib_status mlib_stat; - - if (this->do_scale) { - dy = 0; - dst_height = this->dest_height; - - for (;;) { - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - pu += this->uv_stride; - - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - pv += this->uv_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - py += this->y_stride; - scale_line (py, this->y_buffer + this->dest_width, - this->dest_width, this->step_dx); - py += this->y_stride; - - mlib_stat = mlib_VideoColorYUV2ABGR420(image, - this->y_buffer, - this->u_buffer, - this->v_buffer, - this->dest_width & ~1, 2, - this->rgb_stride, - this->dest_width, - this->dest_width >> 1); - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - - dy += this->step_dy; - image += this->rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); - dy += this->step_dy; - image += this->rgb_stride; - } - - if (dst_height <= 0) - break; - - dy -= 32768; - } - } else { - mlib_stat = mlib_VideoColorYUV2ABGR420(image, py, pu, pv, - this->source_width, - this->source_height, - this->rgb_stride, - this->y_stride, - this->uv_stride); - } -} - - -void yuv2rgb_init_mlib (yuv2rgb_factory_t *this) { - - if (this->swapped) return; /*no swapped pixel output upto now*/ - - switch (this->mode) { - case MODE_24_RGB: - this->yuv2rgb_fun = mlib_yuv420_rgb24; - break; - case MODE_32_RGB: - this->yuv2rgb_fun = mlib_yuv420_argb32; - break; - case MODE_32_BGR: - this->yuv2rgb_fun = mlib_yuv420_abgr32; - break; - } -} - - -#endif /* HAVE_MLIB */ diff --git a/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c b/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c deleted file mode 100644 index f092e6f..0000000 --- a/noncore/multimedia/opieplayer2/yuv2rgb_mmx.c +++ b/dev/null @@ -1,1047 +0,0 @@ -/* - * yuv2rgb_mmx.c - * Copyright (C) 2000-2001 Silicon Integrated System Corp. - * All Rights Reserved. - * - * Author: Olie Lho <ollie@sis.com.tw> - * - * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. - * - * mpeg2dec is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mpeg2dec is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifdef ARCH_X86 - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <inttypes.h> - -#include "yuv2rgb.h" -#include "xineutils.h" - -#define CPU_MMXEXT 0 -#define CPU_MMX 1 - -/* CPU_MMXEXT/CPU_MMX adaptation layer */ - -#define movntq(src,dest) \ -do { \ - if (cpu == CPU_MMXEXT) \ - movntq_r2m (src, dest); \ - else \ - movq_r2m (src, dest); \ -} while (0) - -static mmx_t mmx_subYw = {0x1010101010101010}; -static mmx_t mmx_addYw = {0x0000000000000000}; - -void mmx_yuv2rgb_set_gamma(int gamma) -{ -int a,s,i; - - if( gamma <= 16 ) { - a = 0; - s = 16 - gamma; - } else { - a = gamma - 16; - s = 0; - } - - for( i = 0; i < 8; i++ ) { - *((unsigned char *)&mmx_subYw + i) = s; - *((unsigned char *)&mmx_addYw + i) = a; - } -} - -static inline void mmx_yuv2rgb (uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - static mmx_t mmx_80w = {0x0080008000800080}; - static mmx_t mmx_U_green = {0xf37df37df37df37d}; - static mmx_t mmx_U_blue = {0x4093409340934093}; - static mmx_t mmx_V_red = {0x3312331233123312}; - static mmx_t mmx_V_green = {0xe5fce5fce5fce5fc}; - static mmx_t mmx_00ffw = {0x00ff00ff00ff00ff}; - static mmx_t mmx_Y_coeff = {0x253f253f253f253f}; - - movq_m2r (*py, mm6); // mm6 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 - pxor_r2r (mm4, mm4); // mm4 = 0 - - psubusb_m2r (mmx_subYw, mm6); // Y -= 16 - paddusb_m2r (mmx_addYw, mm6); - - movd_m2r (*pu, mm0); // mm0 = 00 00 00 00 u3 u2 u1 u0 - movq_r2r (mm6, mm7); // mm7 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 - - pand_m2r (mmx_00ffw, mm6); // mm6 = Y6 Y4 Y2 Y0 - psrlw_i2r (8, mm7); // mm7 = Y7 Y5 Y3 Y1 - - movd_m2r (*pv, mm1); // mm1 = 00 00 00 00 v3 v2 v1 v0 - psllw_i2r (3, mm6); // promote precision - - pmulhw_m2r (mmx_Y_coeff, mm6); // mm6 = luma_rgb even - psllw_i2r (3, mm7); // promote precision - - punpcklbw_r2r (mm4, mm0); // mm0 = u3 u2 u1 u0 - - psubsw_m2r (mmx_80w, mm0); // u -= 128 - punpcklbw_r2r (mm4, mm1); // mm1 = v3 v2 v1 v0 - - pmulhw_m2r (mmx_Y_coeff, mm7); // mm7 = luma_rgb odd - psllw_i2r (3, mm0); // promote precision - - psubsw_m2r (mmx_80w, mm1); // v -= 128 - movq_r2r (mm0, mm2); // mm2 = u3 u2 u1 u0 - - psllw_i2r (3, mm1); // promote precision - - movq_r2r (mm1, mm4); // mm4 = v3 v2 v1 v0 - - pmulhw_m2r (mmx_U_blue, mm0); // mm0 = chroma_b - - - // slot - - - // slot - - - pmulhw_m2r (mmx_V_red, mm1); // mm1 = chroma_r - movq_r2r (mm0, mm3); // mm3 = chroma_b - - paddsw_r2r (mm6, mm0); // mm0 = B6 B4 B2 B0 - paddsw_r2r (mm7, mm3); // mm3 = B7 B5 B3 B1 - - packuswb_r2r (mm0, mm0); // saturate to 0-255 - - - pmulhw_m2r (mmx_U_green, mm2); // mm2 = u * u_green - - - packuswb_r2r (mm3, mm3); // saturate to 0-255 - - - punpcklbw_r2r (mm3, mm0); // mm0 = B7 B6 B5 B4 B3 B2 B1 B0 - - - pmulhw_m2r (mmx_V_green, mm4); // mm4 = v * v_green - - - // slot - - - // slot - - - paddsw_r2r (mm4, mm2); // mm2 = chroma_g - movq_r2r (mm2, mm5); // mm5 = chroma_g - - - movq_r2r (mm1, mm4); // mm4 = chroma_r - paddsw_r2r (mm6, mm2); // mm2 = G6 G4 G2 G0 - - - packuswb_r2r (mm2, mm2); // saturate to 0-255 - paddsw_r2r (mm6, mm1); // mm1 = R6 R4 R2 R0 - - packuswb_r2r (mm1, mm1); // saturate to 0-255 - paddsw_r2r (mm7, mm4); // mm4 = R7 R5 R3 R1 - - packuswb_r2r (mm4, mm4); // saturate to 0-255 - paddsw_r2r (mm7, mm5); // mm5 = G7 G5 G3 G1 - - - packuswb_r2r (mm5, mm5); // saturate to 0-255 - - - punpcklbw_r2r (mm4, mm1); // mm1 = R7 R6 R5 R4 R3 R2 R1 R0 - - - punpcklbw_r2r (mm5, mm2); // mm2 = G7 G6 G5 G4 G3 G2 G1 G0 -} - -// basic opt -static inline void mmx_unpack_16rgb (uint8_t * image, int cpu) -{ - static mmx_t mmx_bluemask = {0xf8f8f8f8f8f8f8f8}; - static mmx_t mmx_greenmask = {0xfcfcfcfcfcfcfcfc}; - static mmx_t mmx_redmask = {0xf8f8f8f8f8f8f8f8}; - - /* - * convert RGB plane to RGB 16 bits - * mm0 -> B, mm1 -> R, mm2 -> G - * mm4 -> GB, mm5 -> AR pixel 4-7 - * mm6 -> GB, mm7 -> AR pixel 0-3 - */ - - pand_m2r (mmx_bluemask, mm0); // mm0 = b7b6b5b4b3______ - pxor_r2r (mm4, mm4); // mm4 = 0 - - pand_m2r (mmx_greenmask, mm2); // mm2 = g7g6g5g4g3g2____ - psrlq_i2r (3, mm0); // mm0 = ______b7b6b5b4b3 - - movq_r2r (mm2, mm7); // mm7 = g7g6g5g4g3g2____ - movq_r2r (mm0, mm5); // mm5 = ______b7b6b5b4b3 - - pand_m2r (mmx_redmask, mm1); // mm1 = r7r6r5r4r3______ - punpcklbw_r2r (mm4, mm2); - - punpcklbw_r2r (mm1, mm0); - - psllq_i2r (3, mm2); - - punpckhbw_r2r (mm4, mm7); - por_r2r (mm2, mm0); - - psllq_i2r (3, mm7); - - movntq (mm0, *image); - punpckhbw_r2r (mm1, mm5); - - por_r2r (mm7, mm5); - - // U - // V - - movntq (mm5, *(image+8)); -} - -static inline void mmx_unpack_15rgb (uint8_t * image, int cpu) -{ - static mmx_t mmx_bluemask = {0xf8f8f8f8f8f8f8f8}; - static mmx_t mmx_greenmask = {0xf8f8f8f8f8f8f8f8}; - static mmx_t mmx_redmask = {0xf8f8f8f8f8f8f8f8}; - - /* - * convert RGB plane to RGB 15 bits - * mm0 -> B, mm1 -> R, mm2 -> G - * mm4 -> GB, mm5 -> AR pixel 4-7 - * mm6 -> GB, mm7 -> AR pixel 0-3 - */ - - pand_m2r (mmx_bluemask, mm0); // mm0 = b7b6b5b4b3______ - pxor_r2r (mm4, mm4); // mm4 = 0 - - pand_m2r (mmx_greenmask, mm2); // mm2 = g7g6g5g4g3g2____ - psrlq_i2r (3, mm0); // mm0 = ______b7b6b5b4b3 - - movq_r2r (mm2, mm7); // mm7 = g7g6g5g4g3g2____ - movq_r2r (mm0, mm5); // mm5 = ______b7b6b5b4b3 - - pand_m2r (mmx_redmask, mm1); // mm1 = r7r6r5r4r3______ - punpcklbw_r2r (mm4, mm2); - - psrlq_i2r (1, mm1); - punpcklbw_r2r (mm1, mm0); - - psllq_i2r (2, mm2); - - punpckhbw_r2r (mm4, mm7); - por_r2r (mm2, mm0); - - psllq_i2r (2, mm7); - - movntq (mm0, *image); - punpckhbw_r2r (mm1, mm5); - - por_r2r (mm7, mm5); - - // U - // V - - movntq (mm5, *(image+8)); -} - -static inline void mmx_unpack_32rgb (uint8_t * image, int cpu) -{ - /* - * convert RGB plane to RGB packed format, - * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, - * mm4 -> GB, mm5 -> AR pixel 4-7, - * mm6 -> GB, mm7 -> AR pixel 0-3 - */ - - pxor_r2r (mm3, mm3); - movq_r2r (mm0, mm6); - - punpcklbw_r2r (mm2, mm6); - movq_r2r (mm1, mm7); - - punpcklbw_r2r (mm3, mm7); - movq_r2r (mm0, mm4); - - punpcklwd_r2r (mm7, mm6); - movq_r2r (mm1, mm5); - - /* scheduling: this is hopeless */ - movntq (mm6, *image); - movq_r2r (mm0, mm6); - punpcklbw_r2r (mm2, mm6); - punpckhwd_r2r (mm7, mm6); - movntq (mm6, *(image+8)); - punpckhbw_r2r (mm2, mm4); - punpckhbw_r2r (mm3, mm5); - punpcklwd_r2r (mm5, mm4); - movntq (mm4, *(image+16)); - movq_r2r (mm0, mm4); - punpckhbw_r2r (mm2, mm4); - punpckhwd_r2r (mm5, mm4); - movntq (mm4, *(image+24)); -} - -static inline void mmx_unpack_32bgr (uint8_t * image, int cpu) -{ - /* - * convert RGB plane to RGB packed format, - * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, - * mm4 -> GB, mm5 -> AR pixel 4-7, - * mm6 -> GB, mm7 -> AR pixel 0-3 - */ - - pxor_r2r (mm3, mm3); - movq_r2r (mm1, mm6); - - punpcklbw_r2r (mm2, mm6); - movq_r2r (mm0, mm7); - - punpcklbw_r2r (mm3, mm7); - movq_r2r (mm1, mm4); - - punpcklwd_r2r (mm7, mm6); - movq_r2r (mm0, mm5); - - /* scheduling: this is hopeless */ - movntq (mm6, *image); - movq_r2r (mm0, mm6); - punpcklbw_r2r (mm2, mm6); - punpckhwd_r2r (mm7, mm6); - movntq (mm6, *(image+8)); - punpckhbw_r2r (mm2, mm4); - punpckhbw_r2r (mm3, mm5); - punpcklwd_r2r (mm5, mm4); - movntq (mm4, *(image+16)); - movq_r2r (mm0, mm4); - punpckhbw_r2r (mm2, mm4); - punpckhwd_r2r (mm5, mm4); - movntq (mm4, *(image+24)); -} - -static inline void mmx_unpack_24rgb (uint8_t * image, int cpu) -{ - /* - * convert RGB plane to RGB packed format, - * mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, - * mm4 -> GB, mm5 -> AR pixel 4-7, - * mm6 -> GB, mm7 -> AR pixel 0-3 - */ - - pxor_r2r (mm3, mm3); - movq_r2r (mm0, mm6); - - punpcklbw_r2r (mm2, mm6); - movq_r2r (mm1, mm7); - - punpcklbw_r2r (mm3, mm7); - movq_r2r (mm0, mm4); - - punpcklwd_r2r (mm7, mm6); - movq_r2r (mm1, mm5); - - /* scheduling: this is hopeless */ - movntq (mm6, *image); - movq_r2r (mm0, mm6); - punpcklbw_r2r (mm2, mm6); - punpckhwd_r2r (mm7, mm6); - movntq (mm6, *(image+8)); - punpckhbw_r2r (mm2, mm4); - punpckhbw_r2r (mm3, mm5); - punpcklwd_r2r (mm5, mm4); - movntq (mm4, *(image+16)); -} - -static inline void yuv420_rgb16 (yuv2rgb_t *this, - uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv, - int cpu) -{ - int i; - int rgb_stride = this->rgb_stride; - int y_stride = this->y_stride; - int uv_stride = this->uv_stride; - int width = this->source_width; - int height = this->source_height; - int dst_height = this->dest_height; - uint8_t *img; - - width >>= 3; - - if (!this->do_scale) { - y_stride -= 8 * width; - uv_stride -= 4 * width; - - do { - - i = width; img = image; - do { - mmx_yuv2rgb (py, pu, pv); - mmx_unpack_16rgb (img, cpu); - py += 8; - pu += 4; - pv += 4; - img += 16; - } while (--i); - - py += y_stride; - image += rgb_stride; - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - } else { - pu -= 4 * width; - pv -= 4 * width; - } - } while (--height); - - } else { - - scale_line_func_t scale_line = this->scale_line; - uint8_t *y_buf, *u_buf, *v_buf; - int dy = 0; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - for (height = 0;; ) { - - y_buf = this->y_buffer; - u_buf = this->u_buffer; - v_buf = this->v_buffer; - - i = this->dest_width >> 3; img = image; - do { - /* printf ("i : %d\n",i); */ - - mmx_yuv2rgb (y_buf, u_buf, v_buf); - mmx_unpack_16rgb (img, cpu); - y_buf += 8; - u_buf += 4; - v_buf += 4; - img += 16; - } while (--i); - - dy += this->step_dy; - image += rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - - xine_fast_memcpy (image, image-rgb_stride, this->dest_width*2); - - dy += this->step_dy; - image += rgb_stride; - } - - if (dst_height <= 0) - break; - - do { - dy -= 32768; - - py += y_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - - } - height++; - } while( dy>=32768); - } - } -} - -static inline void yuv420_rgb15 (yuv2rgb_t *this, - uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv, - int cpu) -{ - int i; - int rgb_stride = this->rgb_stride; - int y_stride = this->y_stride; - int uv_stride = this->uv_stride; - int width = this->source_width; - int height = this->source_height; - int dst_height = this->dest_height; - uint8_t *img; - - width >>= 3; - - if (!this->do_scale) { - y_stride -= 8 * width; - uv_stride -= 4 * width; - - do { - - i = width; img = image; - do { - mmx_yuv2rgb (py, pu, pv); - mmx_unpack_15rgb (img, cpu); - py += 8; - pu += 4; - pv += 4; - img += 16; - } while (--i); - - py += y_stride; - image += rgb_stride; - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - } else { - pu -= 4 * width; - pv -= 4 * width; - } - } while (--height); - - } else { - - scale_line_func_t scale_line = this->scale_line; - uint8_t *y_buf, *u_buf, *v_buf; - int dy = 0; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - for (height = 0;; ) { - - y_buf = this->y_buffer; - u_buf = this->u_buffer; - v_buf = this->v_buffer; - - i = this->dest_width >> 3; img = image; - do { - /* printf ("i : %d\n",i); */ - - mmx_yuv2rgb (y_buf, u_buf, v_buf); - mmx_unpack_15rgb (img, cpu); - y_buf += 8; - u_buf += 4; - v_buf += 4; - img += 16; - } while (--i); - - dy += this->step_dy; - image += rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - - xine_fast_memcpy (image, image-rgb_stride, this->dest_width*2); - - dy += this->step_dy; - image += rgb_stride; - } - - if (dst_height <= 0) - break; - - do { - dy -= 32768; - py += y_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - - } - height++; - } while( dy>=32768 ); - } - } -} - -static inline void yuv420_rgb24 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv, int cpu) -{ - int i; - int rgb_stride = this->rgb_stride; - int y_stride = this->y_stride; - int uv_stride = this->uv_stride; - int width = this->source_width; - int height = this->source_height; - int dst_height = this->dest_height; - uint8_t *img; - - /* rgb_stride -= 4 * this->dest_width; */ - width >>= 3; - - if (!this->do_scale) { - y_stride -= 8 * width; - uv_stride -= 4 * width; - - do { - i = width; img = image; - do { - mmx_yuv2rgb (py, pu, pv); - mmx_unpack_24rgb (img, cpu); - py += 8; - pu += 4; - pv += 4; - img += 24; - } while (--i); - - py += y_stride; - image += rgb_stride; - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - } else { - pu -= 4 * width; - pv -= 4 * width; - } - } while (--height); - } else { - - scale_line_func_t scale_line = this->scale_line; - uint8_t *y_buf, *u_buf, *v_buf; - int dy = 0; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - for (height = 0;; ) { - - y_buf = this->y_buffer; - u_buf = this->u_buffer; - v_buf = this->v_buffer; - - - i = this->dest_width >> 3; img=image; - do { - /* printf ("i : %d\n",i); */ - - mmx_yuv2rgb (y_buf, u_buf, v_buf); - mmx_unpack_24rgb (img, cpu); - y_buf += 8; - u_buf += 4; - v_buf += 4; - img += 24; - } while (--i); - - dy += this->step_dy; - image += rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - - xine_fast_memcpy (image, image-rgb_stride, this->dest_width*3); - - dy += this->step_dy; - image += rgb_stride; - } - - if (dst_height <= 0) - break; - - do { - dy -= 32768; - py += y_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - } - height++; - } while( dy>=32768 ); - - } - - } -} - -static inline void yuv420_argb32 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv, int cpu) -{ - int i; - int rgb_stride = this->rgb_stride; - int y_stride = this->y_stride; - int uv_stride = this->uv_stride; - int width = this->source_width; - int height = this->source_height; - int dst_height = this->dest_height; - uint8_t *img; - - /* rgb_stride -= 4 * this->dest_width; */ - width >>= 3; - - if (!this->do_scale) { - y_stride -= 8 * width; - uv_stride -= 4 * width; - - do { - i = width; img = image; - do { - mmx_yuv2rgb (py, pu, pv); - mmx_unpack_32rgb (img, cpu); - py += 8; - pu += 4; - pv += 4; - img += 32; - } while (--i); - - py += y_stride; - image += rgb_stride; - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - } else { - pu -= 4 * width; - pv -= 4 * width; - } - } while (--height); - } else { - - scale_line_func_t scale_line = this->scale_line; - uint8_t *y_buf, *u_buf, *v_buf; - int dy = 0; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - for (height = 0;; ) { - - y_buf = this->y_buffer; - u_buf = this->u_buffer; - v_buf = this->v_buffer; - - - i = this->dest_width >> 3; img=image; - do { - /* printf ("i : %d\n",i); */ - - mmx_yuv2rgb (y_buf, u_buf, v_buf); - mmx_unpack_32rgb (img, cpu); - y_buf += 8; - u_buf += 4; - v_buf += 4; - img += 32; - } while (--i); - - dy += this->step_dy; - image += rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - - xine_fast_memcpy (image, image-rgb_stride, this->dest_width*4); - - dy += this->step_dy; - image += rgb_stride; - } - - if (dst_height <= 0) - break; - - do { - dy -= 32768; - py += y_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - } - height++; - } while( dy>=32768 ); - } - - } -} - -static inline void yuv420_abgr32 (yuv2rgb_t *this, - uint8_t * image, uint8_t * py, - uint8_t * pu, uint8_t * pv, int cpu) -{ - int i; - int rgb_stride = this->rgb_stride; - int y_stride = this->y_stride; - int uv_stride = this->uv_stride; - int width = this->source_width; - int height = this->source_height; - int dst_height = this->dest_height; - uint8_t *img; - - /* rgb_stride -= 4 * this->dest_width; */ - width >>= 3; - - if (!this->do_scale) { - y_stride -= 8 * width; - uv_stride -= 4 * width; - - do { - i = width; img = image; - do { - mmx_yuv2rgb (py, pu, pv); - mmx_unpack_32bgr (img, cpu); - py += 8; - pu += 4; - pv += 4; - img += 32; - } while (--i); - - py += y_stride; - image += rgb_stride; - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - } else { - pu -= 4 * width; - pv -= 4 * width; - } - } while (--height); - } else { - - scale_line_func_t scale_line = this->scale_line; - uint8_t *y_buf, *u_buf, *v_buf; - int dy = 0; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - for (height = 0;; ) { - - y_buf = this->y_buffer; - u_buf = this->u_buffer; - v_buf = this->v_buffer; - - - i = this->dest_width >> 3; img=image; - do { - /* printf ("i : %d\n",i); */ - - mmx_yuv2rgb (y_buf, u_buf, v_buf); - mmx_unpack_32bgr (img, cpu); - y_buf += 8; - u_buf += 4; - v_buf += 4; - img += 32; - } while (--i); - - dy += this->step_dy; - image += rgb_stride; - - while (--dst_height > 0 && dy < 32768) { - - xine_fast_memcpy (image, image-rgb_stride, this->dest_width*4); - - dy += this->step_dy; - image += rgb_stride; - } - - if (dst_height <= 0) - break; - - do { - dy -= 32768; - py += y_stride; - - scale_line (py, this->y_buffer, - this->dest_width, this->step_dx); - - if (height & 1) { - pu += uv_stride; - pv += uv_stride; - - scale_line (pu, this->u_buffer, - this->dest_width >> 1, this->step_dx); - scale_line (pv, this->v_buffer, - this->dest_width >> 1, this->step_dx); - } - height++; - } while( dy>=32768 ); - - } - - } -} - -static void mmxext_rgb15 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb15 (this, image, py, pu, pv, CPU_MMXEXT); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmxext_rgb16 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb16 (this, image, py, pu, pv, CPU_MMXEXT); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmxext_rgb24 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb24 (this, image, py, pu, pv, CPU_MMXEXT); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmxext_argb32 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_argb32 (this, image, py, pu, pv, CPU_MMXEXT); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmxext_abgr32 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_abgr32 (this, image, py, pu, pv, CPU_MMXEXT); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmx_rgb15 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb15 (this, image, py, pu, pv, CPU_MMX); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmx_rgb16 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb16 (this, image, py, pu, pv, CPU_MMX); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmx_rgb24 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_rgb24 (this, image, py, pu, pv, CPU_MMX); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmx_argb32 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_argb32 (this, image, py, pu, pv, CPU_MMX); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -static void mmx_abgr32 (yuv2rgb_t *this, uint8_t * image, - uint8_t * py, uint8_t * pu, uint8_t * pv) -{ - yuv420_abgr32 (this, image, py, pu, pv, CPU_MMX); - emms(); /* re-initialize x86 FPU after MMX use */ -} - -void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this) { - - if (this->swapped) - return; /*no swapped pixel output upto now*/ - - switch (this->mode) { - case MODE_15_RGB: - this->yuv2rgb_fun = mmxext_rgb15; - break; - case MODE_16_RGB: - this->yuv2rgb_fun = mmxext_rgb16; - break; - case MODE_24_RGB: - this->yuv2rgb_fun = mmxext_rgb24; - break; - case MODE_32_RGB: - this->yuv2rgb_fun = mmxext_argb32; - break; - case MODE_32_BGR: - this->yuv2rgb_fun = mmxext_abgr32; - break; - } -} - -void yuv2rgb_init_mmx (yuv2rgb_factory_t *this) { - - if (this->swapped) - return; /*no swapped pixel output upto now*/ - - switch (this->mode) { - case MODE_15_RGB: - this->yuv2rgb_fun = mmx_rgb15; - break; - case MODE_16_RGB: - this->yuv2rgb_fun = mmx_rgb16; - break; - case MODE_24_RGB: - this->yuv2rgb_fun = mmx_rgb24; - break; - case MODE_32_RGB: - this->yuv2rgb_fun = mmx_argb32; - break; - case MODE_32_BGR: - this->yuv2rgb_fun = mmx_abgr32; - break; - } -} - - -#endif |