// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io>
 *
 * Based on sun4i_backend.c, which is:
 *   Copyright (C) 2015 Free Electrons
 *   Copyright (C) 2015 NextThing Co
 */

#include <linux/component.h>
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/reset.h>

#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_probe_helper.h>

#include "sun4i_drv.h"
#include "sun8i_mixer.h"
#include "sun8i_ui_layer.h"
#include "sun8i_vi_layer.h"
#include "sunxi_engine.h"

struct de2_fmt_info {
	u32	drm_fmt;
	u32	de2_fmt;
};

static const struct de2_fmt_info de2_formats[] = {
	{
		.drm_fmt = DRM_FORMAT_ARGB8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB8888,
	},
	{
		.drm_fmt = DRM_FORMAT_ABGR8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR8888,
	},
	{
		.drm_fmt = DRM_FORMAT_RGBA8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA8888,
	},
	{
		.drm_fmt = DRM_FORMAT_BGRA8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA8888,
	},
	{
		.drm_fmt = DRM_FORMAT_XRGB8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_XRGB8888,
	},
	{
		.drm_fmt = DRM_FORMAT_XBGR8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_XBGR8888,
	},
	{
		.drm_fmt = DRM_FORMAT_RGBX8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBX8888,
	},
	{
		.drm_fmt = DRM_FORMAT_BGRX8888,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRX8888,
	},
	{
		.drm_fmt = DRM_FORMAT_RGB888,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGB888,
	},
	{
		.drm_fmt = DRM_FORMAT_BGR888,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGR888,
	},
	{
		.drm_fmt = DRM_FORMAT_RGB565,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGB565,
	},
	{
		.drm_fmt = DRM_FORMAT_BGR565,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGR565,
	},
	{
		.drm_fmt = DRM_FORMAT_ARGB4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB4444,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_XRGB4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB4444,
	},
	{
		.drm_fmt = DRM_FORMAT_ABGR4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR4444,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_XBGR4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR4444,
	},
	{
		.drm_fmt = DRM_FORMAT_RGBA4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA4444,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_RGBX4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA4444,
	},
	{
		.drm_fmt = DRM_FORMAT_BGRA4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA4444,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_BGRX4444,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA4444,
	},
	{
		.drm_fmt = DRM_FORMAT_ARGB1555,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB1555,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_XRGB1555,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB1555,
	},
	{
		.drm_fmt = DRM_FORMAT_ABGR1555,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR1555,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_XBGR1555,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR1555,
	},
	{
		.drm_fmt = DRM_FORMAT_RGBA5551,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA5551,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_RGBX5551,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA5551,
	},
	{
		.drm_fmt = DRM_FORMAT_BGRA5551,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA5551,
	},
	{
		/* for DE2 VI layer which ignores alpha */
		.drm_fmt = DRM_FORMAT_BGRX5551,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA5551,
	},
	{
		.drm_fmt = DRM_FORMAT_ARGB2101010,
		.de2_fmt = SUN8I_MIXER_FBFMT_ARGB2101010,
	},
	{
		.drm_fmt = DRM_FORMAT_ABGR2101010,
		.de2_fmt = SUN8I_MIXER_FBFMT_ABGR2101010,
	},
	{
		.drm_fmt = DRM_FORMAT_RGBA1010102,
		.de2_fmt = SUN8I_MIXER_FBFMT_RGBA1010102,
	},
	{
		.drm_fmt = DRM_FORMAT_BGRA1010102,
		.de2_fmt = SUN8I_MIXER_FBFMT_BGRA1010102,
	},
	{
		.drm_fmt = DRM_FORMAT_UYVY,
		.de2_fmt = SUN8I_MIXER_FBFMT_UYVY,
	},
	{
		.drm_fmt = DRM_FORMAT_VYUY,
		.de2_fmt = SUN8I_MIXER_FBFMT_VYUY,
	},
	{
		.drm_fmt = DRM_FORMAT_YUYV,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUYV,
	},
	{
		.drm_fmt = DRM_FORMAT_YVYU,
		.de2_fmt = SUN8I_MIXER_FBFMT_YVYU,
	},
	{
		.drm_fmt = DRM_FORMAT_NV16,
		.de2_fmt = SUN8I_MIXER_FBFMT_NV16,
	},
	{
		.drm_fmt = DRM_FORMAT_NV61,
		.de2_fmt = SUN8I_MIXER_FBFMT_NV61,
	},
	{
		.drm_fmt = DRM_FORMAT_NV12,
		.de2_fmt = SUN8I_MIXER_FBFMT_NV12,
	},
	{
		.drm_fmt = DRM_FORMAT_NV21,
		.de2_fmt = SUN8I_MIXER_FBFMT_NV21,
	},
	{
		.drm_fmt = DRM_FORMAT_YUV422,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV422,
	},
	{
		.drm_fmt = DRM_FORMAT_YUV420,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV420,
	},
	{
		.drm_fmt = DRM_FORMAT_YUV411,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV411,
	},
	{
		.drm_fmt = DRM_FORMAT_YVU422,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV422,
	},
	{
		.drm_fmt = DRM_FORMAT_YVU420,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV420,
	},
	{
		.drm_fmt = DRM_FORMAT_YVU411,
		.de2_fmt = SUN8I_MIXER_FBFMT_YUV411,
	},
	{
		.drm_fmt = DRM_FORMAT_P010,
		.de2_fmt = SUN8I_MIXER_FBFMT_P010_YUV,
	},
	{
		.drm_fmt = DRM_FORMAT_P210,
		.de2_fmt = SUN8I_MIXER_FBFMT_P210_YUV,
	},
};

int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format)
{
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(de2_formats); ++i)
		if (de2_formats[i].drm_fmt == format) {
			*hw_format = de2_formats[i].de2_fmt;
			return 0;
		}

	return -EINVAL;
}

static void sun8i_mixer_commit(struct sunxi_engine *engine)
{
	DRM_DEBUG_DRIVER("Committing changes\n");

	regmap_write(engine->regs, SUN8I_MIXER_GLOBAL_DBUFF,
		     SUN8I_MIXER_GLOBAL_DBUFF_ENABLE);
}

static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
					    struct sunxi_engine *engine)
{
	struct drm_plane **planes;
	struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine);
	int i;

	planes = devm_kcalloc(drm->dev,
			      mixer->cfg->vi_num + mixer->cfg->ui_num + 1,
			      sizeof(*planes), GFP_KERNEL);
	if (!planes)
		return ERR_PTR(-ENOMEM);

	for (i = 0; i < mixer->cfg->vi_num; i++) {
		struct sun8i_vi_layer *layer;

		layer = sun8i_vi_layer_init_one(drm, mixer, i);
		if (IS_ERR(layer)) {
			dev_err(drm->dev,
				"Couldn't initialize overlay plane\n");
			return ERR_CAST(layer);
		}

		planes[i] = &layer->plane;
	}

	for (i = 0; i < mixer->cfg->ui_num; i++) {
		struct sun8i_ui_layer *layer;

		layer = sun8i_ui_layer_init_one(drm, mixer, i);
		if (IS_ERR(layer)) {
			dev_err(drm->dev, "Couldn't initialize %s plane\n",
				i ? "overlay" : "primary");
			return ERR_CAST(layer);
		}

		planes[mixer->cfg->vi_num + i] = &layer->plane;
	}

	return planes;
}

static const struct sunxi_engine_ops sun8i_engine_ops = {
	.commit		= sun8i_mixer_commit,
	.layers_init	= sun8i_layers_init,
};

static struct regmap_config sun8i_mixer_regmap_config = {
	.reg_bits	= 32,
	.val_bits	= 32,
	.reg_stride	= 4,
	.max_register	= 0xffffc, /* guessed */
};

static int sun8i_mixer_of_get_id(struct device_node *node)
{
	struct device_node *ep, *remote;
	struct of_endpoint of_ep;

	/* Output port is 1, and we want the first endpoint. */
	ep = of_graph_get_endpoint_by_regs(node, 1, -1);
	if (!ep)
		return -EINVAL;

	remote = of_graph_get_remote_endpoint(ep);
	of_node_put(ep);
	if (!remote)
		return -EINVAL;

	of_graph_parse_endpoint(remote, &of_ep);
	of_node_put(remote);
	return of_ep.id;
}

static int sun8i_mixer_bind(struct device *dev, struct device *master,
			      void *data)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct drm_device *drm = data;
	struct sun4i_drv *drv = drm->dev_private;
	struct sun8i_mixer *mixer;
	struct resource *res;
	void __iomem *regs;
	unsigned int base;
	int plane_cnt;
	int i, ret;

	/*
	 * The mixer uses single 32-bit register to store memory
	 * addresses, so that it cannot deal with 64-bit memory
	 * addresses.
	 * Restrict the DMA mask so that the mixer won't be
	 * allocated some memory that is too high.
	 */
	ret = dma_set_mask(dev, DMA_BIT_MASK(32));
	if (ret) {
		dev_err(dev, "Cannot do 32-bit DMA.\n");
		return ret;
	}

	mixer = devm_kzalloc(dev, sizeof(*mixer), GFP_KERNEL);
	if (!mixer)
		return -ENOMEM;
	dev_set_drvdata(dev, mixer);
	mixer->engine.ops = &sun8i_engine_ops;
	mixer->engine.node = dev->of_node;

	if (of_find_property(dev->of_node, "iommus", NULL)) {
		/*
		 * This assume we have the same DMA constraints for
		 * all our the mixers in our pipeline. This sounds
		 * bad, but it has always been the case for us, and
		 * DRM doesn't do per-device allocation either, so we
		 * would need to fix DRM first...
		 */
		ret = of_dma_configure(drm->dev, dev->of_node, true);
		if (ret)
			return ret;
	}

	/*
	 * While this function can fail, we shouldn't do anything
	 * if this happens. Some early DE2 DT entries don't provide
	 * mixer id but work nevertheless because matching between
	 * TCON and mixer is done by comparing node pointers (old
	 * way) instead comparing ids. If this function fails and
	 * id is needed, it will fail during id matching anyway.
	 */
	mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node);

	mixer->cfg = of_device_get_match_data(dev);
	if (!mixer->cfg)
		return -EINVAL;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	regs = devm_ioremap_resource(dev, res);
	if (IS_ERR(regs))
		return PTR_ERR(regs);

	mixer->engine.regs = devm_regmap_init_mmio(dev, regs,
						   &sun8i_mixer_regmap_config);
	if (IS_ERR(mixer->engine.regs)) {
		dev_err(dev, "Couldn't create the mixer regmap\n");
		return PTR_ERR(mixer->engine.regs);
	}

	mixer->reset = devm_reset_control_get(dev, NULL);
	if (IS_ERR(mixer->reset)) {
		dev_err(dev, "Couldn't get our reset line\n");
		return PTR_ERR(mixer->reset);
	}

	ret = reset_control_deassert(mixer->reset);
	if (ret) {
		dev_err(dev, "Couldn't deassert our reset line\n");
		return ret;
	}

	mixer->bus_clk = devm_clk_get(dev, "bus");
	if (IS_ERR(mixer->bus_clk)) {
		dev_err(dev, "Couldn't get the mixer bus clock\n");
		ret = PTR_ERR(mixer->bus_clk);
		goto err_assert_reset;
	}
	clk_prepare_enable(mixer->bus_clk);

	mixer->mod_clk = devm_clk_get(dev, "mod");
	if (IS_ERR(mixer->mod_clk)) {
		dev_err(dev, "Couldn't get the mixer module clock\n");
		ret = PTR_ERR(mixer->mod_clk);
		goto err_disable_bus_clk;
	}

	/*
	 * It seems that we need to enforce that rate for whatever
	 * reason for the mixer to be functional. Make sure it's the
	 * case.
	 */
	if (mixer->cfg->mod_rate)
		clk_set_rate(mixer->mod_clk, mixer->cfg->mod_rate);

	clk_prepare_enable(mixer->mod_clk);

	list_add_tail(&mixer->engine.list, &drv->engine_list);

	base = sun8i_blender_base(mixer);

	/* Reset registers and disable unused sub-engines */
	if (mixer->cfg->is_de3) {
		for (i = 0; i < DE3_MIXER_UNIT_SIZE; i += 4)
			regmap_write(mixer->engine.regs, i, 0);

		regmap_write(mixer->engine.regs, SUN50I_MIXER_FCE_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_PEAK_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_LCTI_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_BLS_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_FCC_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_DNS_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_DRC_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_FMT_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_CDC0_EN, 0);
		regmap_write(mixer->engine.regs, SUN50I_MIXER_CDC1_EN, 0);
	} else {
		for (i = 0; i < DE2_MIXER_UNIT_SIZE; i += 4)
			regmap_write(mixer->engine.regs, i, 0);

		regmap_write(mixer->engine.regs, SUN8I_MIXER_FCE_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_BWS_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_LTI_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_PEAK_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_ASE_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_FCC_EN, 0);
		regmap_write(mixer->engine.regs, SUN8I_MIXER_DCSC_EN, 0);
	}

	/* Enable the mixer */
	regmap_write(mixer->engine.regs, SUN8I_MIXER_GLOBAL_CTL,
		     SUN8I_MIXER_GLOBAL_CTL_RT_EN);

	/* Set background color to black */
	regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR(base),
		     SUN8I_MIXER_BLEND_COLOR_BLACK);

	/*
	 * Set fill color of bottom plane to black. Generally not needed
	 * except when VI plane is at bottom (zpos = 0) and enabled.
	 */
	regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
		     SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0));
	regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, 0),
		     SUN8I_MIXER_BLEND_COLOR_BLACK);

	plane_cnt = mixer->cfg->vi_num + mixer->cfg->ui_num;
	for (i = 0; i < plane_cnt; i++)
		regmap_write(mixer->engine.regs,
			     SUN8I_MIXER_BLEND_MODE(base, i),
			     SUN8I_MIXER_BLEND_MODE_DEF);

	regmap_update_bits(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
			   SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK, 0);

	return 0;

