Changeset 70a8bb9649c3e44350d0fd579c24b8a9ddd7af34
- Timestamp:
- 06/12/07 21:46:35
(1 year ago)
- Author:
- Laurent Aimar <fenrir@videolan.org>
- git-committer:
- Laurent Aimar <fenrir@videolan.org> 1181677595 +0000
- git-parent:
[8f1901a659e0778dd4c6086bcc3b9d7174d1abaf]
- git-author:
- Laurent Aimar <fenrir@videolan.org> 1181677595 +0000
- Message:
All: preliminary support for audio while playing faster/slower (1/4 -> 4).
It use our standard resampler to do it and so we do not keep
pitch yet (I am working on a soundtouch resampler).
Please test any regression.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rbf48c33 |
r70a8bb9 |
|
| 170 | 170 | #define A52_FRAME_NB 1536 |
|---|
| 171 | 171 | |
|---|
| | 172 | /* Max input rate factor (1/4 -> 4) */ |
|---|
| | 173 | #define AOUT_MAX_INPUT_RATE (4) |
|---|
| | 174 | |
|---|
| 172 | 175 | /** date incrementation helper structure without long-term |
|---|
| 173 | 176 | * rounding errors |
|---|
| … | … | |
| 278 | 281 | vlc_bool_t b_changed; |
|---|
| 279 | 282 | |
|---|
| | 283 | /* last rate from input */ |
|---|
| | 284 | int i_last_input_rate; |
|---|
| 280 | 285 | /* internal caching delay from input */ |
|---|
| 281 | 286 | int i_pts_delay; |
|---|
| rd3fe7f2 |
r70a8bb9 |
|
| 124 | 124 | /* Calculate worst case for the length of the filter wing */ |
|---|
| 125 | 125 | d_factor = (double)p_filter->output.i_rate |
|---|
| 126 | | / p_filter->input.i_rate; |
|---|
| | 126 | / p_filter->input.i_rate / AOUT_MAX_INPUT_RATE; |
|---|
| 127 | 127 | i_filter_wing = ((SMALL_FILTER_NMULT + 1)/2.0) |
|---|
| 128 | 128 | * __MAX(1.0, 1.0/d_factor) + 10; |
|---|
| rab1b0eb |
r70a8bb9 |
|
| 30 | 30 | #include <vlc_codec.h> |
|---|
| 31 | 31 | #include <vlc_aout.h> |
|---|
| | 32 | #include <vlc_input.h> |
|---|
| 32 | 33 | #include <vlc_block_helper.h> |
|---|
| 33 | 34 | |
|---|
| … | … | |
| 58 | 59 | unsigned int i_rate, i_channels, i_channels_conf; |
|---|
| 59 | 60 | |
|---|
| | 61 | int i_input_rate; |
|---|
| 60 | 62 | }; |
|---|
| 61 | 63 | |
|---|
| … | … | |
| 129 | 131 | |
|---|
| 130 | 132 | p_sys->bytestream = block_BytestreamInit( p_dec ); |
|---|
| | 133 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 131 | 134 | |
|---|
| 132 | 135 | /* Set output properties */ |
|---|
| … | … | |
| 188 | 191 | } |
|---|
| 189 | 192 | |
|---|
| | 193 | if( (*pp_block)->i_rate > 0 ) |
|---|
| | 194 | p_sys->i_input_rate = (*pp_block)->i_rate; |
|---|
| | 195 | |
|---|
| 190 | 196 | block_BytestreamPush( &p_sys->bytestream, *pp_block ); |
|---|
| 191 | 197 | |
|---|
| … | … | |
| 386 | 392 | |
|---|
| 387 | 393 | p_buf->start_date = aout_DateGet( &p_sys->end_date ); |
|---|
| 388 | | p_buf->end_date = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB ); |
|---|
| | 394 | p_buf->end_date = aout_DateIncrement( &p_sys->end_date, |
|---|
| | 395 | A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT ); |
|---|
| 389 | 396 | |
|---|
| 390 | 397 | return p_buf; |
|---|
| … | … | |
| 404 | 411 | p_block->i_pts = p_block->i_dts = aout_DateGet( &p_sys->end_date ); |
|---|
| 405 | 412 | |
|---|
| 406 | | p_block->i_length = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB ) - |
|---|
| 407 | | p_block->i_pts; |
|---|
| | 413 | p_block->i_length = |
|---|
| | 414 | aout_DateIncrement( &p_sys->end_date, |
|---|
| | 415 | A52_FRAME_NB * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) - |
|---|
| | 416 | p_block->i_pts; |
|---|
| 408 | 417 | |
|---|
| 409 | 418 | return p_block; |
|---|
| r7b0773e |
r70a8bb9 |
|
| 70 | 70 | |
|---|
| 71 | 71 | vlc_bool_t b_sbr, b_ps; |
|---|
| | 72 | |
|---|
| | 73 | int i_input_rate; |
|---|
| 72 | 74 | }; |
|---|
| 73 | 75 | |
|---|
| … | … | |
| 167 | 169 | p_sys->p_buffer = 0; |
|---|
| 168 | 170 | |
|---|
| | 171 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| | 172 | |
|---|
| 169 | 173 | /* Faad2 can't deal with truncated data (eg. from MPEG TS) */ |
|---|
| 170 | 174 | p_dec->b_need_packetized = VLC_TRUE; |
|---|
| … | … | |
| 191 | 195 | return NULL; |
|---|
| 192 | 196 | } |
|---|
| | 197 | |
|---|
| | 198 | if( p_block->i_rate > 0 ) |
|---|
| | 199 | p_sys->i_input_rate = p_block->i_rate; |
|---|
| 193 | 200 | |
|---|
| 194 | 201 | /* Append the block to the temporary buffer */ |
|---|
| … | … | |
| 375 | 382 | p_out->start_date = aout_DateGet( &p_sys->date ); |
|---|
| 376 | 383 | p_out->end_date = aout_DateIncrement( &p_sys->date, |
|---|
| 377 | | frame.samples / frame.channels ); |
|---|
| | 384 | (frame.samples / frame.channels) * p_sys->i_input_rate / INPUT_RATE_DEFAULT ); |
|---|
| 378 | 385 | |
|---|
| 379 | 386 | DoReordering( p_dec, (uint32_t *)p_out->p_buffer, samples, |
|---|
| r1fc3e36 |
r70a8bb9 |
|
| 29 | 29 | #include <vlc_aout.h> |
|---|
| 30 | 30 | #include <vlc_codec.h> |
|---|
| | 31 | #include <vlc_input.h> |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | /* ffmpeg header */ |
|---|
| … | … | |
| 76 | 77 | /* */ |
|---|
| 77 | 78 | int i_reject_count; |
|---|
| | 79 | |
|---|
| | 80 | int i_input_rate; |
|---|
| 78 | 81 | }; |
|---|
| 79 | 82 | |
|---|
| … | … | |
| 147 | 150 | p_sys->i_samples = 0; |
|---|
| 148 | 151 | p_sys->i_reject_count = 0; |
|---|
| | 152 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 149 | 153 | |
|---|
| 150 | 154 | aout_DateSet( &p_sys->end_date, 0 ); |
|---|
| … | … | |
| 179 | 183 | |
|---|
| 180 | 184 | p_buffer->start_date = aout_DateGet( &p_sys->end_date ); |
|---|
| 181 | | p_buffer->end_date = aout_DateIncrement( &p_sys->end_date, i_samples ); |
|---|
| | 185 | p_buffer->end_date = aout_DateIncrement( &p_sys->end_date, |
|---|
| | 186 | i_samples * p_sys->i_input_rate / INPUT_RATE_DEFAULT ); |
|---|
| 182 | 187 | |
|---|
| 183 | 188 | memcpy( p_buffer->p_buffer, p_sys->p_samples, p_buffer->i_nb_bytes ); |
|---|
| … | … | |
| 202 | 207 | |
|---|
| 203 | 208 | p_block = *pp_block; |
|---|
| | 209 | |
|---|
| | 210 | if( p_block->i_rate > 0 ) |
|---|
| | 211 | p_sys->i_input_rate = p_block->i_rate; |
|---|
| 204 | 212 | |
|---|
| 205 | 213 | if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) |
|---|
| rbf48c33 |
r70a8bb9 |
|
| 31 | 31 | #include <vlc_codec.h> |
|---|
| 32 | 32 | #include <vlc_aout.h> |
|---|
| | 33 | #include <vlc_input.h> |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | #include <vlc_block_helper.h> |
|---|
| … | … | |
| 63 | 64 | |
|---|
| 64 | 65 | vlc_bool_t b_discontinuity; |
|---|
| | 66 | |
|---|
| | 67 | int i_input_rate; |
|---|
| 65 | 68 | }; |
|---|
| 66 | 69 | |
|---|
| … | … | |
| 156 | 159 | p_sys->bytestream = block_BytestreamInit( p_dec ); |
|---|
| 157 | 160 | p_sys->b_discontinuity = VLC_FALSE; |
|---|
| | 161 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 158 | 162 | |
|---|
| 159 | 163 | /* Set output properties */ |
|---|
| … | … | |
| 220 | 224 | return NULL; |
|---|
| 221 | 225 | } |
|---|
| | 226 | |
|---|
| | 227 | if( (*pp_block)->i_rate > 0 ) |
|---|
| | 228 | p_sys->i_input_rate = (*pp_block)->i_rate; |
|---|
| 222 | 229 | |
|---|
| 223 | 230 | block_BytestreamPush( &p_sys->bytestream, *pp_block ); |
|---|
| … | … | |
| 536 | 543 | p_buf->start_date = aout_DateGet( &p_sys->end_date ); |
|---|
| 537 | 544 | p_buf->end_date = |
|---|
| 538 | | aout_DateIncrement( &p_sys->end_date, p_sys->i_frame_length ); |
|---|
| | 545 | aout_DateIncrement( &p_sys->end_date, |
|---|
| | 546 | p_sys->i_frame_length * p_sys->i_input_rate / INPUT_RATE_DEFAULT ); |
|---|
| 539 | 547 | p_buf->b_discontinuity = p_sys->b_discontinuity; |
|---|
| 540 | 548 | p_sys->b_discontinuity = VLC_FALSE; |
|---|
| … | … | |
| 560 | 568 | |
|---|
| 561 | 569 | p_block->i_length = |
|---|
| 562 | | aout_DateIncrement( &p_sys->end_date, p_sys->i_frame_length ) - |
|---|
| 563 | | p_block->i_pts; |
|---|
| | 570 | aout_DateIncrement( &p_sys->end_date, |
|---|
| | 571 | p_sys->i_frame_length * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) - |
|---|
| | 572 | p_block->i_pts; |
|---|
| 564 | 573 | |
|---|
| 565 | 574 | return p_block; |
|---|
| r61d5259 |
r70a8bb9 |
|
| 79 | 79 | int i_last_block_size; |
|---|
| 80 | 80 | |
|---|
| | 81 | int i_input_rate; |
|---|
| | 82 | |
|---|
| 81 | 83 | /* |
|---|
| 82 | 84 | ** Channel reordering |
|---|
| … | … | |
| 238 | 240 | p_sys->b_packetizer = VLC_FALSE; |
|---|
| 239 | 241 | p_sys->i_headers = 0; |
|---|
| | 242 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 240 | 243 | |
|---|
| 241 | 244 | /* Take care of vorbis init */ |
|---|
| … | … | |
| 292 | 295 | oggpacket.packet = (*pp_block)->p_buffer; |
|---|
| 293 | 296 | oggpacket.bytes = (*pp_block)->i_buffer; |
|---|
| | 297 | |
|---|
| | 298 | if( (*pp_block)->i_rate > 0 ) |
|---|
| | 299 | p_sys->i_input_rate = (*pp_block)->i_rate; |
|---|
| 294 | 300 | } |
|---|
| 295 | 301 | else |
|---|
| … | … | |
| 564 | 570 | p_aout_buffer->start_date = aout_DateGet( &p_sys->end_date ); |
|---|
| 565 | 571 | p_aout_buffer->end_date = aout_DateIncrement( &p_sys->end_date, |
|---|
| 566 | | i_samples ); |
|---|
| | 572 | i_samples * p_sys->i_input_rate / INPUT_RATE_DEFAULT ); |
|---|
| 567 | 573 | return p_aout_buffer; |
|---|
| 568 | 574 | } |
|---|
| … | … | |
| 591 | 597 | |
|---|
| 592 | 598 | if( p_sys->i_headers >= 3 ) |
|---|
| 593 | | p_block->i_length = aout_DateIncrement( &p_sys->end_date, i_samples ) - |
|---|
| 594 | | p_block->i_pts; |
|---|
| | 599 | p_block->i_length = aout_DateIncrement( &p_sys->end_date, |
|---|
| | 600 | i_samples * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) - |
|---|
| | 601 | p_block->i_pts; |
|---|
| 595 | 602 | else |
|---|
| 596 | 603 | p_block->i_length = 0; |
|---|
| rab1b0eb |
r70a8bb9 |
|
| 35 | 35 | #include <vlc_sout.h> |
|---|
| 36 | 36 | #include <vlc_codecs.h> |
|---|
| | 37 | #include <vlc_input.h> |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | #include "vlc_block_helper.h" |
|---|
| … | … | |
| 73 | 74 | unsigned int i_channels; |
|---|
| 74 | 75 | unsigned int i_rate, i_frame_length, i_header_size; |
|---|
| | 76 | |
|---|
| | 77 | int i_input_rate; |
|---|
| 75 | 78 | }; |
|---|
| 76 | 79 | |
|---|
| … | … | |
| 147 | 150 | aout_DateSet( &p_sys->end_date, 0 ); |
|---|
| 148 | 151 | p_sys->bytestream = block_BytestreamInit( p_dec ); |
|---|
| | 152 | p_sys->i_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 149 | 153 | |
|---|
| 150 | 154 | /* Set output properties */ |
|---|
| … | … | |
| 242 | 246 | |
|---|
| 243 | 247 | p_block->i_length = aout_DateIncrement( &p_sys->end_date, |
|---|
| 244 | | p_dec->fmt_out.audio.i_frame_length ) - p_block->i_pts; |
|---|
| | 248 | p_dec->fmt_out.audio.i_frame_length * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) - p_block->i_pts; |
|---|
| 245 | 249 | |
|---|
| 246 | 250 | return p_block; |
|---|
| … | … | |
| 278 | 282 | } |
|---|
| 279 | 283 | |
|---|
| | 284 | if( (*pp_block)->i_rate > 0 ) |
|---|
| | 285 | p_sys->i_input_rate = (*pp_block)->i_rate; |
|---|
| | 286 | |
|---|
| 280 | 287 | block_BytestreamPush( &p_sys->bytestream, *pp_block ); |
|---|
| 281 | 288 | |
|---|
| … | … | |
| 444 | 451 | |
|---|
| 445 | 452 | p_block->i_length = aout_DateIncrement( &p_sys->end_date, |
|---|
| 446 | | p_sys->i_frame_length ) - p_block->i_pts; |
|---|
| | 453 | p_sys->i_frame_length * p_sys->i_input_rate / INPUT_RATE_DEFAULT ) - |
|---|
| | 454 | p_block->i_pts; |
|---|
| 447 | 455 | |
|---|
| 448 | 456 | *pp_out_buffer = p_block; |
|---|
| rbf48c33 |
r70a8bb9 |
|
| 80 | 80 | int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ); |
|---|
| 81 | 81 | int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, |
|---|
| 82 | | aout_buffer_t * p_buffer ); |
|---|
| | 82 | aout_buffer_t * p_buffer, int i_input_rate ); |
|---|
| 83 | 83 | |
|---|
| 84 | 84 | /* From filters.c : */ |
|---|
| … | … | |
| 130 | 130 | aout_buffer_t * aout_DecNewBuffer( aout_instance_t *, aout_input_t *, size_t ); |
|---|
| 131 | 131 | void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * ); |
|---|
| 132 | | int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t * ); |
|---|
| | 132 | int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_input_rate ); |
|---|
| 133 | 133 | |
|---|
| r4f6b904 |
r70a8bb9 |
|
| 311 | 311 | *****************************************************************************/ |
|---|
| 312 | 312 | int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, |
|---|
| 313 | | aout_buffer_t * p_buffer ) |
|---|
| | 313 | aout_buffer_t * p_buffer, int i_input_rate ) |
|---|
| 314 | 314 | { |
|---|
| 315 | 315 | if ( p_buffer->start_date == 0 ) |
|---|
| … | … | |
| 318 | 318 | aout_BufferFree( p_buffer ); |
|---|
| 319 | 319 | return -1; |
|---|
| | 320 | } |
|---|
| | 321 | |
|---|
| | 322 | if( i_input_rate > INPUT_RATE_DEFAULT * AOUT_MAX_INPUT_RATE || |
|---|
| | 323 | i_input_rate < INPUT_RATE_DEFAULT / AOUT_MAX_INPUT_RATE ) |
|---|
| | 324 | { |
|---|
| | 325 | aout_BufferFree( p_buffer ); |
|---|
| | 326 | return 0; |
|---|
| 320 | 327 | } |
|---|
| 321 | 328 | |
|---|
| … | … | |
| 376 | 383 | mwait( p_buffer->start_date - AOUT_MAX_PREPARE_TIME ); |
|---|
| 377 | 384 | |
|---|
| 378 | | if ( aout_InputPlay( p_aout, p_input, p_buffer ) == -1 ) |
|---|
| | 385 | if ( aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate ) == -1 ) |
|---|
| 379 | 386 | { |
|---|
| 380 | 387 | vlc_mutex_unlock( &p_input->lock ); |
|---|
| r0e39834 |
r70a8bb9 |
|
| 294 | 294 | |
|---|
| 295 | 295 | int i_output_size = p_filter->output.i_bytes_per_frame |
|---|
| 296 | | * p_filter->output.i_rate |
|---|
| | 296 | * p_filter->output.i_rate * AOUT_MAX_INPUT_RATE |
|---|
| 297 | 297 | / p_filter->output.i_frame_length; |
|---|
| 298 | 298 | int i_input_size = p_filter->input.i_bytes_per_frame |
|---|
| 299 | | * p_filter->input.i_rate |
|---|
| | 299 | * p_filter->input.i_rate * AOUT_MAX_INPUT_RATE |
|---|
| 300 | 300 | / p_filter->input.i_frame_length; |
|---|
| 301 | 301 | |
|---|
| … | … | |
| 358 | 358 | *pp_input_buffer = p_output_buffer; |
|---|
| 359 | 359 | } |
|---|
| 360 | | } |
|---|
| 361 | | } |
|---|
| 362 | | |
|---|
| | 360 | |
|---|
| | 361 | if( p_output_buffer->i_nb_samples <= 0 ) |
|---|
| | 362 | break; |
|---|
| | 363 | } |
|---|
| | 364 | } |
|---|
| | 365 | |
|---|
| r4f6b904 |
r70a8bb9 |
|
| 45 | 45 | |
|---|
| 46 | 46 | static void inputFailure( aout_instance_t *, aout_input_t *, const char * ); |
|---|
| 47 | | static void inputDrop( aout_instance_t *, aout_input_t * ); |
|---|
| | 47 | static void inputDrop( aout_instance_t *, aout_input_t *, aout_buffer_t * ); |
|---|
| | 48 | static void inputResamplingStop( aout_input_t *p_input ); |
|---|
| | 49 | |
|---|
| 48 | 50 | static int VisualizationCallback( vlc_object_t *, char const *, |
|---|
| 49 | 51 | vlc_value_t, vlc_value_t, void * ); |
|---|
| … | … | |
| 365 | 367 | * p_input->input.i_rate |
|---|
| 366 | 368 | / p_input->input.i_frame_length) ); |
|---|
| 367 | | |
|---|
| 368 | 369 | /* Success */ |
|---|
| 369 | 370 | p_input->b_error = VLC_FALSE; |
|---|
| 370 | 371 | p_input->b_restart = VLC_FALSE; |
|---|
| | 372 | p_input->i_last_input_rate = INPUT_RATE_DEFAULT; |
|---|
| 371 | 373 | |
|---|
| 372 | 374 | return 0; |
|---|
| … | … | |
| 398 | 400 | * This function must be entered with the input lock. |
|---|
| 399 | 401 | *****************************************************************************/ |
|---|
| | 402 | /* XXX Do not activate it !! */ |
|---|
| | 403 | //#define AOUT_PROCESS_BEFORE_CHEKS |
|---|
| 400 | 404 | int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, |
|---|
| 401 | | aout_buffer_t * p_buffer ) |
|---|
| | 405 | aout_buffer_t * p_buffer, int i_input_rate ) |
|---|
| 402 | 406 | { |
|---|
| 403 | 407 | mtime_t start_date; |
|---|
| … | … | |
| 421 | 425 | |
|---|
| 422 | 426 | vlc_mutex_unlock( &p_aout->mixer_lock ); |
|---|
| | 427 | } |
|---|
| | 428 | |
|---|
| | 429 | #ifdef AOUT_PROCESS_BEFORE_CHEKS |
|---|
| | 430 | /* Run pre-filters. */ |
|---|
| | 431 | aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters, |
|---|
| | 432 | &p_buffer ); |
|---|
| | 433 | |
|---|
| | 434 | /* Actually run the resampler now. */ |
|---|
| | 435 | if ( p_input->i_nb_resamplers > 0 ) |
|---|
| | 436 | { |
|---|
| | 437 | const mtime_t i_date = p_buffer->start_date; |
|---|
| | 438 | aout_FiltersPlay( p_aout, p_input->pp_resamplers, |
|---|
| | 439 | p_input->i_nb_resamplers, |
|---|
| | 440 | &p_buffer ); |
|---|
| | 441 | } |
|---|
| | 442 | |
|---|
| | 443 | if( p_buffer->i_nb_samples <= 0 ) |
|---|
| | 444 | { |
|---|
| | 445 | aout_BufferFree( p_buffer ); |
|---|
| | 446 | return 0; |
|---|
| | 447 | } |
|---|
| | 448 | #endif |
|---|
| | 449 | |
|---|
| | 450 | /* Handle input rate change by modifying resampler input rate */ |
|---|
| | 451 | if( i_input_rate != p_input->i_last_input_rate ) |
|---|
| | 452 | { |
|---|
| | 453 | unsigned int * const pi_rate = &p_input->pp_resamplers[0]->input.i_rate; |
|---|
| | 454 | #define F(r,ir) ( INPUT_RATE_DEFAULT * (r) / (ir) ) |
|---|
| | 455 | const int i_delta = *pi_rate - F(p_input->input.i_rate,p_input->i_last_input_rate); |
|---|
| | 456 | *pi_rate = F(p_input->input.i_rate + i_delta, i_input_rate); |
|---|
| | 457 | #undef F |
|---|
| | 458 | p_input->i_last_input_rate = i_input_rate; |
|---|
| 423 | 459 | } |
|---|
| 424 | 460 | |
|---|
| … | … | |
| 443 | 479 | if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE ) |
|---|
| 444 | 480 | msg_Warn( p_aout, "timing screwed, stopping resampling" ); |
|---|
| 445 | | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| 446 | | if ( p_input->i_nb_resamplers != 0 ) |
|---|
| 447 | | { |
|---|
| 448 | | p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate; |
|---|
| 449 | | p_input->pp_resamplers[0]->b_continuity = VLC_FALSE; |
|---|
| 450 | | } |
|---|
| | 481 | inputResamplingStop( p_input ); |
|---|
| 451 | 482 | start_date = 0; |
|---|
| 452 | | inputDrop( p_aout, p_input ); |
|---|
| 453 | 483 | } |
|---|
| 454 | 484 | |
|---|
| … | … | |
| 460 | 490 | mdate() - p_buffer->start_date ); |
|---|
| 461 | 491 | |
|---|
| 462 | | inputDrop( p_aout, p_input ); |
|---|
| 463 | | aout_BufferFree( p_buffer ); |
|---|
| 464 | | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| 465 | | if ( p_input->i_nb_resamplers != 0 ) |
|---|
| 466 | | { |
|---|
| 467 | | p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate; |
|---|
| 468 | | p_input->pp_resamplers[0]->b_continuity = VLC_FALSE; |
|---|
| 469 | | } |
|---|
| | 492 | inputDrop( p_aout, p_input, p_buffer ); |
|---|
| | 493 | inputResamplingStop( p_input ); |
|---|
| 470 | 494 | return 0; |
|---|
| 471 | 495 | } |
|---|
| … | … | |
| 484 | 508 | if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE ) |
|---|
| 485 | 509 | msg_Warn( p_aout, "timing screwed, stopping resampling" ); |
|---|
| 486 | | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| 487 | | if ( p_input->i_nb_resamplers != 0 ) |
|---|
| 488 | | { |
|---|
| 489 | | p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate; |
|---|
| 490 | | p_input->pp_resamplers[0]->b_continuity = VLC_FALSE; |
|---|
| 491 | | } |
|---|
| | 510 | inputResamplingStop( p_input ); |
|---|
| 492 | 511 | start_date = 0; |
|---|
| 493 | 512 | } |
|---|
| … | … | |
| 497 | 516 | msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer", |
|---|
| 498 | 517 | start_date - p_buffer->start_date ); |
|---|
| 499 | | aout_BufferFree( p_buffer ); |
|---|
| 500 | | inputDrop( p_aout, p_input ); |
|---|
| | 518 | inputDrop( p_aout, p_input, p_buffer ); |
|---|
| 501 | 519 | return 0; |
|---|
| 502 | 520 | } |
|---|
| … | … | |
| 504 | 522 | if ( start_date == 0 ) start_date = p_buffer->start_date; |
|---|
| 505 | 523 | |
|---|
| | 524 | #ifndef AOUT_PROCESS_BEFORE_CHEKS |
|---|
| 506 | 525 | /* Run pre-filters. */ |
|---|
| 507 | | |
|---|
| 508 | 526 | aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters, |
|---|
| 509 | 527 | &p_buffer ); |
|---|
| | 528 | #endif |
|---|
| 510 | 529 | |
|---|
| 511 | 530 | /* Run the resampler if needed. |
|---|
| … | … | |
| 556 | 575 | /* Check if everything is back to normal, in which case we can stop the |
|---|
| 557 | 576 | * resampling */ |
|---|
| 558 | | if( p_input->pp_resamplers[0]->input.i_rate == |
|---|
| 559 | | p_input->input.i_rate ) |
|---|
| | 577 | if( p_input->pp_resamplers[0]->input.i_rate == 1000 * p_input->input.i_rate / i_input_rate ) |
|---|
| 560 | 578 | { |
|---|
| 561 | 579 | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| … | … | |
| 583 | 601 | * is bad. We'd better stop the resampling right now. */ |
|---|
| 584 | 602 | msg_Warn( p_aout, "timing screwed, stopping resampling" ); |
|---|
| 585 | | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| 586 | | p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate; |
|---|
| 587 | | } |
|---|
| 588 | | } |
|---|
| | 603 | inputResamplingStop( p_input ); |
|---|
| | 604 | } |
|---|
| | 605 | } |
|---|
| | 606 | |
|---|
| | 607 | #ifndef AOUT_PROCESS_BEFORE_CHEKS |
|---|
| | 608 | /* Actually run the resampler now. */ |
|---|
| | 609 | if ( p_input->i_nb_resamplers > 0 ) |
|---|
| | 610 | { |
|---|
| | 611 | aout_FiltersPlay( p_aout, p_input->pp_resamplers, |
|---|
| | 612 | p_input->i_nb_resamplers, |
|---|
| | 613 | &p_buffer ); |
|---|
| | 614 | } |
|---|
| | 615 | |
|---|
| | 616 | if( p_buffer->i_nb_samples <= 0 ) |
|---|
| | 617 | { |
|---|
| | 618 | aout_BufferFree( p_buffer ); |
|---|
| | 619 | return 0; |
|---|
| | 620 | } |
|---|
| | 621 | #endif |
|---|
| 589 | 622 | |
|---|
| 590 | 623 | /* Adding the start date will be managed by aout_FifoPush(). */ |
|---|
| … | … | |
| 593 | 626 | p_buffer->start_date = start_date; |
|---|
| 594 | 627 | |
|---|
| 595 | | /* Actually run the resampler now. */ |
|---|
| 596 | | if ( p_input->i_nb_resamplers > 0 ) |
|---|
| 597 | | { |
|---|
| 598 | | aout_FiltersPlay( p_aout, p_input->pp_resamplers, |
|---|
| 599 | | p_input->i_nb_resamplers, |
|---|
| 600 | | &p_buffer ); |
|---|
| 601 | | } |
|---|
| 602 | | |
|---|
| 603 | 628 | vlc_mutex_lock( &p_aout->input_fifos_lock ); |
|---|
| 604 | 629 | aout_FifoPush( p_aout, &p_input->fifo, p_buffer ); |
|---|
| 605 | 630 | vlc_mutex_unlock( &p_aout->input_fifos_lock ); |
|---|
| 606 | | |
|---|
| 607 | 631 | return 0; |
|---|
| 608 | 632 | } |
|---|
| … | … | |
| 633 | 657 | } |
|---|
| 634 | 658 | |
|---|
| 635 | | static void inputDrop( aout_instance_t *p_aout, aout_input_t *p_input ) |
|---|
| | 659 | static void inputDrop( aout_instance_t *p_aout, aout_input_t *p_input, aout_buffer_t *p_buffer ) |
|---|
| 636 | 660 | { |
|---|
| | 661 | aout_BufferFree( p_buffer ); |
|---|
| | 662 | |
|---|
| 637 | 663 | if( !p_input->p_input_thread ) |
|---|
| 638 | 664 | return; |
|---|
| … | … | |
| 641 | 667 | stats_UpdateInteger( p_aout, p_input->p_input_thread->p->counters.p_lost_abuffers, 1, NULL ); |
|---|
| 642 | 668 | vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock); |
|---|
| | 669 | } |
|---|
| | 670 | |
|---|
| | 671 | static void inputResamplingStop( aout_input_t *p_input ) |
|---|
| | 672 | { |
|---|
| | 673 | p_input->i_resampling_type = AOUT_RESAMPLING_NONE; |
|---|
| | 674 | if( p_input->i_nb_resamplers != 0 ) |
|---|
| | 675 | { |
|---|
| | 676 | p_input->pp_resamplers[0]->input.i_rate = INPUT_RATE_DEFAULT * |
|---|
| | 677 | p_input->input.i_rate / p_input->i_last_input_rate; |
|---|
| | 678 | p_input->pp_resamplers[0]->b_continuity = VLC_FALSE; |
|---|
| | 679 | } |
|---|
| 643 | 680 | } |
|---|
| 644 | 681 | |
|---|
| r8919d21 |
r70a8bb9 |
|
| 469 | 469 | { |
|---|
| 470 | 470 | input_thread_t *p_input = p_dec->p_owner->p_input; |
|---|
| | 471 | const int i_rate = p_block->i_rate; |
|---|
| 471 | 472 | aout_buffer_t *p_aout_buf; |
|---|
| 472 | 473 | |
|---|
| … | … | |
| 492 | 493 | aout_DecPlay( p_dec->p_owner->p_aout, |
|---|
| 493 | 494 | p_dec->p_owner->p_aout_input, |
|---|
| 494 | | p_aout_buf ); |
|---|
| | 495 | p_aout_buf, i_rate ); |
|---|
| 495 | 496 | } |
|---|
| 496 | 497 | } |
|---|
| … | … | |
| 524 | 525 | picture_t *p_pic = p_vout->render.pp_picture[i]; |
|---|
| 525 | 526 | |
|---|
| 526 | | if( p_pic->i_status != READY_PICTURE ) |
|---|
| | 527 | if( p_pic->i_status == READY_PICTURE || |
|---|
| | 528 | p_pic->i_status == DISPLAYED_PICTURE ) |
|---|
| 527 | 529 | { |
|---|
| 528 | 530 | /* We cannot change picture status if it is in READY_PICTURE state, |
|---|
| re444ba7 |
r70a8bb9 |
|
| 34 | 34 | #include <vlc_es_out.h> |
|---|
| 35 | 35 | #include <vlc_block.h> |
|---|
| | 36 | #include <vlc_aout.h> |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | #include "input_internal.h" |
|---|
| … | … | |
| 1217 | 1218 | } |
|---|
| 1218 | 1219 | |
|---|
| 1219 | | /* +11 -> avoid null value with non null dts/pts */ |
|---|
| 1220 | 1220 | if( p_block->i_dts > 0 && (p_block->i_flags&BLOCK_FLAG_PREROLL) ) |
|---|
| 1221 | 1221 | { |
|---|
| … | … | |
| 1253 | 1253 | |
|---|
| 1254 | 1254 | /* TODO handle mute */ |
|---|
| 1255 | | if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || |
|---|
| 1256 | | p_input->p->i_rate == INPUT_RATE_DEFAULT ) ) |
|---|
| | 1255 | if( es->p_dec && |
|---|
| | 1256 | ( es->fmt.i_cat != AUDIO_ES || |
|---|
| | 1257 | ( p_input->p->i_rate >= INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE && |
|---|
| | 1258 | p_input->p->i_rate <= INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE ) ) ) |
|---|
| 1257 | 1259 | { |
|---|
| 1258 | 1260 | input_DecoderDecode( es->p_dec, p_block ); |
|---|
| … | … | |
| 1512 | 1514 | i_pcr = (int64_t)va_arg( args, int64_t ); |
|---|
| 1513 | 1515 | /* search program */ |
|---|
| 1514 | | /* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */ |
|---|
| 1515 | 1516 | input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, i_pcr ); |
|---|
| 1516 | 1517 | return VLC_SUCCESS; |
|---|
| re444ba7 |
r70a8bb9 |
|
| 1671 | 1671 | var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL ); |
|---|
| 1672 | 1672 | |
|---|
| 1673 | | /* We will not send audio data if new rate != default */ |
|---|
| 1674 | | if( i_rate != INPUT_RATE_DEFAULT && p_input->p->i_rate == INPUT_RATE_DEFAULT ) |
|---|
| 1675 | | input_EsOutDiscontinuity( p_input->p->p_es_out, VLC_FALSE, VLC_TRUE ); |
|---|
| | 1673 | input_EsOutDiscontinuity( p_input->p->p_es_out, |
|---|
| | 1674 | VLC_FALSE, VLC_FALSE ); |
|---|
| 1676 | 1675 | |
|---|
| 1677 | 1676 | p_input->p->i_rate = i_rate; |
|---|