コード例 #1
0
ファイル: wm8731.c プロジェクト: MaxChina/linux
static int wm8731_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
	u16 iface = snd_soc_read(codec, WM8731_IFACE) & 0xfff3;
	int i = get_coeff(wm8731->sysclk, params_rate(params));
	u16 srate = (coeff_div[i].sr << 2) |
		(coeff_div[i].bosr << 1) | coeff_div[i].usb;

	wm8731->playback_fs = params_rate(params);

	snd_soc_write(codec, WM8731_SRATE, srate);

	/* bit size */
	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
		break;
	case SNDRV_PCM_FORMAT_S20_3LE:
		iface |= 0x0004;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		iface |= 0x0008;
		break;
	}

	wm8731_set_deemph(codec);

	snd_soc_write(codec, WM8731_IFACE, iface);
	return 0;
}
コード例 #2
0
ファイル: wm8971.c プロジェクト: AllenDou/linux
static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params,
	struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec);
	u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3;
	u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0;
	int coeff = get_coeff(wm8971->sysclk, params_rate(params));

	/* bit size */
	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
		break;
	case SNDRV_PCM_FORMAT_S20_3LE:
		iface |= 0x0004;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		iface |= 0x0008;
		break;
	case SNDRV_PCM_FORMAT_S32_LE:
		iface |= 0x000c;
		break;
	}

	/* set iface & srate */
	snd_soc_write(codec, WM8971_IFACE, iface);
	if (coeff >= 0)
		snd_soc_write(codec, WM8971_SRATE, srate |
			(coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);

	return 0;
}
コード例 #3
0
ファイル: modbus.c プロジェクト: atikbif/Scales
unsigned short read_holdregs(request* req)
{
	unsigned short tmp,value;
	//unsigned char err_cnt=0;
	if((req->cnt >= 129)||(req->cnt == 0)) return(get_error(req,0x03));
	if(req->addr + req->cnt >= 129) return(get_error(req,0x02));
    for(tmp=0;tmp<req->cnt;tmp++)
    {
        switch(req->addr + tmp) {
            case 0: value = get_net_address();break;
            case 1: value = adc;break;
            case 2: value = weight;break;
            case 3: value = get_platform_weight();break;
            case 4: value = get_coeff();break;
            case 5: value = 1807;break; // код идентификации устройства
            default: value = 0;
        }
        req->tx_buf[3+tmp*2]=value>>8;
        req->tx_buf[4+tmp*2]=value&0xFF;
    }
	req->tx_buf[0]=cur_net_addr;
	req->tx_buf[1]=0x03;
	req->tx_buf[2]=req->cnt*2;

    tmp=GetCRC16(req->tx_buf,3+ req->cnt*2);
    req->tx_buf[3+req->cnt*2]=tmp>>8;
    req->tx_buf[4+req->cnt*2]=tmp&0xFF;
    return(5+req->cnt*2);
}
コード例 #4
0
ファイル: wm8711.c プロジェクト: AlexShiLucky/linux
static int wm8711_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params,
	struct snd_soc_dai *dai)
{
	struct snd_soc_component *component = dai->component;
	struct wm8711_priv *wm8711 =  snd_soc_component_get_drvdata(component);
	u16 iface = snd_soc_component_read32(component, WM8711_IFACE) & 0xfff3;
	int i = get_coeff(wm8711->sysclk, params_rate(params));
	u16 srate = (coeff_div[i].sr << 2) |
		(coeff_div[i].bosr << 1) | coeff_div[i].usb;

	snd_soc_component_write(component, WM8711_SRATE, srate);

	/* bit size */
	switch (params_width(params)) {
	case 16:
		break;
	case 20:
		iface |= 0x0004;
		break;
	case 24:
		iface |= 0x0008;
		break;
	}