err_disable_bus_clk:
	clk_disable_unprepare(mixer->bus_clk);
err_assert_reset:
	reset_control_assert(mixer->reset);
	return ret;
}

static void sun8i_mixer_unbind(struct device *dev, struct device *master,
				 void *data)
{
	struct sun8i_mixer *mixer = dev_get_drvdata(dev);

	list_del(&mixer->engine.list);

	clk_disable_unprepare(mixer->mod_clk);
	clk_disable_unprepare(mixer->bus_clk);
	reset_control_assert(mixer->reset);
}

static const struct component_ops sun8i_mixer_ops = {
	.bind	= sun8i_mixer_bind,
	.unbind	= sun8i_mixer_unbind,
};

static int sun8i_mixer_probe(struct platform_device *pdev)
{
	return component_add(&pdev->dev, &sun8i_mixer_ops);
}

static int sun8i_mixer_remove(struct platform_device *pdev)
{
	component_del(&pdev->dev, &sun8i_mixer_ops);

	return 0;
}

static const struct sun8i_mixer_cfg sun8i_a83t_mixer0_cfg = {
	.ccsc		= 0,
	.scaler_mask	= 0xf,
	.scanline_yuv	= 2048,
	.ui_num		= 3,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun8i_a83t_mixer1_cfg = {
	.ccsc		= 1,
	.scaler_mask	= 0x3,
	.scanline_yuv	= 2048,
	.ui_num		= 1,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun8i_h3_mixer0_cfg = {
	.ccsc		= 0,
	.mod_rate	= 432000000,
	.scaler_mask	= 0xf,
	.scanline_yuv	= 2048,
	.ui_num		= 3,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun8i_r40_mixer0_cfg = {
	.ccsc		= 0,
	.mod_rate	= 297000000,
	.scaler_mask	= 0xf,
	.scanline_yuv	= 2048,
	.ui_num		= 3,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun8i_r40_mixer1_cfg = {
	.ccsc		= 1,
	.mod_rate	= 297000000,
	.scaler_mask	= 0x3,
	.scanline_yuv	= 2048,
	.ui_num		= 1,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun8i_v3s_mixer_cfg = {
	.vi_num = 2,
	.ui_num = 1,
	.scaler_mask = 0x3,
	.scanline_yuv = 2048,
	.ccsc = 0,
	.mod_rate = 150000000,
};

static const struct sun8i_mixer_cfg sun50i_a64_mixer0_cfg = {
	.ccsc		= 0,
	.mod_rate	= 297000000,
	.scaler_mask	= 0xf,
	.scanline_yuv	= 4096,
	.ui_num		= 3,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun50i_a64_mixer1_cfg = {
	.ccsc		= 1,
	.mod_rate	= 297000000,
	.scaler_mask	= 0x3,
	.scanline_yuv	= 2048,
	.ui_num		= 1,
	.vi_num		= 1,
};

static const struct sun8i_mixer_cfg sun50i_h6_mixer0_cfg = {
	.ccsc		= 0,
	.is_de3		= true,
	.mod_rate	= 600000000,
	.scaler_mask	= 0xf,
	.scanline_yuv	= 4096,
	.ui_num		= 3,
	.vi_num		= 1,
};

static const struct of_device_id sun8i_mixer_of_table[] = {
	{
		.compatible = "allwinner,sun8i-a83t-de2-mixer-0",
		.data = &sun8i_a83t_mixer0_cfg,
	},
	{
		.compatible = "allwinner,sun8i-a83t-de2-mixer-1",
		.data = &sun8i_a83t_mixer1_cfg,
	},
	{
		.compatible = "allwinner,sun8i-h3-de2-mixer-0",
		.data = &sun8i_h3_mixer0_cfg,
	},
	{
		.compatible = "allwinner,sun8i-r40-de2-mixer-0",
		.data = &sun8i_r40_mixer0_cfg,
	},
	{
		.compatible = "allwinner,sun8i-r40-de2-mixer-1",
		.data = &sun8i_r40_mixer1_cfg,
	},
	{
		.compatible = "allwinner,sun8i-v3s-de2-mixer",
		.data = &sun8i_v3s_mixer_cfg,
	},
	{
		.compatible = "allwinner,sun50i-a64-de2-mixer-0",
		.data = &sun50i_a64_mixer0_cfg,
	},
	{
		.compatible = "allwinner,sun50i-a64-de2-mixer-1",
		.data = &sun50i_a64_mixer1_cfg,
	},
	{
		.compatible = "allwinner,sun50i-h6-de3-mixer-0",
		.data = &sun50i_h6_mixer0_cfg,
	},
	{ }
};
MODULE_DEVICE_TABLE(of, sun8i_mixer_of_table);

static struct platform_driver sun8i_mixer_platform_driver = {
	.probe		= sun8i_mixer_probe,
	.remove		= sun8i_mixer_remove,
	.driver		= {
		.name		= "sun8i-mixer",
		.of_match_table	= sun8i_mixer_of_table,
	},
};
module_platform_driver(sun8i_mixer_platform_driver);

MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.io>");
MODULE_DESCRIPTION("Allwinner DE2 Mixer driver");
MODULE_LICENSE("GPL");

{'repo_name': 'torvalds/linux', 'stars': '94062', 'repo_language': 'C', 'file_name': 'fsi-master-gpio.c', 'mime_type': 'text/x-c', 'hash': -7799786164064052308, 'source_dataset': 'data'}


[preset00]
fRating=2.000000
fGammaAdj=1.000000
fDecay=1.000000
fVideoEchoZoom=1.000000
fVideoEchoAlpha=0.500000
nVideoEchoOrientation=1
nWaveMode=0
bAdditiveWaves=0
bWaveDots=0
bWaveThick=0
bModWaveAlphaByVolume=0
bMaximizeWaveColor=1
bTexWrap=0
bDarkenCenter=0
bRedBlueStereo=0
bBrighten=1
bDarken=0
bSolarize=0
bInvert=0
fWaveAlpha=0.001000
fWaveScale=0.334693
fWaveSmoothing=0.750000
fWaveParam=-0.219900
fModWaveAlphaStart=0.750000
fModWaveAlphaEnd=0.950000
fWarpAnimSpeed=1.000000
fWarpScale=1.000000
fZoomExponent=1.000000
fShader=0.300000
zoom=0.999900
rot=0.100000
cx=0.500000
cy=0.500000
dx=0.000000
dy=0.000000
warp=1.000000
sx=1.000000
sy=1.000000
wave_r=0.500000
wave_g=0.500000
wave_b=0.500000
wave_x=0.500000
wave_y=0.500000
ob_size=0.010000
ob_r=0.000000
ob_g=0.000000
ob_b=0.000000
ob_a=0.800000
ib_size=0.005000
ib_r=0.400000
ib_g=0.000000
ib_b=0.000000
ib_a=0.000000
nMotionVectorsX=64.000000
nMotionVectorsY=48.000000
mv_dx=0.000000
mv_dy=0.000000
mv_l=0.000000
mv_r=0.000000
mv_g=0.700000
mv_b=1.000000
mv_a=0.000000
wavecode_0_enabled=0
wavecode_0_samples=512
wavecode_0_sep=0
wavecode_0_bSpectrum=0
wavecode_0_bUseDots=0
wavecode_0_bDrawThick=1
wavecode_0_bAdditive=0
wavecode_0_scaling=1.000000
wavecode_0_smoothing=0.500000
wavecode_0_r=1.000000
wavecode_0_g=0.800000
wavecode_0_b=0.300000
wavecode_0_a=1.000000
wave_0_per_point1=n=sample*6.283;
wave_0_per_point2=
wave_0_per_point3=xp=sin(n);
wave_0_per_point4=yp=cos(n);
wave_0_per_point5=
wave_0_per_point6=tm=q3 - sample;
wave_0_per_point7=
wave_0_per_point8=xof=sin(tm) * sin(tm*3) * 0.4 + 0.5;
wave_0_per_point9=yof=cos(tm*1.3) * sin(tm*5.4) * 0.4 + 0.5;
wave_0_per_point10=
wave_0_per_point11=
wave_0_per_point12=x= xof;
wave_0_per_point13=y= (1-yof);
wave_0_per_point14=
wave_0_per_point15=a=1-sample;
wave_0_per_point16=
wave_0_per_point17=
wave_0_per_point18=
wave_0_per_point19=
wavecode_1_enabled=1
wavecode_1_samples=512
wavecode_1_sep=0
wavecode_1_bSpectrum=0
wavecode_1_bUseDots=0
wavecode_1_bDrawThick=1
wavecode_1_bAdditive=0
wavecode_1_scaling=1.000000
wavecode_1_smoothing=0.500000
wavecode_1_r=1.000000
wavecode_1_g=0.700000
wavecode_1_b=0.200000
wavecode_1_a=1.000000
wave_1_per_point1=n=sample*6.283;
wave_1_per_point2=n2=(sample-q8 - time*0.1)*6;
wave_1_per_point3=
wave_1_per_point4=xp=sin(n);
wave_1_per_point5=yp=cos(n);
wave_1_per_point6=
wave_1_per_point7=tm=q8 - sample;
wave_1_per_point8=
wave_1_per_point9=tx= sin(n2*13)*sin(n2*5) * sample * 0.05;
wave_1_per_point10=ty= cos(n2*13)*sin(n2*7) * sample * 0.05;
wave_1_per_point11=
wave_1_per_point12=xof=sin(tm) * sin(tm*3) * 0.4 + 0.5 + tx;
wave_1_per_point13=yof=cos(tm*1.3) * sin(tm*5.4) * 0.4 + 0.5 + ty;
wave_1_per_point14=
wave_1_per_point15=xran=(rand(10) - 5) * 0.0005; xran=xran*sample;
wave_1_per_point16=yran=(rand(10) - 5) * 0.0005; yran=yran*sample;
wave_1_per_point17=
wave_1_per_point18=x= xof + xran;
wave_1_per_point19=y= (1-yof) + yran;
wave_1_per_point20=
wave_1_per_point21=a=(1-sample);
wave_1_per_point22=g=g*(1-sample);
wave_1_per_point23=b=b*(1-sample)
wavecode_2_enabled=1
wavecode_2_samples=512
wavecode_2_sep=0
wavecode_2_bSpectrum=0
wavecode_2_bUseDots=1
wavecode_2_bDrawThick=1
wavecode_2_bAdditive=0
wavecode_2_scaling=1.000000
wavecode_2_smoothing=0.500000
wavecode_2_r=1.000000
wavecode_2_g=0.780000
wavecode_2_b=0.200000
wavecode_2_a=1.000000
wave_2_per_point1=n=sample*6.283;
wave_2_per_point2=n2=(sample-q8 - time*0.1)*6;
wave_2_per_point3=
wave_2_per_point4=xp=sin(n);
wave_2_per_point5=yp=cos(n);
wave_2_per_point6=
wave_2_per_point7=tm=q8 - sample;
wave_2_per_point8=
wave_2_per_point9=tx= sin(n2*13)*sin(n2*5) * sample * 0.05;
wave_2_per_point10=ty= cos(n2*13)*sin(n2*7) * sample * 0.05;
wave_2_per_point11=
wave_2_per_point12=xof=sin(tm) * sin(tm*3) * 0.4 + 0.5 + tx;
wave_2_per_point13=yof=cos(tm*1.3) * sin(tm*5.4) * 0.4 + 0.5 + ty;
wave_2_per_point14=
wave_2_per_point15=xran=(rand(10) - 5) * 0.0005; xran=xran*sample;
wave_2_per_point16=yran=(rand(10) - 5) * 0.0005; yran=yran*sample;
wave_2_per_point17=
wave_2_per_point18=x= xof + xran;
wave_2_per_point19=y= (1-yof) + yran;
wave_2_per_point20=
wave_2_per_point21=a=(1-sample);
wave_2_per_point22=g=g*(1-sample);
wave_2_per_point23=b=b*(1-sample)
wavecode_3_enabled=0
wavecode_3_samples=512
wavecode_3_sep=0
wavecode_3_bSpectrum=0
wavecode_3_bUseDots=0
wavecode_3_bDrawThick=1
wavecode_3_bAdditive=0
wavecode_3_scaling=1.000000
wavecode_3_smoothing=0.500000
wavecode_3_r=1.000000
wavecode_3_g=1.000000
wavecode_3_b=1.000000
wavecode_3_a=1.000000
wave_3_per_point1=xs=sin(sample*6.28);
wave_3_per_point2=ys=cos(sample*6.28);
wave_3_per_point3=xs=xs*0.7 + 0.5;
wave_3_per_point4=ys=ys*0.7 + 0.5;
wave_3_per_point5=xs=min(xs,0.958);
wave_3_per_point6=xs=max(xs,0.042);
wave_3_per_point7=ys=min(ys,0.988);
wave_3_per_point8=ys=max(ys,0.012);
wave_3_per_point9=x=xs;y=ys;
wave_3_per_point10=
wave_3_per_point11=n2=abs((sample*6.283)-3.1415);
wave_3_per_point12=
wave_3_per_point13=r=sin(n2+time)*0.5+0.5;
wave_3_per_point14=g=sin(n2+2.1+time)*0.5+0.5;
wave_3_per_point15=b=sin(n2+4.2+time)*0.5+0.5;
wave_3_per_point16=
wave_3_per_point17=
wave_3_per_point18=a=a * above(sin(n2*9+q8*2), sin(time) )
shapecode_0_enabled=1
shapecode_0_sides=5
shapecode_0_additive=1
shapecode_0_thickOutline=0
shapecode_0_textured=0
shapecode_0_x=0.500000
shapecode_0_y=0.500000
shapecode_0_rad=0.110462
shapecode_0_ang=0.000000
shapecode_0_tex_ang=0.000000
shapecode_0_tex_zoom=1.000000
shapecode_0_r=1.000000
shapecode_0_g=1.000000
shapecode_0_b=0.500000
shapecode_0_a=1.000000
shapecode_0_r2=1.000000
shapecode_0_g2=0.500000
shapecode_0_b2=0.000000
shapecode_0_a2=0.000000
shapecode_0_border_r=1.000000
shapecode_0_border_g=1.000000
shapecode_0_border_b=1.000000
shapecode_0_border_a=0.100000
shape_0_per_frame1=x=q1;
shape_0_per_frame2=y=1-q2;
shape_0_per_frame3=ang=time
shapecode_1_enabled=1
shapecode_1_sides=5
shapecode_1_additive=0
shapecode_1_thickOutline=0
shapecode_1_textured=0
shapecode_1_x=0.500000
shapecode_1_y=0.500000
shapecode_1_rad=0.030000
shapecode_1_ang=0.000000
shapecode_1_tex_ang=0.000000
shapecode_1_tex_zoom=1.000000
shapecode_1_r=0.000000
shapecode_1_g=0.000000
shapecode_1_b=0.000000
shapecode_1_a=1.000000
shapecode_1_r2=0.000000
shapecode_1_g2=0.000000
shapecode_1_b2=0.000000
shapecode_1_a2=1.000000
shapecode_1_border_r=1.000000
shapecode_1_border_g=1.000000
shapecode_1_border_b=1.000000
shapecode_1_border_a=0.100000
shape_1_per_frame1=x=q1;
shape_1_per_frame2=y=1-q2;
shape_1_per_frame3=ang=time
shapecode_2_enabled=0
shapecode_2_sides=4
shapecode_2_additive=0
shapecode_2_thickOutline=0
shapecode_2_textured=0
shapecode_2_x=0.500000
shapecode_2_y=0.500000
shapecode_2_rad=0.100000
shapecode_2_ang=0.000000
shapecode_2_tex_ang=0.000000
shapecode_2_tex_zoom=1.000000
shapecode_2_r=1.000000
shapecode_2_g=0.000000
shapecode_2_b=0.000000
shapecode_2_a=1.000000
shapecode_2_r2=0.000000
shapecode_2_g2=1.000000
shapecode_2_b2=0.000000
shapecode_2_a2=0.000000
shapecode_2_border_r=1.000000
shapecode_2_border_g=1.000000
shapecode_2_border_b=1.000000
shapecode_2_border_a=0.100000
shapecode_3_enabled=0
shapecode_3_sides=4
shapecode_3_additive=0
shapecode_3_thickOutline=0
shapecode_3_textured=0
shapecode_3_x=0.500000
shapecode_3_y=0.500000
shapecode_3_rad=0.100000
shapecode_3_ang=0.000000
shapecode_3_tex_ang=0.000000
shapecode_3_tex_zoom=1.000000
shapecode_3_r=1.000000
shapecode_3_g=0.000000
shapecode_3_b=0.000000
shapecode_3_a=1.000000
shapecode_3_r2=0.000000
shapecode_3_g2=1.000000
shapecode_3_b2=0.000000
shapecode_3_a2=0.000000
shapecode_3_border_r=1.000000
shapecode_3_border_g=1.000000
shapecode_3_border_b=1.000000
shapecode_3_border_a=0.100000
per_frame_1=warp=0;
per_frame_2=wave_r = wave_r + 0.45*(0.5*sin(time*0.701)+ 0.3*cos(time*0.438));
per_frame_3=wave_b = wave_b - 0.4*(0.5*sin(time*4.782)+0.5*cos(time*0.722));
per_frame_4=wave_g = wave_g + 0.4*sin(time*1.931);
per_frame_5=wave_r = 0.2125*wave_r + 0.7154*wave_g + 0.0721*wave_b;
per_frame_6=wave_g = wave_r;
per_frame_7=wave_b = wave_r;
per_frame_8=vol = 0.167*(bass+mid);
per_frame_9=xamptarg = if(equal(frame%15,0),min(0.5*vol*bass_att,0.5),xamptarg);
per_frame_10=xamp = xamp + 0.5*(xamptarg-xamp);
per_frame_11=xdir = if(above(abs(xpos),xamp),-sign(xpos),if(below(abs(xspeed),0.1),2*above(xpos,0)-1,xdir));
per_frame_12=xspeed = xspeed + xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp);
per_frame_13=xpos = xpos + 0.001*xspeed;
per_frame_14=wave_x = 1.25*xpos + 0.5;
per_frame_15=yamptarg = if(equal(frame%15,0),min(0.3*vol*treb_att,0.5),yamptarg);
per_frame_16=yamp = yamp + 0.5*(yamptarg-yamp);
per_frame_17=ydir = if(above(abs(ypos),yamp),-sign(ypos),if(below(abs(yspeed),0.1),2*above(ypos,0)-1,ydir));
per_frame_18=yspeed = yspeed + ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp);
per_frame_19=ypos = ypos + 0.001*yspeed;
per_frame_20=wave_y = 1.25*ypos + 0.5;
per_frame_21=dx = dx + dx_residual;
per_frame_22=dy = dy + dy_residual;
per_frame_23=bass_thresh = above(bass_att,bass_thresh)*2 + (1-above(bass_att,bass_thresh))*((bass_thresh-1.3)*0.96+1.3);
per_frame_24=dx_residual = equal(bass_thresh,2)*0.003*sin(time*7) + (1-equal(bass_thresh,2))*dx_residual;
per_frame_25=dy_residual = equal(bass_thresh,2)*0.001*sin(time*9) + (1-equal(bass_thresh,2))*dy_residual;
per_frame_26=rot = 0.1;
per_frame_27=
per_frame_28=vol=(bass+mid+treb)*0.25;
per_frame_29=vol=vol*vol;
per_frame_30=mtime=mtime + vol*0.01*(75/fps);
per_frame_31=q8=mtime;
per_frame_32=
per_frame_33=
per_frame_34=q1=sin(mtime) * sin(mtime*3) * 0.4 + 0.5;
per_frame_35=q2=cos(mtime*1.3) * sin(mtime*5.4) * 0.4 + 0.5;
per_frame_36=
per_frame_37=
per_frame_38=
per_frame_39=ib_r = tan(time);
per_frame_40=ib_r = min(1, max(ib_r,0));
per_frame_41=
per_frame_42=ib_g = tan(time+2.1);
per_frame_43=ib_g = min(1, max(ib_g,0));
per_frame_44=
per_frame_45=ib_b = tan(time+4.2);
per_frame_46=ib_b = min(1, max(ib_b,0));
per_frame_47=
per_frame_48=q3 = 10+8*(0.6*sin(0.223*time) + 0.4*sin(0.153*time));
per_frame_49=q4 = 1/q3;
per_frame_50=q5 = 0.5*sign(xpos);
per_frame_51=q6 = 0.5*sign(ypos);
per_frame_52=
per_frame_53=monitor=q4
per_frame_54=
per_frame_55=
per_pixel_1=cx = ((0&(x*q3-q5))+q5)*q4;
per_pixel_2=cy = ((0&(y*q3-q6))+q6)*q4;
per_pixel_3=newx = q1-x;
per_pixel_4=newy = q2-y;
per_pixel_5=newrad = sqrt((newx)*(newx)+0.5625*(newy)*(newy))*2;
per_pixel_6=newzoom = pow(1.05 + 0.03*newrad, pow(0.01+sin(newrad*newrad), newrad*2-1));
per_pixel_7=dx = (newx)*newzoom - newx;
per_pixel_8=dy = (newy)*newzoom - newy;
per_pixel_9=dx =dx*0.1;
per_pixel_10=dy=dy*0.1;
per_pixel_11=rot = 2*newrad*(0.5*(0.5-rad)+0.1);
per_pixel_12=rot=rot*sin(time)*0.2;
per_pixel_13=//sx=-1

{'repo_name': 'projectM-visualizer/projectm', 'stars': '884', 'repo_language': 'C++', 'file_name': 'shell.nix', 'mime_type': 'text/plain', 'hash': 118318036856971813, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.freescale.cdt.launch.cw.download">
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Debugger.processor" value="K70FN1M0"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.busFaultErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.checkUsageFaultErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.hardFaultErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.intErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.memManageErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.noCoprocessorErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Exceptions.stateUsageFaultErr" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Interrupt.disable_interrupts_during_stepping" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Interrupt.interrupt_enabled" value="false"/>
<intAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Interrupt.interrupt_mask" value="0"/>
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Debugger PIC Settings Panel.altLoadAddr" value="0"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Debugger PIC Settings Panel.enableAltLoadAddr" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IDconstant" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IDexecutable" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IDinitialized" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IDuninitialized" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IVconstant" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IVexecutable" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IVinitialized" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.IVuninitialized" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SDconstant" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SDexecutable" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SDinitialized" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SDuninitialized" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SVconstant" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SVexecutable" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SVinitialized" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Download.SVuninitialized" value="false"/>
<intAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.coreIndex" value="0"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.homogeneousMulticore" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.initPath" value="${ProjDirPath}/Debugger/init_kinetis.tcl"/>
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.memConfigPath" value="${ProjDirPath}/Debugger/K70FN1M0.mem"/>
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.simulator" value=""/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.smp" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.systemType" value="com.freescale.cw.system.kinetis.K70F.K70FN1M0"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.useDefaultConfigFile" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.useInitFile" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.Embedded Initialization.useMemoryConfigFile" value="true"/>
<listAttribute key="com.freescale.cdt.debug.cw.CoreNameList">
<listEntry value="K70FN1M0#0"/>
</listAttribute>
<listAttribute key="com.freescale.cdt.debug.cw.Debug"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.DebuggerTab.StopAtProgramEntryPoint" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.DebuggerTab.StopAtStartUp" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.DebuggerTab.StopAtUserSpecified" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.Embedded Download.ExecuteTasks" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.Embedded Download.StandardDownload" value="true"/>
<listAttribute key="com.freescale.cdt.debug.cw.Embedded Download.TaskInitialLaunches"/>
<listAttribute key="com.freescale.cdt.debug.cw.Embedded Download.TaskNames"/>
<listAttribute key="com.freescale.cdt.debug.cw.Embedded Download.TaskSuccessiveRuns"/>
<listAttribute key="com.freescale.cdt.debug.cw.Embedded Download.TaskTypes"/>
<listAttribute key="com.freescale.cdt.debug.cw.ExecutablePath"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.InitializePC" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.InitializePCAtProgramEntryPoint" value="true"/>
<stringAttribute key="com.freescale.cdt.debug.cw.InitializePCAtSymbol" value="main"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.InitializePCAtUserSpecified" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.LaunchMode" value="DOWNLOAD"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.PN_StopAtProgramEntryPoint" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.PN_StopAtStartUp" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.PN_StopAtUserSpecified" value="true"/>
<stringAttribute key="com.freescale.cdt.debug.cw.RefreshPolicy.RefreshPeriod" value="2.0"/>
<listAttribute key="com.freescale.cdt.debug.cw.RemoteDownload"/>
<listAttribute key="com.freescale.cdt.debug.cw.RemotePath"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.ResumeProgram" value="true"/>
<listAttribute key="com.freescale.cdt.debug.cw.SMPCores"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.SYNC_WITH_ENCL_PROJ" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.Symbolics.CacheSymbolicsBetweenRuns" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.Symbolics.UseExecutableCopy" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.UDPPort" value="1234"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.UseApplication" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.core.settings.ConnectionCommonData.TargetConnectionLost.RetryConnectionOn" value="false"/>
<intAttribute key="com.freescale.cdt.debug.cw.core.settings.ConnectionCommonData.TargetConnectionLost.RetryTimeout" value="20"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.core.settings.ConnectionCommonData.TargetConnectionLost.RetryWithTimeoutOn" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.core.settings.ConnectionCommonData.TargetConnectionLost.TerminateConnectionOn" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.core.settings.ConnectionCommonData.TargetConnectionLost.promptUserActionOn" value="true"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.DebuggerCommonData.Connection Protocol Plugin Name" value="ARM GDI"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.DebuggerCommonData.Connection Type" value="com.freescale.mcu.debug.connections.jlink.arm"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.DebuggerCommonData.Processor Attr Name" value="com.freescale.cdt.debug.cw.CW_SHADOWED_PREF.ARM Debugger.processor"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.GdiConnection.Common.PhysicalConnectionAttributeBase" value="com.freescale.mcu.debug.connections.jlink.arm."/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.GdiConnection.Common.SimulatorConnectionAttributeBase" value=""/>
<booleanAttribute key="com.freescale.cdt.debug.cw.core.settings.GdiConnection.Common.logData" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.rseSystemId" value="com.freescale.cdt.debug.cw.core.ui.rse.systemtype.bareboard.hardware.140905160549-0600.2"/>
<stringAttribute key="com.freescale.cdt.debug.cw.core.settings.wizardSystemNameHint" value="PnE U-MultiLink"/>
<stringAttribute key="com.freescale.cdt.debug.cw.debuggerAddress" value="127.0.0.1"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.disableIO" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.ethCtrl" value="UEC1"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.executeInitScripts" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.executePerCoresReset" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.executePerprocessorReset" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.executeReset" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.executeResetSequence" value="true"/>
<stringAttribute key="com.freescale.cdt.debug.cw.gateway" value="127.0.0.1"/>
<listAttribute key="com.freescale.cdt.debug.cw.initPathList">
<listEntry value="${ProjDirPath}/Debugger/init_kinetis.tcl"/>
</listAttribute>
<stringAttribute key="com.freescale.cdt.debug.cw.macAddress" value="**-**-**-**-**-**"/>
<listAttribute key="com.freescale.cdt.debug.cw.memConfigPathList">
<listEntry value="${ProjDirPath}/Debugger/K70FN1M0.mem"/>
</listAttribute>
<stringAttribute key="com.freescale.cdt.debug.cw.netMask" value="255.255.255.255"/>
<stringAttribute key="com.freescale.cdt.debug.cw.osawareness.osContributorID" value="com.freescale.os.mqx.cortexm"/>
<stringAttribute key="com.freescale.cdt.debug.cw.osawareness.rtospluginname" value="MQX RTOS CORTEXM"/>
<stringAttribute key="com.freescale.cdt.debug.cw.osawareness.targetos" value="MQX OS for Cortex"/>
<listAttribute key="com.freescale.cdt.debug.cw.perCoreResetList"/>
<listAttribute key="com.freescale.cdt.debug.cw.perProcessorResetList"/>
<stringAttribute key="com.freescale.cdt.debug.cw.processor" value="Generic"/>
<listAttribute key="com.freescale.cdt.debug.cw.runOutOfResetList">
<listEntry value="false"/>
</listAttribute>
<booleanAttribute key="com.freescale.cdt.debug.cw.skipSystemInitialization" value="false"/>
<stringAttribute key="com.freescale.cdt.debug.cw.targetAddress" value="127.0.0.1"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.useGateway" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.useHSSTIO" value="false"/>
<listAttribute key="com.freescale.cdt.debug.cw.useInitPathList">
<listEntry value="true"/>
</listAttribute>
<booleanAttribute key="com.freescale.cdt.debug.cw.useMacAddress" value="false"/>
<listAttribute key="com.freescale.cdt.debug.cw.useMemConfigPathList">
<listEntry value="true"/>
</listAttribute>
<booleanAttribute key="com.freescale.cdt.debug.cw.useNetworkTransferIO" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.useSerialTransferIO" value="false"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.useStopTransferIO" value="true"/>
<booleanAttribute key="com.freescale.cdt.debug.cw.useUDPPort" value="false"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.CommandLineArgs" value=""/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.ConfigFile" value=""/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.Debug port interface" value="JTAG"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.Delay after reset (ms)" value="0"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.JTAG/SWD fixed speed (Khz)" value="4000"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.JTAG/SWD speed" value="Fixed"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.Library" value="arm_jlink_gdi"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.USB device" value="0"/>
<stringAttribute key="com.freescale.mcu.debug.connections.jlink.arm.names_of_user_added_attributes" value=""/>
<listAttribute key="com.freescale.panel.list">
<listEntry value="Debugger Common Settings"/>
<listEntry value="ARM Exceptions"/>
<listEntry value="ARM Interrupt"/>
<listEntry value="Embedded Download"/>
<listEntry value="Debugger PIC Settings Panel"/>
<listEntry value="Other Executables"/>
<listEntry value="Symbolics"/>
<listEntry value="osawareness"/>
</listAttribute>
<booleanAttribute key="com.freescale.sa.mcu.launch.ENABLE_ANALYSIS" value="false"/>
<stringAttribute key="com.pemicro.mcu.debug.connections.pne.arm.CommandLineArgs" value="arm_icd"/>
<stringAttribute key="com.pemicro.mcu.debug.connections.pne.arm.Library" value="arm_pne_gdi"/>
<stringAttribute key="com.pemicro.mcu.debug.connections.pne.arm.PEDEBUG_CURRENTDEVICE" value="K70FN1M0"/>
<stringAttribute key="com.pemicro.mcu.debug.connections.pne.arm.STARTUP_PORT" value="21"/>
<stringAttribute key="com.pemicro.mcu.debug.connections.pne.arm.STARTUP_interface_selection" value="1"/>
<booleanAttribute key="forceShellDownload" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="com.freescale.cdt.debug.cw.arm.ArmDebugger"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_RESTORE_WATCHPOINTS" value="true"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<globalVariableList/>
"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<memoryBlockExpressionList/>
"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="twrk70f120m_Int_Flash_SramData_Debug/wolfssl_client.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="wolfssl_client"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="org.eclipse.cdt.cross.arm.gnu.sourcery.windows.elf.debug.1358518006"/>
<intAttribute key="org.eclipse.cdt.launch.SET_REGULAR_BREAKPOINT_TYPE_AS" value="0"/>
<booleanAttribute key="org.eclipse.cdt.launch.USE_SET_REGULAR_BREAKPOINT_TYPE_AS" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/wolfssl_client"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_REDIRECT_TO_SERVER_SOCKET" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_REDIRECT_TO_SOCKET" value="false"/>
<stringAttribute key="org.eclipse.debug.ui.ATTR_REDIRECT_TO_SOCKET_HOST" value=""/>
<stringAttribute key="org.eclipse.debug.ui.ATTR_REDIRECT_TO_SOCKET_PORT" value=""/>
<stringAttribute key="process_factory_id" value="com.freescale.cdt.debug.cw.core.ProcessFactoryID"/>
</launchConfiguration>

{'repo_name': 'RavenSystem/esp-homekit-devices', 'stars': '763', 'repo_language': 'C', 'file_name': 'component.mk', 'mime_type': 'text/plain', 'hash': -986494998033164283, 'source_dataset': 'data'}


/* Slovak initialisation for the jQuery UI date picker plugin. */
/* Written by Vojtech Rinik (vojto@hmm.sk). */
jQuery(function($){
	$.datepicker.regional['sk'] = {
		closeText: 'Zavrieť',
		prevText: '<Predchádzajúci',
		nextText: 'Nasledujúci>',
		currentText: 'Dnes',
		monthNames: ['január','február','marec','apríl','máj','jún',
		'júl','august','september','október','november','december'],
		monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
		'Júl','Aug','Sep','Okt','Nov','Dec'],
		dayNames: ['nedeľa','pondelok','utorok','streda','štvrtok','piatok','sobota'],
		dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'],
		dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'],
		weekHeader: 'Ty',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['sk']);
});

{'repo_name': 'wmzsoft/JXADF', 'stars': '756', 'repo_language': 'JavaScript', 'file_name': 'LEAVE.SQL', 'mime_type': 'text/plain', 'hash': 3127442757425378709, 'source_dataset': 'data'}


package io.buoyant.linkerd.protocol

import com.twitter.conversions.StorageUnitOps._
import com.twitter.finagle.{Service, ServiceFactory, Stack, param}
import com.twitter.finagle.http.{param => hparam}
import com.twitter.finagle.http.{Request, Response, Status, Version}
import com.twitter.finagle.stats.InMemoryStatsReceiver
import com.twitter.finagle.buoyant.linkerd.DelayedRelease
import com.twitter.finagle.buoyant.linkerd.Headers.{param => hErrParam}
import com.twitter.io.Pipe
import com.twitter.util.{Future, Promise, Time}
import io.buoyant.linkerd.protocol.http.ResponseClassifiers
import io.buoyant.router.RetryBudgetConfig
import io.buoyant.router.RetryBudgetModule.{param => ev}
import io.buoyant.test.Awaits
import org.scalatest.FunSuite
import org.scalatest.concurrent.Eventually
import scala.language.reflectiveCalls

class HttpInitializerTest extends FunSuite with Awaits with Eventually {

  test("path stack: services are not closed until streams are complete") {
    // Build a path stack that is controllable with promises. This is
    // only really useful for a single request.
    val serviceP, responseP, bodyP, respondingP, closedP = Promise[Unit]
    val http = new HttpInitializer {
      val svc = new Service[Request, Response] {
        def apply(req: Request) = {
          val rw = new Pipe()
          val rsp = Response(req.version, Status.Ok, rw)
          val _ = bodyP.before(rw.close())
          respondingP.setDone()
          responseP.before(Future.value(rsp))
        }

        override def close(d: Time) = {
          closedP.setDone()
          Future.Unit
        }
      }
      val sf = ServiceFactory { () => serviceP.before(Future.value(svc)) }

      def make(params: Stack.Params = Stack.Params.empty) =
        (defaultRouter.pathStack ++ Stack.leaf(Stack.Role("leaf"), sf)).make(params)
    }

    // The factory is returned immediately because it is wrapped in a
    // FactoryToService.
    val factory = http.make()
    val svcf = factory()
    assert(svcf.isDefined)
    val svc = await(svcf)

    // When a request is processed, first the service must be acquired
    // from the service factory, and then the response must be
    // returned from the service.
    val rspf = svc(Request())
    assert(!rspf.isDefined)
    assert(!respondingP.isDefined)

    serviceP.setDone()
    eventually { assert(respondingP.isDefined) }
    assert(!rspf.isDefined)

    responseP.setDone()
    eventually { assert(rspf.isDefined) }

    // Once the response is returned, FactoryToService tries to close
    // the service factory. Ensure that the service is not closed
    // until the response body is completely sent.
    val rsp = await(rspf)
    assert(rsp.isChunked)
    assert(!closedP.isDefined)

    // When the response body is written, it must be fully read from
    // response before the service will be closed.
    bodyP.setDone()
    assert(!closedP.isDefined)

    assert(await(rsp.reader.read()) == None)
    eventually { assert(closedP.isDefined) }
  }

  test("path stack: retries") {
    @volatile var requests = 0
    val http = new HttpInitializer {
      val sf = ServiceFactory.const(Service.mk[Request, Response] { req =>
        requests += 1
        Future.value(Response(req.version, Status.InternalServerError))
      })

      def make(params: Stack.Params = Stack.Params.empty) =
        (defaultRouter.pathStack ++ Stack.leaf(Stack.Role("leaf"), sf)).make(params)
    }

    val params = Stack.Params.empty +
      param.ResponseClassifier(ResponseClassifiers.RetryableReadFailures) +
      RetryBudgetConfig(Some(10), Some(0), Some(0.5))
    val factory = http.make(params)

    val service = await(factory())

    // First request just returns, since retry budget hasn't yet accrued.
    val response0 = await(service(Request()))
    assert(requests == 1)

    // The second request is retryable because of the 50% retry
    // budget.
    val response1 = await(service(Request()))
    assert(requests == 3)
  }

  class WildErr extends Exception
  test("path stack: error handling") {
    @volatile var requests = 0
    val http = new HttpInitializer {
      val sf = ServiceFactory.const(Service.mk[Request, Response] { req =>
        requests += 1
        Future.exception(new WildErr)
      })

      def make(params: Stack.Params = Stack.Params.empty) =
        (defaultRouter.pathStack ++ Stack.leaf(Stack.Role("leaf"), sf)).make(params)
    }

    val stats = new InMemoryStatsReceiver
    val factory = http.make(Stack.Params.empty + param.Stats(stats))
    val service = await(factory())

    val response = await(service(Request()))
    assert(requests == 1)
    assert(response.status == Status.BadGateway)
    assert(response.headerMap.contains("l5d-err"))

    val counter = Seq("failures", "io.buoyant.linkerd.protocol.HttpInitializerTest$WildErr")
    assert(stats.counters.get(counter) == Some(1))
  }

  test("server has codec parameters from router") {
    val maxHeaderSize = hparam.MaxHeaderSize(20.kilobytes)
    val maxInitLineSize = hparam.MaxInitialLineSize(30.kilobytes)
    val maxReqSize = hparam.MaxRequestSize(40.kilobytes)
    val maxRspSize = hparam.MaxResponseSize(50.kilobytes)
    val maxErrRspSize = hErrParam.MaxErrResponseSize(30.kilobytes)
    val streaming = hparam.Streaming(false)
    val compression = hparam.CompressionLevel(3)

    val router = HttpInitializer.router
      .configured(maxHeaderSize).configured(maxInitLineSize)
      .configured(maxReqSize).configured(maxRspSize)
      .configured(maxErrRspSize)
      .configured(streaming).configured(compression)
      .serving(HttpServerConfig(None, None, None).mk(HttpInitializer, "yolo"))
      .initialize()
    assert(router.servers.size == 1)
    val sparams = router.servers.head.params
    assert(sparams[hparam.MaxHeaderSize] == maxHeaderSize)
    assert(sparams[hparam.MaxInitialLineSize] == maxInitLineSize)
    assert(sparams[hparam.MaxRequestSize] == maxReqSize)
    assert(sparams[hparam.MaxResponseSize] == maxRspSize)
    assert(sparams[hErrParam.MaxErrResponseSize] == maxErrRspSize)
    assert(sparams[hparam.Streaming] == streaming)
    assert(sparams[hparam.CompressionLevel] == compression)
  }
}

{'repo_name': 'linkerd/linkerd', 'stars': '5245', 'repo_language': 'Scala', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 1120002575231331903, 'source_dataset': 'data'}


/*
 *  Copyright 2019-2020 Diligent Graphics LLC
 *  Copyright 2015-2019 Egor Yusov
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  In no event and under no legal theory, whether in tort (including negligence),
 *  contract, or otherwise, unless required by applicable law (such as deliberate
 *  and grossly negligent acts) or agreed to in writing, shall any Contributor be
 *  liable for any damages, including any direct, indirect, special, incidental,
 *  or consequential damages of any character arising as a result of this License or
 *  out of the use or inability to use the software (including but not limited to damages
 *  for loss of goodwill, work stoppage, computer failure or malfunction, or any and
 *  all other commercial damages or losses), even if such Contributor has been advised
 *  of the possibility of such damages.
 */

#include "pch.h"
#include "D3D11TypeConversions.hpp"

#include "D3D11TypeDefinitions.h"
#include "D3DTypeConversionImpl.hpp"
#include "D3DViewDescConversionImpl.hpp"

namespace Diligent
{

D3D11_FILTER FilterTypeToD3D11Filter(FILTER_TYPE MinFilter, FILTER_TYPE MagFilter, FILTER_TYPE MipFilter)
{
    return FilterTypeToD3DFilter<D3D11_FILTER>(MinFilter, MagFilter, MipFilter);
}

D3D11_TEXTURE_ADDRESS_MODE TexAddressModeToD3D11AddressMode(TEXTURE_ADDRESS_MODE Mode)
{
    return TexAddressModeToD3DAddressMode<D3D11_TEXTURE_ADDRESS_MODE>(Mode);
}

D3D11_COMPARISON_FUNC ComparisonFuncToD3D11ComparisonFunc(COMPARISON_FUNCTION Func)
{
    return ComparisonFuncToD3DComparisonFunc<D3D11_COMPARISON_FUNC>(Func);
}

void DepthStencilStateDesc_To_D3D11_DEPTH_STENCIL_DESC(const DepthStencilStateDesc& DepthStencilDesc,
                                                       D3D11_DEPTH_STENCIL_DESC&    d3d11DSSDesc)
{
    DepthStencilStateDesc_To_D3D_DEPTH_STENCIL_DESC<D3D11_DEPTH_STENCIL_DESC, D3D11_DEPTH_STENCILOP_DESC, D3D11_STENCIL_OP, D3D11_COMPARISON_FUNC>(DepthStencilDesc, d3d11DSSDesc);
}

void RasterizerStateDesc_To_D3D11_RASTERIZER_DESC(const RasterizerStateDesc& RasterizerDesc,
                                                  D3D11_RASTERIZER_DESC&     d3d11RSDesc)
{
    RasterizerStateDesc_To_D3D_RASTERIZER_DESC<D3D11_RASTERIZER_DESC, D3D11_FILL_MODE, D3D11_CULL_MODE>(RasterizerDesc, d3d11RSDesc);
    d3d11RSDesc.ScissorEnable = RasterizerDesc.ScissorEnable ? TRUE : FALSE;
}

void BlendStateDesc_To_D3D11_BLEND_DESC(const BlendStateDesc& BSDesc,
                                        D3D11_BLEND_DESC&     d3d11BSDesc)
{
    BlendStateDescToD3DBlendDesc<D3D11_BLEND_DESC, D3D11_BLEND, D3D11_BLEND_OP>(BSDesc, d3d11BSDesc);

    for (int i = 0; i < 8; ++i)
    {
        const auto& SrcRTDesc = BSDesc.RenderTargets[i];
        if (SrcRTDesc.LogicOperationEnable)
        {
            LOG_ERROR("Logical operations on render targets are not supported by D3D11 device");
        }
    }
}

void LayoutElements_To_D3D11_INPUT_ELEMENT_DESCs(const InputLayoutDesc&                                                               InputLayout,
                                                 std::vector<D3D11_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D11_INPUT_ELEMENT_DESC>>& D3D11InputElements)
{
    LayoutElements_To_D3D_INPUT_ELEMENT_DESCs<D3D11_INPUT_ELEMENT_DESC>(InputLayout, D3D11InputElements);
}

D3D11_PRIMITIVE_TOPOLOGY TopologyToD3D11Topology(PRIMITIVE_TOPOLOGY Topology)
{
    return TopologyToD3DTopology<D3D11_PRIMITIVE_TOPOLOGY>(Topology);
}

void TextureViewDesc_to_D3D11_SRV_DESC(const TextureViewDesc&           TexViewDesc,
                                       D3D11_SHADER_RESOURCE_VIEW_DESC& D3D11SRVDesc,
                                       Uint32                           SampleCount)
{
    TextureViewDesc_to_D3D_SRV_DESC(TexViewDesc, D3D11SRVDesc, SampleCount);
}

void TextureViewDesc_to_D3D11_RTV_DESC(const TextureViewDesc&         TexViewDesc,
                                       D3D11_RENDER_TARGET_VIEW_DESC& D3D11RTVDesc,
                                       Uint32                         SampleCount)
{
    TextureViewDesc_to_D3D_RTV_DESC(TexViewDesc, D3D11RTVDesc, SampleCount);
}

void TextureViewDesc_to_D3D11_DSV_DESC(const TextureViewDesc&         TexViewDesc,
                                       D3D11_DEPTH_STENCIL_VIEW_DESC& D3D11DSVDesc,
                                       Uint32                         SampleCount)
{
    TextureViewDesc_to_D3D_DSV_DESC(TexViewDesc, D3D11DSVDesc, SampleCount);
}

void TextureViewDesc_to_D3D11_UAV_DESC(const TextureViewDesc&            TexViewDesc,
                                       D3D11_UNORDERED_ACCESS_VIEW_DESC& D3D11UAVDesc)
{
    TextureViewDesc_to_D3D_UAV_DESC(TexViewDesc, D3D11UAVDesc);
}

void BufferViewDesc_to_D3D11_SRV_DESC(const BufferDesc&                BuffDesc,
                                      const BufferViewDesc&            SRVDesc,
                                      D3D11_SHADER_RESOURCE_VIEW_DESC& D3D11SRVDesc)
{
    if (BuffDesc.Mode == BUFFER_MODE_RAW && SRVDesc.Format.ValueType == VT_UNDEFINED)
    {
        // Raw buffer view
        UINT ElementByteStride = 4;
        DEV_CHECK_ERR((SRVDesc.ByteOffset % 16) == 0, "Byte offest (", SRVDesc.ByteOffset, ") is not multiple of 16");
        DEV_CHECK_ERR((SRVDesc.ByteWidth % ElementByteStride) == 0, "Byte width (", SRVDesc.ByteWidth, ") is not multiple of 4");
        D3D11SRVDesc.BufferEx.FirstElement = SRVDesc.ByteOffset / ElementByteStride;
        D3D11SRVDesc.BufferEx.NumElements  = SRVDesc.ByteWidth / ElementByteStride;
        D3D11SRVDesc.BufferEx.Flags        = D3D11_BUFFEREX_SRV_FLAG_RAW;
        D3D11SRVDesc.Format                = DXGI_FORMAT_R32_TYPELESS;
        D3D11SRVDesc.ViewDimension         = D3D_SRV_DIMENSION_BUFFEREX;
    }
    else
    {
        BufferViewDesc_to_D3D_SRV_DESC(BuffDesc, SRVDesc, D3D11SRVDesc);
    }
}

void BufferViewDesc_to_D3D11_UAV_DESC(const BufferDesc&                 BuffDesc,
                                      const BufferViewDesc&             UAVDesc,
                                      D3D11_UNORDERED_ACCESS_VIEW_DESC& D3D11UAVDesc)
{
    BufferViewDesc_to_D3D_UAV_DESC(BuffDesc, UAVDesc, D3D11UAVDesc);
}

} // namespace Diligent

{'repo_name': 'DiligentGraphics/DiligentCore', 'stars': '206', 'repo_language': 'C++', 'file_name': 'vulkan_android.h', 'mime_type': 'text/x-c', 'hash': -3330229414707106917, 'source_dataset': 'data'}


<a href="<%= user_path(current_user) %>">
  <%= gravatar_for current_user, size: 52 %>

  <%= current_user.name %>

  <%= link_to "view my profile", current_user %>

  <%= pluralize(current_user.microposts.count, "micropost") %>

{'repo_name': 'yasslab/sample_apps', 'stars': '202', 'repo_language': 'Ruby', 'file_name': '404.html', 'mime_type': 'text/html', 'hash': -2647568087346821494, 'source_dataset': 'data'}


/**
 * Copyright (c) 2009, 2013, Pecunia Project. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#import "MCEMTableView.h"

@interface NSObject (MCEMTableView)
- (NSColor *)tableView: (MCEMTableView *)tv labelColorForRow: (int)row;
@end

@implementation MCEMTableView

- (void)drawRow: (int)rowIndex clipRect: (NSRect)clipRect
{
    NSColor *rowColor = nil;
    /* Outcommented to avoid a warning. This class will go anyway.
     if([[self delegate ] respondsToSelector: @selector(tableView:labelColorForRow:) ]) rowColor = [[self delegate] tableView:self labelColorForRow:rowIndex];
     */
    if (![[self selectedRowIndexes] containsIndex: rowIndex] && rowColor) {
        NSRect rect = [self rectOfRow: rowIndex];
        rect.origin.x += 1.0;
        rect.size.width -= 2.0;
        rect.size.height -= 3.0;
        rect.origin.y += 1.0;

        NSBezierPath *path = [NSBezierPath bezierPath];
        [path appendBezierPathWithRoundedRect: rect xRadius: 9.0 yRadius: 9.0];

        NSGradient *aGradient = [[NSGradient alloc]
                                 initWithColorsAndLocations: [NSColor whiteColor], (CGFloat) - 0.1, rowColor, (CGFloat)1.1,
                                 nil];

        [aGradient drawInBezierPath: path angle: 90.0];
    }
    [super drawRow: rowIndex clipRect: clipRect];
}

@end

{'repo_name': 'pecuniabanking/pecunia-client', 'stars': '200', 'repo_language': 'Objective-C', 'file_name': 'Pecunia AppStore.xcscheme', 'mime_type': 'text/xml', 'hash': 1837364950020999168, 'source_dataset': 'data'}


#include <jni.h>
#include <string.h>
#include <android/log.h>
#include "stdio.h"
#include "stdlib.h"
#include <unistd.h>

#include <android/native_window_jni.h>
#include <android/native_window.h>
#include "libyuv.h"
#include "libyuv/convert_from.h"
#include "ffmpeg/libavutil/time.h"
#include "pthread.h"

//封装格式
#include "ffmpeg/libavformat/avformat.h"
//解码
#include "ffmpeg/libavcodec/avcodec.h"
//缩放
#include "ffmpeg/libswscale/swscale.h"
//重采样
#include "ffmpeg/libswresample/swresample.h"

//格式转换
#include "libyuv.h"

//存放Avpacket的队列
#include "queue.h"

//播放视频包括两个流：视频流，音频流，字幕流（这里不处理）
#define MAX_STREAM 2
#define PACKET_QUEUE_SIZE 50
#define MAX_AUDIO_FRME_SIZE 48000 * 4

#define MIN_SLEEP_TIME_US 1000ll
#define AUDIO_TIME_ADJUST_US -200000ll

#define LOGI(FORMAT, ...) __android_log_print(ANDROID_LOG_INFO,"sys.out",FORMAT,##__VA_ARGS__);
#define LOGE(FORMAT, ...) __android_log_print(ANDROID_LOG_ERROR,"sys.out",FORMAT,##__VA_ARGS__);

/**
 * 解决音频、视频同步的问题
 * 1. 创建队列，用来存储AvPacket, 一个生产者（），两个消费者（）
 */
/**
 * 定义player结构体，存储用来传输的变量
 */
typedef struct Player {
    JavaVM *javaVM; //查找java层方法id使用

    AVFormatContext *input_format_ctx;  //封装格式上下文
    int video_stream_idx; //视频流索引位置
    int audio_stream_idx; //音频流索引位置
    AVCodecContext *input_codec_ctx[MAX_STREAM]; //解码器上下文数组，包括视频，音频解码器
    pthread_t decode_threads[MAX_STREAM]; //播放音视频的线程id

    ANativeWindow *nativeWindow; //播放视频的窗口

    int capture_streams_no; //流的总个数

    SwrContext *swr_ctx; //音频播放需要的参数
    //输入的采样格式
    enum AVSampleFormat in_sample_fmt;
    //输出采样格式16bit PCM
    enum AVSampleFormat out_sample_fmt;
    //输入采样率
    int in_sample_rate;
    //输出采样率
    int out_sample_rate;
    //输出的声道个数
    int out_channel_nb;

    //JNI
    jobject audio_track;
    jmethodID audio_track_write_mid;

    pthread_t thread_read_from_stream;
    //音频，视频读取队列，有两个队列，还可以加入字幕队列
    Queue *packets[MAX_STREAM];

    //互斥锁
    pthread_mutex_t mutex;
    //条件变量
    pthread_cond_t cond;

    //视频开始播放的时间
    int64_t start_time;

    int64_t audio_clock;

} Player;

//解码数据
typedef struct _DecoderData {
    Player *player;
    int stream_index; //在解码的时候，通过该索引拿到对应的队列
} DecoderData;

void decode_video(Player *pPlayer, AVPacket *pPacket);

void decode_audio_prepare(Player *pPlayer);

/**
 * 初始化工作，主要找到音频，视频的索引位置
 */
void init_input_format_ctx(Player *player, const char *input_cstr) {
    //1.注册组件
    av_register_all();

    //封装格式上下文
    AVFormatContext *pFormatCtx = avformat_alloc_context();

    //2.打开输入视频文件
    if (avformat_open_input(&pFormatCtx, input_cstr, NULL, NULL) != 0) {
        LOGE("%s", "打开输入视频文件失败");
        return;
    }
    //3.获取视频信息
    if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
        LOGE("%s", "获取视频信息失败");
        return;
    }

    //视频解码，需要找到视频对应的AVStream所在pFormatCtx->streams的索引位置
    int i = 0;
    player->capture_streams_no = pFormatCtx->nb_streams;
    for (; i < player->capture_streams_no; i++) {
        //根据类型判断，是否是视频流,音频流
        if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
            player->video_stream_idx = i;
        } else if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            player->audio_stream_idx = i;
        }
    }
    player->input_format_ctx = pFormatCtx;
}

