avcodec/shorten: Check residual size