Mercurial > libavcodec.hg
comparison sparc/dsputil_vis.c @ 1966:e1fc7c598558 libavcodec
License change and cpu detection patch by (James Morrison <ja2morri at csclub dot uwaterloo dot ca>)
| author | michael |
|---|---|
| date | Sat, 24 Apr 2004 15:23:50 +0000 |
| parents | 55b7435c59b8 |
| children | fd1665b9093c |
comparison
equal
deleted
inserted
replaced
| 1965:f74f306c30b5 | 1966:e1fc7c598558 |
|---|---|
| 1 /* | 1 /* |
| 2 * motion_comp_vis.c | 2 * dsputil_vis.c |
| 3 * Copyright (C) 2003 David S. Miller <davem@redhat.com> | 3 * Copyright (C) 2003 David S. Miller <davem@redhat.com> |
| 4 * | 4 * |
| 5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | 5 * This file is part of ffmpeg, a free MPEG-4 video stream decoder. |
| 6 * See http://libmpeg2.sourceforge.net/ for updates. | 6 * See http://ffmpeg.sourceforge.net/ for updates. |
| 7 * | 7 * |
| 8 * mpeg2dec is free software; you can redistribute it and/or modify | 8 * ffmpeg is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU Lesser General Public License as published by |
| 10 * the Free Software Foundation; either version 2 of the License, or | 10 * the Free Software Foundation; either version 2.1 of the License, or |
| 11 * (at your option) any later version. | 11 * (at your option) any later version. |
| 12 * | 12 * |
| 13 * mpeg2dec is distributed in the hope that it will be useful, | 13 * ffmpeg is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 * GNU General Public License for more details. | 16 * GNU General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU General Public License | 18 * You should have received a copy of the Lesser GNU General Public License |
| 19 * along with this program; if not, write to the Free Software | 19 * along with this program; if not, write to the Free Software |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 /* The *no_round* functions have been added by James A. Morrison, 2003. | 23 /* The *no_round* functions have been added by James A. Morrison, 2003,2004. |
| 24 The vis code from libmpeg2 was adapted for ffmpeg by James A. Morrison. | 24 The vis code from libmpeg2 was adapted for ffmpeg by James A. Morrison. |
| 25 Note: This code is GPL'd and may only be distributed in a GPL'd package. | |
| 26 */ | 25 */ |
| 27 | 26 |
| 28 #include "config.h" | 27 #include "config.h" |
| 29 | 28 |
| 30 #ifdef ARCH_SPARC | 29 #ifdef ARCH_SPARC |
| 31 | 30 |
| 32 #include <inttypes.h> | 31 #include <inttypes.h> |
| 32 #include <signal.h> | |
| 33 #include <setjmp.h> | |
| 33 | 34 |
| 34 #include "../dsputil.h" | 35 #include "../dsputil.h" |
| 35 | 36 |
| 36 #include "vis.h" | 37 #include "vis.h" |
| 37 | 38 |
| 3998 dest += 8; | 3999 dest += 8; |
| 3999 ref += stride; | 4000 ref += stride; |
| 4000 } | 4001 } |
| 4001 } | 4002 } |
| 4002 | 4003 |
| 4004 static sigjmp_buf jmpbuf; | |
| 4005 static volatile sig_atomic_t canjump = 0; | |
| 4006 | |
| 4007 static void sigill_handler (int sig) | |
| 4008 { | |
| 4009 if (!canjump) { | |
| 4010 signal (sig, SIG_DFL); | |
| 4011 raise (sig); | |
| 4012 } | |
| 4013 | |
| 4014 canjump = 0; | |
| 4015 siglongjmp (jmpbuf, 1); | |
| 4016 } | |
| 4017 | |
| 4018 #define ACCEL_SPARC_VIS 1 | |
| 4019 #define ACCEL_SPARC_VIS2 2 | |
| 4020 | |
| 4021 static int vis_level () | |
| 4022 { | |
| 4023 int accel = 0; | |
| 4024 | |
| 4025 signal (SIGILL, sigill_handler); | |
| 4026 if (sigsetjmp (jmpbuf, 1)) { | |
| 4027 signal (SIGILL, SIG_DFL); | |
| 4028 return accel; | |
| 4029 } | |
| 4030 | |
| 4031 canjump = 1; | |
| 4032 | |
| 4033 /* pdist %f0, %f0, %f0 */ | |
| 4034 __asm__ __volatile__(".word\t0x81b007c0"); | |
| 4035 | |
| 4036 canjump = 0; | |
| 4037 accel |= ACCEL_SPARC_VIS; | |
| 4038 | |
| 4039 if (sigsetjmp (jmpbuf, 1)) { | |
| 4040 signal (SIGILL, SIG_DFL); | |
| 4041 return accel; | |
| 4042 } | |
| 4043 | |
| 4044 canjump = 1; | |
| 4045 | |
| 4046 /* edge8n %g0, %g0, %g0 */ | |
| 4047 __asm__ __volatile__(".word\t0x81b00020"); | |
| 4048 | |
| 4049 canjump = 0; | |
| 4050 accel |= ACCEL_SPARC_VIS2; | |
| 4051 | |
| 4052 signal (SIGILL, SIG_DFL); | |
| 4053 | |
| 4054 return accel; | |
| 4055 } | |
| 4056 | |
| 4003 /* libavcodec initialization code */ | 4057 /* libavcodec initialization code */ |
| 4004 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) | 4058 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) |
| 4005 { | 4059 { |
| 4006 /* VIS specific optimisations */ | 4060 /* VIS specific optimisations */ |
| 4007 c->get_pixels = get_pixels_vis; | 4061 int accel = vis_level (); |
| 4008 c->put_pixels_tab[0][0] = MC_put_o_16_vis; | 4062 |
| 4009 c->put_pixels_tab[0][1] = MC_put_x_16_vis; | 4063 if (accel & ACCEL_SPARC_VIS) { |
| 4010 c->put_pixels_tab[0][2] = MC_put_y_16_vis; | 4064 c->get_pixels = get_pixels_vis; |
| 4011 c->put_pixels_tab[0][3] = MC_put_xy_16_vis; | 4065 c->put_pixels_tab[0][0] = MC_put_o_16_vis; |
| 4066 c->put_pixels_tab[0][1] = MC_put_x_16_vis; | |
| 4067 c->put_pixels_tab[0][2] = MC_put_y_16_vis; | |
| 4068 c->put_pixels_tab[0][3] = MC_put_xy_16_vis; | |
| 4069 | |
| 4070 c->put_pixels_tab[1][0] = MC_put_o_8_vis; | |
| 4071 c->put_pixels_tab[1][1] = MC_put_x_8_vis; | |
| 4072 c->put_pixels_tab[1][2] = MC_put_y_8_vis; | |
| 4073 c->put_pixels_tab[1][3] = MC_put_xy_8_vis; | |
| 4074 | |
| 4075 c->avg_pixels_tab[0][0] = MC_avg_o_16_vis; | |
| 4076 c->avg_pixels_tab[0][1] = MC_avg_x_16_vis; | |
| 4077 c->avg_pixels_tab[0][2] = MC_avg_y_16_vis; | |
| 4078 c->avg_pixels_tab[0][3] = MC_avg_xy_16_vis; | |
| 4012 | 4079 |
| 4013 c->put_pixels_tab[1][0] = MC_put_o_8_vis; | 4080 c->avg_pixels_tab[1][0] = MC_avg_o_8_vis; |
| 4014 c->put_pixels_tab[1][1] = MC_put_x_8_vis; | 4081 c->avg_pixels_tab[1][1] = MC_avg_x_8_vis; |
| 4015 c->put_pixels_tab[1][2] = MC_put_y_8_vis; | 4082 c->avg_pixels_tab[1][2] = MC_avg_y_8_vis; |
| 4016 c->put_pixels_tab[1][3] = MC_put_xy_8_vis; | 4083 c->avg_pixels_tab[1][3] = MC_avg_xy_8_vis; |
| 4017 | 4084 |
| 4018 c->avg_pixels_tab[0][0] = MC_avg_o_16_vis; | 4085 c->put_no_rnd_pixels_tab[0][0] = MC_put_no_round_o_16_vis; |
| 4019 c->avg_pixels_tab[0][1] = MC_avg_x_16_vis; | 4086 c->put_no_rnd_pixels_tab[0][1] = MC_put_no_round_x_16_vis; |
| 4020 c->avg_pixels_tab[0][2] = MC_avg_y_16_vis; | 4087 c->put_no_rnd_pixels_tab[0][2] = MC_put_no_round_y_16_vis; |
| 4021 c->avg_pixels_tab[0][3] = MC_avg_xy_16_vis; | 4088 c->put_no_rnd_pixels_tab[0][3] = MC_put_no_round_xy_16_vis; |
| 4089 | |
| 4090 c->put_no_rnd_pixels_tab[1][0] = MC_put_no_round_o_8_vis; | |
| 4091 c->put_no_rnd_pixels_tab[1][1] = MC_put_no_round_x_8_vis; | |
| 4092 c->put_no_rnd_pixels_tab[1][2] = MC_put_no_round_y_8_vis; | |
| 4093 c->put_no_rnd_pixels_tab[1][3] = MC_put_no_round_xy_8_vis; | |
| 4022 | 4094 |
| 4023 c->avg_pixels_tab[1][0] = MC_avg_o_8_vis; | 4095 c->avg_no_rnd_pixels_tab[0][0] = MC_avg_no_round_o_16_vis; |
| 4024 c->avg_pixels_tab[1][1] = MC_avg_x_8_vis; | 4096 c->avg_no_rnd_pixels_tab[0][1] = MC_avg_no_round_x_16_vis; |
| 4025 c->avg_pixels_tab[1][2] = MC_avg_y_8_vis; | 4097 c->avg_no_rnd_pixels_tab[0][2] = MC_avg_no_round_y_16_vis; |
| 4026 c->avg_pixels_tab[1][3] = MC_avg_xy_8_vis; | 4098 c->avg_no_rnd_pixels_tab[0][3] = MC_avg_no_round_xy_16_vis; |
| 4027 | 4099 |
| 4028 c->put_no_rnd_pixels_tab[0][0] = MC_put_no_round_o_16_vis; | 4100 c->avg_no_rnd_pixels_tab[1][0] = MC_avg_no_round_o_8_vis; |
| 4029 c->put_no_rnd_pixels_tab[0][1] = MC_put_no_round_x_16_vis; | 4101 c->avg_no_rnd_pixels_tab[1][1] = MC_avg_no_round_x_8_vis; |
| 4030 c->put_no_rnd_pixels_tab[0][2] = MC_put_no_round_y_16_vis; | 4102 c->avg_no_rnd_pixels_tab[1][2] = MC_avg_no_round_y_8_vis; |
| 4031 c->put_no_rnd_pixels_tab[0][3] = MC_put_no_round_xy_16_vis; | 4103 c->avg_no_rnd_pixels_tab[1][3] = MC_avg_no_round_xy_8_vis; |
| 4032 | 4104 } |
| 4033 c->put_no_rnd_pixels_tab[1][0] = MC_put_no_round_o_8_vis; | |
| 4034 c->put_no_rnd_pixels_tab[1][1] = MC_put_no_round_x_8_vis; | |
| 4035 c->put_no_rnd_pixels_tab[1][2] = MC_put_no_round_y_8_vis; | |
| 4036 c->put_no_rnd_pixels_tab[1][3] = MC_put_no_round_xy_8_vis; | |
| 4037 | |
| 4038 c->avg_no_rnd_pixels_tab[0][0] = MC_avg_no_round_o_16_vis; | |
| 4039 c->avg_no_rnd_pixels_tab[0][1] = MC_avg_no_round_x_16_vis; | |
| 4040 c->avg_no_rnd_pixels_tab[0][2] = MC_avg_no_round_y_16_vis; | |
| 4041 c->avg_no_rnd_pixels_tab[0][3] = MC_avg_no_round_xy_16_vis; | |
| 4042 | |
| 4043 c->avg_no_rnd_pixels_tab[1][0] = MC_avg_no_round_o_8_vis; | |
| 4044 c->avg_no_rnd_pixels_tab[1][1] = MC_avg_no_round_x_8_vis; | |
| 4045 c->avg_no_rnd_pixels_tab[1][2] = MC_avg_no_round_y_8_vis; | |
| 4046 c->avg_no_rnd_pixels_tab[1][3] = MC_avg_no_round_xy_8_vis; | |
| 4047 } | 4105 } |
| 4048 | 4106 |
| 4049 #endif /* !(ARCH_SPARC) */ | 4107 #endif /* !(ARCH_SPARC) */ |
