1function [l0, m0] = src_find_l0m0(L, M) 2 3% find_l0m0 - find l0, m0 to meet -l0*L + m0*M == 1 4% 5% [l0, m0] = find_l0m0(L, M) 6% 7% L - interpolatation factor 8% M - decimation factor 9% 10 11% Copyright (c) 2016, Intel Corporation 12% All rights reserved. 13% 14% Redistribution and use in source and binary forms, with or without 15% modification, are permitted provided that the following conditions are met: 16% * Redistributions of source code must retain the above copyright 17% notice, this list of conditions and the following disclaimer. 18% * Redistributions in binary form must reproduce the above copyright 19% notice, this list of conditions and the following disclaimer in the 20% documentation and/or other materials provided with the distribution. 21% * Neither the name of the Intel Corporation nor the 22% names of its contributors may be used to endorse or promote products 23% derived from this software without specific prior written permission. 24% 25% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35% POSSIBILITY OF SUCH DAMAGE. 36% 37% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 38% 39 40if M == 1 41 l0 = 0; 42 m0 = 1; 43 return 44end 45 46if L == 1 47 l0 = 1; 48 m0 = 0; 49 return 50end 51 52l0 = []; 53m0 = []; 54for lt=1:4*L 55 mt = (1+lt*L)/M; % Check if -lt*L + mt*M == 1 56 if floor(mt) == mt 57 l0 = [l0 lt]; 58 m0 = [m0 mt]; 59 end 60end 61 62s = l0+m0; 63idx = find(s == min(s), 1, 'first'); 64l0 = l0(idx); 65m0 = m0(idx); 66 67if -l0*L + m0*M ~= 1 68 error('Something went wrong!'); 69end 70 71end 72