	snd_soc_component_write(component, WM8711_IFACE, iface);
	return 0;
}
コード例 #5
0
ファイル: wm8750.c プロジェクト: 3null/linux
static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params,
				struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec);
	u16 iface = snd_soc_read(codec, WM8750_IFACE) & 0x1f3;
	u16 srate = snd_soc_read(codec, WM8750_SRATE) & 0x1c0;
	int coeff = get_coeff(wm8750->sysclk, params_rate(params));

	/* bit size */
	switch (params_width(params)) {
	case 16:
		break;
	case 20:
		iface |= 0x0004;
		break;
	case 24:
		iface |= 0x0008;
		break;
	case 32:
		iface |= 0x000c;
		break;
	}

	/* set iface & srate */
	snd_soc_write(codec, WM8750_IFACE, iface);
	if (coeff >= 0)
		snd_soc_write(codec, WM8750_SRATE, srate |
			(coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);

	return 0;
}
コード例 #6
0
ファイル: pb_decl_plugin.cpp プロジェクト: EinNarr/z3
bool pb_util::has_unit_coefficients(func_decl* f) const {
    if (is_at_most_k(f) || is_at_least_k(f)) return true;
    unsigned sz = f->get_arity();
    for (unsigned i = 0; i < sz; ++i) {
        if (!get_coeff(f, i).is_one()) return false;
    }
    return true;
}
コード例 #7
0
static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
                                struct snd_pcm_hw_params *params,
                                struct snd_soc_dai *dai)
{
    struct snd_soc_pcm_runtime *rtd = substream->private_data;
    struct snd_soc_codec *codec = rtd->codec;
    struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
    u16 iface = snd_soc_read(codec, WM8988_IFACE) & 0x1f3;
    u16 srate = snd_soc_read(codec, WM8988_SRATE) & 0x180;
    int coeff;

    coeff = get_coeff(wm8988->sysclk, params_rate(params));
    if (coeff < 0) {
        coeff = get_coeff(wm8988->sysclk / 2, params_rate(params));
        srate |= 0x40;
    }
    if (coeff < 0) {
        dev_err(codec->dev,
                "Unable to configure sample rate %dHz with %dHz MCLK\n",
                params_rate(params), wm8988->sysclk);
        return coeff;
    }


    switch (params_format(params)) {
    case SNDRV_PCM_FORMAT_S16_LE:
        break;
    case SNDRV_PCM_FORMAT_S20_3LE:
        iface |= 0x0004;
        break;
    case SNDRV_PCM_FORMAT_S24_LE:
        iface |= 0x0008;
        break;
    case SNDRV_PCM_FORMAT_S32_LE:
        iface |= 0x000c;
        break;
    }