/**
 * 根据获取视频，音频解码器，初始化解码器上下文
 * @param player
 * @param stream_idx
 */
void init_codec_context(Player *player, int stream_idx) {
    //获取视频解码器,音频解码器
    AVFormatContext *format_ctx = player->input_format_ctx;
    AVCodecContext *pCodeCtx = format_ctx->streams[stream_idx]->codec;

    AVCodec *pCodec = avcodec_find_decoder(pCodeCtx->codec_id);
    if (pCodec == NULL) {
        LOGE("%s", "无法解码");
        return;
    }
    //打开解码器
    if (avcodec_open2(pCodeCtx, pCodec, NULL) < 0) {
        LOGE("%s", "解码器无法打开");
        return;
    }
    player->input_codec_ctx[stream_idx] = pCodeCtx;
}

//准备播放视频的surfaceView，这时候获取env都是在主线程
void decode_video_prepare(JNIEnv *env, Player *player, jobject surface) {
    player->nativeWindow = ANativeWindow_fromSurface(env, surface);
}

//准备音频播放器
void decode_audio_prepare(Player *player) {
    AVCodecContext *codecCtx = player->input_codec_ctx[player->audio_stream_idx];
    //设置音频格式，采样率
    SwrContext *swrCtx = swr_alloc();
    //初始化输出参数
    //输入的采样格式，设置输出格式
    enum AVSampleFormat in_sample_fmt = codecCtx->sample_fmt;
    //输出采样格式16bit PCM
    enum AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16;
    //输入采样率
    int in_sample_rate = codecCtx->sample_rate;
    //输出采样率
    int out_sample_rate = 44100;
    //获取输入的声道布局
    //根据声道个数获取默认的声道布局（2个声道，默认立体声stereo）
    //av_get_default_channel_layout(codecCtx->channels);
    uint64_t in_ch_layout = codecCtx->channel_layout;
    //输出的声道布局（立体声）
    uint64_t out_ch_layout = AV_CH_LAYOUT_STEREO;
    swr_alloc_set_opts(swrCtx,
                       out_ch_layout, out_sample_fmt, out_sample_rate,
                       in_ch_layout, in_sample_fmt, in_sample_rate,
                       0, NULL);
    swr_init(swrCtx);
    //输出的声道个数
    int out_channel_nb = av_get_channel_layout_nb_channels(out_ch_layout);
    //重采样设置参数-------------end

    //在player中保存初始化的变量
    player->in_sample_fmt = in_sample_fmt;
    player->out_sample_fmt = out_sample_fmt;
    player->in_sample_rate = in_sample_rate;
    player->out_sample_rate = out_sample_rate;
    player->out_channel_nb = out_channel_nb;
    player->swr_ctx = swrCtx;
}

