|
From: John M M. <jo...@us...> - 2002-09-07 07:36:13
|
Update of /cvsroot/squeak/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video
In directory usw-pr-cvs1:/tmp/cvs-serv4927/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video
Modified Files:
output.c
Log Message:
1.3 Add clip arrays for blue screening and alpha channel logic. Also some minor tuning
Index: output.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video/output.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** output.c 5 May 2002 18:52:56 -0000 1.2
--- output.c 7 Sep 2002 07:36:08 -0000 1.3
***************
*** 30,36 ****
/* Changed Sept 15th by John M McIntosh to support Macintosh & Squeak
Feb/march 2001, JMM tuning for the mac
! I've coded up mpeg3video_ditherframeFastRGB555 and mpeg3video_ditherframeFastRGBA which
do specialized 16 and 32 bit Crb to rgb mapping (Intel should do this too?)
I also coded up clip arrays versus using CLIP() This avoid test/branchs which slows things down
*/
#include "libmpeg3.h"
--- 30,37 ----
/* Changed Sept 15th by John M McIntosh to support Macintosh & Squeak
Feb/march 2001, JMM tuning for the mac
! I've coded up mpeg3video_ditherframeFastRGB555 and mpeg3video_ditherframeFastARGB which
do specialized 16 and 32 bit Crb to rgb mapping (Intel should do this too?)
I also coded up clip arrays versus using CLIP() This avoid test/branchs which slows things down
+ Sept 2002, JMM added clip arrays to enable blue screening and value for alpha channel
*/
#include "libmpeg3.h"
***************
*** 38,47 ****
#include <string.h>
! unsigned char gClipArray[1026];
! unsigned short gClipArray16r[1026],gClipArray16g[1026],gClipArray16b[1026];
! unsigned char *gClipArray_ptr=&gClipArray[512];
! unsigned short *gClipArray_ptr16r=&gClipArray16r[512];
! unsigned short *gClipArray_ptr16g=&gClipArray16g[512];
! unsigned short *gClipArray_ptr16b=&gClipArray16b[512];
int doClippingArrays=1;
--- 39,44 ----
#include <string.h>
! unsigned char gClipArray[1028];
! unsigned short gClipArray16r[1028],gClipArray16g[1028],gClipArray16b[1028];
int doClippingArrays=1;
***************
*** 515,542 ****
#define STORE_PIXEL_BGR888 \
! *data++ = clipArray_ptr[b_l]; \
! *data++ = clipArray_ptr[g_l]; \
! *data++ = clipArray_ptr[r_l];
#define STORE_PIXEL_BGRA8888 \
! *data++ = clipArray_ptr[b_l]; \
! *data++ = clipArray_ptr[g_l]; \
! *data++ = clipArray_ptr[r_l]; \
! *data++ = 0;
#define STORE_PIXEL_RGB565 \
! foo = ((clipArray_ptr[r_l] & 0xf8) << 8) | \
! ((clipArray_ptr[g_l] & 0xfc) << 3) | \
! ((clipArray_ptr[b_l] & 0xf8) >> 3); *(unsigned short*)data = foo; data += 2;
#define STORE_PIXEL_RGB555 \
! foo = ((clipArray_ptr[r_l] & 0xf8) << 7) | \
! ((clipArray_ptr[g_l] & 0xf8) << 2) | \
! ((clipArray_ptr[b_l] & 0xf8) >> 3); *(unsigned short*)data = foo; data += 2;
#define STORE_PIXEL_RGBI555 \
! foo = ((clipArray_ptr[r_l] & 0xf8) << 7) | \
! ((clipArray_ptr[g_l] & 0xf8) << 2) | \
! ((clipArray_ptr[b_l] & 0xf8) >> 3); \
if((unsigned long)data & 0x00000002L) { \
data -= 2; \
--- 512,539 ----
#define STORE_PIXEL_BGR888 \
! *data++ = clipArray_ptr_B[b_l]; \
! *data++ = clipArray_ptr_G[g_l]; \
! *data++ = clipArray_ptr_R[r_l];
#define STORE_PIXEL_BGRA8888 \
! *data++ = clipArray_ptr_B[b_l]; \
! *data++ = clipArray_ptr_G[g_l]; \
! *data++ = clipArray_ptr_R[r_l]; \
! *data++ = alphaChannelValue;
#define STORE_PIXEL_RGB565 \
! foo = ((clipArray_ptr_R[r_l] & 0xf8) << 8) | \
! ((clipArray_ptr_G[g_l] & 0xfc) << 3) | \
! ((clipArray_ptr_B[b_l] & 0xf8) >> 3); *(unsigned short*)data = foo; data += 2;
#define STORE_PIXEL_RGB555 \
! foo = ((clipArray_ptr_R[r_l] & 0xf8) << 7) | \
! ((clipArray_ptr_G[g_l] & 0xf8) << 2) | \
! ((clipArray_ptr_B[b_l] & 0xf8) >> 3); *(unsigned short*)data = foo; data += 2;
#define STORE_PIXEL_RGBI555 \
! foo = ((clipArray_ptr_R[r_l] & 0xf8) << 7) | \
! ((clipArray_ptr_G[g_l] & 0xf8) << 2) | \
! ((clipArray_ptr_B[b_l] & 0xf8) >> 3); \
if((unsigned long)data & 0x00000002L) { \
data -= 2; \
***************
*** 550,575 ****
#define STORE_PIXEL_RGB888 \
! *data++ = clipArray_ptr[r_l]; \
! *data++ = clipArray_ptr[g_l]; \
! *data++ = clipArray_ptr[b_l];
#define STORE_PIXEL_RGBA8888 \
! *data++ = clipArray_ptr[r_l]; \
! *data++ = clipArray_ptr[g_l]; \
! *data++ = clipArray_ptr[b_l]; \
! *data++ = 0;
#define STORE_PIXEL_ARGB8888 \
! *data++ = 0; \
! *data++ = clipArray_ptr[r_l]; \
! *data++ = clipArray_ptr[g_l]; \
! *data++ = clipArray_ptr[b_l];
#define STORE_PIXEL_RGBA16161616 \
! *data_s++ = clipArray_ptr[r_l]; \
! *data_s++ = clipArray_ptr[g_l]; \
! *data_s++ = clipArray_ptr[b_l]; \
! *data_s++ = 0;
!
--- 547,572 ----
#define STORE_PIXEL_RGB888 \
! *data++ = clipArray_ptr_R[r_l]; \
! *data++ = clipArray_ptr_G[g_l]; \
! *data++ = clipArray_ptr_B[b_l];
#define STORE_PIXEL_RGBA8888 \
! *data++ = clipArray_ptr_R[r_l]; \
! *data++ = clipArray_ptr_G[g_l]; \
! *data++ = clipArray_ptr_B[b_l]; \
! *data++ = alphaChannelValue;
#define STORE_PIXEL_ARGB8888 \
! *data++ = alphaChannelValue; \
! *data++ = clipArray_ptr_R[r_l]; \
! *data++ = clipArray_ptr_G[g_l]; \
! *data++ = clipArray_ptr_B[b_l];
#define STORE_PIXEL_RGBA16161616 \
! *data_s++ = clipArray_ptr_R[r_l]; \
! *data_s++ = clipArray_ptr_G[g_l]; \
! *data_s++ = clipArray_ptr_B[b_l]; \
! *data_s++ = alphaChannelValue;
! /* JMM broken for 16 bit color here */
***************
*** 578,584 ****
{
int h = 0;
! register unsigned char *y_in, *cb_in, *cr_in;
long y_l, r_l, b_l, g_l;
! register unsigned char *data,*clipArray_ptr=gClipArray_ptr;
register int uv_subscript, step, w = -1;
register short foo;
--- 575,584 ----
{
int h = 0;
! register unsigned char *y_in, *cb_in, *cr_in,alphaChannelValue=video->alphaChannelValue;
long y_l, r_l, b_l, g_l;
! register unsigned char *data,
! *clipArray_ptr_R=&video->clipArray_Red[512],
! *clipArray_ptr_G=&video->clipArray_Green[512],
! *clipArray_ptr_B=&video->clipArray_Blue[512];
register int uv_subscript, step, w = -1;
register short foo;
***************
*** 971,975 ****
else
if (video->color_model == MPEG3_ARGB8888)
! return mpeg3video_ditherframeFastRGBA(video, src, video->output_rows);
else
return mpeg3video_ditherframe(video, src, video->output_rows);
--- 971,975 ----
else
if (video->color_model == MPEG3_ARGB8888)
! return mpeg3video_ditherframeFastARGB(video, src, video->output_rows);
else
return mpeg3video_ditherframe(video, src, video->output_rows);
***************
*** 1031,1043 ****
}
! int mpeg3video_ditherframeFastRGBA(mpeg3video_t *video, unsigned char **src, unsigned char **output_rows) {
int h = 0;
! register unsigned char *y_in, *cb_in, *cr_in, *clipArray_ptr;
long y_l, r_l, b_l, g_l;
register unsigned long *data;
register int uv_subscript, step, w = -1,t1,t2;
! register long *cr_to_gPtr,*cr_to_rPtr,*cb_to_bPtr,*cb_to_gPtr;;
!
! clipArray_ptr = gClipArray_ptr;
cr_to_rPtr = &video->cr_to_r[0];
cr_to_gPtr = &video->cr_to_g[0];
--- 1031,1048 ----
}
! int mpeg3video_ditherframeFastARGB(mpeg3video_t *video, unsigned char **src, unsigned char **output_rows) {
int h = 0;
! register unsigned char *y_in, *cb_in, *cr_in, *clipArray_ptr_R, *clipArray_ptr_G, *clipArray_ptr_B;
long y_l, r_l, b_l, g_l;
register unsigned long *data;
register int uv_subscript, step, w = -1,t1,t2;
! register long *cr_to_gPtr,*cr_to_rPtr,*cb_to_bPtr,*cb_to_gPtr;
! unsigned long alphaChannelValue_t;
!
! clipArray_ptr_R = &video->clipArray_Red[512];
! clipArray_ptr_G = &video->clipArray_Green[512];
! clipArray_ptr_B = &video->clipArray_Blue[512];
! alphaChannelValue_t = video->alphaChannelValue << 24;
!
cr_to_rPtr = &video->cr_to_r[0];
cr_to_gPtr = &video->cr_to_g[0];
***************
*** 1061,1065 ****
r_l = (r_l + cr_to_rPtr[*cr_in]) >> 16;
b_l = (b_l + cb_to_bPtr[*cb_in]) >> 16;
! *data++ = (clipArray_ptr[r_l] << 16) | (clipArray_ptr[g_l] << 8) | clipArray_ptr[b_l];
if(w & 1) {
cr_in++;
--- 1066,1070 ----
r_l = (r_l + cr_to_rPtr[*cr_in]) >> 16;
b_l = (b_l + cb_to_bPtr[*cb_in]) >> 16;
! *data++ = alphaChannelValue_t | (clipArray_ptr_R[r_l] << 16) | (clipArray_ptr_G[g_l] << 8) | clipArray_ptr_B[b_l];
if(w & 1) {
cr_in++;
***************
*** 1077,1081 ****
r_l = (r_l + cr_to_rPtr[t1]) >> 16;
b_l = (b_l + cb_to_bPtr[t2]) >> 16;
! *data++ = (clipArray_ptr[r_l] << 16) | (clipArray_ptr[g_l] << 8) | clipArray_ptr[b_l];
}
}
--- 1082,1086 ----
r_l = (r_l + cr_to_rPtr[t1]) >> 16;
b_l = (b_l + cb_to_bPtr[t2]) >> 16;
! *data++ = alphaChannelValue_t | (clipArray_ptr_R[r_l] << 16) | (clipArray_ptr_G[g_l] << 8) | clipArray_ptr_B[b_l];
}
}
***************
*** 1086,1107 ****
int mpeg3video_ditherframeFastRGB555(mpeg3video_t *video, unsigned char **src, unsigned char **output_rows) {
int h = 0;
- register unsigned char *y_in, *cb_in, *cr_in, *clipArray_ptr;
- register unsigned short *clipArray_ptr16r,*clipArray_ptr16g,*clipArray_ptr16b;
long y_l, r_l, b_l, g_l;
! register unsigned short *data;
! register int uv_subscript, step, w = -1,t1,t2;
! register long *cr_to_gPtr,*cr_to_rPtr,*cb_to_bPtr,*cb_to_gPtr;;
! clipArray_ptr = gClipArray_ptr;
! clipArray_ptr16r = gClipArray_ptr16r;
! clipArray_ptr16g = gClipArray_ptr16g;
! clipArray_ptr16b = gClipArray_ptr16b;
! cr_to_rPtr = &video->cr_to_r[0];
cr_to_gPtr = &video->cr_to_g[0];
cb_to_bPtr = &video->cb_to_b[0];
cb_to_gPtr = &video->cb_to_g[0];
! for(h = 0; h < video->out_h; h++)
! {
t1 = video->y_table[h] + video->in_y;
t2 = (t1 >> 1) * video->chrom_width;
--- 1091,1110 ----
int mpeg3video_ditherframeFastRGB555(mpeg3video_t *video, unsigned char **src, unsigned char **output_rows) {
int h = 0;
long y_l, r_l, b_l, g_l;
! unsigned char *y_in, *cb_in, *cr_in;
! unsigned short *clipArray_ptr16r,*clipArray_ptr16g,*clipArray_ptr16b,*data;
! int w,t1,t2;
! long *cr_to_gPtr,*cr_to_rPtr,*cb_to_bPtr,*cb_to_gPtr;;
! clipArray_ptr16r = &video->clipArray16_Red[512];
! clipArray_ptr16g = &video->clipArray16_Green[512];
! clipArray_ptr16b = &video->clipArray16_Blue[512];
! cr_to_rPtr = &video->cr_to_r[0];
cr_to_gPtr = &video->cr_to_g[0];
cb_to_bPtr = &video->cb_to_b[0];
cb_to_gPtr = &video->cb_to_g[0];
! if(video->out_w == video->horizontal_size) {
! for(h = 0; h < video->out_h; h++) {
t1 = video->y_table[h] + video->in_y;
t2 = (t1 >> 1) * video->chrom_width;
***************
*** 1111,1116 ****
data = (unsigned short*) output_rows[h];
! if(video->out_w == video->horizontal_size) {
! for(w = 0; w < video->horizontal_size; w++) {
y_l = *y_in++;
r_l = g_l = b_l = y_l << 16;
--- 1114,1118 ----
data = (unsigned short*) output_rows[h];
! for (w = 0; w < video->horizontal_size; w++) {
y_l = *y_in++;
r_l = g_l = b_l = y_l << 16;
***************
*** 1118,1132 ****
r_l = (r_l + cr_to_rPtr[*cr_in]) >> 16;
b_l = (b_l + cb_to_bPtr[*cb_in]) >> 16;
! *data++ = clipArray_ptr16r[r_l] |
clipArray_ptr16g[g_l] |
clipArray_ptr16b[b_l];
if(w & 1) {
! cr_in++;
! cb_in++;
! }
}
! } else {
! for(w = 0; w < video->out_w; w++)
! {
uv_subscript = video->x_table[w] / 2;
r_l = g_l = b_l = (y_in[video->x_table[w]]) << 16;
--- 1120,1145 ----
r_l = (r_l + cr_to_rPtr[*cr_in]) >> 16;
b_l = (b_l + cb_to_bPtr[*cb_in]) >> 16;
! *data++ = clipArray_ptr16r[r_l] |
clipArray_ptr16g[g_l] |
clipArray_ptr16b[b_l];
+
if(w & 1) {
! cr_in++;
! cb_in++;
! }
}
! }
! } else {
! int uv_subscript;
!
! for(h = 0; h < video->out_h; h++) {
! t1 = video->y_table[h] + video->in_y;
! t2 = (t1 >> 1) * video->chrom_width;
! y_in = &src[0][t1 * video->coded_picture_width] + video->in_x;
! cb_in = &src[1][t2] + (video->in_x >> 2);
! cr_in = &src[2][t2] + (video->in_x >> 1);
! data = (unsigned short*) output_rows[h];
!
! for (w = 0; w < video->out_w; w++) {
uv_subscript = video->x_table[w] / 2;
r_l = g_l = b_l = (y_in[video->x_table[w]]) << 16;
***************
*** 1139,1145 ****
clipArray_ptr16g[g_l] |
clipArray_ptr16b[b_l];
! }
}
! }
--- 1152,1159 ----
clipArray_ptr16g[g_l] |
clipArray_ptr16b[b_l];
!
}
! }
! }
***************
*** 1152,1168 ****
unsigned char **src = video->output_src;
- if (doClippingArrays) {
- for(h=-512;h<=512;h++) {
- gClipArray_ptr[h]=CLIP(h);
- gClipArray_ptr16r[h]=(CLIP(h) & 0xf8) << 7;
- gClipArray_ptr16g[h]=(CLIP(h) & 0xf8) << 2;
- gClipArray_ptr16b[h]=(CLIP(h) & 0xf8) >> 3;
- if (gClipArray_ptr[h] == 0x00)
- gClipArray_ptr[h] = 0x01;
- if (gClipArray_ptr16b[h] == 0x00)
- gClipArray_ptr16b[h] = 0x01;
- }
- doClippingArrays = 0;
- }
/* Copy YUV buffers */
--- 1166,1169 ----
***************
*** 1225,1229 ****
else
if (video->color_model == MPEG3_ARGB8888)
! mpeg3video_ditherframeFastRGBA(video, src, video->output_rows);
else
mpeg3video_ditherframe(video, src, video->output_rows);
--- 1226,1230 ----
else
if (video->color_model == MPEG3_ARGB8888)
! mpeg3video_ditherframeFastARGB(video, src, video->output_rows);
else
mpeg3video_ditherframe(video, src, video->output_rows);
***************
*** 1272,1273 ****
--- 1273,1312 ----
return 0;
}
+
+ void doClipArrays(mpeg3_t *file) {
+ long h,i;
+
+ if (doClippingArrays) {
+
+ for(h=-512;h<=512;h++) {
+ gClipArray[h+512]=CLIP(h);
+ gClipArray16r[h+512]=(CLIP(h) & 0xf8) << 7;
+ gClipArray16g[h+512]=(CLIP(h) & 0xf8) << 2;
+ gClipArray16b[h+512]=(CLIP(h) & 0xf8) >> 3;
+ if (gClipArray[h+512] == 0x00)
+ gClipArray[h+512] = 0x01;
+ if (gClipArray16b[h+512] == 0x00)
+ gClipArray16b[h+512] = 0x01;
+ }
+ doClippingArrays = 0;
+ }
+
+ for(h=0;h<file->total_vstreams;h++) {
+ memcpy(&file->vtrack[h]->video->clipArray_Red,&gClipArray,1028);
+ memcpy(&file->vtrack[h]->video->clipArray_Green,&gClipArray,1028);
+ memcpy(&file->vtrack[h]->video->clipArray_Blue,&gClipArray,1028);
+ memcpy(&file->vtrack[h]->video->clipArray16_Red,&gClipArray16r,1028*2);
+ memcpy(&file->vtrack[h]->video->clipArray16_Green,&gClipArray16g,1028*2);
+ memcpy(&file->vtrack[h]->video->clipArray16_Blue,&gClipArray16b,1028*2);
+ file->vtrack[h]->video->alphaChannelValue =0x00;
+ for(i=0;i<256;i++) {
+ file->vtrack[h]->video->blueScreenMappingR[i] = i;
+ file->vtrack[h]->video->blueScreenMappingG[i] = i;
+ file->vtrack[h]->video->blueScreenMappingB[i] = i;
+ }
+ file->vtrack[h]->video->blueScreenMappingR[0] = 1;
+ file->vtrack[h]->video->blueScreenMappingG[0] = 1;
+ file->vtrack[h]->video->blueScreenMappingB[0] = 1;
+ }
+ }
+
|