/*
- * dsputil_vis.c
* Copyright (C) 2003 David S. Miller <davem@redhat.com>
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
-#ifdef ARCH_SPARC
-
#include <inttypes.h>
-#include <signal.h>
-#include <setjmp.h>
-#include "../dsputil.h"
+#include "libavcodec/dsputil.h"
+#include "dsputil_vis.h"
#include "vis.h"
* fpsub16 f12, f10, f10
*/
-#define ATTR_ALIGN(alignd) __attribute__ ((aligned(alignd)))
-
#define DUP4(x) {x, x, x, x}
#define DUP8(x) {x, x, x, x, x, x, x, x}
-static const int16_t constants1[] ATTR_ALIGN(8) = DUP4 (1);
-static const int16_t constants2[] ATTR_ALIGN(8) = DUP4 (2);
-static const int16_t constants3[] ATTR_ALIGN(8) = DUP4 (3);
-static const int16_t constants6[] ATTR_ALIGN(8) = DUP4 (6);
-static const int8_t constants_fe[] ATTR_ALIGN(8) = DUP8 (0xfe);
-static const int8_t constants_7f[] ATTR_ALIGN(8) = DUP8 (0x7f);
-static const int8_t constants128[] ATTR_ALIGN(8) = DUP8 (128);
-static const int16_t constants256_512[] ATTR_ALIGN(8) =
+DECLARE_ALIGNED(8, static const int16_t, constants1)[] = DUP4 (1);
+DECLARE_ALIGNED(8, static const int16_t, constants2)[] = DUP4 (2);
+DECLARE_ALIGNED(8, static const int16_t, constants3)[] = DUP4 (3);
+DECLARE_ALIGNED(8, static const int16_t, constants6)[] = DUP4 (6);
+DECLARE_ALIGNED(8, static const int8_t, constants_fe)[] = DUP8 (0xfe);
+DECLARE_ALIGNED(8, static const int8_t, constants_7f)[] = DUP8 (0x7f);
+DECLARE_ALIGNED(8, static const int8_t, constants128)[] = DUP8 (128);
+DECLARE_ALIGNED(8, static const int16_t, constants256_512)[] =
{256, 512, 256, 512};
-static const int16_t constants256_1024[] ATTR_ALIGN(8) =
+DECLARE_ALIGNED(8, static const int16_t, constants256_1024)[] =
{256, 1024, 256, 1024};
#define REF_0 0
#define TMP30 56
#define TMP32 58
-static void MC_put_o_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_o_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
do { /* 5 cycles */
vis_ld64(ref[0], TMP0);
} while (--height);
}
-static void MC_put_o_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_o_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
do { /* 4 cycles */
vis_ld64(ref[0], TMP0);
}
-static void MC_avg_o_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_o_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
ref = vis_alignaddr(ref);
vis_st64_2(TMP22, dest, 8);
}
-static void MC_avg_o_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_o_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64(TMP4, dest[0]);
}
-static void MC_put_x_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_x_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
vis_st64_2(TMP8, dest, 8);
}
-static void MC_put_x_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_x_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
dest += stride;
}
-static void MC_avg_x_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_x_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
} while (--height);
}
-static void MC_avg_x_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_x_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_times_2 = stride << 1;
} while (--height);
}
-static void MC_put_y_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_y_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64_2(TMP2, dest, 8);
}
-static void MC_put_y_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_y_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64(DST_0, dest[0]);
}
-static void MC_avg_y_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_y_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
int stride_16 = stride + 16;
} while (--height);
}
-static void MC_avg_y_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_y_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
} while (--height);
}
-static void MC_put_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_xy_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_put_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_xy_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_avg_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_xy_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_avg_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_xy_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
* fpadd16 f12, f10, f10
*/
-static void MC_put_no_round_o_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
do { /* 5 cycles */
vis_ld64(ref[0], TMP0);
} while (--height);
}
-static void MC_put_no_round_o_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_o_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
do { /* 4 cycles */
vis_ld64(ref[0], TMP0);
}
-static void MC_avg_no_round_o_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
ref = vis_alignaddr(ref);
vis_st64_2(TMP22, dest, 8);
}
-static void MC_avg_no_round_o_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_o_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64(TMP4, dest[0]);
}
-static void MC_put_no_round_x_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
vis_st64_2(TMP8, dest, 8);
}
-static void MC_put_no_round_x_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_x_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
dest += stride;
}
-static void MC_avg_no_round_x_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
} while (--height);
}
-static void MC_avg_no_round_x_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_x_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_times_2 = stride << 1;
} while (--height);
}
-static void MC_put_no_round_y_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64_2(TMP2, dest, 8);
}
-static void MC_put_no_round_y_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_y_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
-
ref = vis_alignaddr(ref);
vis_ld64(ref[0], TMP0);
vis_st64(DST_0, dest[0]);
}
-static void MC_avg_no_round_y_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
int stride_16 = stride + 16;
} while (--height);
}
-static void MC_avg_no_round_y_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_y_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
int stride_8 = stride + 8;
vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
} while (--height);
}
-static void MC_put_no_round_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_put_no_round_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_put_no_round_xy_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_avg_no_round_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
} while (--height);
}
-static void MC_avg_no_round_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
+static void MC_avg_no_round_xy_8_vis (uint8_t * dest, const uint8_t * ref,
const int stride, int height)
{
- uint8_t *ref = (uint8_t *) _ref;
unsigned long off = (unsigned long) ref & 0x7;
unsigned long off_plus_1 = off + 1;
int stride_8 = stride + 8;
/* End of no rounding code */
-static sigjmp_buf jmpbuf;
-static volatile sig_atomic_t canjump = 0;
-
-static void sigill_handler (int sig)
-{
- if (!canjump) {
- signal (sig, SIG_DFL);
- raise (sig);
- }
-
- canjump = 0;
- siglongjmp (jmpbuf, 1);
-}
-
#define ACCEL_SPARC_VIS 1
#define ACCEL_SPARC_VIS2 2
-static int vis_level ()
+static int vis_level(void)
{
int accel = 0;
-
- signal (SIGILL, sigill_handler);
- if (sigsetjmp (jmpbuf, 1)) {
- signal (SIGILL, SIG_DFL);
- return accel;
- }
-
- canjump = 1;
-
- /* pdist %f0, %f0, %f0 */
- __asm__ __volatile__(".word\t0x81b007c0");
-
- canjump = 0;
accel |= ACCEL_SPARC_VIS;
-
- if (sigsetjmp (jmpbuf, 1)) {
- signal (SIGILL, SIG_DFL);
- return accel;
- }
-
- canjump = 1;
-
- /* edge8n %g0, %g0, %g0 */
- __asm__ __volatile__(".word\t0x81b00020");
-
- canjump = 0;
accel |= ACCEL_SPARC_VIS2;
-
- signal (SIGILL, SIG_DFL);
-
return accel;
}
/* libavcodec initialization code */
void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx)
{
- /* VIS specific optimisations */
+ /* VIS-specific optimizations */
int accel = vis_level ();
+ const int high_bit_depth = avctx->bits_per_raw_sample > 8;
if (accel & ACCEL_SPARC_VIS) {
+ if (avctx->bits_per_raw_sample <= 8 &&
+ avctx->idct_algo == FF_IDCT_SIMPLEVIS) {
+ c->idct_put = ff_simple_idct_put_vis;
+ c->idct_add = ff_simple_idct_add_vis;
+ c->idct = ff_simple_idct_vis;
+ c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
+ }
+
+ if (!high_bit_depth) {
c->put_pixels_tab[0][0] = MC_put_o_16_vis;
c->put_pixels_tab[0][1] = MC_put_x_16_vis;
c->put_pixels_tab[0][2] = MC_put_y_16_vis;
c->avg_no_rnd_pixels_tab[1][1] = MC_avg_no_round_x_8_vis;
c->avg_no_rnd_pixels_tab[1][2] = MC_avg_no_round_y_8_vis;
c->avg_no_rnd_pixels_tab[1][3] = MC_avg_no_round_xy_8_vis;
+ }
}
}
-
-#endif /* !(ARCH_SPARC) */