void jni_audio_prepare(JNIEnv *env, jobject jthiz, Player *player) {
    //JNI begin------------------
    jclass player_class = (*env)->GetObjectClass(env, jthiz);

    //AudioTrack对象
    jmethodID create_audio_track_mid = (*env)->GetMethodID(env, player_class, "createAudioTrack",
                                                           "(II)Landroid/media/AudioTrack;");
    jobject audio_track = (*env)->CallObjectMethod(env, jthiz, create_audio_track_mid,
                                                   player->out_sample_rate, player->out_channel_nb);

    //调用AudioTrack.play方法
    jclass audio_track_class = (*env)->GetObjectClass(env, audio_track);
    jmethodID audio_track_play_mid = (*env)->GetMethodID(env, audio_track_class, "play", "()V");
    (*env)->CallVoidMethod(env, audio_track, audio_track_play_mid);

    //AudioTrack.write
    jmethodID audio_track_write_mid = (*env)->GetMethodID(env, audio_track_class, "write",
                                                          "([BII)I");

    //JNI end------------------
    player->audio_track = (*env)->NewGlobalRef(env, audio_track);
    //(*env)->DeleteGlobalRef
    player->audio_track_write_mid = audio_track_write_mid;
}

void *player_fill_packet() {
    AVPacket *packet = malloc(sizeof(AVPacket));
    return packet;
}

