• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/mlpdsp.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007-2008 Ian Caulfield
00003  *               2009 Ramiro Polla
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #include "libavcodec/mlp.h"
00023 #include "dsputil.h"
00024 
00025 static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff,
00026                                   int firorder, int iirorder,
00027                                   unsigned int filter_shift, int32_t mask, int blocksize,
00028                                   int32_t *sample_buffer)
00029 {
00030     int32_t *firbuf = state;
00031     int32_t *iirbuf = state + MAX_BLOCKSIZE + MAX_FIR_ORDER;
00032     const int32_t *fircoeff = coeff;
00033     const int32_t *iircoeff = coeff + MAX_FIR_ORDER;
00034     int i;
00035 
00036     for (i = 0; i < blocksize; i++) {
00037         int32_t residual = *sample_buffer;
00038         unsigned int order;
00039         int64_t accum = 0;
00040         int32_t result;
00041 
00042         for (order = 0; order < firorder; order++)
00043             accum += (int64_t) firbuf[order] * fircoeff[order];
00044         for (order = 0; order < iirorder; order++)
00045             accum += (int64_t) iirbuf[order] * iircoeff[order];
00046 
00047         accum  = accum >> filter_shift;
00048         result = (accum + residual) & mask;
00049 
00050         *--firbuf = result;
00051         *--iirbuf = result - accum;
00052 
00053         *sample_buffer = result;
00054         sample_buffer += MAX_CHANNELS;
00055     }
00056 }
00057 
00058 void ff_mlp_init(DSPContext* c, AVCodecContext *avctx)
00059 {
00060     c->mlp_filter_channel = ff_mlp_filter_channel;
00061     if (ARCH_X86)
00062         ff_mlp_init_x86(c, avctx);
00063 }

Generated on Fri Sep 16 2011 17:17:39 for FFmpeg by  doxygen 1.7.1