- /* return single packed with fixed size */
- out_data_size = FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx);
- if (*data_size < out_data_size) {
- av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n", *data_size);
- return AVERROR(EINVAL);
+ /* get output buffer */
+ esc->frame.nb_samples = (FFMIN(MAX_FRAME_SIZE, esc->samples_size - esc->samples_idx) +avctx->channels-1) / avctx->channels;
+ if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;