void player_alloc_queues(Player *player) {
    int i;
    //初始化两个队列
    for (i = 0; i < player->capture_streams_no; i++) {
        Queue *queue = queue_init(PACKET_QUEUE_SIZE, player_fill_packet);
        player->packets[i] = queue;
    }
}

void *packet_free_func(AVPacket *packet) {
    av_free_packet(packet);
    return 0;
}

/**
 * 获取视频当前播放时间
 */
int64_t player_get_current_video_time(Player *player) {
    int64_t current_time = av_gettime();
    return current_time - player->start_time;
}

/**
 * 延迟
 */
void player_wait_for_frame(Player *player, int64_t stream_time,
                           int stream_no) {
    pthread_mutex_lock(&player->mutex);
    for(;;){
        int64_t current_video_time = player_get_current_video_time(player);
        int64_t sleep_time = stream_time - current_video_time;
        if (sleep_time < -300000ll) {
            // 300 ms late
            int64_t new_value = player->start_time - sleep_time;
            LOGI("player_wait_for_frame[%d] correcting %f to %f because late",
                 stream_no, (av_gettime() - player->start_time) / 1000000.0,
                 (av_gettime() - new_value) / 1000000.0);

            player->start_time = new_value;
            pthread_cond_broadcast(&player->cond);
        }

        if (sleep_time <= MIN_SLEEP_TIME_US) {
            // We do not need to wait if time is slower then minimal sleep time
            break;
        }

        if (sleep_time > 500000ll) {
            // if sleep time is bigger then 500ms just sleep this 500ms
            // and check everything again
            sleep_time = 500000ll;
        }
        //等待指定时长
        int timeout_ret = pthread_cond_timeout_np(&player->cond,
                                                  &player->mutex, sleep_time/1000ll);

        // just go further
        LOGI("player_wait_for_frame[%d] finish", stream_no);
    }
    pthread_mutex_unlock(&player->mutex);
}

