James McAvoy's 'Filth' Lands at Magnolia

Filth Still H

The film is based on the cult novel by Irvine Welsh, who also wrote "Trainspotting."

Magnolia Pictures has picked up the North American rights to Filth, a black comedy that stars James McAvoy as a dirty and corrupt cop. The company is eyeing a spring 2014 theatrical release.

VIDEO: 'Filth' Red Band Trailer

The movie, based on a novel by Irvine Welsh, who also wrote Trainspotting, was the second highest-grossing R-rated film in the UK (the crazy red band trailer probably helped).

It has also racked up British Independent Film Award nominations for McAvoy for best actor, Jon S. Baird for best director, Shirley Henderson for best supporting actress, Eddie Marsan for best supporting actor and a nomination for best achievement in production.

According to Magnolia, providing the logline, "McAvoy plays Detective Sergeant Bruce Robertson, a scheming, manipulative, misanthropic man who spends his time indulging in drugs, alcohol, sexually abusive relationships, and 'the games' – cruel plots and systematic bullying of his coworkers and friends. While working on the murder case of a Japanese student, he starts coming unhinged, slowly losing his grip on reality and suffering from a series of increasingly severe hallucinations as he desperately tries to hold his life together."

PHOTOS: A-Listers Angle to Play Music's Biggest Icons

Also in the cast are Jamie Bell, Imogen Poots and Jim Broadbent.

CAA and UTA repped the filmmaker in the deal.