Cleanup, use av_freep() instead of av_free(x); x=NULL