/**
 * 对视频数据进行解码
 * @param player
 * @param packet
 */
void decode_video(Player *player, AVPacket *packet) {
    AVFormatContext *input_format_ctx = player->input_format_ctx;
    AVStream *stream = input_format_ctx->streams[player->video_stream_idx];

    //像素数据（解码数据）
    AVFrame *yuv_frame = av_frame_alloc();
    AVFrame *rgb_frame = av_frame_alloc();
    //绘制时的缓冲区
    ANativeWindow_Buffer outBuffer;
    AVCodecContext *pCodeCtx = player->input_codec_ctx[player->video_stream_idx];
    int got_frame;

    //解码AVPacket->AVFrame
    avcodec_decode_video2(pCodeCtx, yuv_frame, &got_frame, packet);

    //非零，正在解码
    if (got_frame) {
        //lock
        //设置缓冲区的属性（宽、高、像素格式）
        ANativeWindow_setBuffersGeometry(player->nativeWindow, pCodeCtx->width, pCodeCtx->height,
                                         WINDOW_FORMAT_RGBA_8888);
        ANativeWindow_lock(player->nativeWindow, &outBuffer, NULL);

        //设置rgb_frame的属性（像素格式、宽高）和缓冲区
        //rgb_frame缓冲区与outBuffer.bits是同一块内存
        avpicture_fill((AVPicture *) rgb_frame, (const uint8_t *) outBuffer.bits, PIX_FMT_RGBA,
                       pCodeCtx->width, pCodeCtx->height);

        //YUV->RGBA_8888
        I420ToARGB(yuv_frame->data[0], yuv_frame->linesize[0],
                   yuv_frame->data[2], yuv_frame->linesize[2],
                   yuv_frame->data[1], yuv_frame->linesize[1],
                   rgb_frame->data[0], rgb_frame->linesize[0],
                   pCodeCtx->width, pCodeCtx->height);

        //计算延迟
        int64_t pts = av_frame_get_best_effort_timestamp(yuv_frame);
        //转换（不同时间基时间转换）
        int64_t time = av_rescale_q(pts,stream->time_base,AV_TIME_BASE_Q);

        player_wait_for_frame(player,time,player->video_stream_idx);

        //unlock
        ANativeWindow_unlockAndPost(player->nativeWindow);
        usleep(1000 * 16);
    }
    av_frame_free(&yuv_frame);
    av_frame_free(&rgb_frame);
}

/**
 * 音频解码
 */
void decode_audio(struct Player *player, AVPacket *packet) {
    AVFormatContext *input_format_ctx = player->input_format_ctx;
    AVStream *stream = input_format_ctx->streams[player->audio_stream_idx];

    AVCodecContext *codec_ctx = player->input_codec_ctx[player->audio_stream_idx];
    LOGI("%s", "decode_audio");
    //解压缩数据
    AVFrame *frame = av_frame_alloc();
    int got_frame;
    avcodec_decode_audio4(codec_ctx, frame, &got_frame, packet);

    //16bit 44100 PCM 数据（重采样缓冲区）
    uint8_t *out_buffer = (uint8_t *) av_malloc(MAX_AUDIO_FRME_SIZE);
    //解码一帧成功
    if (got_frame > 0) {
        swr_convert(player->swr_ctx, &out_buffer, MAX_AUDIO_FRME_SIZE,
                    (const uint8_t **) frame->data, frame->nb_samples);
        //获取sample的size
        int out_buffer_size = av_samples_get_buffer_size(NULL, player->out_channel_nb,
                                                         frame->nb_samples, player->out_sample_fmt,
                                                         1);

        int64_t pts = packet->pts;
        if (pts != AV_NOPTS_VALUE) {
            player->audio_clock = av_rescale_q(pts, stream->time_base, AV_TIME_BASE_Q);
            //				av_q2d(stream->time_base) * pts;
            LOGI("player_write_audio - read from pts");
            player_wait_for_frame(player,
                                  player->audio_clock + AUDIO_TIME_ADJUST_US, player->audio_stream_idx);
        }

        //关联当前线程的JNIEnv
        JavaVM *javaVM = player->javaVM;
        JNIEnv *env;
        (*javaVM)->AttachCurrentThread(javaVM, &env, NULL);

        //out_buffer缓冲区数据，转成byte数组
        jbyteArray audio_sample_array = (*env)->NewByteArray(env, out_buffer_size);
        jbyte *sample_bytep = (*env)->GetByteArrayElements(env, audio_sample_array, NULL);
        //out_buffer的数据复制到sampe_bytep
        memcpy(sample_bytep, out_buffer, out_buffer_size);
        //同步
        (*env)->ReleaseByteArrayElements(env, audio_sample_array, sample_bytep, 0);

        //AudioTrack.write PCM数据
        (*env)->CallIntMethod(env, player->audio_track, player->audio_track_write_mid,
                              audio_sample_array, 0, out_buffer_size);
        //释放局部引用
        (*env)->DeleteLocalRef(env, audio_sample_array);

        (*javaVM)->DetachCurrentThread(javaVM);

        usleep(1000 * 16);
    }

    av_frame_free(&frame);
}

/**
 * 两个消费者从对应的队列中拿内容进行设置，这里要从队列中拿数据，然后消费
 * @param arg
 * @return
 */
void *decode_data(void *arg) {
    DecoderData *decoderData = (DecoderData *) arg;
    Player *player = decoderData->player;
    int stream_index = decoderData->stream_index;
    Queue *queue = player->packets[stream_index];

    AVFormatContext *format_ctx = player->input_format_ctx;

    //编码数据
    AVPacket *packet = (AVPacket *) av_malloc(sizeof(AVPacket));

    int video_frame_count = 0, audio_frame_count = 0;
    for (;;) {
        if (queue != NULL) {
            //音频和视频进行消费
            pthread_mutex_lock(&player->mutex); //在这里进行加锁控制，保证不会在读的时候进行覆盖？？？？
            AVPacket *packet = (AVPacket *) queue_pop(queue, &player->mutex, &player->cond);
            pthread_mutex_unlock(&player->mutex);
            if (stream_index == player->video_stream_idx) {
                decode_video(player, packet);
                LOGI("video_frame_count:%d", video_frame_count++);
            } else if (stream_index == player->audio_stream_idx) {
                decode_audio(player, packet);
                LOGI("audio_frame_count:%d", audio_frame_count++);
            }
        } else {
            break;
        }
    }

//    //一帧一帧读取压缩的视频数据AVPacket
//    while (av_read_frame(format_ctx, packet) >= 0) {
//        /*if (packet->stream_index == player->video_stream_idx) {
//            decode_video(player, packet);
//            LOGI("解码%d帧", framecount++);
//        } else */if (packet->stream_index == player->audio_stream_idx) {
//            decode_audio(player, packet);
//        }
//        av_free_packet(packet);
//    }
}

/**
 * 生产者队列：从流中读出数据放入两个队列中，音频队列，视频队列
 * @param player
 * @return
 */
void *player_read_from_stream(Player *player) {
    int index = 0;
    int ret;
    //拿到AvPacket，判断类型，对对应的队列中元素进行赋值
    AVPacket packet, *pkt = &packet;
    //要一直进行读取
    for (;;) {
        ret = av_read_frame(player->input_format_ctx, pkt);
        if (ret < 0) {
            break;
        }
        //根据序号拿到对应的队列
        Queue *queue = player->packets[pkt->stream_index];
        //在入队列的时候加锁，赋值完成后，解锁，保证不能对正在读的数据进行修改
        pthread_mutex_lock(&player->mutex);
        //找到队列的顶部，拿到它的地址
        AVPacket *packet_data = queue_push(queue, &player->mutex, &player->cond);
        *packet_data = packet; //深拷贝，赋值
        pthread_mutex_unlock(&player->mutex);
        //释放 todo:内存的释放需要修改
        //queue_free(queue, packet_free_func);

    }
}

//音视频通过创建子线程进行播放
//1. 对播放器解码，上下文进行初始化，只能在主线程获取javaVm，供子线程获取上下文使用，对于getMethodid等需要在主线程中获取
//2. 线程都单独对应一个上下文
//3. 数据的播放
//1.找数据流-》找解码器-》解码
void JNICALL
Java_com_lx_multimedialearn_ffmpegstudy_FFmpegUtils_videoPthreadPlay(JNIEnv *env, jobject instance,
                                                         jstring inputPath_, jobject surface) {
    const char *input_cstr = (*env)->GetStringUTFChars(env, inputPath_, 0);
    Player *player = (Player *) malloc(sizeof(Player));
    //对javaVm进行赋值
    (*env)->GetJavaVM(env, &(player->javaVM));
    init_input_format_ctx(player, input_cstr);

    //获取视频解码器,音频解码器
    int video_stream_index = player->video_stream_idx;
    int audio_stream_index = player->audio_stream_idx;
    init_codec_context(player, video_stream_index);
    init_codec_context(player, audio_stream_index);

    decode_video_prepare(env, player, surface);
    decode_audio_prepare(player);

    //准备audioTrack，在主线程中找到methodId，Class
    jni_audio_prepare(env, instance, player);

    //初始化队列，供生产者和消费者使用
    player_alloc_queues(player);

    //对互斥锁，条件变量初始化
    pthread_mutex_init(&player->mutex, NULL);
    pthread_cond_init(&player->cond, NULL);

    //创建线程，在子线程播放视频
//    pthread_create(&(player->decode_threads[player->video_stream_idx]), NULL, decode_data,
//                   (void *) player);

    //创建三个线程：生产者线程，两个消费者线程，生产者把AvPacket放入到队列中
    pthread_create(&(player->thread_read_from_stream), NULL, player_read_from_stream,
                   (void *) player);
    sleep(1);
    player->start_time = 0; //音视频同步，设置初始时间，有一个播放的时长，通过读取当前播放的时间，音频，或者视频进行等待，保证播放同步
    //在播放音视频的过程中进行等待处理
    //当前为什么不能播放，因为缓冲区大小是50，视频处理的比较慢，对缓冲区不断的覆盖，导致消费者进程读到的是错误的数据帧
    //通过加锁的方法，保证读完了，才会生产下一步

    DecoderData data1 = {player, video_stream_index}, *decode_data1 = &data1;
    //创建线程，在子线程中播放音频，这是两个消费者线程
    pthread_create(&(player->decode_threads[player->video_stream_idx]), NULL, decode_data,
                   (void *) decode_data1);

    DecoderData data2 = {player, audio_stream_index}, *decode_data2 = &data2;
    pthread_create(&(player->decode_threads[player->audio_stream_idx]), NULL, decode_data,
                   (void *) decode_data2);

    //todo 按了后退键，这里没有销毁，可以监听surface的状态，destroy时进行暂停，创建后，继续播放
    sleep(10);
    //todo: 这里join，会屏蔽其它按钮
//    pthread_join(player->thread_read_from_stream,NULL);
//    pthread_join(player->decode_threads[video_stream_index],NULL);
//    pthread_join(player->decode_threads[audio_stream_index],NULL);
//      void *p_result;
//    //todo: 在锁屏，退出的时候如何释放资源，这里需要重新处理，在本地方法的子线程，仍然不能连续播放！！！
//    通过pthread_join阻塞等待播放完毕，再释放资源，阻塞会导致后退键不起作用，这里需要再考虑
//      pthread_join(player->decode_threads[player->video_stream_idx], p_result);
//    释放资源
//    (*env)->ReleaseStringUTFChars(env, inputPath_, input_cstr);
//    avcodec_close(player->input_codec_ctx[player->video_stream_idx]);
//    avformat_free_context(player->input_format_ctx);
//    free(player);
}

{'repo_name': 'lixiaoshaxing/MultiMediaLearn', 'stars': '347', 'repo_language': 'C', 'file_name': 'ExampleUnitTest.java', 'mime_type': 'text/html', 'hash': -7732032832254582112, 'source_dataset': 'data'}


<?php
declare(strict_types=1);

namespace StubTests\Model;

use PhpParser\Node\Stmt\Interface_;
use ReflectionClass;
use stdClass;

class PHPInterface extends BasePHPClass
{
    public array $parentInterfaces = [];

    /**
     * @param ReflectionClass $interface
     * @return $this
     */
    public function readObjectFromReflection($interface): self
    {
        $this->name = $interface->getName();
        foreach ($interface->getMethods() as $method) {
            if ($method->getDeclaringClass()->getName() !== $this->name) {
                continue;
            }
            $this->methods[$method->name] = (new PHPMethod())->readObjectFromReflection($method);
        }
        $this->parentInterfaces = $interface->getInterfaceNames();
        foreach ($interface->getReflectionConstants() as $constant) {
            if ($constant->getDeclaringClass()->getName() !== $this->name) {
                continue;
            }
            $this->constants[$constant->name] = (new PHPConst())->readObjectFromReflection($constant);
        }
        return $this;
    }

    /**
     * @param Interface_ $node
     * @return $this
     */
    public function readObjectFromStubNode($node): self
    {
        $this->name = $this->getFQN($node);
        $this->collectTags($node);
        if (!empty($node->extends)) {
            $this->parentInterfaces[] = implode('\\', $node->extends[0]->parts);
        }
        return $this;
    }

    public function readMutedProblems($jsonData): void
    {
        /**@var stdClass $interface */
        foreach ($jsonData as $interface) {
            if ($interface->name === $this->name) {
                if (!empty($interface->problems)) {
                    /**@var stdClass $problem */
                    foreach ($interface->problems as $problem) {
                        switch ($problem) {
                            case 'wrong parent':
                                $this->mutedProblems[] = StubProblemType::WRONG_PARENT;
                                break;
                            case 'missing interface':
                                $this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
                                break;
                            default:
                                $this->mutedProblems[] = -1;
                                break;
                        }
                    }
                }
                if (!empty($interface->methods)) {
                    foreach ($this->methods as $method) {
                        $method->readMutedProblems($interface->methods);
                    }
                }
                if (!empty($interface->constants)) {
                    foreach ($this->constants as $constant) {
                        $constant->readMutedProblems($interface->constants);
                    }
                }
                return;
            }
        }
    }
}

{'repo_name': 'JetBrains/phpstorm-stubs', 'stars': '916', 'repo_language': 'PHP', 'file_name': 'ssh2.php', 'mime_type': 'text/x-php', 'hash': -2327648419335505253, 'source_dataset': 'data'}


import { Action } from './Action';
import {
  Conference,
  ConferenceTitlesToIds,
  IndexedConferences
} from './Conference';
import {
  ConferenceInput,
  JSONInput,
  PresenterInput,
  VideoInput
} from './InputJSON';
import { IndexedPresenters, Presenter } from './Presenter';
import { IndexedVideos, Video } from './Video';

export {
  Action,
  Video,
  IndexedVideos,
  Presenter,
  IndexedPresenters,
  Conference,
  IndexedConferences,
  ConferenceTitlesToIds,
  ConferenceInput,
  VideoInput,
  PresenterInput,
  JSONInput
};

{'repo_name': 'simonccarter/react-conf-videos', 'stars': '155', 'repo_language': 'TypeScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': -1119479982890096677, 'source_dataset': 'data'}


{% extends "admin/delete_confirmation.html" %}
{% load i18n static %}