    snd_soc_write(codec, WM8988_IFACE, iface);
    if (coeff >= 0)
        snd_soc_write(codec, WM8988_SRATE, srate |
                      (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);

    return 0;
}
コード例 #8
0
ファイル: laplace_2d.c プロジェクト: evatux/kaa
int main(int argc, char **argv)
{
    int  n  = (argc > 1) ? atoi(argv[1]) : 100;
    const char* matr_fname = (argc > 2) ? argv[2] : "l2_default.csr";
    const char* pict_fname = (argc > 3) ? argv[3] : NULL;

    real h  = 1. / n;
    int size = (n - 1) * (n - 1);
    int nonz = 4 * size;

    int err;

    TMatrix_DCSR _m;
    TMatrix_DCSR *m = &_m;
    err = matrix_create(m, size, nonz, 1);
    if (err) PRINT_ERROR_MESSAGE_AND_EXIT(err);

    for (int i = 1; i <= size; ++i)
        m->row_ptr[i] = 4 * i;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            int todo[4] = { 
                            ij2k(n, i - 1, j - 1), // bl
                            ij2k(n, i - 1, j - 0), // br
                            ij2k(n, i - 0, j - 1), // tl
                            ij2k(n, i - 0, j - 0), // tr
                          };

            for (int ci = 0; ci < 4; ++ci) {
                int k = todo[ci];
                if (k < 0) continue;
                real coeff = get_coeff(j*h - h/2, i*h - h/2);
                m->diag[k] += 1 * coeff;

                for (int cj = 0; cj < 4; ++cj) {
                    int off = loc_off(ci, cj);
                    if (off < 0) continue;
                    m->col_ind[m->row_ptr[k] + off] =  todo[cj];
                    m->val    [m->row_ptr[k] + off] -= 0.5 * coeff;
                }
            }
        }
    }

    TMatrix_DCSR _l2;
    TMatrix_DCSR *l2 = &_l2;
    matrix_copy_fix(m, l2);
    matrix_destroy(m);

    if (pict_fname) matrix_portrait(l2, pict_fname, 5., 0, NULL);
    if (strstr(matr_fname, ".mtx") != NULL) matrix_save_fmc(l2, matr_fname);
    else matrix_save(l2, matr_fname);

    return 0;
}
コード例 #9
0
ファイル: wm8988.c プロジェクト: 020gzh/linux
static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params,
				struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
	u16 iface = snd_soc_read(codec, WM8988_IFACE) & 0x1f3;
	u16 srate = snd_soc_read(codec, WM8988_SRATE) & 0x180;
	int coeff;

	coeff = get_coeff(wm8988->sysclk, params_rate(params));
	if (coeff < 0) {
		coeff = get_coeff(wm8988->sysclk / 2, params_rate(params));
		srate |= 0x40;
	}
	if (coeff < 0) {
		dev_err(codec->dev,
			"Unable to configure sample rate %dHz with %dHz MCLK\n",
			params_rate(params), wm8988->sysclk);
		return coeff;
	}

	/* bit size */
	switch (params_width(params)) {
	case 16:
		break;
	case 20:
		iface |= 0x0004;
		break;
	case 24:
		iface |= 0x0008;
		break;
	case 32:
		iface |= 0x000c;
		break;
	}

	/* set iface & srate */
	snd_soc_write(codec, WM8988_IFACE, iface);
	if (coeff >= 0)
		snd_soc_write(codec, WM8988_SRATE, srate |
			(coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);

	return 0;
}
コード例 #10
0
ファイル: ml26124.c プロジェクト: AshishNamdev/linux
static int ml26124_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *hw_params,
			    struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
	int i = get_coeff(priv->mclk, params_rate(hw_params));
	int srate;

	if (i < 0)
		return i;
	priv->substream = substream;
	priv->rate = params_rate(hw_params);

	if (priv->clk_in) {
		switch (priv->mclk / params_rate(hw_params)) {
		case 256:
			snd_soc_update_bits(codec, ML26124_CLK_CTL,
					    BIT(0) | BIT(1), 1);
			break;
		case 512:
			snd_soc_update_bits(codec, ML26124_CLK_CTL,
					    BIT(0) | BIT(1), 2);
			break;
		case 1024:
			snd_soc_update_bits(codec, ML26124_CLK_CTL,
					    BIT(0) | BIT(1), 3);
			break;
		default:
			dev_err(codec->dev, "Unsupported MCLKI\n");
			break;
		}
	} else {
		snd_soc_update_bits(codec, ML26124_CLK_CTL,
				    BIT(0) | BIT(1), 0);
	}

	srate = get_srate(params_rate(hw_params));
	if (srate < 0)
		return srate;

	snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf, srate);
	snd_soc_update_bits(codec, ML26124_PLLNL, 0xff, coeff_div[i].pllnl);
	snd_soc_update_bits(codec, ML26124_PLLNH, 0x1, coeff_div[i].pllnh);
	snd_soc_update_bits(codec, ML26124_PLLML, 0xff, coeff_div[i].pllml);
	snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh);
	snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv);

	return 0;
}
コード例 #11
0
static int rk610_codec_pcm_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params,
				struct snd_soc_dai *dai)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_codec *codec = rtd->codec;
	struct rk610_codec_priv *rk610_codec =snd_soc_codec_get_drvdata(codec);
	unsigned int dai_fmt = rtd->card->dai_link[0].dai_fmt;

	u16 iface = rk610_codec_read_reg_cache(codec, ACCELCODEC_R09) & 0x1f3;
	u16 srate = rk610_codec_read_reg_cache(codec, ACCELCODEC_R00) & 0x180;
	int coeff;

	coeff = get_coeff(rk610_codec->sysclk, params_rate(params));
	DBG("Enter::%s----%d  rk610_codec->sysclk=%d coeff = %d\n",__FUNCTION__,__LINE__,rk610_codec->sysclk, coeff);
	/* bit size */
	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
		break;
	case SNDRV_PCM_FORMAT_S20_3LE:
		iface |= 0x0004;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		iface |= 0x0008;
		break;
	case SNDRV_PCM_FORMAT_S32_LE:
		iface |= 0x000c;
		break;
	}
	DBG("Enter::%s----%d  iface=%x srate =%x rate=%d\n",__FUNCTION__,__LINE__,iface,srate,params_rate(params));

