History

swr: allow flushing in multiple steps if the output is too small.

Michael Niedermayer committed 14 years ago

Commit 4f161531 parent 8bf95e82 files · +15 −11Browse files

Unified · Split

2 files
  1. libswresample/swresample.c +14 −11
  2. libswresample/swresample_internal.h +1 −0
libswresample/swresample.c+14−11
@@ -435,19 +435,22 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun · 434 unmodified lines
435435
436436 if(!in_arg){
437437 if(s->in_buffer_count){
438− AudioData *a= &s->in_buffer;
439− int i, j, ret;
440− if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0)
441− return ret;
442− av_assert0(a->planar);
443− for(i=0; i<a->ch_count; i++){
444− for(j=0; j<s->in_buffer_count; j++){
445− memcpy(a->ch[i] + (s->in_buffer_index+s->in_buffer_count+j )*a->bps,
446− a->ch[i] + (s->in_buffer_index+s->in_buffer_count-j-1)*a->bps, a->bps);
438+ if (!s->flushed) {
439+ AudioData *a= &s->in_buffer;
440+ int i, j, ret;
441+ if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0)
442+ return ret;
443+ av_assert0(a->planar);
444+ for(i=0; i<a->ch_count; i++){
445+ for(j=0; j<s->in_buffer_count; j++){
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+ }
447449 }
450+ s->in_buffer_count += (s->in_buffer_count+1)/2;
451+ s->resample_in_constraint = 0;
452+ s->flushed = 1;
448453 }
449− s->in_buffer_count += (s->in_buffer_count+1)/2;
450− s->resample_in_constraint = 0;
451454 }else{
452455 return 0;
453456 }
libswresample/swresample_internal.h+1−0
@@ -64,6 +64,7 @@ struct SwrContext { · 63 unmodified lines
6464 int in_buffer_index; ///< cached buffer position
6565 int in_buffer_count; ///< cached buffer length
6666 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
6768
6869 struct AudioConvert *in_convert; ///< input conversion context
6970 struct AudioConvert *out_convert; ///< output conversion context

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t