问题
I want to feed libsamplerate (a library to downsample audio data which needs the following struct filled:
typedef struct
{ float *data_in, *data_out ;
long input_frames, output_frames ;
long input_frames_used, output_frames_gen ;
int end_of_input ;
double src_ratio ;
} SRC_DATA ;
The fields of this struct which must be filled in by the caller are:
data_in : A pointer to the input data samples.
input_frames : The number of frames of data pointed to by data_in.
data_out : A pointer to the output data samples.
output_frames : Maximum number of frames pointer to by data_out.
src_ratio : Equal to output_sample_rate / input_sample_rate.
end_of_input : Equal to 0 if more input data is available and 1
otherwise.
To fill this struct, I have data_in but I don't know the frame count so I cannot define input_frames. Is there an easy way to trim the PCM byte stream? So I can input it into this function also with the correct number of frames. (So this question is not directly related to libsamplerate)
来源:https://stackoverflow.com/questions/17789917/how-to-trim-pcm-data-to-identify-sample-count-or-frame-count-to-feed