//	rk610_codec_write(codec,ACCELCODEC_R0C, 0x17);
	rk610_codec_write(codec,ACCELCODEC_R04, ASC_INT_MUTE_L|ASC_INT_MUTE_R|ASC_SIDETONE_L_OFF|ASC_SIDETONE_R_OFF);   //soft mute
	//必须先将clk和EN_INT都disable掉,否则切换bclk分频值可能导致codec内部时序混乱掉,
	//表现出来的现象是,以后的音乐都变成了噪音,而且就算把输入codec的I2S_DATAOUT断开也一样出噪音
	rk610_codec_write(codec,ACCELCODEC_R0B, ASC_DEC_DISABLE|ASC_INT_DISABLE);  //0x00

	/* set iface & srate */
	if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
		iface |= ASC_INVERT_BCLK;//翻转BCLK  master状态送出的少了半个时钟,导致未到最大音量的时候破音、

	rk610_codec_write(codec, ACCELCODEC_R09, iface);
	if (coeff >= 0){
	//    rk610_codec_write(codec, ACCELCODEC_R00, srate|coeff_div[coeff].bclk);
		rk610_codec_write(codec, ACCELCODEC_R0A, (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb|ASC_CLKNODIV|ASC_CLK_ENABLE);
	}
	rk610_codec_write(codec,ACCELCODEC_R0B, gR0BReg);

	return 0;
}
コード例 #12
0
ファイル: alc5623.c プロジェクト: 19Dan01/linux
static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
	int coeff, rate;
	u16 iface;

	iface = snd_soc_read(codec, ALC5623_DAI_CONTROL);
	iface &= ~ALC5623_DAI_I2S_DL_MASK;

	/* bit size */
	switch (params_width(params)) {
	case 16:
		iface |= ALC5623_DAI_I2S_DL_16;
		break;
	case 20:
		iface |= ALC5623_DAI_I2S_DL_20;
		break;
	case 24:
		iface |= ALC5623_DAI_I2S_DL_24;
		break;
	case 32:
		iface |= ALC5623_DAI_I2S_DL_32;
		break;
	default:
		return -EINVAL;
	}

	/* set iface & srate */
	snd_soc_write(codec, ALC5623_DAI_CONTROL, iface);
	rate = params_rate(params);
	coeff = get_coeff(codec, rate);
	if (coeff < 0)
		return -EINVAL;

	coeff = coeff_div[coeff].regvalue;
	dev_dbg(codec->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n",
		__func__, alc5623->sysclk, rate, coeff);
	snd_soc_write(codec, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff);

	return 0;
}
コード例 #13
0
static int alc5632_pcm_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_codec *codec = rtd->codec;
	int coeff, rate;
	u16 iface;

	iface = snd_soc_read(codec, ALC5632_DAI_CONTROL);
	iface &= ~ALC5632_DAI_I2S_DL_MASK;

	/*          */
	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
		iface |= ALC5632_DAI_I2S_DL_16;
		break;
	case SNDRV_PCM_FORMAT_S20_3LE:
		iface |= ALC5632_DAI_I2S_DL_20;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		iface |= ALC5632_DAI_I2S_DL_24;
		break;
	default:
		return -EINVAL;
	}

	/*                   */
	snd_soc_write(codec, ALC5632_DAI_CONTROL, iface);
	rate = params_rate(params);
	coeff = get_coeff(codec, rate);
	if (coeff < 0)
		return -EINVAL;

	coeff = coeff_div[coeff].regvalue;
	snd_soc_write(codec, ALC5632_DAC_CLK_CTRL1, coeff);

	return 0;
}
コード例 #14
0
ファイル: alc5632.c プロジェクト: Astralix/mainline-dss11
static int alc5632_pcm_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	int coeff, rate;
	u16 iface;

	iface = snd_soc_read(codec, ALC5632_DAI_CONTROL);
	iface &= ~ALC5632_DAI_I2S_DL_MASK;

	/* bit size */
	switch (params_width(params)) {
	case 16:
		iface |= ALC5632_DAI_I2S_DL_16;
		break;
	case 20:
		iface |= ALC5632_DAI_I2S_DL_20;
		break;
	case 24:
		iface |= ALC5632_DAI_I2S_DL_24;
		break;
	default:
		return -EINVAL;
	}

	/* set iface & srate */
	snd_soc_write(codec, ALC5632_DAI_CONTROL, iface);
	rate = params_rate(params);
	coeff = get_coeff(codec, rate);
	if (coeff < 0)
		return -EINVAL;

	coeff = coeff_div[coeff].regvalue;
	snd_soc_write(codec, ALC5632_DAC_CLK_CTRL1, coeff);

	return 0;
}
コード例 #15
0
ファイル: cplex_solver.c プロジェクト: aeolus-project/opossum
// return the coefficient value of a package
CUDFcoefficient cplex_solver::get_constraint_coeff(int rank) { return (CUDFcoefficient)get_coeff(rank); }
コード例 #16
0
int main(int argc, char **argv)
{
    int    i, c, interlace, frames, err;
    int    ywidth, yheight, uvwidth, uvheight, ylen, uvlen;
    int    verbose = 0, fdin;
    int    NlumaX = 4, NlumaY = 4, NchromaX = 4, NchromaY = 4;
    float  BWlumaX = 0.8, BWlumaY = 0.8, BWchromaX = 0.7, BWchromaY = 0.7;
    struct filter *lumaXtaps, *lumaYtaps, *chromaXtaps, *chromaYtaps;
    u_char *yuvinout[3];
    float *yuvtmp1,*yuvtmp2;
    y4m_stream_info_t istream, ostream;
    y4m_frame_info_t iframe;

    fdin = fileno(stdin);
    
    y4m_accept_extensions(1);

    /* read command line */
    opterr = 0;
    while   ((c = getopt(argc, argv, "hvL:C:x:X:y:Y:")) != EOF)
	{
	    switch  (c)
		{
		case    'L':
		    sscanf(optarg,"%d,%f,%d,%f",&NlumaX,&BWlumaX,&NlumaY,&BWlumaY);
		    break;
		case    'C':
		    sscanf(optarg,"%d,%f,%d,%f",&NchromaX,&BWchromaX,&NchromaY,&BWchromaY);
		    break;
		case    'x':
		    sscanf(optarg,"%d,%f",&NchromaX,&BWchromaX);
		    break;
		case    'X':
		    sscanf(optarg,"%d,%f",&NlumaX,&BWlumaX);
		    break;
		case    'y':
		    sscanf(optarg,"%d,%f",&NchromaY,&BWchromaY);
		    break;
		case    'Y':
		    sscanf(optarg,"%d,%f",&NlumaY,&BWlumaY);
		    break;
		case    'v':
		    verbose++;
		    break;
		case    '?':
		case    'h':
		default:
		    usage();
		}
	}
    
    if (BWlumaX <= 0.0 || BWlumaX > 1.0)
       mjpeg_error_exit1("Horizontal luma bandwidth '%f' not >0 and <=1.0", BWlumaX);
    if (BWlumaY <= 0.0 || BWlumaY > 1.0)
       mjpeg_error_exit1("Vertical luma bandwidth '%f' not >0 and <=1.0", BWlumaY);
    if (BWchromaX <= 0.0 || BWchromaX > 1.0)
       mjpeg_error_exit1("Horizontal chroma bandwidth '%f' not >0 and <=1.0", BWchromaX);
    if (BWchromaY <= 0.0 || BWchromaY > 1.0)
       mjpeg_error_exit1("Vertical chroma bandwidth '%f' not >0 and <=1.0", BWchromaY);

    /* initialize input stream and check chroma subsampling and interlacing */
    y4m_init_stream_info(&istream);
    y4m_init_frame_info(&iframe);
    err = y4m_read_stream_header(fdin, &istream);
    if (err != Y4M_OK)
	mjpeg_error_exit1("Input stream error: %s\n", y4m_strerr(err));

    if	(y4m_si_get_plane_count(&istream) != 3)
	mjpeg_error_exit1("Only the 3 plane formats supported");

    i = y4m_si_get_interlace(&istream);
    switch (i)
        {
        case Y4M_ILACE_NONE:
	    interlace = 0;
	    break;
        case Y4M_ILACE_BOTTOM_FIRST:
        case Y4M_ILACE_TOP_FIRST:
	    interlace = 1;
	    break;
        default:
	    mjpeg_warn("Unknown interlacing '%d', assuming non-interlaced", i);
	    interlace = 0;
	    break;
        }

    ywidth = y4m_si_get_width(&istream);	/* plane 0 = Y */
    yheight = y4m_si_get_height(&istream);
    ylen = ywidth * yheight;
    uvwidth = y4m_si_get_plane_width(&istream, 1);	/* planes 1&2 = U+V */
    uvheight = y4m_si_get_plane_height(&istream, 1);
    uvlen = y4m_si_get_plane_length(&istream, 1);
    
    /* initialize output stream */
    y4m_init_stream_info(&ostream);
    y4m_copy_stream_info(&ostream, &istream);
    y4m_write_stream_header(fileno(stdout), &ostream);
    
    /* allocate input and output buffers */
    yuvinout[0] = my_malloc(ylen*sizeof(u_char));
    yuvinout[1] = my_malloc(uvlen*sizeof(u_char));
    yuvinout[2] = my_malloc(uvlen*sizeof(u_char));
    yuvtmp1 = my_malloc(MAX(ylen,uvlen)*sizeof(float));
    yuvtmp2 = my_malloc(MAX(ylen,uvlen)*sizeof(float));

    /* get filter taps */
    lumaXtaps   = get_coeff(NlumaX, BWlumaX);
    lumaYtaps   = get_coeff(NlumaY, BWlumaY);
    chromaXtaps = get_coeff(NchromaX, BWchromaX);
    chromaYtaps = get_coeff(NchromaY, BWchromaY);

    set_accel(uvwidth,uvheight);

    if (verbose)
	y4m_log_stream_info(mjpeg_loglev_t("info"), "", &istream);
    
    /* main processing loop */
    for (frames=0; y4m_read_frame(fdin,&istream,&iframe,yuvinout) == Y4M_OK; frames++)
	{
	    if (verbose && ((frames % 100) == 0))
		mjpeg_info("Frame %d\n", frames);
	    
            convolveFrame(yuvinout[0],ywidth,yheight,interlace,lumaXtaps,lumaYtaps,yuvtmp1,yuvtmp2);
            convolveFrame(yuvinout[1],uvwidth,uvheight,interlace,chromaXtaps,chromaYtaps,yuvtmp1,yuvtmp2);
            convolveFrame(yuvinout[2],uvwidth,uvheight,interlace,chromaXtaps,chromaYtaps,yuvtmp1,yuvtmp2);

	    y4m_write_frame(fileno(stdout), &ostream, &iframe, yuvinout);

	}
    
    /* clean up */
    y4m_fini_frame_info(&iframe);
    y4m_fini_stream_info(&istream);
    y4m_fini_stream_info(&ostream);
    exit(0);
}
コード例 #17
0
ファイル: vf_perspective.c プロジェクト: 26mansi/FFmpeg
static int config_input(AVFilterLink *inlink)
{
    double x0, x1, x2, x3, x4, x5, x6, x7, q;
    AVFilterContext *ctx = inlink->dst;
    PerspectiveContext *s = ctx->priv;
    double (*ref)[2] = s->ref;
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
    double values[VAR_VARS_NB] = { [VAR_W] = inlink->w, [VAR_H] = inlink->h };
    int h = inlink->h;
    int w = inlink->w;
    int x, y, i, j, ret;

    for (i = 0; i < 4; i++) {
        for (j = 0; j < 2; j++) {
            if (!s->expr_str[i][j])
                return AVERROR(EINVAL);
            ret = av_expr_parse_and_eval(&s->ref[i][j], s->expr_str[i][j],
                                         var_names, &values[0],
                                         NULL, NULL, NULL, NULL,
                                         0, 0, ctx);
            if (ret < 0)
                return ret;
        }
    }

    s->hsub = desc->log2_chroma_w;
    s->vsub = desc->log2_chroma_h;
    s->nb_planes = av_pix_fmt_count_planes(inlink->format);
    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
        return ret;

    s->height[1] = s->height[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
    s->height[0] = s->height[3] = inlink->h;

    s->pv = av_realloc_f(s->pv, w * h, 2 * sizeof(*s->pv));
    if (!s->pv)
        return AVERROR(ENOMEM);

    x6 = ((ref[0][0] - ref[1][0] - ref[2][0] + ref[3][0]) *
          (ref[2][1] - ref[3][1]) -
         ( ref[0][1] - ref[1][1] - ref[2][1] + ref[3][1]) *
          (ref[2][0] - ref[3][0])) * h;
    x7 = ((ref[0][1] - ref[1][1] - ref[2][1] + ref[3][1]) *
          (ref[1][0] - ref[3][0]) -
         ( ref[0][0] - ref[1][0] - ref[2][0] + ref[3][0]) *
          (ref[1][1] - ref[3][1])) * w;
    q =  ( ref[1][0] - ref[3][0]) * (ref[2][1] - ref[3][1]) -
         ( ref[2][0] - ref[3][0]) * (ref[1][1] - ref[3][1]);

    x0 = q * (ref[1][0] - ref[0][0]) * h + x6 * ref[1][0];
    x1 = q * (ref[2][0] - ref[0][0]) * w + x7 * ref[2][0];
    x2 = q *  ref[0][0] * w * h;
    x3 = q * (ref[1][1] - ref[0][1]) * h + x6 * ref[1][1];
    x4 = q * (ref[2][1] - ref[0][1]) * w + x7 * ref[2][1];
    x5 = q *  ref[0][1] * w * h;

    for (y = 0; y < h; y++){
        for (x = 0; x < w; x++){
            int u, v;

            u = (int)floor(SUB_PIXELS * (x0 * x + x1 * y + x2) /
                                        (x6 * x + x7 * y + q * w * h) + 0.5);
            v = (int)floor(SUB_PIXELS * (x3 * x + x4 * y + x5) /
                                        (x6 * x + x7 * y + q * w * h) + 0.5);

            s->pv[x + y * w][0] = u;
            s->pv[x + y * w][1] = v;
        }
    }

    for (i = 0; i < SUB_PIXELS; i++){
        double d = i / (double)SUB_PIXELS;
        double temp[4];
        double sum = 0;

        for (j = 0; j < 4; j++)
            temp[j] = get_coeff(j - d - 1);

        for (j = 0; j < 4; j++)
            sum += temp[j];

        for (j = 0; j < 4; j++)
            s->coeff[i][j] = (int)floor((1 << COEFF_BITS) * temp[j] / sum + 0.5);
    }

    return 0;
}
コード例 #18
0
 real_t
 Constraint::get_coeff(const Variable& v) const
 {
   return get_coeff(v.get_name());
 }
コード例 #19
0
ファイル: es8323.c プロジェクト: Ciastex/kernel_rk3168_86v_yk
static int es8323_pcm_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params,
				struct snd_soc_dai *dai)
{ 

        static int codecfirstuse=0;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_codec *codec = rtd->codec;
	struct es8323_priv *es8323 = snd_soc_codec_get_drvdata(codec);
	//u16 iface = snd_soc_read(codec, es8323_IFACE) & 0x1f3;
	//u16 srate = snd_soc_read(codec, es8323_SRATE) & 0x180;
	
	u16 srate    = snd_soc_read(codec, ES8323_IFACE) & 0x80;
	u16 adciface = snd_soc_read(codec, ES8323_ADC_IFACE) & 0xE3;
	u16 daciface = snd_soc_read(codec, ES8323_DAC_IFACE) & 0xC7;
	
	int coeff;

	coeff = get_coeff(es8323->sysclk, params_rate(params));
	if (coeff < 0) {
		coeff = get_coeff(es8323->sysclk / 2, params_rate(params));
		srate |= 0x40;
	}
	if (coeff < 0) {
		dev_err(codec->dev,
			"Unable to configure sample rate %dHz with %dHz MCLK\n",
			params_rate(params), es8323->sysclk);
		return coeff;
	}

	/* bit size */
 switch (params_format(params)) {
  case SNDRV_PCM_FORMAT_S16_LE:
      adciface |= 0x000C;
      daciface |= 0x0018;
      break;
  case SNDRV_PCM_FORMAT_S20_3LE:
      adciface |= 0x0004;
      daciface |= 0x0008;
      break;
  case SNDRV_PCM_FORMAT_S24_LE:
      break;
  case SNDRV_PCM_FORMAT_S32_LE:
      adciface |= 0x0010;
      daciface |= 0x0020;
      break;
  }

  /* set iface & srate*/
  snd_soc_write(codec, ES8323_DAC_IFACE, daciface); //dac bits length
  snd_soc_write(codec, ES8323_ADC_IFACE, adciface); //adc bits length

	if (coeff >= 0)
		{
		 snd_soc_write(codec, ES8323_IFACE, srate);  //bclk div,mclkdiv2
		 snd_soc_write(codec, ES8323_ADCCONTROL5, coeff_div[coeff].sr | (coeff_div[coeff].usb) << 4);
		 snd_soc_write(codec, ES8323_DACCONTROL2, coeff_div[coeff].sr | (coeff_div[coeff].usb) << 4);
		}
	if (codecfirstuse == 0)
		{
			snd_soc_write(codec, ES8323_LOUT2_VOL, es8323_DEF_VOL);//0x1c);   // 
		  snd_soc_write(codec, ES8323_ROUT2_VOL, es8323_DEF_VOL);//0x1c);   // 
		  codecfirstuse=1;
			}

	return 0;
}