Even a opt-in filter on an infrastructure level would imply DPI, and therefore would enable the ability for traffic analysis. And besides it creates a national 'watches porn' list.
If the filter is opt-in, it's a "doesn't want to watch porn" list :)
In a free market economy, you could provide filtering as a service to those who want it. You get to use whatever setup of proxies and packet sniffers you please, so as long as they don't overstep the users mandate. Routing your other customers past these intermediaries would be a good idea, you can provide each customer the service they want.
That works as long as the ISP faithfully reports the routing rules they use for each user, which is rather hard to verify. ( And it would probably illegal for the ISP to tell their customers, if the government wants to use the DPI equipment.)
Most ISPs already do DPI, albeit lightly. That's how they do 'traffic shaping' against bit torrent, etc.