MCPcopy Create free account
hub / github.com/defold/defold / put_line

Method put_line

engine/dlib/src/basis/encoder/basisu_resampler.cpp:463–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 }
462
463 bool Resampler::put_line(const Sample * Psrc)
464 {
465 int i;
466
467 if (m_cur_src_y >= m_resample_src_y)
468 return false;
469
470 /* Does this source line contribute
471 * to any destination line? if not,
472 * exit now.
473 */
474
475 if (!m_Psrc_y_count[resampler_range_check(m_cur_src_y, m_resample_src_y)])
476 {
477 m_cur_src_y++;
478 return true;
479 }
480
481 /* Find an empty slot in the scanline buffer. (FIXME: Perf. is terrible here with extreme scaling ratios.) */
482
483 for (i = 0; i < MAX_SCAN_BUF_SIZE; i++)
484 if (m_Pscan_buf->scan_buf_y[i] == -1)
485 break;
486
487 /* If the buffer is full, exit with an error. */
488
489 if (i == MAX_SCAN_BUF_SIZE)
490 {
491 m_status = STATUS_SCAN_BUFFER_FULL;
492 return false;
493 }
494
495 m_Psrc_y_flag[resampler_range_check(m_cur_src_y, m_resample_src_y)] = true;
496 m_Pscan_buf->scan_buf_y[i] = m_cur_src_y;
497
498 /* Does this slot have any memory allocated to it? */
499
500 if (!m_Pscan_buf->scan_buf_l[i])
501 {
502 if ((m_Pscan_buf->scan_buf_l[i] = (Sample*)malloc(m_intermediate_x * sizeof(Sample))) == NULL)
503 {
504 m_status = STATUS_OUT_OF_MEMORY;
505 return false;
506 }
507 }
508
509 // Resampling on the X axis first?
510 if (m_delay_x_resample)
511 {
512 assert(m_intermediate_x == m_resample_src_x);
513
514 // Y-X resampling order
515 memcpy(m_Pscan_buf->scan_buf_l[i], Psrc, m_intermediate_x * sizeof(Sample));
516 }
517 else
518 {
519 assert(m_intermediate_x == m_resample_dst_x);
520

Callers 1

image_resampleFunction · 0.80

Calls 3

resampler_range_checkFunction · 0.85
mallocFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected