Esempio n. 1
0
File: rtm.c Progetto: conghui/rtm
void backward_propagate_onestep_2d(int nx, int nz, float* vel, float *wav, float* waveN, float* waveNm1, int nt, float dt, int srcx, int srcz, int time_step)
{
	int model_size = nx * nz;
	int check_step = 5;

	if (time_step  ==  nt - 1) {
		//Load last two time_step wave field
		char check_file_name1[64] = "/tmp/check_time_last_1.su";
		char check_file_name2[64] = "/tmp/check_time_last_2.su";
		readimg(check_file_name1, waveNm1, nx, nz);
		readimg(check_file_name2, waveN, nx, nz);
	}
	else if ((check_step > 0) && !(time_step % check_step) && (time_step != 0)) {
		char check_file_name1[64];
		char check_file_name2[64];
		sprintf(check_file_name1, "/tmp/check_time_%d_1.su", time_step);
		sprintf(check_file_name2, "/tmp/check_time_%d_2.su", time_step);
		readimg(check_file_name1, waveNm1, nx, nz);
		readimg(check_file_name2, waveN, nx, nz);
	}

	fd4t10s_2d(nx, nz, vel, waveN, waveNm1);
	float  *tmp = waveN;
	waveN = waveNm1;
	waveNm1 = tmp;

	if (time_step < nt) {
		int src_i = 0;
		for (src_i = 0; src_i < 1 ; src_i ++) {
			int source_location = srcx * nz + srcz;
			waveN[source_location] -= wav[time_step];
		}
	}
}
Esempio n. 2
0
bool
PNGInput::read_native_scanline (int y, int z, void *data)
{
    y -= m_spec.y;
    if (y < 0 || y >= m_spec.height)   // out of range scanline
        return false;

    if (m_interlace_type != 0) {
        // Interlaced.  Punt and read the whole image
        if (m_buf.empty ())
            readimg ();
        size_t size = spec().scanline_bytes();
        memcpy (data, &m_buf[0] + y * size, size);
    } else {
        // Not an interlaced image -- read just one row
        if (m_next_scanline > y) {
            // User is trying to read an earlier scanline than the one we're
            // up to.  Easy fix: close the file and re-open.
            ImageSpec dummyspec;
            int subimage = current_subimage();
            if (! close ()  ||
                ! open (m_filename, dummyspec)  ||
                ! seek_subimage (subimage, dummyspec))
                return false;    // Somehow, the re-open failed
            assert (m_next_scanline == 0 && current_subimage() == subimage);
        }
        while (m_next_scanline <= y) {
            // Keep reading until we're read the scanline we really need
            // std::cerr << "reading scanline " << m_next_scanline << "\n";
            std::string s = PNG_pvt::read_next_scanline (m_png, data);
            if (s.length ()) {
                close ();
                error ("%s", s.c_str ());
                return false;
            }
            ++m_next_scanline;
        }
    }

    // PNG specifically dictates unassociated (un-"premultiplied") alpha.
    // Convert to associated unless we were requested not to do so.
    if (m_spec.alpha_channel != -1 && !m_keep_unassociated_alpha) {
        float gamma = m_spec.get_float_attribute ("oiio:Gamma", 1.0f);
        if (m_spec.format == TypeDesc::UINT16)
            associateAlpha ((unsigned short *)data, m_spec.width,
                            m_spec.nchannels, m_spec.alpha_channel, 
                            gamma);
        else
            associateAlpha ((unsigned char *)data, m_spec.width,
                            m_spec.nchannels, m_spec.alpha_channel, 
                            gamma);
    }

    return true;
}