X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fencode.c;h=d81b32b98382ee7731d6bb5312464c98a3eef610;hb=5e546864b09379910721b35a14713982d933d9dd;hp=d12c42526be5b94eac158752a8041f06aaa61278;hpb=b8eb0827f053230dd919bc73e25381b47b4fe1a7;p=ffmpeg diff --git a/libavcodec/encode.c b/libavcodec/encode.c index d12c42526be..d81b32b9838 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -174,8 +174,14 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, goto end; } } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { - if (frame->nb_samples < avctx->frame_size && - !avctx->internal->last_audio_frame) { + /* if we already got an undersized frame, that must have been the last */ + if (avctx->internal->last_audio_frame) { + av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame (avcodec_encode_audio2)\n", avctx->frame_size); + ret = AVERROR(EINVAL); + goto end; + } + + if (frame->nb_samples < avctx->frame_size) { ret = pad_last_frame(avctx, &padded_frame, frame); if (ret < 0) goto end;