Changeset a8af64458655e9f803cb2f754cfa04affaf944b8
- Timestamp:
- 06/28/08 11:37:27
(2 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1214645847 +0300
- git-parent:
[3c5f3a24ced2212136529fb8637072070d5ca58f]
- git-author:
- Rov Juvano <rovjuvano@users.sourceforge.net> 1214150967 -0400
- Message:
Use the Scaletempo audio filter
Scaletempo maintains the audio pitch when playback rate != 1.0 (i.e.
no chipmunk effect). This fixes the pitch scaling caused by using the
resampler to handle playback rate.
Signed-off-by: Rémi Denis-Courmont <rdenis@simphalempin.com>
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r55f1d32 |
ra8af644 |
|
| 255 | 255 | aout_filter_t * pp_filters[AOUT_MAX_FILTERS]; |
|---|
| 256 | 256 | int i_nb_filters; |
|---|
| | 257 | |
|---|
| | 258 | aout_filter_t * p_playback_rate_filter; |
|---|
| 257 | 259 | |
|---|
| 258 | 260 | /* resamplers */ |
|---|
| rd666030 |
ra8af644 |
|
| 402 | 402 | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| 403 | 403 | |
|---|
| | 404 | p_input->p_playback_rate_filter = NULL; |
|---|
| | 405 | for( int i = 0; i < p_input->i_nb_filters; i++ ) |
|---|
| | 406 | { |
|---|
| | 407 | aout_filter_t *p_filter = p_input->pp_filters[i]; |
|---|
| | 408 | if( strcmp( "scaletempo", p_filter->psz_object_name ) == 0 ) |
|---|
| | 409 | { |
|---|
| | 410 | p_input->p_playback_rate_filter = p_filter; |
|---|
| | 411 | break; |
|---|
| | 412 | } |
|---|
| | 413 | } |
|---|
| | 414 | if( ! p_input->p_playback_rate_filter && p_input->i_nb_resamplers > 0 ) |
|---|
| | 415 | { |
|---|
| | 416 | p_input->p_playback_rate_filter = p_input->pp_resamplers[0]; |
|---|
| | 417 | } |
|---|
| | 418 | |
|---|
| 404 | 419 | aout_FiltersHintBuffers( p_aout, p_input->pp_filters, |
|---|
| 405 | 420 | p_input->i_nb_filters, |
|---|
| … | … | |
| 476 | 491 | } |
|---|
| 477 | 492 | |
|---|
| 478 | | if( i_input_rate != INPUT_RATE_DEFAULT && p_input->i_nb_resamplers <= 0 ) |
|---|
| | 493 | if( i_input_rate != INPUT_RATE_DEFAULT && p_input->p_playback_rate_filter == NULL ) |
|---|
| 479 | 494 | { |
|---|
| 480 | 495 | inputDrop( p_aout, p_input, p_buffer ); |
|---|
| … | … | |
| 503 | 518 | #endif |
|---|
| 504 | 519 | |
|---|
| 505 | | /* Handle input rate change by modifying resampler input rate */ |
|---|
| | 520 | /* Handle input rate change, but keep drift correction */ |
|---|
| 506 | 521 | if( i_input_rate != p_input->i_last_input_rate ) |
|---|
| 507 | 522 | { |
|---|
| 508 | | unsigned int * const pi_rate = &p_input->pp_resamplers[0]->input.i_rate; |
|---|
| | 523 | unsigned int * const pi_rate = &p_input->p_playback_rate_filter->input.i_rate; |
|---|
| 509 | 524 | #define F(r,ir) ( INPUT_RATE_DEFAULT * (r) / (ir) ) |
|---|
| 510 | 525 | const int i_delta = *pi_rate - F(p_input->input.i_rate,p_input->i_last_input_rate); |
|---|
| … | … | |
| 552 | 567 | /* If the audio drift is too big then it's not worth trying to resample |
|---|
| 553 | 568 | * the audio. */ |
|---|
| | 569 | mtime_t i_pts_tolerance = 3 * AOUT_PTS_TOLERANCE * i_input_rate / INPUT_RATE_DEFAULT; |
|---|
| 554 | 570 | if ( start_date != 0 && |
|---|
| 555 | | ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) ) |
|---|
| | 571 | ( start_date < p_buffer->start_date - i_pts_tolerance ) ) |
|---|
| 556 | 572 | { |
|---|
| 557 | 573 | msg_Warn( p_aout, "audio drift is too big (%"PRId64"), clearing out", |
|---|
| … | … | |
| 567 | 583 | } |
|---|
| 568 | 584 | else if ( start_date != 0 && |
|---|
| 569 | | ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) ) |
|---|
| | 585 | ( start_date > p_buffer->start_date + i_pts_tolerance) ) |
|---|
| 570 | 586 | { |
|---|
| 571 | 587 | msg_Warn( p_aout, "audio drift is too big (%"PRId64"), dropping buffer", |
|---|
| … | … | |
| 630 | 646 | /* Check if everything is back to normal, in which case we can stop the |
|---|
| 631 | 647 | * resampling */ |
|---|
| 632 | | if( p_input->pp_resamplers[0]->input.i_rate == 1000 * p_input->input.i_rate / i_input_rate ) |
|---|
| | 648 | unsigned int i_nominal_rate = |
|---|
| | 649 | (p_input->pp_resamplers[0] == p_input->p_playback_rate_filter) |
|---|
| | 650 | ? INPUT_RATE_DEFAULT * p_input->input.i_rate / i_input_rate |
|---|
| | 651 | : p_input->input.i_rate; |
|---|
| | 652 | if( p_input->pp_resamplers[0]->input.i_rate == i_nominal_rate ) |
|---|
| 633 | 653 | { |
|---|
| 634 | 654 | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| … | … | |
| 734 | 754 | if( p_input->i_nb_resamplers != 0 ) |
|---|
| 735 | 755 | { |
|---|
| 736 | | p_input->pp_resamplers[0]->input.i_rate = INPUT_RATE_DEFAULT * |
|---|
| 737 | | p_input->input.i_rate / p_input->i_last_input_rate; |
|---|
| | 756 | p_input->pp_resamplers[0]->input.i_rate = |
|---|
| | 757 | ( p_input->pp_resamplers[0] == p_input->p_playback_rate_filter ) |
|---|
| | 758 | ? INPUT_RATE_DEFAULT * p_input->input.i_rate / p_input->i_last_input_rate |
|---|
| | 759 | : p_input->input.i_rate; |
|---|
| 738 | 760 | p_input->pp_resamplers[0]->b_continuity = false; |
|---|
| 739 | 761 | } |
|---|