*
* Copyright (c) 2001-2003 BERO <bero@geocities.co.jp>
*
- * 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 "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
+#include "dsputil_sh4.h"
#define LP(p) *(uint32_t*)(p)
+#define LPC(p) *(const uint32_t*)(p)
#define UNPACK(ph,pl,tt0,tt1) do { \
#define OP_C4(ofs) \
ref-=ofs; \
do { \
- OP(LP(dest),MERGE1(LP(ref),LP(ref+4),ofs)); \
+ OP(LP(dest),MERGE1(LPC(ref),LPC(ref+4),ofs)); \
ref+=stride; \
dest+=stride; \
} while(--height)
#define OP_C40() \
do { \
- OP(LP(dest),LP(ref)); \
+ OP(LP(dest),LPC(ref)); \
ref+=stride; \
dest+=stride; \
} while(--height)
ref-=ofs; \
do { \
uint32_t t0,t1; \
- t0 = LP(ref+0); \
- t1 = LP(ref+4); \
+ t0 = LPC(ref+0); \
+ t1 = LPC(ref+4); \
OP(LP(dest+0), MERGE1(t0,t1,ofs)); \
- t0 = LP(ref+8); \
+ t0 = LPC(ref+8); \
OP(LP(dest+4), MERGE1(t1,t0,ofs)); \
if (sz==16) { \
- t1 = LP(ref+12); \
+ t1 = LPC(ref+12); \
OP(LP(dest+8), MERGE1(t0,t1,ofs)); \
- t0 = LP(ref+16); \
+ t0 = LPC(ref+16); \
OP(LP(dest+12), MERGE1(t1,t0,ofs)); \
} \
ref+=stride; \
#define OP_C0(sz,avg2) \
{ \
do { \
- OP(LP(dest+0), LP(ref+0)); \
- OP(LP(dest+4), LP(ref+4)); \
+ OP(LP(dest+0), LPC(ref+0)); \
+ OP(LP(dest+4), LPC(ref+4)); \
if (sz==16) { \
- OP(LP(dest+8), LP(ref+8)); \
- OP(LP(dest+12), LP(ref+12)); \
+ OP(LP(dest+8), LPC(ref+8)); \
+ OP(LP(dest+12), LPC(ref+12)); \
} \
ref+=stride; \
dest+= stride; \
ref-=ofs; \
do { \
uint32_t t0,t1; \
- t0 = LP(ref+0); \
- t1 = LP(ref+4); \
+ t0 = LPC(ref+0); \
+ t1 = LPC(ref+4); \
OP(LP(dest+0), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
- t0 = LP(ref+8); \
+ t0 = LPC(ref+8); \
OP(LP(dest+4), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
if (sz==16) { \
- t1 = LP(ref+12); \
+ t1 = LPC(ref+12); \
OP(LP(dest+8), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
- t0 = LP(ref+16); \
+ t0 = LPC(ref+16); \
OP(LP(dest+12), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
} \
ref+=stride; \
{ \
uint32_t t0,t1,t2,t3,t; \
\
- t0 = LP(ref+0); \
- t1 = LP(ref+4); \
+ t0 = LPC(ref+0); \
+ t1 = LPC(ref+4); \
if (sz==16) { \
- t2 = LP(ref+8); \
- t3 = LP(ref+12); \
+ t2 = LPC(ref+8); \
+ t3 = LPC(ref+12); \
} \
do { \
ref += stride; \
\
- t = LP(ref+0); \
+ t = LPC(ref+0); \
OP(LP(dest+0), avg2(t0,t)); t0 = t; \
- t = LP(ref+4); \
+ t = LPC(ref+4); \
OP(LP(dest+4), avg2(t1,t)); t1 = t; \
if (sz==16) { \
- t = LP(ref+8); \
+ t = LPC(ref+8); \
OP(LP(dest+8), avg2(t2,t)); t2 = t; \
- t = LP(ref+12); \
+ t = LPC(ref+12); \
OP(LP(dest+12), avg2(t3,t)); t3 = t; \
} \
dest+= stride; \
uint32_t t0,t1,t2,t3,t,w0,w1; \
\
ref-=ofs; \
- w0 = LP(ref+0); \
- w1 = LP(ref+4); \
+ w0 = LPC(ref+0); \
+ w1 = LPC(ref+4); \
t0 = MERGE1(w0,w1,ofs); \
- w0 = LP(ref+8); \
+ w0 = LPC(ref+8); \
t1 = MERGE1(w1,w0,ofs); \
if (sz==16) { \
- w1 = LP(ref+12); \
+ w1 = LPC(ref+12); \
t2 = MERGE1(w0,w1,ofs); \
- w0 = LP(ref+16); \
+ w0 = LPC(ref+16); \
t3 = MERGE1(w1,w0,ofs); \
} \
do { \
ref += stride; \
\
- w0 = LP(ref+0); \
- w1 = LP(ref+4); \
+ w0 = LPC(ref+0); \
+ w1 = LPC(ref+4); \
t = MERGE1(w0,w1,ofs); \
OP(LP(dest+0), avg2(t0,t)); t0 = t; \
- w0 = LP(ref+8); \
+ w0 = LPC(ref+8); \
t = MERGE1(w1,w0,ofs); \
OP(LP(dest+4), avg2(t1,t)); t1 = t; \
if (sz==16) { \
- w1 = LP(ref+12); \
+ w1 = LPC(ref+12); \
t = MERGE1(w0,w1,ofs); \
OP(LP(dest+8), avg2(t2,t)); t2 = t; \
- w0 = LP(ref+16); \
+ w0 = LPC(ref+16); \
t = MERGE1(w1,w0,ofs); \
OP(LP(dest+12), avg2(t3,t)); t3 = t; \
} \
uint32_t a0,a1,a2,a3,a4,a5,a6,a7; \
\
ref -= ofs; \
- w0 = LP(ref+0); \
- w1 = LP(ref+4); \
+ w0 = LPC(ref+0); \
+ w1 = LPC(ref+4); \
UNPACK(a0,a1,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
- w0 = LP(ref+8); \
+ w0 = LPC(ref+8); \
UNPACK(a2,a3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
if (sz==16) { \
- w1 = LP(ref+12); \
+ w1 = LPC(ref+12); \
UNPACK(a4,a5,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
- w0 = LP(ref+16); \
+ w0 = LPC(ref+16); \
UNPACK(a6,a7,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
} \
do { \
ref+=stride; \
- w0 = LP(ref+0); \
- w1 = LP(ref+4); \
+ w0 = LPC(ref+0); \
+ w1 = LPC(ref+4); \
UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
OP(LP(dest+0),PACK(a0,a1,t2,t3)); \
a0 = t2; a1 = t3; \
- w0 = LP(ref+8); \
+ w0 = LPC(ref+8); \
UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
OP(LP(dest+4),PACK(a2,a3,t2,t3)); \
a2 = t2; a3 = t3; \
if (sz==16) { \
- w1 = LP(ref+12); \
+ w1 = LPC(ref+12); \
UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
OP(LP(dest+8),PACK(a4,a5,t2,t3)); \
a4 = t2; a5 = t3; \
- w0 = LP(ref+16); \
+ w0 = LPC(ref+16); \
UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
OP(LP(dest+12),PACK(a6,a7,t2,t3)); \
a6 = t2; a7 = t3; \
void dsputil_init_align(DSPContext* c, AVCodecContext *avctx)
{
+ const int high_bit_depth = avctx->bits_per_raw_sample > 8;
+
+ if (!high_bit_depth) {
c->put_pixels_tab[0][0] = put_rnd_pixels16_o;
c->put_pixels_tab[0][1] = put_rnd_pixels16_x;
c->put_pixels_tab[0][2] = put_rnd_pixels16_y;
c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x;
c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y;
c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy;
+ }
#ifdef QPEL
dspfunc(avg_qpel, 1, 8);
/* dspfunc(avg_no_rnd_qpel, 1, 8); */
+ if (!high_bit_depth) {
dspfunc(put_h264_qpel, 0, 16);
dspfunc(put_h264_qpel, 1, 8);
dspfunc(put_h264_qpel, 2, 4);
dspfunc(avg_h264_qpel, 0, 16);
dspfunc(avg_h264_qpel, 1, 8);
dspfunc(avg_h264_qpel, 2, 4);
+ }
#undef dspfunc
+ if (!high_bit_depth) {
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;
c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4;
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_sh4;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_sh4;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_sh4;
+ }
c->put_mspel_pixels_tab[0]= put_mspel8_mc00_sh4;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_sh4;