RAII for codec context, format context and codec