{% block extrastyle %}{{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static 'filer/css/admin_filer.css' %}">
{% endblock %}

{% block breadcrumbs %}
    {% include "admin/filer/breadcrumbs.html" with instance=object breadcrumbs_action="Delete" %}
{% endblock %}

{'repo_name': 'divio/django-filer', 'stars': '1290', 'repo_language': 'Python', 'file_name': 'filer_check.py', 'mime_type': 'text/x-python', 'hash': 3200154228951801898, 'source_dataset': 'data'}


//
//  NSSet+RACSequenceAdditions.m
//  ReactiveObjC
//
//  Created by Justin Spahr-Summers on 2012-10-29.
//  Copyright (c) 2012 GitHub. All rights reserved.
//

#import "NSSet+RACSequenceAdditions.h"
#import "NSArray+RACSequenceAdditions.h"

@implementation NSSet (RACSequenceAdditions)

- (RACSequence *)rac_sequence {
	// TODO: First class support for set sequences.
	return self.allObjects.rac_sequence;
}

@end

{'repo_name': 'boai/BABaseProject', 'stars': '473', 'repo_language': 'Objective-C', 'file_name': 'Info.plist', 'mime_type': 'text/xml', 'hash': -8307118773236784446, 'source_dataset': 'data'}


/**

 @Name：用于打包PC完整版，即包含layui.js和所有模块的完整合并（该文件不会存在于构建后的目录）
 @Author：贤心
 @License：LGPL

 */

layui.define(function(exports){
  var cache = layui.cache;
  layui.config({
    dir: cache.dir.replace(/lay\/dest\/$/, '')
  });
  exports('layui.all', layui.v);
});

{'repo_name': 'Leo0216/winadmin', 'stars': '315', 'repo_language': 'JavaScript', 'file_name': 'demo.html', 'mime_type': 'text/html', 'hash': -6293431935567195688, 'source_dataset': 'data'}


/************************************************************************/
/*         *   The Coq Proof Assistant / The Coq Development Team       */
/*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       */
/* <O___,, *       (see CREDITS file for the list of authors)           */
/*   \VV/  **************************************************************/
/*    //   *    This file is distributed under the terms of the         */
/*         *     GNU Lesser General Public License Version 2.1          */
/*         *     (see LICENSE file for the text of the license)         */
/************************************************************************/
.notation {
    /* font-family: "Ubuntu Mono", "Consolas", monospace; */
    white-space: pre-wrap;
}

.notation .notation-sup {
    top: -0.4em;
}

.notation .notation-sub {
    bottom: -0.4em;
    border-radius: 1rem;
}

@font-face { /* This font has been edited to center all characters */
  font-family: 'CoqNotations';
  font-style: normal;
  font-weight: 800;
  src: local('CoqNotations'), url(./CoqNotations.ttf) format('truetype');
}

.notation .notation-sup, .notation .notation-sub {
    background: #EAEAEA;
    border: 1px solid #AAA;
    color: black;
    /* cursor: help; */
    display: inline-block;
    font-size: 0.45em;
    font-weight: bolder;
    font-family: CoqNotations, monospace;
    height: 2.2em;
    line-height: 1.6em;
    position: absolute;
    right: -1em; /* half of the width */
    text-align: center;
    width: 2.2em;
}

.notation .repeat {
    background: #EAEAEA;
    border: 1px solid #AAA;
    display: inline-block;
    padding-right: 0.6em; /* Space for the left half of the sub- and sup-scripts */
    padding-left: 0.2em;
    margin: 0.25em 0;
}

.notation .repeat-wrapper {
    display: inline-block;
    position: relative;
    margin-right: 0.4em; /* Space for the right half of the sub- and sup-scripts */
}

.notation .hole, .std-token .pre {
    color: #4e9a06;
    font-style: italic;
    font-weight: bold;
}

/***********************/
/* Small extra classes */
/***********************/

.math-preamble {
    display: none;
}

.inline-grammar-production {
    font-weight: bold;
}

/************************/
/* Coqtop IO and Coqdoc */
/************************/

.coqtop dd, .ansi-bg-default {
    background: #eeeeee !important;
}

.coqtop dd, .ansi-fg-default {
    color: #2e3436 !important;
}

.coqtop dt {                    /* Questions */
    background: none !important;
    color: #333 !important;
    font-weight: normal !important;
    padding: 0 !important;
    margin: 0 !important;
}

.coqtop dd {                    /* Responses */
    padding: 0.5em;
    margin-left: 0 !important;
    margin-top: 0.5em !important;
}

.coqdoc, .coqtop dl {
    margin: 12px; /* Copied from RTD theme */
}

.coqdoc {
    display: block;
    white-space: pre;
}

.coqtop dt, .coqtop dd {
    border: none !important;
    display: block !important;
}

.coqtop.coqtop-hidden, dd.coqtop-hidden, dt.coqtop-hidden { /* Overqualifying for precedence */
    display: none !important;
}

/* FIXME: Specific to the RTD theme */
.coqdoc, .coqtop dt, .coqtop dd, pre { /* pre added because of production lists */
    font-family: Consolas,"Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace !important; /* Copied from RTD theme */
    font-size: 12px !important; /* Copied from RTD theme */
    line-height: 1.5 !important; /* Copied from RTD theme */
    white-space: pre;
}

/*************/
/* Overrides */
/*************/

.rst-content table.docutils td, .rst-content table.docutils th {
    padding: 8px; /* Reduce horizontal padding */
    border-left: none;
    border-right: none;
}

/* We can't display nested blocks otherwise */
code, .rst-content tt, .rst-content code {
    background: transparent !important;
    border: none !important;
    font-size: inherit !important;
}

code {
    padding: 0 !important;      /* This padding doesn't make sense without a border */
}

dt > .property {
    margin-right: 0.25em;
}

.icon-home:visited {
  color: #FFFFFF;
}

/* Pygments for Coq is confused by ‘…’ */
code span.error {
    background: inherit !important;
    line-height: inherit !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

/* Red is too aggressive */
.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal {
    color: inherit !important;
}

{'repo_name': 'princeton-vl/CoqGym', 'stars': '160', 'repo_language': 'Coq', 'file_name': 'term.html', 'mime_type': 'text/html', 'hash': -4168503065996241404, 'source_dataset': 'data'}


//
//! Copyright (c) 2011
//! Brandon Kohn
//
//  Distributed under the Boost Software License, Version 1.0. (See
//  accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_CAST_TRAITS_HPP
#define BOOST_NUMERIC_CAST_TRAITS_HPP

#include <boost/numeric/conversion/converter_policies.hpp>

namespace boost { namespace numeric {

    template <typename Target, typename Source, typename EnableIf = void>
    struct numeric_cast_traits
    {
        typedef def_overflow_handler    overflow_policy;
        typedef UseInternalRangeChecker range_checking_policy;
        typedef Trunc<Source>           rounding_policy;
    };

}}//namespace boost::numeric;

#if !defined( BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS )
#include <boost/cstdint.hpp>
#include <boost/numeric/conversion/detail/numeric_cast_traits.hpp>
#endif//!defined BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS

#endif//BOOST_NUMERIC_CAST_TRAITS_HPP

{'repo_name': 'RocketChat/Rocket.Chat.ReactNative', 'stars': '812', 'repo_language': 'JavaScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 4292727095284248394, 'source_dataset': 'data'}


<testcase>
<info>
<keywords>
HTTP
POST
POST callback
</keywords>
</info>
#
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake swsclose
Connection: close
Content-Type: text/html

hello
</data>
</reply>

# Client-side
<client>
<server>
http
</server>
# tool is what to use instead of 'curl'
<tool>
lib508
</tool>

 <name>
send HTTP POST using read callback
 </name>
 <command>
http://%HOSTIP:%HTTPPORT/508
</command>
</client>

#
# Verify data after the test has been "shot"
<verify>
<strippart>
# remove CR that CURLOPT_TRANSFERTEXT added, when CharConv enabled:
s/^(this is what we post to the silly web server)\r\n/$1\n/ if($has_charconv)
</strippart>
<protocol>
POST /508 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
Content-Length: 45
Content-Type: application/x-www-form-urlencoded

this is what we post to the silly web server
</protocol>
</verify>
</testcase>

{'repo_name': 'kbengine/kbengine', 'stars': '4026', 'repo_language': 'C', 'file_name': 'psi_base.h', 'mime_type': 'text/x-c', 'hash': 4684306815358218491, 'source_dataset': 'data'}


/*
 *
 * Copyright 2015 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef GRPC_SUPPORT_WORKAROUND_LIST_H
#define GRPC_SUPPORT_WORKAROUND_LIST_H

/* The list of IDs of server workarounds currently maintained by gRPC. For
 * explanation and detailed descriptions of workarounds, see
 * /doc/workarounds.md
 */
typedef enum {
  GRPC_WORKAROUND_ID_CRONET_COMPRESSION = 0,
  GRPC_MAX_WORKAROUND_ID
} grpc_workaround_list;

#endif /* GRPC_SUPPORT_WORKAROUND_LIST_H */

{'repo_name': 'sunlight3d/react_native_v0.49', 'stars': '218', 'repo_language': 'Objective-C', 'file_name': 'profiles_settings.xml', 'mime_type': 'text/plain', 'hash': -3364771579229316495, 'source_dataset': 'data'}


<?php

/*
 * This file is part of PHPExifTool.
 *
 * (c) 2012 Romain Neutron <imprec@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPExiftool\Driver\Tag\Sony;

use JMS\Serializer\Annotation\ExclusionPolicy;
use PHPExiftool\Driver\AbstractTag;

/**
 * @ExclusionPolicy("all")
 */
class AFStatus11F3 extends AbstractTag
{

    protected $Id = 22;

    protected $Name = 'AFStatus_11_F3';

    protected $FullName = 'Sony::AFStatus79';

    protected $GroupName = 'Sony';

    protected $g0 = 'MakerNotes';

    protected $g1 = 'Sony';

    protected $g2 = 'Camera';

    protected $Type = 'int16s';

    protected $Writable = true;

    protected $Description = 'AF Status 11 F3';

    protected $flag_Permanent = true;

    protected $Values = array(
        '-32768' => array(
            'Id' => '-32768',
            'Label' => 'Out of Focus',
        ),
        0 => array(
            'Id' => 0,
            'Label' => 'In Focus',
        ),
    );
}

{'repo_name': 'romainneutron/PHPExiftool', 'stars': '112', 'repo_language': 'PHP', 'file_name': 'MetadataBagTest.php', 'mime_type': 'text/x-php', 'hash': -9044972041470585161, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="dao.CheckoutMapper" >
  <resultMap id="checkoutResultMap" type="Pojo.Checkout" >
    <id column="cid" property="id" jdbcType="INTEGER" />
    <result column="house_id" property="house_id" jdbcType="VARCHAR" />
    <result column="address" property="address" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="VARCHAR" />
     <result column="userlist_id" property="userlist_id" jdbcType="INTEGER" />
     <collection property="userlist" ofType="Pojo.Userlist">
			<id property="id" column="id"/>
		<!--用户id已经在user对象中存在，此处可以不设置-->
			<!-- <result property="userId" column="id"/> -->
			<result property="name" column="name"/>
			<result property="idcard" column="idcard"/>
			<result property="phone" column="phone"/>
			<result property="user_id" column="user_id"/>

		</collection>

  </resultMap>
   <insert id="insertcheckout" parameterType="Pojo.Checkout">
	  insert into checkout(house_id,address,userlist_id,status)
	  values(#{house_id},#{address},#{userlist_id},#{status})
	</insert>
	<select id="getallcheckout" resultMap="checkoutResultMap" >
		SELECT
	c.*, u.*
FROM
	`checkout` c
LEFT JOIN userlist u ON u.id = c.userlist_id
	</select>
		<delete id="deletecheckout" parameterType="Integer" >
		delete from checkout where cid=#{cid}
	</delete>
  </mapper>

{'repo_name': 'chiuwingyan/house', 'stars': '191', 'repo_language': 'Java', 'file_name': 'org.eclipse.core.resources.prefs', 'mime_type': 'text/plain', 'hash': 1519343546985599994, 'source_dataset': 'data'}


[
{ type: install
  message: <<EOM
To use GemRB, you must copy the Chitin.key from your respective Infinity Engine
game CD to the GemRB directory.  If you do not copy this file, GemRB will not
work. Additionally, %%ETCDIR%%/GemRB.cfg needs to be edited to point to the
Infinity Engine game installation directory. Games can be installed with
emulators/wine-devel, archivers/unshield, or the custom GemRB game installer:
http://git.njw.name/cgit/cgit.cgi/gemrb-gameinstallers/

Please see http://www.gemrb.org/ for additional help and instructions.
EOM
}
]

{'repo_name': 'freebsd/freebsd-ports', 'stars': '572', 'repo_language': 'None', 'file_name': 'distinfo', 'mime_type': 'text/plain', 'hash': -6956949521323842366, 'source_dataset': 'data'}