Libav 0.7.1
|
00001 /* 00002 * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org> 00003 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com> 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #include <stdint.h> 00023 #include "avcodec.h" 00024 #include "vp56dsp.h" 00025 00026 /* Gives very similar result than the vp6 version except in a few cases */ 00027 static int vp5_adjust(int v, int t) 00028 { 00029 int s2, s1 = v >> 31; 00030 v ^= s1; 00031 v -= s1; 00032 v *= v < 2*t; 00033 v -= t; 00034 s2 = v >> 31; 00035 v ^= s2; 00036 v -= s2; 00037 v = t - v; 00038 v += s1; 00039 v ^= s1; 00040 return v; 00041 } 00042 00043 static int vp6_adjust(int v, int t) 00044 { 00045 int V = v, s = v >> 31; 00046 V ^= s; 00047 V -= s; 00048 if (V-t-1 >= (unsigned)(t-1)) 00049 return v; 00050 V = 2*t - V; 00051 V += s; 00052 V ^= s; 00053 return V; 00054 } 00055 00056 00057 #define VP56_EDGE_FILTER(pfx, suf, pix_inc, line_inc) \ 00058 static void pfx##_edge_filter_##suf(uint8_t *yuv, int stride, int t) \ 00059 { \ 00060 int pix2_inc = 2 * pix_inc; \ 00061 int i, v; \ 00062 \ 00063 for (i=0; i<12; i++) { \ 00064 v = (yuv[-pix2_inc] + 3*(yuv[0]-yuv[-pix_inc]) - yuv[pix_inc] + 4)>>3;\ 00065 v = pfx##_adjust(v, t); \ 00066 yuv[-pix_inc] = av_clip_uint8(yuv[-pix_inc] + v); \ 00067 yuv[0] = av_clip_uint8(yuv[0] - v); \ 00068 yuv += line_inc; \ 00069 } \ 00070 } 00071 00072 VP56_EDGE_FILTER(vp5, hor, 1, stride) 00073 VP56_EDGE_FILTER(vp5, ver, stride, 1) 00074 VP56_EDGE_FILTER(vp6, hor, 1, stride) 00075 VP56_EDGE_FILTER(vp6, ver, stride, 1) 00076 00077 void ff_vp56dsp_init(VP56DSPContext *s, enum CodecID codec) 00078 { 00079 if (codec == CODEC_ID_VP5) { 00080 s->edge_filter_hor = vp5_edge_filter_hor; 00081 s->edge_filter_ver = vp5_edge_filter_ver; 00082 } else { 00083 s->edge_filter_hor = vp6_edge_filter_hor; 00084 s->edge_filter_ver = vp6_edge_filter_ver; 00085 00086 if (CONFIG_VP6_DECODER) { 00087 s->vp6_filter_diag4 = ff_vp6_filter_diag4_c; 00088 } 00089 } 00090 00091 if (ARCH_ARM) ff_vp56dsp_init_arm(s, codec); 00092 if (HAVE_MMX) ff_vp56dsp_init_x86(s, codec); 00093 }