Changeset 425
- Timestamp:
- 08/17/06 21:32:49 (5 years ago)
- Files:
-
- sweep/branches/display-cache/src/display-cache.c (modified) (22 diffs)
- sweep/branches/display-cache/src/display-cache.h (modified) (1 diff)
- sweep/branches/display-cache/src/sample-display.c (modified) (5 diffs)
- sweep/branches/display-cache/src/sweep_sounddata.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sweep/branches/display-cache/src/display-cache.c
r424 r425 42 42 //#define DEBUG_VERBOSE 43 43 //#define DEBUG_VERY_VERBOSE 44 //#define DEBUG_CUST 44 45 //#define DEBUG_VERBOSE_CUST 45 46 //#define DEBUG_VERY_VERBOSE_CUST … … 82 83 83 84 #ifdef DEBUG_VERBOSE 84 g_print("display_cache_right_realloc: l1:%i l2:%i len:%i\n",l1, l2, len); 85 #endif 86 //XXX i have to add MARGIN to arrays size in case of avoiding sweep crash 87 //XXX it should be checked whats is wrong 88 #define MARGIN 10000 89 tmp = g_malloc0(l1 * sizeof(sw_audio_t) + MARGIN); 85 g_print("display_cache_right_realloc(%p): l1:%i l2:%i len:%i\n", dc, l1, l2, len); 86 #endif 87 88 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 90 89 g_memmove(tmp, dc->min, l2 * sizeof(sw_audio_t)); 91 90 g_free(dc->min); 92 91 dc->min = tmp; 93 92 94 tmp = g_malloc0(l1 * sizeof(sw_audio_t) + MARGIN);93 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 95 94 g_memmove(tmp, dc->max, l2 * sizeof(sw_audio_t)); 96 95 g_free(dc->max); 97 96 dc->max = tmp; 98 97 99 tmp = g_malloc0(l1 * sizeof(sw_audio_t) + MARGIN);98 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 100 99 g_memmove(tmp, dc->rms, l2 * sizeof(sw_audio_t)); 101 100 g_free(dc->rms); 102 101 dc->rms = tmp; 103 102 104 tmpb = g_malloc0(l1 * sizeof(gboolean) + MARGIN);103 tmpb = g_malloc0(l1 * sizeof(gboolean)); 105 104 g_memmove(tmpb, dc->points, l2 * sizeof(gboolean)); 106 105 g_free(dc->points); … … 108 107 109 108 dc->len += len; 110 111 109 } 112 110 … … 122 120 #endif 123 121 124 // dst, src, len125 122 tmp = g_malloc0((l1 + l2) * sizeof(sw_audio_t)); 126 123 g_memmove(tmp + l1, dc->min, l2 * sizeof(sw_audio_t)); … … 144 141 145 142 dc->len += len; 146 147 143 } 148 144 … … 278 274 g_mutex_lock (sample->sounddata->data_mutex); 279 275 280 x0 = n * dc->fpp;281 x1 = x0 + dc->fpp ;276 x0 = n * 1.0 * dc->fpp; 277 x1 = x0 + dc->fpp + 0.5; 282 278 283 279 for (i = start + x0; i < start + x1; i += step) … … 289 285 if (d > maxd) { maxd = d; } 290 286 if (d < mind) { mind = d; } 291 // avgd += d * d;292 287 avgd += d; 293 288 numd++; … … 297 292 g_mutex_unlock (sample->sounddata->data_mutex); 298 293 299 // avgd = sqrt( avgd / numd);300 294 avgd /= numd; 301 295 302 296 #ifdef DEBUG_VERBOSE 303 g_print("display_cache_prepare_minmax: n:%i channel:%i offset:%i min:%f max:%f rms:%f\n", n, channel, n * dc->channels + channel, mind, maxd, avgd); 304 #endif 297 g_print("display_cache_prepare_minmax(%p): n:%i channel:%i offset:%i min:%f max:%f rms:%f\n", 298 dc, n, channel, (n + offset) * dc->channels + channel, mind, maxd, avgd); 299 #endif 300 305 301 dc->min[(n + offset) * dc->channels + channel] = mind; 306 302 dc->max[(n + offset) * dc->channels + channel] = maxd; … … 347 343 dc->max[off] = dc->min[off]; 348 344 dc->rms[off] = 0; 349 if (x == ceil(p / fpp ))345 if (x == ceil(p / fpp + 0.5)) 350 346 { 351 347 p++; … … 375 371 gint offset; 376 372 377 #ifdef DEBUG 378 g_print(" DisplayCache: PREPARE: %psample:%p length:%i start:%i end:%i\n",dc, sample, length, start, end);373 #ifdef DEBUG_VERBOSE 374 g_print("display_cache_prepare(%p): sample:%p length:%i start:%i end:%i\n",dc, sample, length, start, end); 379 375 #endif 380 376 … … 388 384 fpp = (end - start) * 1.0 / length; 389 385 390 #ifdef DEBUG 386 #ifdef DEBUG_VERBOSE 391 387 g_print("DisplayCache: fpp:%f\n",fpp); 392 388 g_print("DisplayCache: dc->fpp:%f\n",dc->fpp); … … 433 429 // and cache is valid 434 430 435 #ifdef DEBUG 431 #ifdef DEBUG_CUST 436 432 g_print("DisplayCache: HIT\n"); 437 433 #endif 438 434 439 435 // compute prepared view offset 440 dc->psoff = (start - dc->start) * 1.0/ dc->fpp;436 dc->psoff = (start - dc->start) / dc->fpp; 441 437 dc->peoff = dc->psoff + length; 442 438 … … 452 448 } else { 453 449 454 #ifdef DEBUG 450 #ifdef DEBUG_CUST 455 451 g_print("DisplayCache: MISS\n"); 456 452 #endif … … 462 458 // and alocate new cache 463 459 464 #ifdef DEBUG 460 #ifdef DEBUG_CUST 465 461 g_print("DisplayCache: MAJOR CHANGE\n"); 466 462 #endif … … 468 464 dc->fpp = fpp; 469 465 dc->start = start; 466 dc->end = end; 470 467 cstart = start; 471 468 dc->psoff = 0; 472 dc-> end = end;469 dc->peoff = length; 473 470 cend = end; 474 dc->peoff = length;475 471 clength = length; 476 472 dc->channels = sample->sounddata->format->channels; 477 473 offset = 0; 478 474 479 display_cache_realloc(dc, length);475 display_cache_realloc(dc, clength); 480 476 481 477 } else … … 486 482 // TODO: make valid parameters for sinc interpolation 487 483 488 #ifdef DEBUG 484 #ifdef DEBUG_CUST 489 485 g_print("DisplayCache: EXPAND CACHE RIGHT\n"); 490 486 #endif … … 492 488 dc->psoff = (start - dc->start) * 1.0 / dc->fpp; 493 489 dc->peoff = dc->psoff + length; 494 if (dc->fpp > 1) 495 { 496 cstart = dc->end; 497 clength = (end - dc->end) * 1.0 / dc->fpp; 498 offset = dc->end * 1.0 / dc->fpp; 499 } else { 490 cstart = dc->end; 491 clength = (end - dc->end) * 1.0 / dc->fpp + 1.0; 492 offset = dc->end * 1.0 / dc->fpp; 493 cend = end; 494 dc->end = end; 495 496 display_cache_right_realloc(dc, clength); 497 498 if (dc->fpp < 1){ 500 499 cstart = start; 501 500 clength = length; 502 501 offset = start * 1.0 / dc->fpp; 503 502 } 504 cend = end;505 dc->end = end;506 507 display_cache_right_realloc(dc, clength);508 503 509 504 } else … … 514 509 // TODO: make valid parameters for sinc interpolation 515 510 516 #ifdef DEBUG 511 #ifdef DEBUG_CUST 517 512 g_print("DisplayCache: EXPAND CACHE LEFT\n"); 518 513 #endif … … 520 515 dc->psoff = 0; 521 516 dc->peoff = dc->psoff + length; 522 if (dc->fpp > 1) 523 { 524 cend = dc->start; 525 clength = (dc->start - start) * 1.0 / dc->fpp; 526 offset = 0; 527 } else { 517 cend = dc->start; 518 clength = (dc->start - start) * 1.0 / dc->fpp + 1.0; 519 offset = 0; 520 cstart = start; 521 dc->start = start; 522 523 display_cache_left_realloc(dc, clength); 524 525 if (dc->fpp < 1){ 528 526 cend = end; 529 527 clength = length; 530 offset = 0;531 528 } 532 cstart = start;533 dc->start = start;534 535 display_cache_left_realloc(dc, clength);536 529 537 530 } else { 538 531 // we have only dirty cache 539 532 // or jump out of present cache 533 534 #ifdef DEBUG_CUST 535 g_print("DisplayCache: DIRTY/MISS CACHE\n"); 536 #endif 540 537 541 538 dc->start = start; … … 622 619 g_return_if_fail(points); 623 620 624 #ifdef DEBUG625 g_print("DisplayCacheMinMax: length:%i\n",length);626 g_print("DisplayCacheMinMax: dc->start:%i\n",dc->start);627 g_print("DisplayCacheMinMax: dc->psoff:%i\n",dc->psoff);628 g_print("DisplayCacheMinMax: dc->peoff:%i\n",dc->peoff);629 g_print("DisplayCacheMinMax: dc->fpp:%f\n",dc->fpp);630 g_print("DisplayCacheMinMax: offset:%i\n",offset);631 g_print("DisplayCacheMinMax: dc->len:%i\n",dc->len);632 #endif633 634 621 if ( offset + length > dc->peoff ) 635 622 { … … 665 652 g_return_if_fail(points); 666 653 667 #ifdef DEBUG668 g_print("DisplayCacheMinMaxRms: length:%i\n",length);669 g_print("DisplayCacheMinMaxRms: dc->start:%i\n",dc->start);670 g_print("DisplayCacheMinMaxRms: dc->psoff:%i\n",dc->psoff);671 g_print("DisplayCacheMinMaxRms: dc->peoff:%i\n",dc->peoff);672 g_print("DisplayCacheMinMaxRms: dc->fpp:%f\n",dc->fpp);673 g_print("DisplayCacheMinMaxRms: offset:%i\n",offset);674 g_print("DisplayCacheMinMaxRms: dc->len:%i\n",dc->len);675 #endif676 677 654 if ( offset + length > dc->peoff ) 678 655 { … … 687 664 688 665 off = (dc->psoff + offset) * dc->channels; 666 #ifdef DEBUG 667 g_print("DisplayCacheMinMaxRms(%p): off:%i length:%i\n",dc,off,length); 668 #endif 689 669 *min = dc->min + off; 690 670 *max = dc->max + off; sweep/branches/display-cache/src/display-cache.h
r424 r425 43 43 struct _DisplayCache 44 44 { 45 g floatfpp; // frames per pixel (display resolution)45 gdouble fpp; // frames per pixel (display resolution) 46 46 sw_framecount_t start; // first cached sample (in frames) 47 47 sw_framecount_t end; // last cached sample (in frames) sweep/branches/display-cache/src/sample-display.c
r424 r425 576 576 int h) 577 577 { 578 #ifdef DOUBLE_BUFFER 578 579 GdkWindow * window; 579 580 GdkVisual * visual; 581 #endif 580 582 sw_framecount_t len, vlen, vlendelta; 581 583 … … 635 637 s->height = h; 636 638 639 #ifdef DOUBLE_BUFFER 637 640 if(s->backing_pixmap) { 638 641 g_object_unref(s->backing_pixmap); … … 643 646 s->backing_pixmap = gdk_pixmap_new (GTK_WIDGET(s)->window, 644 647 w, h, visual->depth); 648 #endif 645 649 } 646 650 … … 893 897 #else 894 898 895 display_cache_get_minmaxrms(s->displaycache, &min, &max, &rms, &points, x, width); 899 #define IND_POINTS_COEF 0.5 900 gint x0, index; 901 902 x0 = x; 903 index = channel; 904 905 if (x > 0){ 906 x0--; 907 index += sample->sounddata->format->channels; 908 } 909 910 display_cache_get_minmaxrms(s->displaycache, &min, &max, &rms, &points, x0, width); 896 911 897 912 prevmaxd = max[channel]; 898 913 prevmind = min[channel]; 899 gint index = channel;900 914 901 915 while(width > 0) { … … 927 941 x, YPOS(mind)); 928 942 929 if (s->displaycache->fpp < 0.25&& points[index])943 if (s->displaycache->fpp < IND_POINTS_COEF && points[index]) 930 944 gdk_draw_rectangle(win, gc, 931 945 TRUE, sweep/branches/display-cache/src/sweep_sounddata.c
r304 r425 120 120 #endif 121 121 sounddata_clear_selection (sounddata); 122 g_mutex_free(sounddata->data_mutex); 122 123 g_free (sounddata); 123 g_mutex_free(sounddata->data_mutex);124 124 } 125 125 }
