00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdint.h>
00023 #include "avcodec.h"
00024 #include "vp56dsp.h"
00025 #include "libavutil/common.h"
00026
00027
00028 static int vp5_adjust(int v, int t)
00029 {
00030 int s2, s1 = v >> 31;
00031 v ^= s1;
00032 v -= s1;
00033 v *= v < 2*t;
00034 v -= t;
00035 s2 = v >> 31;
00036 v ^= s2;
00037 v -= s2;
00038 v = t - v;
00039 v += s1;
00040 v ^= s1;
00041 return v;
00042 }
00043
00044 static int vp6_adjust(int v, int t)
00045 {
00046 int V = v, s = v >> 31;
00047 V ^= s;
00048 V -= s;
00049 if (V-t-1 >= (unsigned)(t-1))
00050 return v;
00051 V = 2*t - V;
00052 V += s;
00053 V ^= s;
00054 return V;
00055 }
00056
00057
00058 #define VP56_EDGE_FILTER(pfx, suf, pix_inc, line_inc) \
00059 static void pfx##_edge_filter_##suf(uint8_t *yuv, int stride, int t) \
00060 { \
00061 int pix2_inc = 2 * pix_inc; \
00062 int i, v; \
00063 \
00064 for (i=0; i<12; i++) { \
00065 v = (yuv[-pix2_inc] + 3*(yuv[0]-yuv[-pix_inc]) - yuv[pix_inc] + 4)>>3;\
00066 v = pfx##_adjust(v, t); \
00067 yuv[-pix_inc] = av_clip_uint8(yuv[-pix_inc] + v); \
00068 yuv[0] = av_clip_uint8(yuv[0] - v); \
00069 yuv += line_inc; \
00070 } \
00071 }
00072
00073 VP56_EDGE_FILTER(vp5, hor, 1, stride)
00074 VP56_EDGE_FILTER(vp5, ver, stride, 1)
00075 VP56_EDGE_FILTER(vp6, hor, 1, stride)
00076 VP56_EDGE_FILTER(vp6, ver, stride, 1)
00077
00078 void ff_vp56dsp_init(VP56DSPContext *s, enum AVCodecID codec)
00079 {
00080 if (codec == AV_CODEC_ID_VP5) {
00081 s->edge_filter_hor = vp5_edge_filter_hor;
00082 s->edge_filter_ver = vp5_edge_filter_ver;
00083 } else {
00084 s->edge_filter_hor = vp6_edge_filter_hor;
00085 s->edge_filter_ver = vp6_edge_filter_ver;
00086
00087 if (CONFIG_VP6_DECODER) {
00088 s->vp6_filter_diag4 = ff_vp6_filter_diag4_c;
00089 }
00090 }
00091
00092 if (ARCH_ARM) ff_vp56dsp_init_arm(s, codec);
00093 if (HAVE_MMX) ff_vp56dsp_init_x86(s, codec);
00094 }