|
|
@ -260,10 +260,7 @@ int FFAudioResample::encodeAudioFrame(AVFrame *frame, int *data_present) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ret = avcodec_receive_packet(resample->outCodecCtx, &resample->outPacket); |
|
|
|
ret = avcodec_receive_packet(resample->outCodecCtx, &resample->outPacket); |
|
|
|
if (ret == AVERROR(EAGAIN)) { |
|
|
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { |
|
|
|
ret = 0; |
|
|
|
|
|
|
|
goto cleanup; |
|
|
|
|
|
|
|
} else if (ret == AVERROR_EOF) { |
|
|
|
|
|
|
|
ret = 0; |
|
|
|
ret = 0; |
|
|
|
goto cleanup; |
|
|
|
goto cleanup; |
|
|
|
} else if (ret < 0) { |
|
|
|
} else if (ret < 0) { |
|
|
@ -319,7 +316,7 @@ int FFAudioResample::resampling(const char *src_file, const char *dst_file, int |
|
|
|
if (initResample()) |
|
|
|
if (initResample()) |
|
|
|
goto cleanup; |
|
|
|
goto cleanup; |
|
|
|
/* Initialize the FIFO buffer to store audio samples to be encoded. */ |
|
|
|
/* Initialize the FIFO buffer to store audio samples to be encoded. */ |
|
|
|
resample->fifo = av_audio_fifo_alloc(resample->outCodecCtx->sample_fmt, |
|
|
|
resample->fifo = av_audio_fifo_alloc(resample->outCodecCtx->sample_fmt, |
|
|
|
resample->outCodecCtx->channels, 1024 * 10); |
|
|
|
resample->outCodecCtx->channels, 1024 * 10); |
|
|
|
if (initOutputFrame(&resample->outFrame, resample->outCodecCtx)) |
|
|
|
if (initOutputFrame(&resample->outFrame, resample->outCodecCtx)) |
|
|
|
goto cleanup; |
|
|
|
goto cleanup; |
|
|
@ -329,7 +326,7 @@ int FFAudioResample::resampling(const char *src_file, const char *dst_file, int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
int finished = 0; |
|
|
|
int finished = 0; |
|
|
|
const int output_frame_size = resample->outCodecCtx->frame_size; |
|
|
|
const int output_frame_size = resample->outCodecCtx->frame_size; |
|
|
|
|
|
|
|
|
|
|
|
while (av_audio_fifo_size(resample->fifo) < output_frame_size) { |
|
|
|
while (av_audio_fifo_size(resample->fifo) < output_frame_size) { |
|
|
|