Unified · Split
| @@ -435,19 +435,22 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun · 434 unmodified lines | |||
| 435 | 435 | ||
| 436 | if(!in_arg){ | 436 | if(!in_arg){ |
| 437 | if(s->in_buffer_count){ | 437 | if(s->in_buffer_count){ |
| 438 | AudioData *a= &s->in_buffer; | 438 | if (!s->flushed) { |
| 439 | int i, j, ret; | 439 | AudioData *a= &s->in_buffer; |
| 440 | if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0) | 440 | int i, j, ret; |
| 441 | return ret; | 441 | if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0) |
| 442 | av_assert0(a->planar); | 442 | return ret; |
| 443 | for(i=0; i<a->ch_count; i++){ | 443 | av_assert0(a->planar); |
| 444 | for(j=0; j<s->in_buffer_count; j++){ | 444 | for(i=0; i<a->ch_count; i++){ |
| 445 | memcpy(a->ch[i] + (s->in_buffer_index+s->in_buffer_count+j )*a->bps, | 445 | for(j=0; j<s->in_buffer_count; j++){ |
| 446 | a->ch[i] + (s->in_buffer_index+s->in_buffer_count-j-1)*a->bps, a->bps); | 446 | memcpy(a->ch[i] + (s->in_buffer_index+s->in_buffer_count+j )*a->bps, |
| 447 | a->ch[i] + (s->in_buffer_index+s->in_buffer_count-j-1)*a->bps, a->bps); | ||
| 448 | } | ||
| 447 | } | 449 | } |
| 450 | s->in_buffer_count += (s->in_buffer_count+1)/2; | ||
| 451 | s->resample_in_constraint = 0; | ||
| 452 | s->flushed = 1; | ||
| 448 | } | 453 | } |
| 449 | s->in_buffer_count += (s->in_buffer_count+1)/2; | ||
| 450 | s->resample_in_constraint = 0; | ||
| 451 | }else{ | 454 | }else{ |
| 452 | return 0; | 455 | return 0; |
| 453 | } | 456 | } |
| @@ -64,6 +64,7 @@ struct SwrContext { · 63 unmodified lines | |||
| 64 | int in_buffer_index; ///< cached buffer position | 64 | int in_buffer_index; ///< cached buffer position |
| 65 | int in_buffer_count; ///< cached buffer length | 65 | int in_buffer_count; ///< cached buffer length |
| 66 | int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise | 66 | int resample_in_constraint; ///< 1 if the input end was reach before the output end, 0 otherwise |
| 67 | int flushed; ///< 1 if data is to be flushed and no further input is expected | ||
| 67 | 68 | ||
| 68 | struct AudioConvert *in_convert; ///< input conversion context | 69 | struct AudioConvert *in_convert; ///< input conversion context |
| 69 | struct AudioConvert *out_convert; ///< output conversion context | 70 | struct AudioConvert *out_convert; ///< output conversion context |