2006-09-17 01:26:09 +03:00
|
|
|
/*
|
2007-04-02 01:28:45 +03:00
|
|
|
* BlackFin DSPUTILS
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
|
|
|
|
* Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
|
2006-09-17 01:26:09 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2006-10-07 18:30:46 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2006-09-17 01:26:09 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 18:30:46 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2006-09-17 01:26:09 +03:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2006-09-17 01:26:09 +03:00
|
|
|
* 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
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2006-09-17 01:26:09 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2014-01-22 02:50:26 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-02-01 12:31:59 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2014-01-22 02:50:26 +03:00
|
|
|
#include "libavutil/bfin/attributes.h"
|
2008-05-09 14:56:36 +03:00
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
#include "libavcodec/dsputil.h"
|
2014-01-22 02:50:26 +03:00
|
|
|
|
|
|
|
void ff_bfin_idct(int16_t *block) attribute_l1_text;
|
|
|
|
void ff_bfin_fdct(int16_t *block) attribute_l1_text;
|
|
|
|
|
|
|
|
void ff_bfin_add_pixels_clamped(const int16_t *block, uint8_t *dest,
|
|
|
|
int line_size) attribute_l1_text;
|
|
|
|
void ff_bfin_put_pixels_clamped(const int16_t *block, uint8_t *dest,
|
|
|
|
int line_size) attribute_l1_text;
|
|
|
|
|
|
|
|
void ff_bfin_diff_pixels(int16_t *block, const uint8_t *s1, const uint8_t *s2,
|
|
|
|
int stride) attribute_l1_text;
|
|
|
|
void ff_bfin_get_pixels(int16_t *restrict block, const uint8_t *pixels,
|
|
|
|
int line_size) attribute_l1_text;
|
|
|
|
|
|
|
|
int ff_bfin_pix_norm1(uint8_t *pix, int line_size) attribute_l1_text;
|
|
|
|
int ff_bfin_pix_sum(uint8_t *p, int stride) attribute_l1_text;
|
|
|
|
|
|
|
|
int ff_bfin_z_sad8x8(uint8_t *blk1, uint8_t *blk2, int dsz,
|
|
|
|
int line_size, int h) attribute_l1_text;
|
|
|
|
int ff_bfin_z_sad16x16(uint8_t *blk1, uint8_t *blk2, int dsz,
|
|
|
|
int line_size, int h) attribute_l1_text;
|
|
|
|
|
|
|
|
int ff_bfin_sse4(void *v, uint8_t *pix1, uint8_t *pix2,
|
|
|
|
int line_size, int h) attribute_l1_text;
|
|
|
|
int ff_bfin_sse8(void *v, uint8_t *pix1, uint8_t *pix2,
|
|
|
|
int line_size, int h) attribute_l1_text;
|
|
|
|
int ff_bfin_sse16(void *v, uint8_t *pix1, uint8_t *pix2,
|
|
|
|
int line_size, int h) attribute_l1_text;
|
2006-09-17 01:26:09 +03:00
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static void bfin_idct_add(uint8_t *dest, int line_size, int16_t *block)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_idct(block);
|
|
|
|
ff_bfin_add_pixels_clamped(block, dest, line_size);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static void bfin_idct_put(uint8_t *dest, int line_size, int16_t *block)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_idct(block);
|
|
|
|
ff_bfin_put_pixels_clamped(block, dest, line_size);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static void bfin_clear_blocks(int16_t *blocks)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
|
|
|
// This is just a simple memset.
|
2014-01-06 12:35:37 +03:00
|
|
|
__asm__ ("P0=192; "
|
|
|
|
"I0=%0; "
|
|
|
|
"R0=0; "
|
|
|
|
"LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
|
|
|
|
"clear_blocks_blkfn_lab:"
|
|
|
|
"[I0++]=R0;"
|
|
|
|
::"a" (blocks) : "P0", "I0", "R0");
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs16(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
return ff_bfin_z_sad16x16(blk1, blk2, line_size, line_size, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2008-02-16 17:17:31 +02:00
|
|
|
static uint8_t vtmp_blk[256] attribute_l1_data_b;
|
2007-04-02 01:28:45 +03:00
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs16_x2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + 1, 16, line_size, h);
|
|
|
|
return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs16_y2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + line_size, 16, line_size, h);
|
|
|
|
return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs16_xy2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_z_put_pixels16_xy2(vtmp_blk, blk2, 16, line_size, h);
|
|
|
|
return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs8(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
return ff_bfin_z_sad8x8(blk1, blk2, line_size, line_size, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs8_x2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + 1, 8, line_size, h);
|
|
|
|
return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs8_y2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + line_size, 8, line_size, h);
|
|
|
|
return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
static int bfin_pix_abs8_xy2(void *c, uint8_t *blk1, uint8_t *blk2,
|
|
|
|
int line_size, int h)
|
2007-04-02 01:28:45 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
ff_bfin_z_put_pixels8_xy2(vtmp_blk, blk2, 8, line_size, h);
|
|
|
|
return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
|
2007-04-02 01:28:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2014-01-06 12:35:37 +03:00
|
|
|
* decoder optimization
|
|
|
|
* start on 2/11 100 frames of 352x240@25 compiled with no optimization -g debugging
|
|
|
|
* 9.824s ~ 2.44x off
|
|
|
|
* 6.360s ~ 1.58x off with -O2
|
|
|
|
* 5.740s ~ 1.43x off with idcts
|
|
|
|
*
|
|
|
|
* 2.64s 2/20 same sman.mp4 decode only
|
|
|
|
*/
|
2007-04-02 01:28:45 +03:00
|
|
|
|
2013-12-30 14:09:03 +03:00
|
|
|
av_cold void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx,
|
|
|
|
unsigned high_bit_depth)
|
2006-09-17 01:26:09 +03:00
|
|
|
{
|
2014-01-06 12:35:37 +03:00
|
|
|
c->diff_pixels = ff_bfin_diff_pixels;
|
|
|
|
|
2007-04-02 01:28:45 +03:00
|
|
|
c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
|
|
|
|
c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
|
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
c->clear_blocks = bfin_clear_blocks;
|
2007-04-02 01:28:45 +03:00
|
|
|
|
2014-01-06 12:35:37 +03:00
|
|
|
c->pix_sum = ff_bfin_pix_sum;
|
|
|
|
c->pix_norm1 = ff_bfin_pix_norm1;
|
|
|
|
|
|
|
|
c->sad[0] = bfin_pix_abs16;
|
|
|
|
c->sad[1] = bfin_pix_abs8;
|
2007-04-02 01:28:45 +03:00
|
|
|
|
|
|
|
/* TODO [0] 16 [1] 8 */
|
|
|
|
c->pix_abs[0][0] = bfin_pix_abs16;
|
|
|
|
c->pix_abs[0][1] = bfin_pix_abs16_x2;
|
|
|
|
c->pix_abs[0][2] = bfin_pix_abs16_y2;
|
|
|
|
c->pix_abs[0][3] = bfin_pix_abs16_xy2;
|
|
|
|
|
|
|
|
c->pix_abs[1][0] = bfin_pix_abs8;
|
|
|
|
c->pix_abs[1][1] = bfin_pix_abs8_x2;
|
|
|
|
c->pix_abs[1][2] = bfin_pix_abs8_y2;
|
|
|
|
c->pix_abs[1][3] = bfin_pix_abs8_xy2;
|
|
|
|
|
|
|
|
c->sse[0] = ff_bfin_sse16;
|
|
|
|
c->sse[1] = ff_bfin_sse8;
|
|
|
|
c->sse[2] = ff_bfin_sse4;
|
|
|
|
|
2013-12-30 14:09:03 +03:00
|
|
|
if (!high_bit_depth) {
|
|
|
|
c->get_pixels = ff_bfin_get_pixels;
|
|
|
|
|
2011-07-20 22:01:56 +03:00
|
|
|
if (avctx->dct_algo == FF_DCT_AUTO)
|
2014-01-06 12:35:37 +03:00
|
|
|
c->fdct = ff_bfin_fdct;
|
2011-07-20 22:01:56 +03:00
|
|
|
|
2013-04-03 14:11:38 +03:00
|
|
|
if (avctx->idct_algo == FF_IDCT_AUTO) {
|
2011-07-20 18:05:05 +03:00
|
|
|
c->idct_permutation_type = FF_NO_IDCT_PERM;
|
|
|
|
c->idct = ff_bfin_idct;
|
|
|
|
c->idct_add = bfin_idct_add;
|
|
|
|
c->idct_put = bfin_idct_put;
|
|
|
|
}
|
2007-08-13 17:16:20 +03:00
|
|
|
}
|
2006-09-17 01:26:09 +03:00
|
|
|
}
|