Advertisement
Guest User

resample test

a guest
Jul 15th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1.     // convert from planar int16 to interleaved float32
  2.     // also change sample rate from 8kHz to 16kHz.
  3.     const int16_t in[2][4] = {{0,1,2,3}, {10, 9, 8, 7}};
  4.     const uint8_t ** in_ptr = (const uint8_t**)in;
  5.     float out[16] = {0};
  6.     uint8_t * out_ptr = (uint8_t*)out;
  7.    
  8.     swr_context = swr_alloc_set_opts(NULL,
  9.                         AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_S16P, 8000,
  10.                         AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_FLT, 16000,
  11.                         0, NULL);
  12.     int res = swr_init(swr_context);
  13.     res = swr_convert(swr_context, &out_ptr, 8, in_ptr, 4);
  14.    
  15.     // i have a debug point here. context seems fine,
  16.     // but out always contains just 0,0,0,...
  17.     // in remains unmodified.
  18.     printf("DONE");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement